-
Notifications
You must be signed in to change notification settings - Fork 14
/
pwntools-sockets.py
47 lines (32 loc) · 1017 Bytes
/
pwntools-sockets.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
ORIG_PROCESS = pwnlib.tubes.process.process.__init__
class P2CWrite:
def __init__(self, fp):
self.fp = fp
self.closed = False
def close(self):
self.fp.close()
self.closed = True
def write(self, data):
self.fp.send(data)
def flush(self):
pass
class C2PRead:
def __init__(self, fp):
self.fp = fp
self.closed = False
def close(self):
self.fp.close()
self.closed = True
def fileno(self):
return self.fp.fileno()
def read(self, numb=-1):
return self.fp.recv(numb)
def process_init(self, *args, **kwargs):
p2cwrite = kwargs.pop("p2cwrite")
c2pread = kwargs.pop("c2pread")
ORIG_PROCESS(self, *args, **kwargs)
self.proc.stdin = P2CWrite(p2cwrite)
self.proc.stdout = C2PRead(c2pread)
pwnlib.tubes.process.process.__init__ = process_init
# parent, child = socket.socketpair()
# tube.process(stdin=child, p2cwrite=parent, stdout=child, c2pread=child, stderr=child)