1
C - C++ / Re: What to use?
« on: April 28, 2015, 06:37:41 PM »
Code::Blocks <3
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
kHandle dd 0
kDir db "SOFTWARE\Microsoft\Windows\CurrentVersion\Run",0
lea edx, [ebp+kHandle] ;ebp is the delta offset, here im getting the pointer to my keyhandler
push edx ;pass the handler
push 0x00000010 ;Ask for reading rights (so i dont get permissions errors)
xor edx, edx
push edx ;push NULL (reserved)
lea edx, [ebp+kDir]
push edx ;subkey string pointer
push 0x80000002 ;HKEY_LOCAL_MACHINE
call 0x75334887 ;Call ROK (i can get it dynamically, but i hardcoded the address to
;reduce error vectors)
@ECHO OFF
nasm -f bin -o %1.bin %1.asm
xxd -c 1 -p %1.bin %1.txt
if exist %1.c (del %1.c)
set /p "=char code[] = "^"<nul >%1.c
for /F %%i in (%1.txt) do set /p "=\x%%i"<nul >>%1.c
echo ^";>>%1.c
echo int main(int argc, char **argv)>>%1.c
echo {>>%1.c
echo int (*func)();>>%1.c
echo func = (int (*)()) code;>>%1.c
echo (int)(*func)();>>%1.c
echo }>>%1.c
gcc -o %1 %1.c
@ECHO ON
GetLibrary:
call LibraryReturn
db 'user32.dllN'
LibraryReturn:
pop ecx ;get the library string
mov [ecx + 10], dl ;insert NULL (edx was cleared right before)
mov ebx, 0x77e7d961 ;LoadLibraryA(libraryname);
push ecx ;beginning of user32.dll
call ebx ;eax will hold the module handle