Skip to content

Commit

Permalink
Some changes to different utils and update version string
Browse files Browse the repository at this point in the history
  • Loading branch information
vil committed Jul 8, 2023
1 parent 8570a59 commit 23f146f
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 20 deletions.
3 changes: 1 addition & 2 deletions h4xtools.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
if os.name == "posix":
os.system("clear")

version = "0.2.11"
version = "0.2.12"


def internet_check():
Expand Down Expand Up @@ -333,7 +333,6 @@ def __main__():
print_banner()
time.sleep(1)
print_menu()
time.sleep(1)
a = input("[*] Select your option : \t")

if a in menu_options:
Expand Down
1 change: 1 addition & 0 deletions utils/ip_lookup.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ def __init__(self, ip):
printer.success(f"Lat - ", values['lat'])
printer.success(f"Lon - ", values['lon'])
printer.success(f"AS - ", values['as'])
printer.success(f"Maps URL - ", f"https://www.google.com/maps/search/{values['lat']},{values['lon']}")

except Exception as e:
printer.error(f"Error : ", e)
Expand Down
2 changes: 1 addition & 1 deletion utils/port_scanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def __init__(self, ip, port_range):
else:
printer.success(f"Found {len(open_ports)} open ports in '{ip}'..!")
except KeyboardInterrupt:
printer.error("Keyboard Interrupt Detected..!")
printer.error("Cancelled..!")


def scan(ip, port_range):
Expand Down
2 changes: 1 addition & 1 deletion utils/web_scrape.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def __init__(self, url):
time.sleep(1)
for link in soup.find_all("a"):
count += 1
printer.info(f"found {count} link(s) : ", link.get("href"))
printer.info(f"found {count} link(s) : ", link.get("href"), " - " + link.text)
except Exception as e:
printer.error(f"Error : ", e)
pass
49 changes: 35 additions & 14 deletions utils/websearch.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,38 @@ class Search:
def __init__(self, query):
url = "https://duckduckgo.com/html/?q=" + query
headers = {"User-Agent": random.choice(users)}
r = requests.get(url, headers=headers)
soup = BeautifulSoup(r.text, "html.parser")
results = soup.find_all("div", {"class": "result__body"})

if len(results) == 0:
printer.error(f"Error : No results found for {query}..!")
return

printer.info(f"Searching for '{query}' -- With the agent {headers['User-Agent']}")
time.sleep(1)
for result in results:
title = result.find("a", {"class": "result__a"}).text
link = result.find("a", {"class": "result__a"})["href"]
printer.success(f"{title} - {link}")

try:
response = requests.get(url, headers=headers)
response.raise_for_status() # Raise exception if request fails

soup = BeautifulSoup(response.text, "html.parser")
results = soup.find_all("div", {"class": "result__body"})

if len(results) == 0:
printer.error(f"No results found for '{query}'..!")
return

printer.info(f"Searching for '{query}' -- With the agent '{headers['User-Agent']}'")
time.sleep(1)
for result in results:
print_result(result)

except requests.exceptions.RequestException as e:
printer.error(f"Error : {e}")
pass
except KeyboardInterrupt:
printer.error("Cancelled..!")
pass


def print_result(result):
"""
Prints the result of a search.
:param result: The result to print.
"""
title = result.find("a", {"class": "result__a"}).text
link = result.find("a", {"class": "result__a"})["href"]
status = requests.get(link).status_code
printer.success(f"'{title}' - {link} - [{status}]")
4 changes: 2 additions & 2 deletions utils/wifi_finder.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ def __init__(self):
try:
subprocess.run(["netsh", "wlan", "show", "networks"], check=True)
except subprocess.CalledProcessError as e:
printer.error(f"Error: {e.returncode}")
printer.error(f"Error : {e.returncode}")
else:
printer.info("Linux system detected..! Doing an nmcli scan...")
time.sleep(1)
try:
subprocess.run(["nmcli", "dev", "wifi"], check=True)
except subprocess.CalledProcessError as e:
printer.error(f"Error: {e.returncode}")
printer.error(f"Error : {e.returncode}")

0 comments on commit 23f146f

Please sign in to comment.