diff --git a/pwnlib/commandline/shellcraft.py b/pwnlib/commandline/shellcraft.py index 497f4a267..84b86f0e3 100644 --- a/pwnlib/commandline/shellcraft.py +++ b/pwnlib/commandline/shellcraft.py @@ -57,9 +57,10 @@ def _string(s): 'p', 'i', 'hexii', 'e', 'elf', + 'd', 'escaped', 'default'], default = 'default', - help = 'Output format (default: hex), choose from {r}aw, {s}tring, {c}-style array, {h}ex string, hex{i}i, {a}ssembly code, {p}reprocssed code', + help = 'Output format (default: hex), choose from {e}lf, {r}aw, {s}tring, {c}-style array, {h}ex string, hex{i}i, {a}ssembly code, {p}reprocssed code, escape{d} hex string', ) p.add_argument( @@ -329,7 +330,8 @@ def main(args): code = pwnlib.util.fiddling.enhex(code) + '\n' elif args.format in ['i', 'hexii']: code = hexii(code) + '\n' - + elif args.format in ['d', 'escaped']: + code = ''.join('\\x%02x' % ord(c) for c in code) + '\n' if not sys.stdin.isatty(): args.out.write(sys.stdin.read())