Skip to content

Commit

Permalink
bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
nullt3r committed May 13, 2022
1 parent 9a40880 commit 995e862
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 22 deletions.
12 changes: 8 additions & 4 deletions jfscan/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,16 +154,20 @@ def main():
# Report results from masscan
logger.info("dumping results")

results = []
result_ips, result_domains = res.get_scan_results()

if arguments.only_domains is True:
results = res.get_scan_results(ips=False, domains=True)
results = result_domains
elif arguments.only_ips is True:
results = res.get_scan_results(ips=True, domains=False)
results = result_ips
else:
results = res.get_scan_results(ips=True, domains=True)
results = result_ips + result_domains

for line in results:
print(line)


# Save results to file
if arguments.output is not None:
logger.info("saving results to %s", arguments.output)
utils.save_results(results, arguments.output)
Expand Down
39 changes: 23 additions & 16 deletions jfscan/core/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ def get_cidrs(self):

return cidrs

def get_scan_results(self, ips=False, domains=False):
def get_scan_results(self):
"""Generates scan results in format target:port
Args:
Expand All @@ -206,25 +206,32 @@ def get_scan_results(self, ips=False, domains=False):
"""
conn = self.conn
cur = conn.cursor()
results = []

if ips is True:
rows = cur.execute(
"SELECT DISTINCT ip, port FROM scan_results"
).fetchall()
for row in rows:
results.append(f"{row[0]}:{row[1]}")
ips = []
domains = []

if domains is True:
rows = cur.execute(
"SELECT DISTINCT domain, ip, port FROM scan_results\
JOIN domains_to_scan ON domain = domains_to_scan.domain WHERE domains_to_scan.ip_rowid = (SELECT rowid FROM ips_to_scan WHERE ip = scan_results.ip) ORDER BY domain"
).fetchall()
rows = cur.execute(
"SELECT DISTINCT ip, port FROM scan_results"
).fetchall()
for row in rows:
ips.append(f"{row[0]}:{row[1]}")


rows = cur.execute(
"SELECT DISTINCT domain, ip, port FROM scan_results\
JOIN domains_to_scan ON domain = domains_to_scan.domain WHERE domains_to_scan.ip_rowid = (SELECT rowid FROM ips_to_scan WHERE ip = scan_results.ip) ORDER BY domain"
).fetchall()

for row in rows:
domains.append(f"{row[0]}:{row[2]}")

ips_unique = list(set(ips))
domains_unique = list(set(domains))

for row in rows:
results.append(f"{row[0]}:{row[2]}")
ips_unique.sort()
domains_unique.sort()

return list(set(results))
return ips_unique, domains_unique

def count_ips(self):
"""Get number of all IPs to scan, including IPs in network ranges
Expand Down
1 change: 1 addition & 0 deletions jfscan/core/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ def load_targets(self, res, targets_file=None, target=None):

target_before = _target

# Oh, just remove it already...
@staticmethod
def file_is_empty(file):
try:
Expand Down
4 changes: 2 additions & 2 deletions jfscan/core/validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,6 @@ def is_url(url):
return False

@staticmethod
def is_domain(domain):
def is_domain(host):
from validators import domain
return domain(domain)
return domain(host)

0 comments on commit 995e862

Please sign in to comment.