コード例 #1
0
ファイル: telegram_noti.py プロジェクト: overjt/Osmedeus
def telegram_notification(noti_type, options, output=None):
    if not options.get('TELEGRAM'):
        return
    if output and 'report' in noti_type:
        if type(output) == list:
            output = list(set(output))
            for report in output:
                if utils.not_empty_file(report):
                    telegram_file(options, report)
        else:
            if utils.not_empty_file(output):
                telegram_file(options, output)
    else:
        telegram_noti(options, str(noti_type))
コード例 #2
0
def slack_notification(noti_type, options, output=None):
    if not options.get('SLACK'):
        return
    if output and 'report' in noti_type:
        if type(output) == list:
            output = list(set(output))
            for report in output:
                if utils.not_empty_file(report):
                    slack_file(options, report)
        else:
            if utils.not_empty_file(output):
                slack_file(options, output)
    else:
        slack_noti(options, str(noti_type))
コード例 #3
0
ファイル: osmedeus.py プロジェクト: faidamine/Osmedeus
def parsing_argument(args):
    # parsing agument
    options = config.parsing_config(args)
    # Start Django API if it's not running
    if not args.client:
        if not utils.connection_check('127.0.0.1', 8000):
            p = Process(target=start_server, args=(options.get('localhost'), ))
            p.start()
            # wait for Django API start
            time.sleep(3)
        else:
            utils.print_info("Look like Django API already ran")

    options = auth.login(options)
    if not options or not (options['JWT'] and options['JWT'] != "None"):
        utils.print_bad("Can't login to get JWT")
        sys.exit(-1)
    # run list of target
    if options.get('target_list') and utils.not_empty_file(
            options.get('target_list')):
        targets = utils.just_read(options.get('target_list'), get_list=True)
        for target in targets:
            options['raw_target'] = target
            options['workspace'] = target
            single_target(options)
    else:
        single_target(options)
コード例 #4
0
def _verify_target(target, target_list):
    if target_list:
        if utils.not_empty_file(target_list):
            real_target = target_list
        else:
            utils.print_bad("Input file not found: {0}".format(target_list))
            sys.exit(-1)
    else:
        real_target = target

    return real_target
コード例 #5
0
    def get_subdomains(self, command):
        utils.print_info("Joining all previous subdomain")
        final_path = command.get('requirement')
        if utils.not_empty_file(final_path):
            return
        subdomain_modules = [
            'SubdomainScanning', 'PermutationScan', 'VhostScan'
        ]
        needed_reports = []
        # get reports
        reports = report.get_report_path(self.options, module=False)
        for rep in reports:
            if rep.get('module') in subdomain_modules and 'final' in rep.get(
                    'note'):
                if utils.not_empty_file(rep.get('report_path')):
                    needed_reports.append(rep.get('report_path'))

        utils.join_files(needed_reports, final_path)
        if utils.not_empty_file(final_path):
            utils.check_output(final_path)
    def get_amass(self, command):
        ips, ip_range, asns = [], [], []
        output_path = command.get('output_path')
        content = utils.just_read(output_path, get_list=True)

        if content:
            ip_range.extend(content)

        amass_output = utils.replace_argument(
            self.options, '$WORKSPACE/subdomain/amass-$OUTPUT/amass.json')
        if not utils.not_empty_file(amass_output):
            return

        real_ips = summary.get_ip(self.options)
        if real_ips:
            ips.extend(real_ips)

        # parsed output from amass result
        jsonl = utils.just_read(amass_output, get_list=True)
        for line in jsonl:
            json_data = utils.get_json(line)
            for item in json_data.get('addresses'):
                ips.append(item.get('ip'))
                ip_range.append(item.get('cidr'))
                asns.append(str(item.get('asn')))

        ips_file = utils.replace_argument(
            self.options, '$WORKSPACE/ipspace/summary-$OUTPUT.txt')
        asn_file = utils.replace_argument(
            self.options, '$WORKSPACE/ipspace/asn-$OUTPUT.txt')
        range_file = utils.replace_argument(
            self.options, '$WORKSPACE/ipspace/range-$OUTPUT.txt')

        utils.just_write(ips_file, "\n".join(utils.unique_list(ips)))
        utils.just_write(asn_file, "\n".join(utils.unique_list(asns)))
        utils.just_write(range_file, "\n".join(utils.unique_list(ip_range)))