Skip to content

Commit

Permalink
Fix/faster
Browse files Browse the repository at this point in the history
  • Loading branch information
ConnorNelson committed Feb 21, 2025
1 parent b387322 commit 9879575
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 15 deletions.
4 changes: 2 additions & 2 deletions intercepting-communication/level-1a/run
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ class ServerHost(Host):
try:
connection, _ = server_socket.accept()
while True:
client_message = connection.recv(1024).decode().strip()
client_message = connection.recv(1024).decode()
if not client_message:
break
if client_message == "Hello, World!":
if client_message == "Hello, World!\n":
connection.sendall(flag.encode())
break
connection.close()
Expand Down
3 changes: 1 addition & 2 deletions intercepting-communication/level-1b/run
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ class ServerHost(Host):
try:
connection, _ = server_socket.accept()
while True:
client_message = connection.recv(1024).decode().strip()
if not client_message:
if not connection.recv(1):
connection.sendall(flag.encode())
break
connection.close()
Expand Down
2 changes: 1 addition & 1 deletion intercepting-communication/level-5/run
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class ClientHost(Host):
client_socket.connect(("10.0.0.2", 31337))
client_socket.sendall(flag.encode())
client_socket.close()
time.sleep(10)
time.sleep(1)
except (ConnectionError, TimeoutError):
continue

Expand Down
2 changes: 1 addition & 1 deletion intercepting-communication/level-6/run
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class ClientHost(Host):
client_socket.sendall(c.encode())
time.sleep(1)
client_socket.close()
time.sleep(10)
time.sleep(1)
except (ConnectionError, TimeoutError):
continue

Expand Down
15 changes: 6 additions & 9 deletions intercepting-communication/level-7/run
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,18 @@ flag = open("/flag").read()

class ClientHost(Host):
def entrypoint(self):
if os.fork() == 0:
while True:
subprocess.run(["/bin/ip", "neigh", "flush", "all"],
check=True,
stdin=subprocess.DEVNULL,
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL)
time.sleep(1)
while True:
try:
client_socket = socket.socket()
client_socket.connect(("10.0.0.3", 31337))
client_socket.sendall(flag.encode())
client_socket.close()
time.sleep(10)
subprocess.run(["/bin/ip", "neigh", "flush", "all"],
check=True,
stdin=subprocess.DEVNULL,
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL)
time.sleep(1)
except (ConnectionError, TimeoutError):
continue

Expand Down

0 comments on commit 9879575

Please sign in to comment.