示例#1
0
    def prepare_input(self):
        if self.is_direct:
            if utils.not_empty_file(self.is_direct):
                ip_file = utils.replace_argument(
                    self.options, '$WORKSPACE/subdomain/final-IP-$OUTPUT.txt')
                # print(ip_file)
                ip_list = utils.just_read(ip_file).splitlines()
                ip_list = list(set([ip for ip in ip_list if ip != 'N/A']))
            else:
                ip_list = utils.resolve_input(self.is_direct)
        else:
            main_json = utils.reading_json(
                utils.replace_argument(self.options,
                                       '$WORKSPACE/$COMPANY.json'))
            main_json['Modules'][self.module_name] = []

            if self.options['SPEED'] == 'slow':
                ip_list = [
                    x.get("IP")
                    for x in main_json['Subdomains'] if x.get("IP") is not None
                ] + main_json['IP Space']

            elif self.options['SPEED'] == 'quick':
                ip_list = [
                    x.get("IP") for x in main_json['Subdomains']
                    if x.get("IP") is not None
                ]

            ip_list = set([ip for ip in ip_list if ip != 'N/A'])

        return ip_list
示例#2
0
    def get_asn(self):
        ip_target = utils.resolve_input(self.target)
        if not ip_target:
            return False
        utils.print_banner(f"Starting scraping detail ASN of {ip_target}")

        utils.print_info(f'Get ASN from IP: {ip_target}')
        url = f'https://ipinfo.io/{ip_target}/json'
        r = sender.send_get(self.options, url, None)
        org_info = r.json().get('org')
        asn = utils.get_asn(org_info)
        if asn:
            utils.print_info(f"Detect target running on {asn}")
            ips = self.get_asn_ip(asn)
            utils.just_write(self.options['output'], "\n".join(ips))
            utils.just_cleanup(self.options['output'])
        else:
            return False
示例#3
0
    def post(self, request, *args, **kwargs):
        serializer = WorkspacesSerializer(data=request.data)
        serializer.is_valid(raise_exception=True)
        data = serializer.data

        # just some verbose options
        mode = data.get('mode')
        verbose = data.get('verbose')
        speed = data.get('speed')
        forced = data.get('forced')
        arch = data.get('arch')

        # input part
        raw_target = data.get('raw_target')
        target = dbutils.clean_input(raw_target)
        # resolve IP if possible
        ip_address = utils.resolve_input(target)

        # strip slash for saving it as path
        workspace = utils.get_ws(target)

        # output and plugin part
        options = dbutils.get_stateless_options()
        workspaces = options.get('WORKSPACES')
        data_path = options.get('DATA_PATH')
        plugin_path = options.get('PLUGINS_PATH')

        modules = utils.set_value(dbutils.get_modules(mode),
                                  data.get('modules'))

        # set if defined or get it as default
        workspace = utils.set_value(workspace, data.get('workspace'))

        output = utils.set_value(workspace, data.get('output'))
        # data part
        workspaces = utils.set_value(workspaces, data.get('workspaces'))
        data_path = utils.set_value(data_path, data.get('data_path'))
        plugin_path = utils.set_value(plugin_path, data.get('plugin_path'))
        target = utils.set_value(target, data.get('target'))
        ip_address = utils.set_value(ip_address, data.get('ip_address'))

        # store it to db
        item = {
            'raw_target': raw_target,
            'target': target,
            'ip_address': ip_address,
            'workspace': workspace,
            'output': output,
            'workspaces': workspaces,
            'modules': modules,
            'arch': arch,
            'mode': mode,
            'speed': speed,
            'forced': forced,
            'verbose': verbose,
        }

        instance, created = Workspaces.objects.get_or_create(
            workspace=workspace)
        Workspaces.objects.filter(workspace=workspace).update(**item)
        real_workspace = utils.join_path(workspaces, workspace)

        if created:
            if instance.arch == 'server':
                utils.make_directory(real_workspace)
                return common.returnJSON(
                    {
                        "workspace": workspace,
                        "msg": "Workspaces created Successfully"
                    }, 200)
        else:
            # person object already exists
            return common.returnJSON(
                {
                    "workspace": workspace,
                    "msg": "Workspaces already exists"
                }, 442)