Tema destacado: ¡Aprende hacking con práctica! - arZone, el wargame de elhacker.net
Autor
|
Tema: Recopilación de mis codigos. (Leído 11,157 veces)
|
|
|
YST
Desconectado
Mensajes: 963
I'm you
|
;Función que cifra con un xor 10 cada byte de una cadena ; cCadena = Puntero de cadena a cifrar ; cTTamaño = Tamaño de cadena a enbcriptar si este es 0 se medira la cadena automaticamente (fin de cadena de caracter nulo ) ; By YST proc EncriptacionXOR,cCadena,cTamaño push ebx xor ebx,ebx cmp [cTamaño],0 je .contar mov ebx,[cTamaño] jmp .Start .contar: mov ebx,0 mov eax,[cCadena] .len: inc ebx inc eax cmp byte[eax],0 jne .len .Start: mov eax,[cCadena] inc ebx dec eax .bucle: dec ebx cmp ebx,0 jbe .salir inc eax xor byte[eax],10 jmp .bucle .salir: pop ebx ret endp
|
|
|
|
|
En línea
|
 Yo le enseñe a Kayser a usar objetos en ASM
|
|
|
YST
Desconectado
Mensajes: 963
I'm you
|
proc ASCIITOUNICODE,Cadena,Buffer push ecx ebx mov eax,[Cadena] mov ebx,[Buffer] dec eax sub ebx,2 .bucle: inc eax cmp byte[eax],0 je .salir add ebx,2 mov cl,byte[eax] mov byte[ebx],cl mov byte[ebx+1],0 jmp .bucle .salir: pop ebx ecx ret endp
|
|
|
|
|
En línea
|
 Yo le enseñe a Kayser a usar objetos en ASM
|
|
|
YST
Desconectado
Mensajes: 963
I'm you
|
macro MacroYSTEncript Posicion,Tamaño{ local ..Caracter,..numero ..numero = Tamaño repeat Tamaño ..numero = ..numero - 1 load ..Caracter from Posicion+%-1 ..Caracter = byte ..Caracter + 3 ..Caracter = byte not ..Caracter ..Caracter = byte ..Caracter xor 45 ..Caracter = byte ..Caracter xor ..numero store ..Caracter at Posicion+%-1 end repeat } proc YSTEncript,cCadena,cBuffer,cTamaño push eax ebx ecx edx esi mov ebx,[cBuffer] mov esi,[cCadena] dec esi dec ebx .Eb: dec [cTamaño] inc esi inc ebx mov cl,byte[esi] add cl,3 mov byte[ebx],cl not byte[ebx] xor byte[ebx],45 mov edx,[cTamaño] xor byte[ebx],dl cmp [cTamaño],0 jne .Eb pop esi edx ecx ebx eax ret endp proc YSTDesencript,cCadena,cBuffer,cTamaño push eax ebx ecx edx esi mov ebx,[cBuffer] mov esi,[cCadena] dec esi dec ebx .Eb: dec [cTamaño] inc esi inc ebx mov cl,byte[esi] mov byte[ebx],cl mov edx,[cTamaño] xor byte[ebx],dl not byte[ebx] xor byte[ebx],45 sub byte[ebx],3 cmp [cTamaño],0 jne .Eb pop esi edx ecx ebx eax ret endp
|
|
|
|
« Última modificación: 20 Septiembre 2009, 05:28 por YST »
|
En línea
|
 Yo le enseñe a Kayser a usar objetos en ASM
|
|
|
YST
Desconectado
Mensajes: 963
I'm you
|
include 'win32ax.inc' .code start: stdcall cInstr,"98y4ct2y3Hola83925832c","Hola" .if eax = FALSE invoke MessageBox,0,"No esta.",0,0 .else invoke MessageBox,0,eax,0,0 .endif invoke ExitProcess,0 ;//////////////////////////////////////////////////////////////////////////////////////////////////// ;//Descripción: Funcion que ve si la segunda cadena se encuentra dentro de la primera // ;//c1 = Cadena // ;//c2 = Cadena que se buscara en c1 // ;// Retorna: // ;// Si no se encuentra o hay error retorna FALSE , en el caso de que se encuentre devuelve eax// ;// apuntandoa la posicion de c1 donde se encontro c2 // ;// by YST // ;//////////////////////////////////////////////////////////////////////////////////////////// proc cInstr,c1,c2 push edi esi ebx ecx edx stdcall Len,[c2] mov edi,eax stdcall Len,[c1] mov esi,eax cmp edi,esi jg .Falso mov edx,[c1] mov ebx,[c2] dec edx inc esi .bucle: dec esi inc edx mov cl,byte[edx+edi] mov byte[edx+edi],0 stdcall comparar,edx,[c2] mov byte[edx+edi],cl .if eax = 0 mov eax,edx jmp .salir .endif cmp esi,0 jne .bucle .Falso: mov eax,FALSE .salir: pop edx ecx ebx esi edi ret endp proc comparar ,SRC,DST ;Funcion que compara push edi ecx esi mov ecx,-1 mov edi,[SRC] mov al,0 repnz scasb mov eax,ecx not eax mov ecx,eax mov esi,[SRC] mov edi,[DST] repz cmpsb mov eax,1 jnz Next dec eax Next: pop esi ecx edi ret endp proc Len,cCadena ;Funcion que mide la cadena push ecx edi mov ecx,-1 mov edi,[cCadena] mov al,0 repnz scasb mov eax,ecx not eax dec eax pop edi ecx ret endp .end start
|
|
|
|
|
En línea
|
 Yo le enseñe a Kayser a usar objetos en ASM
