-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathshellcode-extractor.py
More file actions
executable file
·39 lines (31 loc) · 1.2 KB
/
shellcode-extractor.py
File metadata and controls
executable file
·39 lines (31 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/env python3
import re
import sys
import os
def header():
print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")
print("~ Shellcode Extractor by Ander Arrosteguy, Matthieu Bailly & Mohamed Bouhastine ~")
print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n")
def main():
objdump = os.popen("objdump -d %s" % (sys.argv[1])).read()
opcodes = re.findall("[a-f0-9]{2} ", objdump.split("\n",7)[7])
shellcode = ""
null_bytes = 0
print("[+] found %d opcodes\n" % (len(opcodes)))
for opcode in opcodes:
if (opcode.rstrip() == '00'):
null_bytes += 1
print("\033[91m%s\033[0m" % (opcode), end='')
else:
print("%s" % (opcode), end='')
shellcode = shellcode + "\\x" + opcode.rstrip()
print()
if (null_bytes > 0):
print("\n\033[93m[!] found %d NULL bytes\033[0m" % (null_bytes),end='')
print("\n[+] shellcode result for %s :\n\n%s" % (sys.argv[1], shellcode))
if (__name__ == "__main__"):
header()
if (len(sys.argv[1:]) == 1):
main()
else:
print("Usage : %s <binary_file>" % (sys.argv[0].split('/')[-1]))