Skip to content

Commit

Permalink
further streamline
Browse files Browse the repository at this point in the history
  • Loading branch information
zardus committed Sep 28, 2024
1 parent 4e2e614 commit db8d761
Show file tree
Hide file tree
Showing 12 changed files with 45 additions and 69 deletions.
10 changes: 4 additions & 6 deletions web-security/csrf-reflected-alert/victim
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,11 @@ browser = webdriver.Firefox(service=service, options=options)
atexit.register(browser.quit)

open_ports = { s.laddr.port for s in psutil.net_connections(kind="inet") if s.status == 'LISTEN' }
if 80 in open_ports:
print("Port 80 is open. Will connect to the service there.")
challenge_url = "http://challenge.localhost:80/"
flag = open("/flag").read().strip()
else:
print("Services don't seem to be running?")
if 80 not in open_ports:
print("Service doesn't seem to be running?")
sys.exit(1)
challenge_url = "http://challenge.localhost:80/"
flag = open("/flag").read().strip()

print(f"Visiting {challenge_url}")
browser.get(challenge_url)
Expand Down
10 changes: 4 additions & 6 deletions web-security/level-10/victim
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,11 @@ browser = webdriver.Firefox(service=service, options=options)
atexit.register(browser.quit)

open_ports = { s.laddr.port for s in psutil.net_connections(kind="inet") if s.status == 'LISTEN' }
if 80 in open_ports:
print("Port 80 is open. Will connect to the service there.")
challenge_url = "http://challenge.localhost:80/"
flag = open("/flag").read().strip()
else:
print("Services don't seem to be running?")
if 80 not in open_ports:
print("Service doesn't seem to be running?")
sys.exit(1)
challenge_url = "http://challenge.localhost:80/"
flag = open("/flag").read().strip()

print(f"Visiting {challenge_url}")
browser.get(challenge_url)
Expand Down
10 changes: 4 additions & 6 deletions web-security/level-11/victim
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,11 @@ browser = webdriver.Firefox(service=service, options=options)
atexit.register(browser.quit)

open_ports = { s.laddr.port for s in psutil.net_connections(kind="inet") if s.status == 'LISTEN' }
if 80 in open_ports:
print("Port 80 is open. Will connect to the service there.")
challenge_url = "http://challenge.localhost:80/"
flag = open("/flag").read().strip()
else:
print("Services don't seem to be running?")
if 80 not in open_ports:
print("Service doesn't seem to be running?")
sys.exit(1)
challenge_url = "http://challenge.localhost:80/"
flag = open("/flag").read().strip()

print(f"Visiting {challenge_url}")
browser.get(challenge_url)
Expand Down
10 changes: 4 additions & 6 deletions web-security/level-12/victim
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,11 @@ browser = webdriver.Firefox(service=service, options=options)
atexit.register(browser.quit)

open_ports = { s.laddr.port for s in psutil.net_connections(kind="inet") if s.status == 'LISTEN' }
if 80 in open_ports:
print("Port 80 is open. Will connect to the service there.")
challenge_url = "http://challenge.localhost:80/"
flag = open("/flag").read().strip()
else:
print("Services don't seem to be running?")
if 80 not in open_ports:
print("Service doesn't seem to be running?")
sys.exit(1)
challenge_url = "http://challenge.localhost:80/"
flag = open("/flag").read().strip()

print(f"Visiting {challenge_url}")
browser.get(challenge_url)
Expand Down
10 changes: 4 additions & 6 deletions web-security/level-13/victim
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,11 @@ browser = webdriver.Firefox(service=service, options=options)
atexit.register(browser.quit)

open_ports = { s.laddr.port for s in psutil.net_connections(kind="inet") if s.status == 'LISTEN' }
if 80 in open_ports:
print("Port 80 is open. Will connect to the service there.")
challenge_url = "http://challenge.localhost:80/"
flag = open("/flag").read().strip()
else:
print("Services don't seem to be running?")
if 80 not in open_ports:
print("Service doesn't seem to be running?")
sys.exit(1)
challenge_url = "http://challenge.localhost:80/"
flag = open("/flag").read().strip()

print(f"Visiting {challenge_url}")
browser.get(challenge_url)
Expand Down
10 changes: 4 additions & 6 deletions web-security/level-14/victim
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,11 @@ browser = webdriver.Firefox(service=service, options=options)
atexit.register(browser.quit)

open_ports = { s.laddr.port for s in psutil.net_connections(kind="inet") if s.status == 'LISTEN' }
if 80 in open_ports:
print("Port 80 is open. Will connect to the service there.")
challenge_url = "http://challenge.localhost:80/"
flag = open("/flag").read().strip()
else:
print("Services don't seem to be running?")
if 80 not in open_ports:
print("Service doesn't seem to be running?")
sys.exit(1)
challenge_url = "http://challenge.localhost:80/"
flag = open("/flag").read().strip()