|
|
|
YST
Desconectado
Mensajes: 963
I'm you
|
include 'win32ax.inc' .code start: invoke LoadLibrary,"user32.dll" stdcall GetAddressFunction,eax,"MessageBoxA" stdcall eax,0,0,0,0 invoke ExitProcess,0 proc GetAddressFunction,pMZ,pApi ;EDI = MZ ;Expot data = EBX ;Esi = Cantidad de funciones ;edx = AddressOfNames ;ECX = Propositos generales mov edi, [pMZ] mov ebx,[edi+0x3c] mov ebx,[ebx+edi+0x78] add ebx,edi mov esi,[0x18+ebx] mov edx, [0x20+ebx] add edx,edi .bucle: dec esi cmp esi,0 je .error mov eax,esi rol eax,2 ;Multiplicamos esi por 4 mov eax,[edx + eax] add eax,edi stdcall comparar,[pApi],eax xor eax,0 jnz .bucle mov eax,[0x24+ebx] add eax,edi movzx ecx, word[eax + 2*esi] mov eax, [ebx + 0x1c] add eax,edi mov eax, [eax + 4 * ecx] add eax, edi .salir: ret .error: xor eax,eax jmp .salir endp proc comparar ,SRC,DST push edi ecx esi mov ecx,-1 mov edi,[SRC] mov al,0 repnz scasb mov eax,ecx not eax mov ecx,eax mov esi,[SRC] mov edi,[DST] repz cmpsb mov eax,1 jnz Next dec eax Next: pop esi ecx edi ret endp .end start
|
|
|
|
« Última modificación: 16 Agosto 2009, 02:52 por YST »
|
En línea
|
 Yo le enseñe a Kayser a usar objetos en ASM
|
|
|
|
|
|
|
YST
Desconectado
Mensajes: 963
I'm you
|
include 'win32ax.inc' .data buffer rb 100 .code start: stdcall StrReverse,kk,buffer invoke MessageBox,0,buffer,kk,0 leave ret kk: db "Estoy cifrado",0 proc StrReverse,cCadena,cBuffer push ebx esi edi eax ecx mov ebx, [cCadena] mov esi,[cBuffer] stdcall Len,ebx mov ecx,eax mov al,byte[ebx] dec ecx mov edi,0 .bucle: mov ah,byte[ebx+ecx] mov byte[esi+edi],ah inc edi dec ecx jecxz .salir jmp .bucle .salir: mov byte[esi+edi],al mov byte[esi+edi+1],0 pop ecx eax edi esi ebx ret endp proc Len , SRC push ecx edi mov ecx,-1 mov edi,[SRC] mov al,0 repnz scasb mov eax,ecx not eax dec eax pop edi ecx ret endp .end start
|
|
|
|
|
En línea
|
 Yo le enseñe a Kayser a usar objetos en ASM
