File: gdb_faketerminal.py

package info (click to toggle)
pwntools 4.14.1-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 18,436 kB
  • sloc: python: 59,156; ansic: 48,063; asm: 45,030; sh: 396; makefile: 256
file content (19 lines) | stat: -rwxr-xr-x 549 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/usr/bin/env python
from pwnlib.tubes.process import process
from time import sleep
from sys import argv
from os import environ
sleep(1)
if len(argv) == 2:
    sh = process(argv[1], shell=True, timeout=30)
else:
    sh = process(argv[1:], timeout=30)
sh.sendline('set prompt (gdb)')
if environ.get('GDB_FAKETERMINAL') == '0':
    sh.sendline('set pagination off')
    sh.recvall()
else:
    res = sh.sendlineafter('(gdb)', 'c')
    while res and b'The program is not being run.' not in res:
        res = sh.sendlineafter('(gdb)', 'c')
sh.close()