Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

String To Little Endian Shellcode Generator #26

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions string-to-shellcode.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import sys

def main():
if len(sys.argv) != 2:
print("Usage: %s <string>\n" % (sys.argv[0]))
sys.exit(1)
val = sys.argv[1];
n = int(len(val)/4)+1
c = n-1
if (len(val)-c*4)==3:
print("xor eax, eax")
print("mov al, 0x", end='')
print(hex(ord(val[c*4+2]))[2:])
print("shl eax, 0x10")
print("add ax, 0x", end='')
print(hex(ord(val[c*4+1]))[2:], end='')
print(hex(ord(val[c*4]))[2:])
if (len(val)-c*4)==2:
print("xor eax, eax")
print("mov ax, 0x", end='')
print(hex(ord(val[c*4+1]))[2:], end='')
print(hex(ord(val[c*4]))[2:])
if (len(val)-c*4)==1:
print("xor eax, eax")
print("mov al, 0x", end='')
print(hex(ord(val[c*4]))[2:])
if (len(val)-c*4)==0:
print("xor eax, eax")
print("push eax")
c = c -1
while c >= 0:
print("push 0x", end='')
print(hex(ord(val[c*4+3]))[2:], end='')
print(hex(ord(val[c*4+2]))[2:], end='')
print(hex(ord(val[c*4+1]))[2:], end='')
print(hex(ord(val[c*4]))[2:])
c = c -1
print("push esp")
sys.exit(0)

if __name__ == "__main__":
main()