|
|
|
YST
Desconectado
Mensajes: 963
I'm you
|
include 'win32ax.inc' .code start: stdcall CapetaVaciaOUnidad,"F:" .if eax = TRUE invoke MessageBox,0,"La carpeta esta vacia",0,0 .else invoke MessageBox,0,"La carpeta no esta vacia",0,0 .endif invoke ExitProcess,0 proc CapetaVaciaOUnidad,ruta locals Find WIN32_FIND_DATA ? HandleBusqueda dd ? Ruta dd ? endl push ebx invoke GlobalAlloc,GPTR,MAX_PATH+1 mov [Ruta],eax stdcall Concat,[ruta],"\*", [Ruta] invoke FindFirstFile,[Ruta] , addr Find mov [HandleBusqueda],eax invoke FindNextFile ,eax, addr Find invoke lstrcpy,[Ruta],addr Find.cFileName mov ebx,[Ruta] .if word[ebx] = ".." invoke FindNextFile, [HandleBusqueda], addr Find .endif invoke lstrcpy,[Ruta],addr Find.cFileName mov ebx,[Ruta] .if word[ebx] = ".." invoke GlobalFree,[Ruta] mov eax,TRUE .else .if dword[ebx] = "RECY" .if dword[ebx+4] = "CLER" invoke GlobalFree,[Ruta] mov eax,TRUE .endif .else invoke GlobalFree,[Ruta] mov eax,FALSE .endif .endif .endif pop ebx ret endp proc Concat uses esi edi, @AdrSrc1, @AdrSrc2, @AdrDest mov esi,[@AdrSrc1] mov edi,[@AdrDest] .concat_src1: movsb cmp byte[esi],0 jne .concat_src1 mov esi,[@AdrSrc2] .concat_src2: movsb cmp byte[esi],0 jne .concat_src2 movsb ret endp .end start
|
|
|
|
|
En línea
|
 Yo le enseñe a Kayser a usar objetos en ASM
|
|
|
YST
Desconectado
Mensajes: 963
I'm you
|
format pe console espacio equ 13,10,0 include 'win32ax.inc' .data RutaLib rb MAX_PATH RutaINC rb MAX_PATH .code start: invoke printf,"Ingrese la ruta de la libreria:" invoke printf,espacio invoke scanf,"%s",RutaLib invoke printf,"Ingrese la ruta de la donde se generara el include:" invoke printf,espacio invoke scanf,"%s",RutaINC stdcall CrearImport,RutaLib,RutaINC invoke ExitProcess,0 proc CrearImport,NombreLIB,NombreImport locals DirPEHeader dd ? PunteroPEHeader dd ? RVAofExportDirectory dd ? NumberOfNames dd ? AddressOfNames dd ? Funcion dd ? HFile dd ? Nosirve dd ? Largo dd ? LibHandle dd ? endl push ebx edx edi ecx invoke LoadLibrary, [NombreLIB] mov [LibHandle],eax cmp eax,NULL je .Error push dword[eax + 03Ch] pop [DirPEHeader] push [DirPEHeader] pop [PunteroPEHeader] add [PunteroPEHeader],eax mov ebx,[PunteroPEHeader] cmp word[ebx],"PE" jne .Error push dword[ebx+078h] pop [RVAofExportDirectory] mov ebx, [RVAofExportDirectory] add ebx,eax push dword[ebx+018h] pop [NumberOfNames] mov edx,[NumberOfNames] push dword[ebx+20h] pop [AddressOfNames] mov ebx,[NumberOfNames] mov edi, [AddressOfNames] add edi,[LibHandle] invoke CreateFileA, [NombreImport], GENERIC_WRITE, 0, 0, CREATE_ALWAYS, 0, 0 mov [HFile], eax invoke lstrlen,"import " invoke WriteFile, [HFile], "import ",eax,addr Nosirve, NULL invoke lstrlen,[NombreLIB] sub eax,4 invoke WriteFile, [HFile], [NombreLIB],eax,addr Nosirve, NULL invoke WriteFile,[HFile] , ",\",2,addr Nosirve, NULL invoke WriteFile, [HFile], espacio,2,addr Nosirve, NULL .bucle: dec ebx mov eax, [edi + ebx * 4] add eax,[LibHandle] mov [Funcion],eax invoke lstrlen, [Funcion] invoke WriteFile, [HFile], [Funcion],eax,addr Nosirve, NULL invoke WriteFile, [HFile],",",1,addr Nosirve, NULL invoke WriteFile, [HFile],"'",1,addr Nosirve, NULL invoke lstrlen, [Funcion] invoke WriteFile, [HFile], [Funcion],eax,addr Nosirve, NULL .if ebx = 0 invoke WriteFile, [HFile],"'",1,addr Nosirve, NULL .else invoke WriteFile, [HFile],"',\",3,addr Nosirve, NULL invoke WriteFile, [HFile], espacio,2,addr Nosirve, NULL .endif cmp ebx,0 jne .bucle invoke CloseHandle, [HFile] invoke system,"cls" invoke printf,"Extraida las funciones de: " invoke printf,RutaLib invoke printf,espacio invoke printf,espacio invoke printf,"El include ah sido generado en : " invoke printf,RutaINC invoke printf,espacio invoke printf,espacio invoke printf,"Con " invoke printf,"%d",[NumberOfNames] invoke printf," funciones extraidas." invoke printf,espacio invoke system,"pause" pop ecx edi edx ebx ret .Error: invoke system,"cls" invoke printf,"Ocurrio un error durante la extracciòn." invoke printf,espacio invoke system,"pause" ret endp .end start PD: En este codigose necesita agregar alguna apis a la win32ax.
|
|
|
|
|
En línea
|
 Yo le enseñe a Kayser a usar objetos en ASM
