Skip to content

Commit

Permalink
init: added Go_Wayback discovery tool
Browse files Browse the repository at this point in the history
  • Loading branch information
Abhinandan-Khurana committed Feb 1, 2025
1 parent 8f0f393 commit 2db1fae
Show file tree
Hide file tree
Showing 4 changed files with 90 additions and 2 deletions.
13 changes: 13 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
FROM golang:1.22 as go-wayback-builder
RUN git clone https://github.com/Abhinandan-Khurana/go-wayback.git
WORKDIR /go-wayback
RUN go build -o go_wayback main.go
RUN mv go_wayback /usr/bin

FROM --platform=linux/amd64 python:3.9-slim

# Install wget
Expand All @@ -22,6 +28,13 @@ RUN wget https://github.com/Abhinandan-Khurana/go_virustotal/releases/download/v
RUN mv go_virustotal-linux-v1.0.1 go_virustotal
RUN mv go_virustotal /usr/bin

<<<<<<< HEAD
=======
# Install Go_Wayback
COPY --from=go-wayback-builder /usr/bin/go_wayback /usr/bin


>>>>>>> d7260a4 (init: added Go_Wayback discovery tool)
# Install HTTPX
RUN echo "Installing HTTPX"
RUN wget https://github.com/projectdiscovery/httpx/releases/download/v1.6.8/httpx_1.6.8_linux_amd64.zip
Expand Down
2 changes: 1 addition & 1 deletion configs/local.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ workflow:
cmd: []
workflowConfig:
- moduleName : discovery
tools: ['Subfinder','Go_Virustotal']
tools: ['Subfinder','Go_Virustotal','Go_Wayback']
order: 1
- moduleName: prerecon
tools: ['FindCDN', 'Naabu']
Expand Down
5 changes: 4 additions & 1 deletion mantis/modules/discovery/Go_Virustotal.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
import logging

'''
Tool Author: Abhinandan Khurana
Github: github.com/abhinandan-khurana
Tool Link: github.com/abhinandan-khurana/go_virustotal
Go_Virustotal module enumerates subdomain of the TLDs which are fetched from database.
Output file: .json
------------------
Expand Down Expand Up @@ -68,7 +72,6 @@ def parse_report(self, outfile):
'tool_source': 'Go_Virustotal'
}
output_dict_list.append(domain_dict)
print(output_dict_list)
return output_dict_list

async def db_operations(self, tool_output_dict, asset=None):
Expand Down
72 changes: 72 additions & 0 deletions mantis/modules/discovery/Go_Wayback.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
from mantis.constants import ASSET_TYPE_SUBDOMAIN
from mantis.utils.crud_utils import CrudUtils
from mantis.tool_base_classes.toolScanner import ToolScanner
from mantis.models.args_model import ArgsModel
from mantis.utils.tool_utils import get_assets_grouped_by_type
from mantis.constants import ASSET_TYPE_TLD
import json
import os
import logging

'''
Tool Author: Abhinandan Khurana
Github: github.com/abhinandan-khurana
Tool Link: github.com/abhinandan-khurana/go-wayback
Go_Wayback module enumerates subdomain of the TLDs which are fetched from database.
Output file: .txt
Each subdomain discovered is inserted into the database as a new asset.
'''

class Go_Wayback(ToolScanner):

def __init__(self) -> None:
super().__init__()

async def get_commands(self, args: ArgsModel):
self.org = args.org
self.base_command = 'go-wayback -o {output_file_path} -subdomain {input_domain}'
self.outfile_extension = ".txt"
self.assets = await get_assets_grouped_by_type(self, args, ASSET_TYPE_TLD)
return super().base_get_commands(self.assets)

def clean_url(self, url):
"""Clean URL to extract subdomain only."""
# Remove protocol if present
if '://' in url:
url = url.split('://')[-1]

# Remove URL parameters and paths
url = url.split('?')[0]
url = url.split('/')[0]

# Remove port numbers if present
url = url.split(':')[0]

return url.strip()

def parse_report(self, outfile):
output_dict_list = []
wayback_output = open(outfile).readlines()
seen_domains = set() # To avoid duplicates

for domain in wayback_output:
clean_domain = self.clean_url(domain.rstrip('\n'))

# Skip if domain already processed or empty
if not clean_domain or clean_domain in seen_domains:
continue

seen_domains.add(clean_domain)
domain_dict = {
'_id': clean_domain,
'asset': clean_domain,
'asset_type': ASSET_TYPE_SUBDOMAIN,
'org': self.org,
'tools_source': 'go-wayback'
}
output_dict_list.append(domain_dict)
return output_dict_list

async def db_operations(self, tool_output_dict, asset=None):
await CrudUtils.insert_assets(tool_output_dict)

0 comments on commit 2db1fae

Please sign in to comment.