summaryrefslogtreecommitdiffstats
path: root/templates/shellcode/shelltool.py
diff options
context:
space:
mode:
authorMalfurious <m@lfurio.us>2021-08-22 10:24:45 -0400
committerMalfurious <m@lfurio.us>2021-08-22 10:24:45 -0400
commitad0ff4ede0e35d7c70fa0469f94f526196fa8ad4 (patch)
tree64258b519fa6ea1a36cdf50a7f7bf20567098d13 /templates/shellcode/shelltool.py
parent442640f100727a081cf26460992465386fe3a633 (diff)
parent083f76002476dd722a2989cf2c33d0e616e3fd84 (diff)
downloadlib-des-gnux-ad0ff4ede0e35d7c70fa0469f94f526196fa8ad4.tar.gz
lib-des-gnux-ad0ff4ede0e35d7c70fa0469f94f526196fa8ad4.zip
Merge branch 'shellcode-templates'
This is content from an old repo of mine. I think it makes much more sense to merge it into lib-des-gnux. templates/shellcode/ will track any useful shellcode recipes and contains utilities for building them into ready-to-use payloads. * shellcode-templates: Globally ignore all build artifacts Add Makefile for shellcode templates Refactor genhex into shelltool Add sys_exit shellcode templates Add generic /bin/sh shellcode templates
Diffstat (limited to 'templates/shellcode/shelltool.py')
-rwxr-xr-xtemplates/shellcode/shelltool.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/templates/shellcode/shelltool.py b/templates/shellcode/shelltool.py
new file mode 100755
index 0000000..b95a8cd
--- /dev/null
+++ b/templates/shellcode/shelltool.py
@@ -0,0 +1,30 @@
+#!/usr/bin/env python
+
+# This script will convert shellcode disassembly into an escaped string literal
+# and warn about problematic bytes in the payload.
+# objdump -d elf | ./shelltool.py
+
+import sys
+
+name = None
+bytecode = []
+badchars = [ 0x00, 0x0a ]
+
+for line in sys.stdin:
+ for tok in line.split():
+ if name is None:
+ name = tok
+ if len(tok) == 2:
+ try:
+ bytecode.append(int(tok, base=16))
+ except:
+ pass
+
+result = ''.join([ "\\x%02x"%(x) for x in bytecode ])
+result = f'{name}"{result}"'
+
+for x in badchars:
+ if x in bytecode:
+ result += f' **0x{"%02x"%(x)} detected**'
+
+print(result)