week06
This commit is contained in:
27
week05/hard/pwn_utils.py
Normal file
27
week05/hard/pwn_utils.py
Normal file
@ -0,0 +1,27 @@
|
||||
import asyncio
|
||||
|
||||
|
||||
class utils:
|
||||
@staticmethod
|
||||
async def read_line_safe(reader):
|
||||
"""
|
||||
Simple implementation to read a line from an async reader
|
||||
Mimics the original read_line_safe functionality
|
||||
"""
|
||||
try:
|
||||
line = await reader.readline()
|
||||
return line.decode().strip()
|
||||
except Exception:
|
||||
return None
|
||||
|
||||
|
||||
def log_error(e, client_writer=None):
|
||||
"""
|
||||
Basic error logging function
|
||||
"""
|
||||
print(f"Error occurred: {e}")
|
||||
if client_writer:
|
||||
try:
|
||||
client_writer.write(f"Error: {str(e)}\n".encode())
|
||||
except Exception:
|
||||
print("Could not send error to client")
|
Reference in New Issue
Block a user