Example #1
0
def start():
    if kb.targets and kb.targets.qsize() > 1:
        infoMsg = "penework got a total of %d targets" % kb.targets.qsize()
        logger.log(CUSTOM_LOGGING.SYSINFO, infoMsg)

    runThreads(conf.threads, pocThreads)

    resultTable = PrettyTable(["target-url", "poc-name", "poc-id", "component", "version", "status"])
    resultTable.padding_width = 1

    if not kb.results:
        return

    toNum, sucNum = 0, 0
    for row in kb.results:
        resultTable.add_row(list(row)[:-2])
        toNum += 1
        if row[5] == 'success':
            sucNum += 1

    if not conf.quiet:
        print resultTable
        # infoMsg = "{} of {} success !".format(sucNum, toNum)
        # logger.log(CUSTOM_LOGGING.SYSINFO, infoMsg)
        print "success : {} / {}".format(sucNum, toNum)

    _createTargetDirs()
    _setRecordFiles()

    if conf.report:
        _setReport()
Example #2
0
 def show_options(self, current_module):
     tb = PrettyTable()
     tb.set_style(PLAIN_COLUMNS)
     print(f'\nModule options ({current_module}):\n')
     tb.field_names = ['Name', 'Current Setting', 'Required', 'Description']
     tb.add_row(['----', '---------------', '--------', '-----------'])
     for key in sorted(self.option.keys()):
         tb.add_row([
             key,
             self.get_options(key), self.option[key]['Required'],
             self.option[key]['Description']
         ])
     # print('Name\t\tCurrent Setting                                       \t\t\tRequired\t\tDescription')
     # print('----\t\t---------------                                       \t\t\t--------\t\t-----------')
     # for key in sorted(self.option.keys()):
     #     print('{0:<4}\t\t{1:<55}\t\t\t{2:<8}\t\t{3:<11}'.format(key, self.get_options(key), self.option[key]["Required"], self.option[key]["Description"]))
     # #
     # Name = 4
     # C_Set = 15
     # Required = 8
     # Description = 11
     # for key in sorted(self.option.keys()):
     # print('%s%s\n' % ((key if len(key) == Name else key + ' ' * (len(key) -4)), (self.get_options(key) if len(self.get_options(key)) == C_Set else self.get_options(key) + ' ' * (15 - len(self.get_options(key))))))
     # print('%s' % (self.get_options(key) if len(self.get_options(key)) == C_Set else self.get_options(key) + ' ' * (15 - len(self.get_options(key)))))
     tb.align = 'l'
     print(tb)
     print('\n')
Example #3
0
def start():
    if kb.targets and kb.targets.qsize() > 1:
        infoMsg = "penework got a total of %d targets" % kb.targets.qsize()
        logger.log(CUSTOM_LOGGING.SYSINFO, infoMsg)

    runThreads(conf.threads, pocThreads)

    resultTable = PrettyTable(
        ["target-url", "poc-name", "poc-id", "component", "version", "status"])
    resultTable.padding_width = 1

    if not kb.results:
        return

    toNum, sucNum = 0, 0
    for row in kb.results:
        resultTable.add_row(list(row)[:-2])
        toNum += 1
        if row[5] == 'success':
            sucNum += 1

    if not conf.quiet:
        print resultTable
        # infoMsg = "{} of {} success !".format(sucNum, toNum)
        # logger.log(CUSTOM_LOGGING.SYSINFO, infoMsg)
        print "success : {} / {}".format(sucNum, toNum)

    _createTargetDirs()
    _setRecordFiles()

    if conf.report:
        _setReport()
Example #4
0
 def dump(self):
     fun = inspect.stack()[0][3]
     dbs = conf.dbs
     tables = conf.table
     cols = conf.columns
     '''
     if (len(dbs) > 1 and len(tables)>0) or (len(tables)>1 and len(cols>0)):
         logger.info("Please -D db -T table -C col --dump")
     '''
     for db in dbs:
         if not tables:
             tables = self.do("get_tables", db)
         logger.info(tables)
         for table in tables:
             if (not conf.table
                     and not conf.columns) or (conf.table
                                               and not conf.columns):
                 cols = self.do("get_columns", db, table)
             logger.info(cols)
             out = PrettyTable()
             info = "{0}.{1}\n".format(db, table)
             logger.info(info)
             put_file_contents(DUMP_FILE, info)
             for col in cols:
                 values = self.do(fun, db, table, col)
                 out.add_column(col, values)
                 logger.info(out)
             put_file_contents(DUMP_FILE, str(out))
     return
