Liber 000 - Astrum Argentum
Liber 000 - Astrum Argentum Liber 000 - Astrum Argentum
} sum += *w++; nleft -= 2; /* mop up an odd byte, if necessary */ if (nleft == 1) { *(u_char *)(&answer) = *(u_char *)w ; sum += answer; } /* add back carry outs from top 16 bits to low 16 bits */ */ */ } sum = (sum >> 16) + (sum & 0xffff); /* add hi 16 to low 16 sum += (sum >> 16); /* add carry */ answer = ~sum; /* truncate to 16 bits return(answer); Este algorítmo é utilizado para a determinação do checksum, para o controle propriamente dito, não se preocupe neste momento em entendê-lo, basta dizer que o mesmo será muito útil daqui para a frente. Raio X das Estruturas dos Protocolos : Vamos mostrar abaixo como é a estrutura de vários protocolos para o melhor entendiemnto de nosso estudo. Vamos a eles : a) Cabeçalho UDP : #include /* Parte do cabecalho udp.h que declara a estrutura udphdr */ struct udphdr { u_int16_t source; u_int16_t dest; u_int16_t len; u_int16_t check; }; b) Cabeçalho IP : #include /* Parte do cabecalho ip.h que declara a estrutura iphdr */ struct iphdr { #if __BYTE_ORDER == __LITTLE_ENDIAN unsigned int ihl:4; unsigned int version:4; #elif __BYTE_ORDER == __BIG_ENDIAN unsigned int version:4; unsigned int ihl:4; #else 50
# error "Please fix " #endif u_int8_t tos; u_int16_t tot_len; u_int16_t id; u_int16_t frag_off; u_int8_t ttl; u_int8_t protocol; u_int16_t check; u_int32_t saddr; u_int32_t daddr; /*The options start here. */ }; Não tem nada de familiar acima, com o cabeçalho do datagrama IP ? Se vocês já repararam são as estrturas exatas do mesmo, para serem manipuladas pelo programador ! c) Cabeçalho ICMP : #include /* Parte do cabecalho ipicmp.h que declara a estrutura icmphdr */ struct icmphdr { u_int8_t type; /* message type */ u_int8_t code; /* type sub-code */ u_int16_t checksum; union { struct { u_int16_t id; u_int16_t sequence; } echo; /* echo datagram */ u_int32_t gateway; /* gateway address */ struct { u_int16_t __unused; u_int16_t mtu; } frag; /* path mtu discovery */ } un; }; Dos três, este é o mais complexo de todos, mas é que permite uma série de recursos interessantes. Implementação de Um Gerador de Pacotes UDP Viemos ao longo destas modestas lições sobre sockets mostrar um pouco da programação em C. Uma coisa que eu vi durante o curso foi que muitas pessoas queriam compilar estas aplicações no Windows, que eu infelizmente não pude auxiliar, já que todo o nosso curso foi voltado 51
- Page 1 and 2: 1 E Q U I N O X G R E E N Volume I
- Page 3 and 4: 2. FAZENDO CÓPIAS EXATAS Você pod
- Page 5 and 6: 10. REVISÕES FUTURAS DESTA LICENÇ
- Page 7 and 8: E Q U I N O X G R E E N O O R G Ã
- Page 9 and 10: E D I T O R I A L “Faze o que tu
- Page 11 and 12: Mensagem ao Estudante : Liber 000 A
- Page 13 and 14: Fraters afim de poder atender a tod
- Page 15 and 16: Este mundo tenta levar o neófito a
- Page 17 and 18: O Manifesto de um Hacker Data do Do
- Page 19 and 20: Seção 002h O Primeiro Portal Agor
- Page 21 and 22: Servidor : Endereço IP eth0 : 10.0
- Page 23 and 24: Quod facis, Fac citius Antes de ter
- Page 25 and 26: Nós iremos explorar nestes nossos
- Page 27 and 28: main(){ int e_socket; struct sockad
- Page 29 and 30: utilizando a função CONNECT(). co
- Page 31 and 32: O Grande exemplo I : Eis aqui o sca
- Page 33 and 34: } /*Declaracao do Socket*/; } msock
- Page 35 and 36: transmitidos e aceitos pelo destino
- Page 37 and 38: SackOK é típico de um cliente FTP
- Page 39 and 40: int nsocket, newsocket; struct sock
- Page 41 and 42: if ((he=gethostbyname(argv[1])) ==
- Page 43 and 44: O backtcp.c O backdoor aqui apresen
- Page 45 and 46: Apresentando o Código : Finalmente
- Page 47 and 48: ) Protocolo IP (IP Protocol) - Este
- Page 49: ICMP (Internet Control Message Prot
- Page 53 and 54: ip_origem = inet_addr("127.0.0.1");
- Page 55 and 56: if (envia == -1) { perror("sendto()
- Page 57 and 58: Por Frater Q.V.I.F. 196 O E Q U I N
- Page 59 and 60: de Crowley, não exatamente a tradu
- Page 61 and 62: shellcodes, mas não quer dizer que
- Page 63 and 64: } shellcode/cwrite.c OBS: Sempre d
- Page 65 and 66: Vamos analisar o que fizemos e comp
- 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 -
}<br />
sum += *w++;<br />
nleft -= 2;<br />
/* mop up an odd byte, if necessary */<br />
if (nleft == 1) {<br />
*(u_char *)(&answer) = *(u_char *)w ;<br />
sum += answer;<br />
}<br />
/* add back carry outs from top 16 bits to low 16 bits */<br />
*/<br />
*/<br />
}<br />
sum = (sum >> 16) + (sum & 0xffff); /* add hi 16 to low 16<br />
sum += (sum >> 16); /* add carry */<br />
answer = ~sum; /* truncate to 16 bits<br />
return(answer);<br />
Este algorítmo é utilizado para a determinação do checksum, para o<br />
controle propriamente dito, não se preocupe neste momento em<br />
entendê-lo, basta dizer que o mesmo será muito útil daqui para a frente.<br />
Raio X das Estruturas dos Protocolos :<br />
Vamos mostrar abaixo como é a estrutura de vários protocolos para o<br />
melhor entendiemnto de nosso estudo. Vamos a eles :<br />
a) Cabeçalho UDP :<br />
#include <br />
/* Parte do cabecalho udp.h que declara a estrutura udphdr */<br />
struct udphdr {<br />
u_int16_t source;<br />
u_int16_t dest;<br />
u_int16_t len;<br />
u_int16_t check;<br />
};<br />
b) Cabeçalho IP :<br />
#include <br />
/* Parte do cabecalho ip.h que declara a estrutura iphdr */<br />
struct iphdr<br />
{<br />
#if __BYTE_ORDER == __LITTLE_ENDIAN<br />
unsigned int ihl:4;<br />
unsigned int version:4;<br />
#elif __BYTE_ORDER == __BIG_ENDIAN<br />
unsigned int version:4;<br />
unsigned int ihl:4;<br />
#else<br />
50