Credit:
The information has been provided by Barros .
To keep updated with the tool visit the project's homepage at: http://www.gotfault.net/research.php
objdump2shellcode is a python program to convert the output of objdump -d into a shellcode format.
Code:
# ------------------+-----------------------------------------------------------
# ______________________________ __________
# __ ____/_ __ \__ __/__ __/_____ ____ ____ /_ /_
# _ / __ _ / / /_ / __ /_ _ __ / / / /_ /_ __/
# / /_/ / / /_/ /_ / _ __/ / /_/ // /_/ /_ / / /_
# \____/ \____/ /_/ /_/ \__,_/ \__,_/ /_/ \__/
# Security Community
#
# -----------------------------------------------------------------------------
# objdump2shellcode
# -----------------------------------------------------------------------------
# Homepage : http://www.gotfault.net/research/tool/misc/objdump2shellcode.py
# Author : Barros <barros [at] barrossecurity [dot] com
# Version : 1.0
# -----------------------------------------------------------------------------
# This program converts the output of objdump -d into a shellcode format.
# Ex:
#
# barros@gotfault:~$ objdump -d unpak | python objdump2shellcode.py
# // <_start>
# "\xeb\x1f" // jmp 8048095 <get_sc>
# // <_start0>
# "\x5b" // pop %ebx
# "\x89\xd9" // mov %ebx,%ecx
# // <_start1>
# "\x31\xc0" // xor %eax,%eax
# "\x8a\x43\x01" // mov 0x1(%ebx),%al
# "\x3c\x5a" // cmp $0x5a,%al
# "\x74\x18" // je 804809a <sc>
# "\x2c\x41" // sub $0x41,%al
# "\xc1\xe0\x04" // shl $0x4,%eax
# "\x8a\x23" // mov (%ebx),%ah
# "\x80\xec\x41" // sub $0x41,%ah
# "\x08\xe0" // or %ah,%al
# "\x88\x01" // mov %al,(%ecx)
# "\x41" // inc %ecx
# "\x43" // inc %ebx
# "\x43" // inc %ebx
# "\xeb\xe4" // jmp 8048079 <_start1>
# // <get_sc>
# "\xe8\xdc\xff\xff\xff" // call 8048076 <_start0>
# barros@gotfault:~$
#
# Gr33tz: Everybody in Gotfault, RFDSLabs and posidron (tripbit.net)
#
import sys
import re
try:
while True:
line = sys.stdin.readline()
if line:
# function name?
if re.match("^[^<]*<[^>]*>:.*$",line):
# print function name
print "".ljust(30),"//",re.findall("<[^>]*>",line)[0]
# opcodes + mnemonics line?
elif re.match("^[ ]*[0-9a-f]*:.*$",line):
line =line.split(":")[1].lstrip()
# split opcodes and mnemonics
om = line.split("\t")
# split opcodes
op = re.findall("[0-9a-f][0-9a-f]",om[0])
ops = "\""
for i in op:
ops += "\\x%s" % i
ops += "\""
# print opcodes and mnemonics
print ops.ljust(30),
if len(om) > 1: print "//",om[1].strip("\t\n")
else: print
else: break
except: pass
#EoF
Please enable JavaScript to view the comments powered by Disqus.
blog comments powered by