Example #5
0
 def get_dbs(self):
     fun = inspect.stack()[0][3]
     dbs = self.do(fun)
     out = PrettyTable()
     out.add_column("DATABASE:", dbs)
     logger.info(out)
     put_file_contents(DUMP_FILE, str(out))
     return
Example #6
0
    def do_show(self, args):

        graph = PrettyTable(["config", "value"])
        graph.align["config"] = "l"

        for k,v  in conf.iteritems():
            if v and k != 'httpHeaders':
                graph.add_row([k, v])
        print graph
Example #7
0
    def do_show(self, args):

        graph = PrettyTable(["config", "value"])
        graph.align["config"] = "l"

        for k, v in conf.iteritems():
            if v and k != 'httpHeaders':
                graph.add_row([k, v])
        print graph
Example #8
0
    def do_search(self, args):
        graph = PrettyTable(["pocId", "PocName"])
        graph.align["PocName"] = "m"
        graph.padding_width = 1

        for k, v in kb.unloadedList.iteritems():
            if str(args) in v:
                graph.add_row([k, filepathParser(v)[1]])
        print graph
        pass
Example #9
0
def avaliable():
    graph = PrettyTable(["pocId", "avaliablePocName", "Folder"])
    graph.align["PocsName"] = "m"
    graph.padding_width = 1

    for k, v in kb.unloadedList.iteritems():
        path, name = filepathParser(v)
        graph.add_row([k, name, os.path.relpath(path, paths.POCSUITE_ROOT_PATH)])
        
    print graph
    print
Example #10
0
 def show_options(self):
     """Show option by table"""
     id = 1
     table = PrettyTable()
     print "\033[01;33m            =====%s=====    \033[0m" % self.name
     table.field_names = ["Id", "argName", "argValue", "description"]
     for k, v in self.readme.items():
         argValue= self.config[k]
         des =   getUnicode(v)
         table.add_row([id, k, argValue, v])
     print table
Example #11
0
 def get_columns(self):
     fun = inspect.stack()[0][3]
     db = conf.dbs[0]
     tables = conf.table
     for table in tables:
         cols = self.do(fun, db, table)
         out = PrettyTable()
         out.add_column(table, cols)
         logger.info(out)
         put_file_contents(DUMP_FILE, "table:{0}.{1}".format(db, table))
         put_file_contents(DUMP_FILE, str(out))
     return
Example #12
0
 def get_tables(self):
     fun = inspect.stack()[0][3]
     dbs = conf.dbs
     tables = []
     for db in dbs:
         tables = self.do(fun, db)
         logger.success(db)
         out = PrettyTable()
         out.add_column("TABLES:", tables)
         logger.info(out)
         put_file_contents(DUMP_FILE, "db:{0}".format(db))
         put_file_contents(DUMP_FILE, str(out))
     return
def list_style(items):
    print('\n')
    tb = PrettyTable()
    tb.set_style(PLAIN_COLUMNS)
    tb.field_names = ['Name', 'Module', 'Description']
    tb.add_row(['----', '------', '-----------'])
    for i in items:
        _ = list(i)
        # print(_)
        tb.add_row(_)

    tb.align = 'l'
    print(tb)
    print('\n')
Example #14
0
def start():
    if kb.targets and kb.targets.qsize() > 1:
        infoMsg = "pocsuite got a total of %d targets" % kb.targets.qsize()
        logger.log(CUSTOM_LOGGING.SYSINFO, infoMsg)

    runThreads(conf.threads, pocThreads)

    resultTable = PrettyTable(["target-url", "poc-name", "poc-id", "component", "version", "status"])
    resultTable.padding_width = 1
    for row in kb.results:
        resultTable.add_row(list(row)[:-1])

    print resultTable

    _createTargetDirs()
    _setRecordFiles()

    if conf.report:
        _setReport()
