import utime
file_path = "/network_data.txt"
# Ensure the file exists before modifying
try:
with open(file_path, "r") as file:
pass # File exists, do nothing
except OSError:
with open(file_path, "w") as file:
file.write("REQUEST: google.com") # Simulating victim's request
print("File created with initial request.")
while True:
try:
# Read original request
with open(file_path, "r") as file:
data = file.read()
# Attacker modifies the request to redirect it
fake_response = "FAKE RESPONSE: Welcome to Fake Google!"
print(f"Attacker Intercepts & Modifies Data: {fake_response}")
# Overwrite the request with fake response
with open(file_path, "w") as file:
file.write(fake_response)
except Exception as e:
print("Error:", str(e))
utime.sleep(3) # Modify every 3 seconds