print(f"Visiting {challenge_url}")
browser.get(challenge_url)
Expand Down
6 changes: 2 additions & 4 deletions web-security/level-8/victim
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,7 @@ url_parsed = urllib.parse.urlparse(challenge_url)
if url_parsed.hostname != "challenge.localhost":
print("Hostname should be 'challenge.localhost'.")
sys.exit(2)
if url_parsed.port in {None, 80}:
reward = open("/flag").read()
else:
if url_parsed.port not in {None, 80}:
print("Port should be 80.")
sys.exit(3)

Expand All @@ -49,4 +47,4 @@ except TimeoutException:
sys.exit(3)
else:
print("Alert triggered! Your reward:")
print(reward)
print(open("/flag").read())
8 changes: 3 additions & 5 deletions web-security/level-9/victim
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,8 @@ url_parsed = urllib.parse.urlparse(challenge_url)
if url_parsed.hostname != "challenge.localhost":
print("Hostname should be 'challenge.localhost'.")
sys.exit(2)
if url_parsed.port in {None, 80}:
reward = open("/flag").read()
else:
print("Port should be 80 (real service).")
if url_parsed.port not in {None, 80}:
print("Port should be 80.")
sys.exit(3)

print(f"Visiting {challenge_url}")
Expand All @@ -49,4 +47,4 @@ except TimeoutException:
sys.exit(3)
else:
print("Alert triggered! Your reward:")
print(reward)
print(open("/flag").read())
10 changes: 4 additions & 6 deletions web-security/xss-exfil-cookie/victim
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,11 @@ browser = webdriver.Firefox(service=service, options=options)
atexit.register(browser.quit)

open_ports = { s.laddr.port for s in psutil.net_connections(kind="inet") if s.status == 'LISTEN' }
if 80 in open_ports:
print("Port 80 is open. Will connect to the service there.")
challenge_url = "http://challenge.localhost:80/"
flag = open("/flag").read().strip()
else:
print("Services don't seem to be running?")
if 80 not in open_ports:
print("Service doesn't seem to be running?")
sys.exit(1)
challenge_url = "http://challenge.localhost:80/"
flag = open("/flag").read().strip()

print(f"Visiting {challenge_url}")
browser.get(challenge_url)
Expand Down
10 changes: 4 additions & 6 deletions web-security/xss-rf-post/victim
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,11 @@ browser = webdriver.Firefox(service=service, options=options)
atexit.register(browser.quit)

open_ports = { s.laddr.port for s in psutil.net_connections(kind="inet") if s.status == 'LISTEN' }
if 80 in open_ports:
print("Port 80 is open. Will connect to the service there.")
challenge_url = "http://challenge.localhost:80/"
flag = open("/flag").read().strip()
else:
print("Services don't seem to be running?")
if 80 not in open_ports:
print("Service doesn't seem to be running?")
sys.exit(1)
challenge_url = "http://challenge.localhost:80/"
flag = open("/flag").read().strip()

print(f"Visiting {challenge_url}")
browser.get(challenge_url)
Expand Down
10 changes: 4 additions & 6 deletions web-security/xss-stored-alert/victim
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,11 @@ browser = webdriver.Firefox(service=service, options=options)
atexit.register(browser.quit)

open_ports = { s.laddr.port for s in psutil.net_connections(kind="inet") if s.status == 'LISTEN' }
if 80 in open_ports:
print("Port 80 is open. Will connect to the service there.")
challenge_url = "http://challenge.localhost:80/"
flag = open("/flag").read().strip()
else:
print("Services don't seem to be running?")
if 80 not in open_ports:
print("Service doesn't seem to be running?")
sys.exit(1)
challenge_url = "http://challenge.localhost:80/"
flag = open("/flag").read().strip()

print(f"Visiting {challenge_url}")
browser.get(challenge_url)
Expand Down
10 changes: 4 additions & 6 deletions web-security/xss-stored-html/victim
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,11 @@ import sys
import re

open_ports = { s.laddr.port for s in psutil.net_connections(kind="inet") if s.status == 'LISTEN' }
if 80 in open_ports:
print("Port 80 is open. Will connect to the service there.")
challenge_url = "http://challenge.localhost:80/"
flag = open("/flag").read().strip()
else:
print("Services don't seem to be running?")
if 80 not in open_ports:
print("Service doesn't seem to be running?")
sys.exit(1)
challenge_url = "http://challenge.localhost:80/"
flag = open("/flag").read().strip()

print(f"Visiting {challenge_url}...")
try:
Expand Down

0 comments on commit db8d761

Please sign in to comment.