diff options
author | Malfurious <m@lfurio.us> | 2022-03-10 04:47:04 -0500 |
---|---|---|
committer | Malfurious <m@lfurio.us> | 2022-03-14 00:14:53 -0400 |
commit | f013d802088ede38389705c8b8591e8b26de221e (patch) | |
tree | 274d361124e745e82f5e9ca71376f0ba361ec31a /tools | |
parent | 13ad3d5d41fec4042a35424e0b21c0f8136ed690 (diff) | |
download | lib-des-gnux-f013d802088ede38389705c8b8591e8b26de221e.tar.gz lib-des-gnux-f013d802088ede38389705c8b8591e8b26de221e.zip |
sploit: Add function Comm.readall_nonblock()
Function should consume all available incoming data from target and
return it, however will return 'immediately' (according to a
configurable timeout) if the pipe is empty.
Signed-off-by: Malfurious <m@lfurio.us>
Signed-off-by: dusoleil <howcansocksbereal@gmail.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/sploit/sploit/comm.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/tools/sploit/sploit/comm.py b/tools/sploit/sploit/comm.py index 604045c..4b1d487 100644 --- a/tools/sploit/sploit/comm.py +++ b/tools/sploit/sploit/comm.py @@ -11,6 +11,7 @@ class Comm: logonread = True logonwrite = False flushonwrite = True + timeout = 0.25 # seconds def __init__(self, backend): self.back = backend @@ -42,6 +43,16 @@ class Comm: pass return data + def readall_nonblock(self): + try: + os.set_blocking(self.back.stdin.fileno(), False) + poll = select.poll() + poll.register(self.back.stdin, select.POLLIN) + poll.poll(self.timeout) + return self.readall() + finally: + os.set_blocking(self.back.stdin.fileno(), True) + def readuntil(self, pred, /, *args, **kwargs): data = b'' pred = bind(pred, *args, **kwargs) |