Beispiel #1
0
    def get_targets(self, args):
        targets = []

        if args.url:

            targets.append(args.url)

        if args.file:
            urls = open(args.file).read().split("\n")
            for u in urls:
                if u:
                    targets.append(u)

        if args.import_database:
            if args.rescan:
                targets += run(scope_type="active")
            else:
                targets += run(tool=self.name, args=self.args.tool_args, scope_type="active")

        if args.output_path[0] == "/":
            output_path = os.path.join(
                self.base_config["ARMORY_BASE_PATH"],
                args.output_path[1:],
                str(int(time.time())),
            )

        else:
            output_path = os.path.join(
                self.base_config["ARMORY_BASE_PATH"],
                args.output_path,
                str(int(time.time())),
            )

        if not os.path.exists(output_path):
            os.makedirs(output_path)

        res = []
        for t in targets:
            res.append(
                {
                    "target": t,
                    "output": os.path.join(
                        output_path,
                        t.replace(":", "_")
                        .replace("/", "_")
                        .replace("?", "_")
                        .replace("&", "_")
                        + "-dir.txt",  # noqa: W503
                    ),
                }
            )

        return res
Beispiel #2
0
    def run(self, args):
        
        if args.scope not in ['active', 'passive']:
            args.scope = None


        self.process_output(get_urls.run(scope_type=args.scope), args)
Beispiel #3
0
    def get_targets(self, args):
        targets = []

        if args.url:

            targets.append(args.url)

        if args.file:
            urls = open(args.file).read().split("\n")
            for u in urls:
                if u:
                    targets.append(u)

        if args.import_database:
            if args.rescan:
                targets += get_urls.run(scope_type="active", args=self.args.tool_args)
            else:
                targets += get_urls.run(tool=self.name, scope_type="active", args=self.args.tool_args)

        if args.output_path[0] == "/":
            self.output_path = os.path.join(
                self.base_config["ARMORY_BASE_PATH"],
                args.output_path[1:],
                str(int(time.time())),
            )

        else:
            self.output_path = os.path.join(
                self.base_config["ARMORY_BASE_PATH"],
                args.output_path,
                str(int(time.time())),
            )

        if not os.path.exists(self.output_path):
            os.makedirs(self.output_path)

        res = []
        for t in targets:
            res.append(
                {
                    "target": t,
                    "output": os.path.join(self.output_path, "{}.txt".format(t.replace(':', '_').replace('/', '_')))
                    
                }
            )

        return res
Beispiel #4
0
    def run(self, args):
        urls = []
        if args.url:
            urls.append(args.url)

        if args.file:
            url = open(args.file).read().split("\n")
            for u in url:
                if u:
                    urls.append(u)

        if args.import_db:

            if args.rescan:
                urls += run(scope_type="active")
            else:
                urls += run(scope_type="active", tool=self.name)

        if urls:
            pool = ThreadPool(int(args.threads))
            data = [(u, args.timeout) for u in urls]
            # pdb.set_trace()
            results = pool.map(process_urls, data)
            display_new("Adding headers to the database")

            for headers, cookies in results:
                if len(list(headers.keys())) > 0:
                    h = list(headers.keys())[0]
                    dom, dom_type, scheme, port = get_url_data(h)
                    display(
                        "Processing headers and cookies from URL {}".format(h))

                    if dom_type == 'ip':
                        ip, created = IPAddress.objects.get_or_create(
                            ip_address=dom)

                        ip.add_tool_run(tool=self.name)
                        # pdb.set_trace()
                        p, created = Port.objects.get_or_create(
                            ip_address=ip,
                            port_number=port,
                            service_name=scheme,
                            proto="tcp")
                        if not p.meta.get('headers'):
                            p.meta['headers'] = {}
                        p.meta['headers'][dom] = headers[h]

                        if not p.meta.get('cookies'):
                            p.meta['cookies'] = {}

                        p.meta['cookies'][dom] = cookies.get(h, [])

                        p.save()

                    else:
                        domain, created = Domain.objects.get_or_create(
                            name=dom)

                        domain.add_tool_run(tool=self.name)

                        for ip in domain.ip_addresses.all():

                            p, created = Port.objects.get_or_create(
                                ip_address=ip,
                                port_number=port,
                                service_name=scheme,
                                proto="tcp")
                            if not p.meta.get('headers'):
                                p.meta['headers'] = {}
                            p.meta['headers'][dom] = headers[h]

                            if not p.meta.get('cookies'):
                                p.meta['cookies'] = {}
                            p.meta['cookies'][dom] = cookies.get(h, [])

                            p.save()