mirror of https://github.com/n1nj4sec/pupy.git
change smbspider verbosity
This commit is contained in:
parent
89aa935320
commit
61b11fe4e5
|
@ -2,22 +2,21 @@
|
||||||
# Code modified from the awesome tool CrackMapExec: /cme/spider/smbspider.py
|
# Code modified from the awesome tool CrackMapExec: /cme/spider/smbspider.py
|
||||||
# Thank you to byt3bl33d3r for its work
|
# Thank you to byt3bl33d3r for its work
|
||||||
from pupylib.PupyModule import *
|
from pupylib.PupyModule import *
|
||||||
#from netaddr import *
|
|
||||||
from netaddr import *
|
from netaddr import *
|
||||||
__class_name__="SMBSpider"
|
__class_name__="SMBSpider"
|
||||||
|
|
||||||
@config(cat="admin")
|
@config(cat="admin")
|
||||||
class SMBSpider(PupyModule):
|
class SMBSpider(PupyModule):
|
||||||
""" walk through a smb directory and recursively search a string into files """
|
""" walk through a smb directory and recursively search a string into files """
|
||||||
|
|
||||||
daemon=True
|
daemon=True
|
||||||
|
max_clients=1
|
||||||
|
|
||||||
def init_argparse(self):
|
def init_argparse(self):
|
||||||
|
|
||||||
example = 'Examples:\n'
|
example = 'Examples:\n'
|
||||||
example += '>> run smbspider --pattern password --content 192.168.0.1\n'
|
example += '>> run smbspider 192.168.0.1 --pattern password --content\n'
|
||||||
example += '>> run smbspider -u john -p password1 -d TEST --regex password.* pwd.* --content -e txt,ini 192.168.0.1\n'
|
example += '>> run smbspider 192.168.0.1 -u john -p password1 -d TEST --regex password.* pwd.* --content -e txt,ini\n'
|
||||||
example += '>> run smbspider -u john --regex password.* -H \'aad3b435b51404eeaad3b435b51404ee:da76f2c4c96028b7a6111aef4a50a94d\' 172.16.0.20\n'
|
example += '>> run smbspider 172.16.0.20/24 -u john --regex password.* -H \'aad3b435b51404eeaad3b435b51404ee:da76f2c4c96028b7a6111aef4a50a94d\'\n'
|
||||||
|
|
||||||
self.arg_parser = PupyArgumentParser(prog="smbspider", description=self.__doc__, epilog=example)
|
self.arg_parser = PupyArgumentParser(prog="smbspider", description=self.__doc__, epilog=example)
|
||||||
self.arg_parser.add_argument("-u", metavar="USERNAME", dest='user', default='', help="Username, if omitted null session assumed")
|
self.arg_parser.add_argument("-u", metavar="USERNAME", dest='user', default='', help="Username, if omitted null session assumed")
|
||||||
|
@ -37,6 +36,7 @@ class SMBSpider(PupyModule):
|
||||||
sgroup.add_argument('-e','--extensions',metavar='ext1,ext2,...', help='limit to some extensions')
|
sgroup.add_argument('-e','--extensions',metavar='ext1,ext2,...', help='limit to some extensions')
|
||||||
sgroup.add_argument("--depth", type=int, default=10, help='Spider recursion depth (default: 10)')
|
sgroup.add_argument("--depth", type=int, default=10, help='Spider recursion depth (default: 10)')
|
||||||
sgroup.add_argument('-m','--max-size', type=int, default=7000000, help='max file size in byte (default 7 Mo)')
|
sgroup.add_argument('-m','--max-size', type=int, default=7000000, help='max file size in byte (default 7 Mo)')
|
||||||
|
sgroup.add_argument('-v','--verbose', action='store_true', default=False, help='verbose mode')
|
||||||
|
|
||||||
def run(self, args):
|
def run(self, args):
|
||||||
exts=[]
|
exts=[]
|
||||||
|
@ -49,31 +49,30 @@ class SMBSpider(PupyModule):
|
||||||
hosts = list()
|
hosts = list()
|
||||||
hosts.append(args.target[0])
|
hosts.append(args.target[0])
|
||||||
|
|
||||||
self.info("Loading dependencies")
|
|
||||||
self.client.load_package("impacket")
|
self.client.load_package("impacket")
|
||||||
|
self.client.load_package("calendar")
|
||||||
self.client.load_package("pupyutils.smbspider")
|
self.client.load_package("pupyutils.smbspider")
|
||||||
|
|
||||||
for host in hosts:
|
for host in hosts:
|
||||||
self.info("Connecting to the remote host: %s:%s" % (host, str(args.port)))
|
if args.verbose:
|
||||||
|
self.info("Connection on the remote host: %s:%s" % (host, str(args.port)))
|
||||||
|
|
||||||
smbspider = self.client.conn.modules["pupyutils.smbspider"].SMBSpider(host, args.domain, args.port, args.user, args.passwd, args.hash, args.content, args.regex, args.share, args.exclude_dirs, exts, args.pattern, args.max_size)
|
smbspider = self.client.conn.modules["pupyutils.smbspider"].SMBSpider(host, args.domain, args.port, args.user, args.passwd, args.hash, args.content, args.regex, args.share, args.exclude_dirs, exts, args.pattern, args.max_size)
|
||||||
logged = smbspider.login()
|
logged = smbspider.login()
|
||||||
if not logged:
|
if logged:
|
||||||
self.error("Connection failed !")
|
|
||||||
return
|
|
||||||
|
|
||||||
# spider all shares
|
# spider all shares
|
||||||
if args.share == 'all':
|
if args.share == 'all':
|
||||||
for share in smbspider.list_share():
|
for share in smbspider.list_share():
|
||||||
# self.info("Spidering remote share smb://%s/%s" % (host, share))
|
|
||||||
smbspider.set_share(share)
|
smbspider.set_share(share)
|
||||||
for res in smbspider.spider(args.spider, int(args.depth)):
|
for res in smbspider.spider(args.spider, int(args.depth)):
|
||||||
self.success("%s" % res)
|
self.success("%s > %s" % (host, res))
|
||||||
|
|
||||||
# spider only one share
|
# spider only one share
|
||||||
else:
|
else:
|
||||||
for res in smbspider.spider(args.spider, int(args.depth)):
|
for res in smbspider.spider(args.spider, int(args.depth)):
|
||||||
self.success("%s" % res)
|
self.success("%s" % res)
|
||||||
|
|
||||||
self.info("search finished !")
|
|
||||||
smbspider.logoff()
|
smbspider.logoff()
|
||||||
|
if args.verbose:
|
||||||
|
self.info("Search finished !")
|
||||||
|
else:
|
||||||
|
if args.verbose:
|
||||||
|
self.error("Connection failed !")
|
Loading…
Reference in New Issue