Liber 000 - Astrum Argentum
Liber 000 - Astrum Argentum Liber 000 - Astrum Argentum
{ const struct net_device *out, int (*okfn)(struct sk_buff *)) static char *interface_lo = "lo"; if(strncmp(in->name, interface_lo, 2)) { return NF_DROP; } return NF_ACCEPT; } static struct nf_hok_ops hulk; int init_module() { hulk.hoknum = NF_IP_LOCAL_IN; hulk.priority = NF_IP_PRI_FIRST; hulk.hok = hokfunc; hulk.pf = PF_INET; nf_register_hok(&hulk); return 0; } void cleanup_module() { nf_unregister_hok(&hulk); } Blz antes de um passo a passo no código vamos ver o que aconteceu quando compilamos e rodamos o kernel: bash-2.05b# gcc -c -O3 teste_interface.c bash-2.05b# insmod teste_interface.o Warning: loading teste_interface.o will taint the kernel: no license See http://www.tux.org/lkml/#export-tainted for information about tainted modules Module teste_interface loaded, with warnings bash-2.05b# ping localhost PING localhost (127.0.0.1) 56(84) bytes of data. --- localhost ping statistics --- 4 packets transmitted, 0 received, 100% packet loss, time 3014ms bash-2.05b# Blz parece que tudo funcionou como queriamos :) Partimos agora para um passo a passo: Estas definições são padrão de todos módulos que criamos, pode ser 118
substituida pelas flags -DMODULE e -D__KERNEL__ , no entanto prefiro economizar flags hehehehehe. #define __KERNEL__ #define MODULE vamos ver os includes :P Estes dois são padrão de serem incluidos em módulos do kernel tb: #include #include este declaram nossas hoks priorities etc: #include #include Declaração de struct net_device, usamos para sabermos o nome da interface in->name #include Abaixo vemos nossa função :) que vai fazer o hok do pacote: unsigned int hokfunc(unsigned int hoknum, struct sk_buff **skb, const struct net_device *in, const struct net_device *out, int (*okfn)(struct sk_buff *)) { Declaramos um ponteiro char com o conteúdo "lo", o nome da interface que queremos bloquear static char *interface_lo = "lo"; Fazemos uma simples comparação para sabermos se in->name é igual a nossa interface_lo, caso seja(if retorna 0), retornamos o NF_DROP, que manda o pacote para onde judas perdeu as botas. if(strncmp(in->name, interface_lo, 2)) { return NF_DROP; } Caso não seja o fluxo da função chegará aqui qeu retornará para o pacote ser aceito, e ele passará pelas outras hoks para validação, não tendo nenhum problema chegará ao espaço do usuário para a aplicação que estiver esperando por ele. return NF_ACCEPT; } Todo módulo tem uma função destas, ela é responsável por iniciar os 119
- Page 67 and 68: da próxima instrução que no caso
- Page 69 and 70: Provavelmente você verá uma mensa
- Page 71 and 72: Type "show copying" to see the cond
- Page 73 and 74: oot@motdlabs:~/IP_FIX/shellcode# gc
- Page 75 and 76: * MotdLabs . * Compilação: # gcc
- Page 77 and 78: oot@motdlabs:~/IP_FIX/shellcode# gc
- Page 79 and 80: * Criamos um ponteiro para uma fun
- Page 81 and 82: 0x8048317 : sub $0x8,%esp 0x804831a
- Page 83 and 84: in/sh; */ (0). */ main() { "\x89\xe
- Page 85 and 86: Lembre-se: Se você tiver alguma d
- Page 87 and 88: */ "push $0x6E69622F \n" /* ...a ou
- Page 89 and 90: main() { "\x89\xe1" /* mov %esp,%ec
- Page 91 and 92: */ "push $0x722F3A3A \n" /* ...nova
- Page 93 and 94: main() { "\x68\x3a\x30\x3a\x30" /*
- Page 95 and 96: "mov $0x66, %al \n" "int $0x80 \n"
- Page 97 and 98: Y O G A D I G I T A L Por Frater Ar
- Page 99 and 100: Preparação da Mente: Pratyahara -
- Page 101 and 102: 1a. Invocação : access denied for
- Page 103 and 104: Comando Url: http://www.google.com/
- Page 105 and 106: IPTables : é o atual firewall do G
- Page 107 and 108: extremamente útil ao administrador
- Page 109 and 110: Por: N E T F I L T E R + L K M S I
- Page 111 and 112: pacote não-promiscuo, etc), e ante
- Page 113 and 114: ... /* Network layer header */ unio
- Page 115 and 116: Blz, agora conhecemos o segundo arg
- Page 117: int hoknum; Blz quase terminada nos
- Page 121 and 122: Mãos a obra!! #define __KERNEL__ #
- Page 123 and 124: #include #include #include #incl
- Page 125 and 126: Por Frater Deny M A N I F E S T O F
- Page 127 and 128: No Novo Aeon, o Hacking emerge como
{<br />
const struct net_device *out,<br />
int (*okfn)(struct sk_buff *))<br />
static char *interface_lo = "lo";<br />
if(strncmp(in->name, interface_lo, 2))<br />
{<br />
return NF_DROP;<br />
}<br />
return NF_ACCEPT;<br />
}<br />
static struct nf_hok_ops hulk;<br />
int init_module()<br />
{<br />
hulk.hoknum = NF_IP_LOCAL_IN;<br />
hulk.priority = NF_IP_PRI_FIRST;<br />
hulk.hok = hokfunc;<br />
hulk.pf = PF_INET;<br />
nf_register_hok(&hulk);<br />
return 0;<br />
}<br />
void cleanup_module()<br />
{<br />
nf_unregister_hok(&hulk);<br />
}<br />
Blz antes de um passo a passo no código vamos ver o que aconteceu<br />
quando compilamos e rodamos o kernel:<br />
bash-2.05b# gcc -c -O3 teste_interface.c<br />
bash-2.05b# insmod teste_interface.o<br />
Warning: loading teste_interface.o will taint the kernel: no license<br />
See http://www.tux.org/lkml/#export-tainted for information about<br />
tainted modules<br />
Module teste_interface loaded, with warnings<br />
bash-2.05b# ping localhost<br />
PING localhost (127.0.0.1) 56(84) bytes of data.<br />
--- localhost ping statistics ---<br />
4 packets transmitted, 0 received, 100% packet loss, time 3014ms<br />
bash-2.05b#<br />
Blz parece que tudo funcionou como queriamos :)<br />
Partimos agora para um passo a passo:<br />
Estas definições são padrão de todos módulos que criamos, pode ser<br />
118