fixed rev_shell deadlock when shell instantly closes
This commit is contained in:
parent
67045c6ba0
commit
2d708619b8
@ -98,6 +98,7 @@ class ShellListener:
|
||||
|
||||
print("[-] Disconnected")
|
||||
self.connection = None
|
||||
self.running = False
|
||||
|
||||
def close(self):
|
||||
self.running = False
|
||||
@ -432,7 +433,7 @@ def wait_for_connection(listener, timeout=None, prompt=True):
|
||||
else:
|
||||
print(prompt)
|
||||
|
||||
while listener.connection is None:
|
||||
while listener.connection is None and listener.running:
|
||||
time.sleep(0.5)
|
||||
if timeout is not None:
|
||||
diff = time.time() - start
|
||||
|
9
util.py
9
util.py
@ -321,7 +321,7 @@ def pad(x, n, b=b"\x00", s="r"):
|
||||
x = (n-(len(x)%n))*b + x
|
||||
return x
|
||||
|
||||
def xor(a, b):
|
||||
def xor(a, b, *args):
|
||||
if isinstance(a, int):
|
||||
a = a.to_bytes(math.ceil(math.log(a)/math.log(2)/8.0))
|
||||
if isinstance(b, int):
|
||||
@ -345,9 +345,12 @@ def xor(a, b):
|
||||
if type(b) not in (bytes, bytearray):
|
||||
b = b.encode()
|
||||
|
||||
|
||||
result = b"".join([bytes([c1 ^ c2]) for (c1,c2) in zip(a, b) ])
|
||||
|
||||
return b"".join([bytes([c1 ^ c2]) for (c1,c2) in zip(a, b) ])
|
||||
if len(args) > 0:
|
||||
result = xor(result, *args)
|
||||
|
||||
return result
|
||||
|
||||
def base64urldecode(data):
|
||||
if isinstance(data, str):
|
||||
|
Loading…
Reference in New Issue
Block a user