EvilZone

Programming and Scripting => Assembly - Embedded => : R4k0Z April 25, 2015, 01:26:24 AM

: [ASM] Build script, save your worthless time :)
: R4k0Z April 25, 2015, 01:26:24 AM
Hi everyone,


i've been coding some shellcode in nasm and found really tedious the building steps asm->bin->shellcode->c->exe so i made a script to automate that stuff, nothing fancy, anyways, here it is:


to use it just pass the name of your asm (if its potatoe.asm, you should run "builder.bat potatoe")


NOTE: the bat and asm files must be in the same directory


:

@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

This is just my tiny contribution, thanks everyone for the support and advice!


Hope ill be able to contribute with something more significant in the future :D
: Re: [ASM] Build script, save your worthless time :)
: HTH April 25, 2015, 01:40:31 AM
or...


:
nasm input.asm -f win32 -o output.exe


: Re: [ASM] Build script, save your worthless time :)
: R4k0Z April 25, 2015, 02:21:43 AM
may be a good idea :P


but you dont feel the thrill of the shellcode  ;D