Skip to content

Commit a366e91

Browse files
authored
Add TTY escape function for file transfer (#2422)
1 parent 736cf9d commit a366e91

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

pwnlib/util/fiddling.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1097,3 +1097,11 @@ def js_unescape(s, **kwargs):
10971097
p += 1
10981098

10991099
return b''.join(res)
1100+
1101+
def tty_escape(s, lnext=b'\x16', dangerous=bytes(bytearray(range(0x20)))):
1102+
s = s.replace(lnext, lnext * 2)
1103+
for b in bytearray(dangerous):
1104+
if b in lnext: continue
1105+
b = bytearray([b])
1106+
s = s.replace(b, lnext + b)
1107+
return s

0 commit comments

Comments
 (0)