Skip to content

Commit c7dfb3a

Browse files
committed
Fixed static domain
1 parent a264468 commit c7dfb3a

3 files changed

Lines changed: 41 additions & 43 deletions

File tree

anubis/commands/target.py

Lines changed: 36 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -24,32 +24,6 @@
2424
from .base import Base
2525

2626

27-
def clean_domains(domains):
28-
cleaned = []
29-
for subdomain in domains:
30-
subdomain = subdomain.lower()
31-
if subdomain.find("//") != -1:
32-
subdomain = subdomain[subdomain.find("//") + 2:]
33-
# Some pkey return instances like example.com. - remove the final .
34-
if subdomain.endswith('.'):
35-
subdomain = subdomain[:-1]
36-
# sometimes we'll get something like /www.example.com
37-
if subdomain[0] in ["\\", ".", "/", "#", "$", "%"]:
38-
subdomain = subdomain[1:]
39-
# If it's an email address, only take the domain part
40-
if "@" in subdomain:
41-
subdomain = subdomain.split("@")
42-
# If it's an actual email like mail@example.com, take example.com
43-
if len(subdomain) > 1:
44-
subdomain = subdomain[1]
45-
else:
46-
# If for some reason it's example.com@, take example.com
47-
subdomain = subdomain[0]
48-
49-
cleaned.append(subdomain.strip())
50-
return cleaned
51-
52-
5327
class Target(Base):
5428
"""Main enumeration module"""
5529
domains = list()
@@ -95,8 +69,7 @@ def run(self):
9569
for i in range(len(self.options["TARGET"])):
9670
# Default scans that run every time
9771
target = self.options["TARGET"][i]
98-
processes = [
99-
threading.Thread(target=dns_zonetransfer, args=(self, target)),
72+
threads = [threading.Thread(target=dns_zonetransfer, args=(self, target)),
10073
threading.Thread(target=search_subject_alt_name, args=(self, target)),
10174
threading.Thread(target=subdomain_hackertarget, args=(self, target)),
10275
threading.Thread(target=search_virustotal, args=(self, target)),
@@ -108,37 +81,37 @@ def run(self):
10881
print('test')
10982
# Additional options - ssl cert scan
11083
if self.options["--ssl"]:
111-
processes.append(threading.Thread(target=ssl_scan, args=(self, target)))
84+
threads.append(threading.Thread(target=ssl_scan, args=(self, target)))
11285

11386
# Additional options - shodan.io scan
11487
if self.options["--additional-info"]:
115-
processes.append(threading.Thread(target=search_shodan, args=(self,)))
88+
threads.append(threading.Thread(target=search_shodan, args=(self,)))
11689

11790
# Additional options - nmap scan of dnssec script and a host/port scan
11891
if self.options["--with-nmap"]:
119-
processes.append(
92+
threads.append(
12093
threading.Thread(target=dnssecc_subdomain_enum, args=(self, target)))
121-
processes.append(threading.Thread(target=scan_host, args=(self)))
94+
threads.append(threading.Thread(target=scan_host, args=(self,)))
12295

12396
# Additional options - brute force common subdomains
12497
if self.options["--brute-force"]:
125-
processes.append(
98+
threads.append(
12699
threading.Thread(target=brute_force, args=(self, target)))
127100

128-
# Start all processes
129-
for x in processes:
101+
# Start all threads
102+
for x in threads:
130103
x.start()
131104

132105
# Wait for all of them to finish
133-
for x in processes:
106+
for x in threads:
134107
x.join()
135108

136109
# remove duplicates and clean up
137110

138111
if self.options["--recursive"]:
139112
recursive_search(self)
140113

141-
self.domains = clean_domains(self.domains)
114+
self.domains = self.clean_domains(self.domains)
142115
self.dedupe = set(self.domains)
143116

144117
print("Found", len(self.dedupe), "subdomains")
@@ -172,3 +145,29 @@ def resolve_ips(self):
172145
# String truthiness ignores empty strings
173146
if ip:
174147
ColorPrint.green(ip)
148+
149+
@staticmethod
150+
def clean_domains(domains):
151+
cleaned = []
152+
for subdomain in domains:
153+
subdomain = subdomain.lower()
154+
if subdomain.find("//") != -1:
155+
subdomain = subdomain[subdomain.find("//") + 2:]
156+
# Some pkey return instances like example.com. - remove the final .
157+
if subdomain.endswith('.'):
158+
subdomain = subdomain[:-1]
159+
# sometimes we'll get something like /www.example.com
160+
if subdomain[0] in ["\\", ".", "/", "#", "$", "%"]:
161+
subdomain = subdomain[1:]
162+
# If it's an email address, only take the domain part
163+
if "@" in subdomain:
164+
subdomain = subdomain.split("@")
165+
# If it's an actual email like mail@example.com, take example.com
166+
if len(subdomain) > 1:
167+
subdomain = subdomain[1]
168+
else:
169+
# If for some reason it's example.com@, take example.com
170+
subdomain = subdomain[0]
171+
172+
cleaned.append(subdomain.strip())
173+
return cleaned

anubis/scanners/recursive.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
def recursive_search(self):
1313
print("Starting recursive search - warning, might take a long time")
14-
domains = clean_domains(self.domains)
14+
domains = self.clean_domains(self.domains)
1515
domains_unique = set(domains)
1616
num_workers = 10
1717

tests/commands/test_target.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,9 @@ def test_netcraft(self):
105105
# As of 1/18/18, Pkey currently constantly times out
106106
def test_pkey(self):
107107
search_pkey(self, "google.com")
108-
#self.assertIn("google.com", self.domains)
108+
# self.assertIn("google.com", self.domains)
109109
self.assertTrue(True)
110110

111-
112111
def test_shodan(self):
113112
self.ip = "138.197.125.24"
114113
self.options = {}
@@ -141,13 +140,14 @@ def test_recursive(self):
141140

142141
# Pass through function for recursive search
143142
def clean_domains(self, domains):
144-
return clean_domains(domains)
143+
return Target.clean_domains(domains)
145144

146145
def test_sigints(self):
147146
# Declare function to send sigint, after timer
148147

148+
proc1 = popen(['anubis', '-tr', 'neverssl.com'], stdout=PIPE)
149149

150-
proc1 = popen(['anubis', '-tr','neverssl.com'], stdout=PIPE)
150+
# Function to send sigint to our processes, make sure that it outputss "Quitting" then ends
151151
def send_siginit():
152152
popen.send_signal(proc1, signal.SIGINT)
153153
self.assertTrue("Quitting" in sys.stdout.getvalue())
@@ -165,7 +165,6 @@ def test_exception(self):
165165
self.assertTrue("Test" in sys.stdout.getvalue())
166166

167167

168-
169168
class TestColorPrint(TestCase):
170169

171170
def setUp(self):

0 commit comments

Comments
 (0)