Skip to content

Commit

Permalink
laramies#1383 fix securitytrailssearch.py
Browse files Browse the repository at this point in the history
  • Loading branch information
yoonthegoon committed Jul 24, 2023
1 parent 2579d60 commit 5db041c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
3 changes: 2 additions & 1 deletion theHarvester/discovery/securitytrailssearch.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import asyncio
from typing import Sequence

from theHarvester.discovery.constants import *
from theHarvester.lib.core import *
Expand All @@ -14,7 +15,7 @@ def __init__(self, word) -> None:
self.results = ""
self.totalresults = ""
self.api = "https://api.securitytrails.com/v1/"
self.info = ()
self.info: tuple[set, set] = (set(), set())
self.proxy = False

async def authenticate(self) -> None:
Expand Down
21 changes: 12 additions & 9 deletions theHarvester/parsers/securitytrailsparser.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
from typing import Union, Tuple, List, Set
from typing import List, Set, Tuple, Union


class Parser:

def __init__(self, word, text) -> None:
self.word = word
self.text = text
self.hostnames: Set = set()
self.ips: Set = set()

async def parse_text(self) -> Union[List, Tuple]:
async def parse_text(self) -> tuple[set, set]:
sub_domain_flag = 0
self.text = str(self.text).splitlines()
# Split lines to get a list of lines.
for index in range(0, len(self.text)):
line = self.text[index].strip()
if '"ip":' in line:
# Extract IP.
ip = ''
ip = ""
for ch in line[7:]:
if ch == '"':
break
Expand All @@ -29,13 +28,17 @@ async def parse_text(self) -> Union[List, Tuple]:
sub_domain_flag = 1
continue
elif sub_domain_flag > 0:
if ']' in line:
if "]" in line:
sub_domain_flag = 0
else:
if 'www' in self.word:
self.word = str(self.word).replace('www.', '').replace('www', '')
if "www" in self.word:
self.word = (
str(self.word).replace("www.", "").replace("www", "")
)
# Remove www from word if entered
self.hostnames.add(str(line).replace('"', '').replace(',', '') + '.' + self.word)
self.hostnames.add(
str(line).replace('"', "").replace(",", "") + "." + self.word
)
else:
continue
return list(self.ips), list(self.hostnames)
return self.ips, self.hostnames

0 comments on commit 5db041c

Please sign in to comment.