Example #15
0
 def do_run(self, line):
     """Run all pocs, usage: run"""
     if self.check_target():
         logger.info('Sheep got a total of %d targets.' %
                     self.targets.qsize())
         self.import_pocs()
         self.mix_targets()
         try:
             runThreads(self.threadsun, self.poc_threads)
         except Exception, e:
             logger.error('Run error! %s' % e)
         table = PrettyTable()
         table.field_names = ["pocNmae", "target", "result"]
         table.padding_width = 1
         if not self.results:
             return
         toNum, sucNum = 0, 0
         for row in self.results:
             table.add_row(list(row))
             toNum += 1
             if row[2] == 'success':
                 sucNum += 1
         print
         logger.info("Result:")
         print table
         print "success : %d / %d " % (sucNum, toNum)
         self.set_record_files()
         self.results.clear()
Example #16
0
def checkSearch(args):
    input_path = args.script_name
    list_scripts = args.list_scripts
    search_script = args.search_script
    if search_script and (input_path or list_scripts):
        msg = 'Cannot specify or list script when you use [--search]'
        sys.exit(logger.error(msg))
    if search_script:
        if re.findall(r'[^\w\d\-_ ]', search_script):
            msg = 'The script name you provided is incorrect'
            sys.exit(logger.error(msg))
        scriptsheet = PrettyTable(["Script"])
        scriptsheet.align["Script"] = "l"
        scriptsheet.padding_width = 1
        length = 0
        module_name_list = glob.glob(os.path.join(paths.SCRIPT_PATH, '*.py'))
        for each in module_name_list:
            _str = os.path.split(each)[1][0:-3]
            if _str != '__init__' and re.findall(search_script, _str):
                scriptsheet.add_row([_str])
                length = length + 1
        if length > 0:
            msg = 'Total:{}\n'.format(length)
            print scriptsheet
            dataToStdout(msg)
        else:
            msg = 'No results found'
            logger.error(msg)
        logger.info('System exit')
        sys.exit()
Example #17
0
    def do_unload(self, args):
        # TODO 补全
        graph = PrettyTable(["pocId", "unloadPocsName"])
        graph.align["unloadPocsName"] = "m"
        graph.padding_width = 1

        if hasattr(kb, 'unloadedList') and getattr(kb, 'unloadedList'):
            for no in sorted(kb.unloadedList.keys()):
                from ntpath import split
                graph.add_row([no, split(kb.unloadedList[no])[1]])
        else:
            graph.add_row(["0", "None"])
        print graph
        print
Example #18
0
    def do_loaded(self, args):
        registerPocFromDict()

        graph = PrettyTable(["pocId", "loadedPocsName"])
        graph.align["LoadedPocsName"] = "m"
        graph.padding_width = 1
        count = 0

        if hasattr(kb, 'registeredPocs') and getattr(kb, 'registeredPocs'):
            for poc in sorted(kb.registeredPocs.keys()):
                count += 1
                graph.add_row([count, poc])
        else:
            graph.add_row(["0", "None"])
        print graph
        print
Example #19
0
    def do_search(self, args):
        graph = PrettyTable(["pocId", "PocName"])
        graph.align["PocName"] = "m"
        graph.padding_width = 1

        for k, v in kb.unloadedList.iteritems():
            if str(args) in v:
                graph.add_row([k, filepathParser(v)[1]])
        print graph
        pass
Example #20
0
    def do_unload(self, args):
        # TODO 补全
        graph = PrettyTable(["pocId", "unloadPocsName"])
        graph.align["unloadPocsName"] = "m"
        graph.padding_width = 1

        if hasattr(kb, 'unloadedList') and getattr(kb, 'unloadedList'):
            for no in sorted(kb.unloadedList.keys()):
                from ntpath import split
                graph.add_row([no, split(kb.unloadedList[no])[1]])
        else:
            graph.add_row(["0", "None"])
        print graph
        print
Example #21
0
def avaliable():
    graph = PrettyTable(["pocId", "avaliablePocName", "Folder"])
    graph.align["PocsName"] = "m"
    graph.padding_width = 1

    for k, v in kb.unloadedList.iteritems():
        path, name = filepathParser(v)
        graph.add_row([k, name, os.path.relpath(path, paths.POCSUITE_ROOT_PATH)])
        
    print graph
    print
Example #22
0
def printResult():
    targetsheet = PrettyTable(["Target", "Vulnerable"])
    targetsheet.align["Target"] = "l"
    targetsheet.padding_width = 1
    for i in targetlist:
        targetsheet.add_row(i)
    print targetsheet
    msg = '{} found | {} scanned in {} second'.format(
        th.found_count, th.scan_count,
        str(time.time() - th.start_time)[0:4])
    out = '{}\n'.format(msg)
    dataToStdout(out)
