03 May 2012

convert assembly to opcode

1) gadget.asm
;gadget.asm
[SECTION .text]
; set the code to be 32-bit
; Tip: If you don't have this line in more complex shellcode,
; the resulting instructions may end up being different to
; what you were expecting.
BITS 32
global _start
_start:
POP EAX
POP EDI
POP ESI
POP EBX
POP EBP
RETN


2) Compiling assembly code
# nasm -f bin -o gadget.bin gadget.asm


3) Obtaining shellcode

#objdump -b binary -m i386 -D gadget.bin
atau
# x86dis -e 0 -s intel -f gadget.bin
00000000 58                             pop     eax
00000001 5F                             pop     edi
00000002 5E                             pop     esi
00000003 5B                             pop     ebx
00000004 5D                             pop     ebp
00000005 C3                             ret
 atau
# xxd -i gadget.bin
unsigned char gadget_bin[] = {
  0x58, 0x5f, 0x5e, 0x5b, 0x5d, 0xc3
};
unsigned int gadget_bin_len = 6;


ref>> http://www.projectshellcode.com/node/18 

No comments:

Post a Comment

Terima kasih