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

 

 


Tema destacado: Rompecabezas de Bitcoin, Medio millón USD en premios


+  Foro de elhacker.net
|-+  Seguridad Informática
| |-+  Análisis y Diseño de Malware (Moderador: fary)
| | |-+  [ASM]Cargando la ntdll desde codigo ideal para saltarse algunos hooks olly etc..
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: [ASM]Cargando la ntdll desde codigo ideal para saltarse algunos hooks olly etc..  (Leído 2,828 veces)
kisk

Desconectado Desconectado

Mensajes: 55



Ver Perfil
[ASM]Cargando la ntdll desde codigo ideal para saltarse algunos hooks olly etc..
« en: 19 Noviembre 2010, 15:52 pm »

Hace mucho tiempo que ya no estoy programando a si que les dejo un codigo que lo diseñe pensando en saltarme que sea tan facil debuggearte con el olly y otras cosas =D Vale decir que se puede convertir en un loader para exes entre otras cosas pero necesitas arreglar un poco el cargador del IAT =/

Código
  1.  
  2. ;This code work with the relocation table  :P
  3.          Path fix "C:\windows\system32\ntdll.dll"
  4.  
  5. include "win32ax.inc"
  6. struct UNICODE_STRING
  7.        Len dw ?
  8.        MaxLen dw ?
  9.        Buffer dd ?
  10. ends
  11. .data
  12. kernel32 du "kernel32.dll",0
  13. US UNICODE_STRING
  14. nt dd ?
  15. .code
  16. start:
  17.  
  18.  
  19. stdcall ReadFILE,Path
  20.  
  21. stdcall Loader,eax
  22.  
  23. mov [nt],ecx
  24. stdcall GetAddressFunction,ecx,"RtlInitUnicodeString"
  25.  
  26. stdcall eax,US,kernel32
  27.  
  28.  
  29.  
  30.  
  31. invoke MessageBoxW,0,[US.Buffer],0,0
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40. invoke ExitProcess,0
  41.  
  42.  
  43. proc GetAddressFunction,pMZ,pApi
  44.  
  45. mov edi, [pMZ]
  46. mov ebx,[edi+0x3c]
  47. mov ebx,[ebx+edi+0x78]
  48. add ebx,edi
  49. mov esi,[0x18+ebx]
  50. mov edx, [0x20+ebx]
  51. add edx,edi
  52. .bucle:
  53. dec esi
  54. cmp esi,0
  55. je .error
  56. mov eax,esi
  57. rol eax,2   ;esi * 4
  58. mov eax,[edx + eax]
  59. add eax,edi
  60. stdcall comparar,[pApi],eax
  61. xor eax,0
  62. jnz  .bucle
  63. mov eax,[0x24+ebx]
  64. add eax,edi
  65. movzx ecx, word[eax + 2*esi]
  66. mov eax, [ebx + 0x1c]
  67. add eax,edi
  68. mov eax, [eax + 4 * ecx]
  69. add eax, edi
  70. .salir:
  71. ret
  72. .error:
  73. xor eax,eax
  74. jmp .salir
  75. endp
  76.  
  77.  
  78. proc comparar ,SRC,DST ;lstrcmp
  79. push edi ecx esi
  80. mov ecx,-1
  81. mov edi,[SRC]
  82. mov al,0
  83. repnz scasb
  84. mov eax,ecx
  85. not eax
  86. mov ecx,eax
  87. mov esi,[SRC]
  88. mov edi,[DST]
  89. repz cmpsb
  90. mov eax,1
  91. jnz Next
  92. dec eax
  93. Next:
  94. pop esi ecx edi
  95. ret
  96. endp
  97.  
  98. SizeOfImage       equ 0x50
  99. pe               equ 0x3c
  100. NumberOfSections equ 0x6
  101. VirtualAddr       equ 0xc
  102. proc Loader uses edx edi esi ebx,MZ
  103.        local PE          dd ?
  104.        local ExeBuffer   dd ?
  105.  
  106.        local Delta       dd ?
  107.        local IBR         dd ?
  108.        local NumberBlocks dd ?
  109.        local I               dd ?
  110.        local IBR2 dd ?
  111.        local Type            dd ?
  112.        local IAT             dd ?
  113.        local offset          dd ?
  114.  
  115.  mov eax,[MZ]
  116.  add eax,dword[eax+pe]
  117.  mov [PE],eax
  118.  
  119. mov eax,[PE]
  120. cmp dword[eax+0x80],0
  121. je _EXIT
  122.  
  123. mov eax,[MZ]
  124. mov eax,dword[eax+0x3c]
  125. add eax, [MZ]
  126. xchg eax,[PE]
  127. mov eax,[PE]
  128. mov eax,dword[eax+0x80]
  129. add eax,[MZ]
  130. mov [IAT],eax
  131.  
  132. _LOADERIAT:
  133.  
  134.  
  135. mov eax,[IAT]
  136. mov eax,dword[eax+12]
  137. add eax,[MZ]
  138.  
  139.  
  140.  
  141. invoke LoadLibrary,eax
  142. mov ebx,eax
  143.  
  144. mov eax,[IAT]
  145.  
  146. mov eax,dword[eax+16]
  147. add eax,[MZ]
  148.  
  149. mov edi,eax
  150. _APIs:
  151.  
  152. mov eax,edi
  153. mov ecx,[MZ]
  154. add dword[eax],     ecx
  155.  
  156. mov eax,dword[eax]
  157. add eax,2
  158.  
  159. invoke GetProcAddress,ebx,eax
  160. mov dword[edi],eax
  161.  
  162. add edi,4
  163. cmp dword[edi],0
  164. jne _APIs
  165.  
  166. add [IAT],20
  167. mov eax,[IAT]
  168.  
  169. cmp dword[eax+12],0
  170. jne _LOADERIAT
  171.  
  172.  
  173.  
  174. _EXIT:
  175. invoke GlobalAlloc,GPTR,dword[eax+SizeOfImage]
  176.      mov [ExeBuffer],eax
  177.  
  178. mov eax,[PE]
  179.  
  180. movzx edi,word[eax+NumberOfSections]
  181.  
  182. _Secciones:
  183. dec edi
  184.  
  185. mov eax,28h
  186. mul edi
  187. add eax,0xf8
  188. add eax,[PE]
  189.  
  190. mov ecx,[ExeBuffer]
  191. add ecx,dword[eax+VirtualAddr]
  192.  
  193.  
  194.  
  195. mov edx,dword[eax+0x14];PointerRawData
  196. add edx,[MZ]
  197.  
  198. invoke RtlMoveMemory,ecx, edx,dword[eax+10h]
  199.  
  200. cmp edi,0
  201. jne _Secciones
  202.  
  203.  
  204. mov eax,[PE]
  205. invoke RtlMoveMemory,[ExeBuffer]   , [MZ]   ,dword[eax+0x54]
  206.  
  207. mov edi,[PE]
  208. mov edi,dword[edi+0x34]
  209.  
  210. mov ecx,[ExeBuffer]
  211.  
  212. sub ecx,edi
  213. mov [Delta],ecx
  214.  
  215. mov esi,[PE]
  216.  
  217. mov eax,[esi+0xA0]
  218. add eax,[ExeBuffer]
  219.  
  220.  mov [IBR],eax
  221.  
  222. _EX:
  223.  
  224. mov eax,[IBR]
  225. add eax,8
  226. mov eax,dword[eax]
  227. and eax,0xff
  228.  
  229. mov ecx,[IBR]
  230. mov ecx,dword[ecx+4]
  231. sub cl,8
  232. mov eax,2
  233. xchg eax,ecx
  234. div ecx
  235. mov [NumberBlocks],eax
  236. inc [NumberBlocks]
  237.  
  238. _Ini:
  239. push [IBR]
  240. pop [IBR2]
  241.  
  242. add [IBR2],6; IBR - WORD
  243. _BLOCKS:
  244. dec [NumberBlocks]
  245.  
  246. add [IBR2],2
  247.  
  248. pushad
  249. mov eax,[IBR2]
  250. movzx eax,word[eax]
  251. mov ecx,eax
  252. shr ecx,12
  253. and eax,0xff
  254. .if ecx = 3
  255.  
  256. ;scfd
  257. mov edx,[IBR]
  258. mov edx,[edx]
  259. add edx,eax
  260. add edx,[ExeBuffer]
  261.  
  262.  
  263.  
  264. mov eax,dword[edx]
  265. add eax,[Delta]
  266.  
  267.  
  268.  
  269. mov dword[edx],eax
  270.  
  271. .endif
  272.  
  273.  
  274. popad
  275.  
  276.  
  277. cmp [NumberBlocks],0
  278. jne _BLOCKS
  279.  
  280. mov eax,[IBR]
  281. mov eax,[eax+4]
  282. add [IBR],eax
  283. mov eax,[IBR]
  284. cmp dword[eax],0
  285. jne _EX
  286.  
  287.  
  288.  
  289. mov eax,[PE]
  290. mov ecx,[ExeBuffer]
  291.  
  292.  
  293.    ret
  294. endp
  295.  
  296. proc ReadFILE, ruta
  297. locals
  298.    bUsados dd ?
  299.    hFile   dd ?
  300.    tamAr   dd ?
  301.    hMap    dd ?
  302.    IB      dd ?
  303. endl
  304.  
  305.    invoke  CreateFile, [ruta], GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0
  306.    mov [hFile], eax
  307.    invoke  GetFileSize, [hFile], 0
  308.    mov [tamAr], eax
  309.    invoke  GlobalAlloc, GPTR, eax
  310.    mov [IB], eax
  311.    invoke  ReadFile, [hFile], [IB], [tamAr], addr bUsados, 0
  312.    invoke CloseHandle,  [hFile]
  313.    mov eax, [IB]
  314.    mov ebx,[tamAr]
  315.    ret
  316. endp
  317.  
  318. .end start;By Me
  319.  