|
|
|
YST
Desconectado
Mensajes: 963
I'm you
|
include 'win32ax.inc' .data Separador db "/()·/", 0 Cadena db 'Soy/()·/una/()·/cadena',0 Cantidad dd ? buffer rb MAX_PATH .code start: stdcall Split,Cadena,Separador,buffer mov [Cantidad],eax stdcall Len,Separador mov ebx,eax mov ecx,[Cantidad] inc ecx mov esi,buffer .bucle: push ecx invoke MessageBox,0,esi,esi,0 stdcall Len,esi add esi,eax add esi,ebx pop ecx loop .bucle invoke ExitProcess,0 ; cCadena(in) = Cadena a partir ; cSeparador(in) = Separador que se usara para partir la cadena ; cBuffer(out) = A donde se guardara la cadena partida ; Retorna la cantidad de separadores encontrados proc Split,cCadena,cSeparador,cBuffer push edi esi ecx ebx xor ebx,ebx stdcall copy,[cBuffer],[cCadena] stdcall Len,[cSeparador] mov edi,eax mov esi,[cBuffer] dec esi .bucle: inc esi cmp byte[esi],0 je .salir mov cl,byte[esi+edi] mov byte[esi+edi],0 stdcall comparar,esi,[cSeparador] mov byte[esi+edi],cl cmp eax,0 jne .bucle inc ebx mov byte[esi],0 add esi,edi jmp .bucle .salir: mov eax,ebx pop ebx ecx esi edi ret endp proc comparar ,SRC,DST ;Funcion que compara push edi ecx esi mov ecx,-1 mov edi,[SRC] mov al,0 repnz scasb mov eax,ecx not eax mov ecx,eax mov esi,[SRC] mov edi,[DST] repz cmpsb mov eax,1 jnz Next dec eax Next: pop esi ecx edi ret endp proc Len,cCadena ;Funcion que mide la cadena push ecx edi mov ecx,-1 mov edi,[cCadena] mov al,0 repnz scasb mov eax,ecx not eax dec eax pop edi ecx ret endp proc copy,cDestino,cCadena ;funcion que copia una cadena push ecx edi esi stdcall Len,[cCadena] add eax,2 mov ecx,eax mov esi,[cCadena] mov edi,[cDestino] rep movsb pop esi edi ecx ret endp .end start
|
|
|
|
|
En línea
|
 Yo le enseñe a Kayser a usar objetos en ASM
|
|
|
YST
Desconectado
Mensajes: 963
I'm you
|
include 'win32ax.inc' .data xD db '[soy una cadena.]',0 .code start: stdcall EncriptacionChangeCase,xD,0 invoke MessageBox,0,xD,0,0 invoke ExitProcess,0 ;Función que transforma las miniscula a mayusculas y viceversa ; cCadena = Puntero de cadena a cifrar ; cTTamaño = Tamaño de cadena a enbcriptar si este es 0 se medira la cadena automaticamente (fin de cadena de caracter nulo ) ; By YST proc EncriptacionChangeCase,cCadena,cTamaño push ebx xor ebx,ebx cmp [cTamaño],0 je .contar mov ebx,[cTamaño] jmp .Start .contar: mov ebx,0 mov eax,[cCadena] .len: inc ebx inc eax cmp byte[eax],0 jne .len .Start: mov eax, [cCadena] dec eax inc ebx .bucle: dec ebx inc eax cmp ebx,0 je .salir cmp byte[eax],'A' jb .bucle cmp byte[eax],91 jge .revisar jmp .seguir jmp .bucle .seguir: cmp byte[eax],"Z" jbe .Mayuscula cmp byte[eax],"z" jbe .Miniscula jmp .bucle .salir : xor ebx,ebx mov ebx,0 mov eax,[cCadena] pop ebx ret .revisar: cmp byte[eax],96 jg .seguir jbe .bucle .Mayuscula: ;Si es Mayuscula la pasamos a miniscula add byte[eax],0x20 jmp .bucle .Miniscula: ;Si es miniscula la pasamos a Mayuscula sub byte[eax],0x20 jmp .bucle xor ebx,ebx mov ebx,0 mov eax,[cCadena] endp .end start
|
|
|
|
|
En línea
|
 Yo le enseñe a Kayser a usar objetos en ASM
|
|
|
|
|
|
|
|
|