add interactive arg

This commit is contained in:
Liam Dalgarno 2020-12-06 14:51:33 +00:00
parent 8026609b48
commit 9814d27a0a

View File

@ -42,6 +42,7 @@ arg_parser.add_argument("--min_payload", metavar="min", default=32, type=int, he
arg_parser.add_argument("--max_payload", metavar="max", default=16384, type=int, help="The maximum payload length to try") arg_parser.add_argument("--max_payload", metavar="max", default=16384, type=int, help="The maximum payload length to try")
arg_parser.add_argument("--input_method", metavar="method", choices=['arg', 'file', 'stdin'], default='arg', help="Method of passing the payload to the target binary") arg_parser.add_argument("--input_method", metavar="method", choices=['arg', 'file', 'stdin'], default='arg', help="Method of passing the payload to the target binary")
arg_parser.add_argument("--run", action="store_true", default=False, help="Automatically run the ROP on the executable") arg_parser.add_argument("--run", action="store_true", default=False, help="Automatically run the ROP on the executable")
arg_parser.add_argument("--interactive", action="store_true", default=False, help="Automatically run the ROP on the executable")
args = arg_parser.parse_args() args = arg_parser.parse_args()
@ -52,8 +53,9 @@ min_payload = args.min_payload
max_payload = args.max_payload max_payload = args.max_payload
run = args.run run = args.run
input_method = args.input_method input_method = args.input_method
interactive = args.interactive
def run_program(payload: str, **kwargs): def run_program(payload: str, **kwargs) -> process:
p = None p = None
if input_method == 'arg': if input_method == 'arg':
p = process([f'./{exec_file}', payload], **kwargs) p = process([f'./{exec_file}', payload], **kwargs)
@ -82,7 +84,7 @@ def find_offset_inc(low: int, high: int):
"--ropFile", rop_file, "--ropFile", rop_file,
"--execFile", 'rop_exec_default.json', "--execFile", 'rop_exec_default.json',
], ],
stdout = subprocess.PIPE stdout = subprocess.DEVNULL
) )
with open(rop_file, 'rb') as f: with open(rop_file, 'rb') as f:
@ -156,6 +158,10 @@ if run:
print() print()
print(f"[ Run Program : ./{exec_file} {rop_file} ]") print(f"[ Run Program : ./{exec_file} {rop_file} ]")
with open(rop_file, 'rb') as f: with open(rop_file, 'rb') as f:
term.init()
p = run_program(f.read()) p = run_program(f.read())
if interactive:
term.init()
p.interactive() p.interactive()
else:
print(p.recvall().decode('utf-8'))