Skip to content

Commit e57e2e4

Browse files
author
Mohamed Elbadry
committed
Adding findomain & subfinder
1 parent bfe00b3 commit e57e2e4

File tree

10 files changed

+75
-18
lines changed

10 files changed

+75
-18
lines changed

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ docker run -d -p 8000:8000 scanapi
5252

5353
- [Amass](https://github.com/OWASP/Amass)
5454
- [Gasset](https://github.com/melbadry9/gasset)
55+
- [Findomain](https://github.com/Edu4rdSHL/findomain)
56+
- [Subfinder](https://github.com/projectdiscovery/subfinder)
5557
- [Subover](https://github.com/melbadry9/SubOver)
5658
- [Sublist3r](https://github.com/melbadry9/Sublist3r)
5759
- [Httprobe](https://github.com/tomnomnom/httprobe)

app.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
import json
21
import multiprocessing
32
from flask import Flask, jsonify, render_template, Response, request
43

5-
import lib.core.log_handler
64
from lib.core.config import config
75
from lib.scan.s3_job import s3_job, get_s3
86
from lib.scan.subdomain_job import sub_job, get_subdomains

config.ini

+6-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ enabled = False
1111

1212
[COOKIE]
1313
# gasset cookie to enable censys and virustotal
14-
fb_cookie =
14+
shodan = ''
15+
fb_cookie = ''
1516

1617
[GENERAL]
1718
threads = 30
@@ -23,6 +24,8 @@ gasset = True
2324
subover = True
2425
httprobe = True
2526
gobuster = True
27+
subfinder = True
28+
findomain = True
2629
sublist3r = True
2730
assetfinder = True
2831
gobusterDNS = False
@@ -33,7 +36,8 @@ dns = small
3336
dir = small
3437

3538
[LOGGING]
36-
# disable modules logging
39+
# disable modules logging
40+
db = True
3741
s3 = True
3842
opp = True
3943
slack = True

install.sh

+4
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ go get -u github.com/melbadry9/subover;
88
go get -u github.com/OJ/gobuster;
99
go get -u github.com/tomnomnom/assetfinder;
1010
go get -u github.com/tomnomnom/httprobe;
11+
go get -u -v github.com/projectdiscovery/subfinder/cmd/subfinder;
1112
wget https://github.com/OWASP/Amass/releases/download/v3.1.10/amass_v3.1.10_linux_amd64.zip;
13+
wget https://github.com/Edu4rdSHL/findomain/releases/latest/download/findomain-linux;
14+
chmod +x findomain-linux;
1215
unzip amass_v3.1.10_linux_amd64.zip;
16+
cp findomain-linux $GOPATH/bin/findomain;
1317
cp amass_v3.1.10_linux_amd64/amass $GOPATH/bin/;

lib/core/database.py

+21-10
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1-
import os
21
import json
32
import sqlite3
3+
import logging
44

5-
from pathlib2 import Path
65
from threading import Lock
76
from ..paths.helper import DB_FILE
87

98

9+
database = logging.getLogger("db")
10+
database.addHandler(logging.NullHandler())
11+
1012
class DataBase(object):
1113
lock = Lock()
1214
def __init__(self):
@@ -72,31 +74,40 @@ def __init__(self, domain):
7274

7375
def __del__(self):
7476
self.db.close()
77+
78+
def Save(self):
79+
self.db.commit()
7580

7681
def create_db(self):
7782
with self.lock:
7883
self.cdb.executescript("""CREATE TABLE IF NOT EXISTS "domains" ( `id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT UNIQUE, `main_domain` TEXT NOT NULL, `sub_domain` TEXT, `http` INTEGER NOT NULL DEFAULT 0, `https` INTEGER NOT NULL DEFAULT 0 )""")
79-
self.db.commit()
84+
self.Save()
8085

8186
def insert_domains(self, sub_domain:list):
8287
with self.lock:
8388
for item in sub_domain:
8489
if item not in self.old_sub:
8590
self.cdb.execute("insert into domains (main_domain,sub_domain) values (?,?)",(self.domain,item))
86-
self.db.commit()
91+
self.Save()
8792

8893
def read_domains(self):
8994
self.cdb.execute("select sub_domain from domains where main_domain = ?",(self.domain,))
9095
return [i[0] for i in self.cdb.fetchall()]
9196

9297
def update_protocol(self, protocol:str, sub_domain:list):
9398
with self.lock:
94-
for item in sub_domain:
95-
if protocol == "http":
96-
self.cdb.execute("update domains set http = 1 where sub_domain = ?",(item,))
97-
elif protocol == "https":
98-
self.cdb.execute("update domains set https = 1 where sub_domain = ?",(item,))
99-
self.db.commit()
99+
done = False
100+
while not done:
101+
try:
102+
for item in sub_domain:
103+
if protocol == "http":
104+
self.cdb.execute("update domains set http = 1 where sub_domain = ?",(item,))
105+
elif protocol == "https":
106+
self.cdb.execute("update domains set https = 1 where sub_domain = ?",(item,))
107+
done = True
108+
except Exception as e:
109+
database.error("Error while updateing db\n {0}".format(e), stack_info=True)
110+
100111

101112
def read_domains_protocol(self, protocol:str):
102113
if protocol == "http":

lib/core/log_handler.py

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
logging.basicConfig(filename=config['LOGGING']['file_path'], filemode='w', format='%(asctime)s [%(levelname)s] [%(name)s] %(message)s', datefmt='%d-%b-%y %H:%M:%S', level=logging.DEBUG)
77

88
loggers = [
9+
'db',
910
's3',
1011
'opp',
1112
'slack',

lib/core/opp.py

+14-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44

55
from ..core.config import config
66
from ..paths.setter import DIR_LIST, DNS_LIST
7-
from ..thirdparty.Gasset.asset import main as Gasset
8-
from ..thirdparty.Sublist3r.sublist3r import main as Sublist3r
97

108
opp_logger = logging.getLogger("opp")
119
opp_logger.addHandler(logging.NullHandler())
@@ -59,6 +57,20 @@ def __init__(self, domain):
5957
self.command = "amass enum -passive -d {0}".format(domain)
6058
self.pattern = r"(.+)\n"
6159

60+
class Findomain(ProcessBase):
61+
def __init__(self, domain):
62+
ProcessBase.__init__(self)
63+
self.name = "Findomain"
64+
self.command = "findomain -t {0} -q".format(domain)
65+
self.pattern = r"(.+)\n"
66+
67+
class Subfinder(ProcessBase):
68+
def __init__(self, domain):
69+
ProcessBase.__init__(self)
70+
self.name = "Subfinder"
71+
self.command = "subfinder -d {0} -silent".format(domain)
72+
self.pattern = r"(.+)\n"
73+
6274
class GoBusterDNS(ProcessBase):
6375
def __init__(self, domain):
6476
ProcessBase.__init__(self)

lib/core/slack.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import time
2-
import json
32
import logging
43
import requests
54

lib/scan/subdomain_job.py

+26-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from ..core.log_handler import scan_logger
1010
from ..thirdparty.Gasset.asset import main as Gasset
1111
from ..thirdparty.Sublist3r.sublist3r import main as Sublist3r
12-
from ..core.opp import SubOver, GoBuster, AssetFinder, Amass, GoBusterDNS, Httprobe
12+
from ..core.opp import SubOver, GoBuster, AssetFinder, Amass, GoBusterDNS, Httprobe, Findomain, Subfinder
1313

1414

1515
def sub_job(domain):
@@ -52,6 +52,30 @@ def sub_job(domain):
5252
error_msg = "AssetFinder: " + str(e)
5353
scan_logger.error(error_msg, exc_info=True)
5454
final_error.append(error_msg)
55+
56+
# Findomain
57+
if config['TOOLS'].getboolean('findomain'):
58+
try:
59+
pro_findomain_finder = Findomain(domain)
60+
data = pro_findomain_finder.exec_command()
61+
final_list.extend(data['Findomain']['data'])
62+
final_error.append(data['Findomain']['error'])
63+
except Exception as e:
64+
error_msg = "Findomain: " + str(e)
65+
scan_logger.error(error_msg, exc_info=True)
66+
final_error.append(error_msg)
67+
68+
# Subfinder
69+
if config['TOOLS'].getboolean('subfinder'):
70+
try:
71+
pro_subfinder_finder = Subfinder(domain)
72+
data = pro_subfinder_finder.exec_command()
73+
final_list.extend(data['Subfinder']['data'])
74+
final_error.append(data['Subfinder']['error'])
75+
except Exception as e:
76+
error_msg = "Subfinder: " + str(e)
77+
scan_logger.error(error_msg, exc_info=True)
78+
final_error.append(error_msg)
5579

5680
# Amass
5781
if config['TOOLS'].getboolean('amass'):
@@ -112,6 +136,7 @@ def sub_job(domain):
112136
http_domain = [dom.replace("http://","") for dom in alive_data if dom.startswith("http://")]
113137
DB.update_protocol("http", http_domain)
114138
DB.update_protocol("https", https_domain)
139+
DB.Save()
115140
except Exception as e:
116141
error_msg = "Httprobe: " + str(e)
117142
scan_logger.error(error_msg, exc_info=True)

lib/thirdparty/Gasset/asset.py

+1
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ def __init__(self, domain, shared=None):
145145
self.url = self.BASE_URL.format(domain=domain)
146146

147147
def SendRequest(self, url):
148+
self.HEADERS['Cookie'] = config["COOKIE"]["shodan"]
148149
return self.session.get(url, stream=True)
149150

150151
def HandleResponse(self, res):

0 commit comments

Comments
 (0)