Example #23
0
    def do_loaded(self, args):
        registerPocFromFile()

        graph = PrettyTable(["pocId", "loadedPocsName"])
        graph.align["LoadedPocsName"] = "m"
        graph.padding_width = 1
        count = 0

        if hasattr(kb, 'registeredPocs') and getattr(kb, 'registeredPocs'):
            for poc in sorted(kb.registeredPocs.keys()):
                count += 1
                graph.add_row([count, poc])
        else:
            graph.add_row(["0", "None"])
        print graph
        print
Example #24
0
def checkShow(args):
    input_path = args.script_name
    list_scripts = args.list_scripts
    search_script = args.search_script
    if list_scripts and (input_path or search_script):
        msg = 'Cannot specify or search script when you use [--list]'
        sys.exit(logger.error(msg))
    scriptsheet = PrettyTable(["Script"])
    scriptsheet.align["Script"] = "l"
    scriptsheet.padding_width = 1
    if list_scripts:
        module_name_list = glob.glob(os.path.join(
            paths.SCRIPT_PATH, '*.py'))  #获取script文件夹下所有.py文件列表
        msg = 'Total:{}\n'.format(str(len(module_name_list) -
                                      1))  #除去__init__.py算出total总数
        for each in module_name_list:
            _str = os.path.split(each)[1][0:-3]
            if _str != '__init__':
                scriptsheet.add_row([_str])
        print scriptsheet
        dataToStdout(msg)
        logger.info('System exit')
        sys.exit()
Example #25
0
 def show_options(self):
     """Show option by table"""
     table = PrettyTable()
     print "\033[01;33m            =====Detect subdomain=====    \033[0m"
     table.field_names = ["Id", "argName", "argValue", "description"]
     table.add_row(
         [1, "domain", self.domain, "To detect for a domain name"])
     table.add_row([
         2, "full_scan", self.full_scan,
         "Full scan, a large NAMES FILE will be used during the scan, default=False"
     ])
     table.add_row([
         3, "i", self.i,
         "Ignore domains pointed to private IPs, default=False"
     ])
     table.add_row([
         4, "output", self.output,
         "Output file name. default is  data/subdomain/{target}.txt"
     ])
     print table
def search_style(result):
    tb = PrettyTable()
    tb.set_style(PLAIN_COLUMNS)
    tb.field_names = ['Name', 'Module']
    tb.add_row(['----', '------'])
    if result:
        for i in result:
            if type(i) == tuple:
                tb.add_row([i[0], i[1]])
            elif type(i) == list:
                tb.add_row([i[0][0], i[0][1]])

        tb.align = 'l'
        print(tb)
    else:
        return None
Example #27
0
 def show_options(self):
     """Show option by table"""
     ipDec = "target ip/mask, usage: set = 127.0.0.1/24"
     fileDec = "target file, Please put the DATA directory.  ussge: set file = target.txt"
     urlDec = "target url. usage: set url = www.baidu.com"
     threadDec = "Default thread id 1, usage: set threads = 10"
     table = PrettyTable()
     print "\033[01;33m          ---------------------------------------------\033[0m"
     print "\033[01;32m          *******target(Choose one of the three)*******\033[0m"
     print "\033[01;33m          ---------------------------------------------\033[0m"
     table.field_names = ["Id", "argName", "argValue", "description"]
     table.add_row([1, 'ip', self.ip, ipDec])
     table.add_row([2, 'file', self.file, fileDec])
     table.add_row([3, 'url', self.url, urlDec])
     table.add_row([4, 'threads', self.threadsun, threadDec])
     print table
Example #28
0
def main():
    x = PrettyTable(["City name", "Area", "Population", "Annual Rainfall"])
    x.sortby = "Population"
    x.reversesort = True
    x.int_format["Area"] = "04d"
    x.float_format = "6.1f"
    x.align["City name"] = "l"  # Left align city names
    x.add_row(["Adelaide", 1295, 1158259, 600.5])
    x.add_row(["Brisbane", 5905, 1857594, 1146.4])
    x.add_row(["Darwin", 112, 120900, 1714.7])
    x.add_row(["Hobart", 1357, 205556, 619.5])
    x.add_row(["Sydney", 2058, 4336374, 1214.8])
    x.add_row(["Melbourne", 1566, 3806092, 646.9])
    x.add_row(["Perth", 5386, 1554769, 869.4])
    print(x)