Si quieren sacarle algunas apis es cosa de cambiarlas por funciones =P

Código
  1. ;Descripcion: Esta función funciona igual que la winapi RtlMoveMemory
  2. ; by YST
  3. proc cRtlMoveMemory,cBuffer,Cpuntero,cCantidad
  4. push esi edi
  5. xchg edi,[cBuffer]
  6. xchg esi,[Cpuntero]
  7. .bucleb:
  8. dec [cCantidad]
  9. movsb
  10. cmp  [cCantidad],0
  11. jge .bucleb
  12. pop edi esi
  13. ret
« Última modificación: 19 Noviembre 2010, 15:56 pm por kisk » En línea

La vieja escuela me da nostalgia la nueva me da naucias dime cual es la escuela si ambas me deprimen (8)
W0lFy


Desconectado Desconectado

Mensajes: 551



Ver Perfil WWW
Re: [ASM]Cargando la ntdll desde codigo ideal para saltarse algunos hooks olly etc..
« Respuesta #1 en: 19 Noviembre 2010, 17:11 pm »

guau que bien me va a venir :)
En línea

K@NuT0
Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
Colorear codigo en Olly.....se puede?
Ingeniería Inversa
Tinkipinki 4 2,905 Último mensaje 14 Agosto 2011, 19:37 pm
por Tinkipinki
Numerar en decimal las lineas de codigo en Olly.....se puede?
Ingeniería Inversa
Tinkipinki 3 3,102 Último mensaje 1 Septiembre 2011, 12:04 pm
por .:UND3R:.
En busca de la SIM ideal capaz de saltarse el roaming
Noticias
wolfbcn 0 1,048 Último mensaje 2 Abril 2013, 17:31 pm
por wolfbcn
Páginas web de grandes compañías se mostrarán “cargando” desde el 10 de ...
Noticias
wolfbcn 1 1,407 Último mensaje 5 Septiembre 2014, 21:21 pm
por crazykenny
LECCION 16 OLLY DESDE 0.NARVAJA
Ingeniería Inversa
jucasa 2 2,246 Último mensaje 3 Febrero 2015, 18:04 pm
por jucasa
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines