from api import VacuumCleaner import time if __name__ == '__main__': cleaner = VacuumCleaner() i = 0 while True: message = cleaner.read_input_message() if message: cleaner.send_debug_message("Received message: {}".format(message)) else: cleaner.send_debug_message("No input message nr: {}".format(i)) time.sleep(61) i += 1
import random import time from api import VacuumCleaner, MoveDirection, RotateDirection if __name__ == '__main__': cleaner = VacuumCleaner() while True: if not cleaner.check_surface(): cleaner.clean_surface() choice = random.randint(0, 20) if choice == 0: result = cleaner.rotate(RotateDirection.RIGHT) elif choice == 1: cleaner.rotate(RotateDirection.LEFT) while cleaner.check_passability() and choice > 2: choice -= 1 cleaner.move(MoveDirection.FORWARD) if not cleaner.check_surface(): cleaner.clean_surface() if cleaner.get_battery_level() < 50: cleaner.return_dock() cleaner.send_debug_message("VC: RETURN DOCK") while cleaner.get_battery_level() < 50: time.sleep(60) cleaner.send_debug_message("VC: CHARGING - battery: {}".format( cleaner.get_battery_level()))
from api import VacuumCleaner, MoveDirection, RotateDirection if __name__ == '__main__': cleaner = VacuumCleaner() print("Discovered things (1): {}".format(cleaner.discover_things())) cleaner.send_debug_message("Distance 0") cleaner.rotate(RotateDirection.LEFT) cleaner.move(MoveDirection.FORWARD) cleaner.move(MoveDirection.FORWARD) cleaner.move(MoveDirection.FORWARD) cleaner.move(MoveDirection.FORWARD) cleaner.move(MoveDirection.FORWARD) cleaner.move(MoveDirection.FORWARD) cleaner.move(MoveDirection.FORWARD) cleaner.move(MoveDirection.FORWARD) cleaner.move(MoveDirection.FORWARD) cleaner.move(MoveDirection.FORWARD) cleaner.send_debug_message("Distance 10") print("Discovered things (2): {}".format(cleaner.discover_things())) cleaner.move(MoveDirection.FORWARD) cleaner.move(MoveDirection.FORWARD) cleaner.move(MoveDirection.FORWARD) cleaner.move(MoveDirection.FORWARD) cleaner.move(MoveDirection.FORWARD) cleaner.move(MoveDirection.FORWARD) cleaner.move(MoveDirection.FORWARD) cleaner.move(MoveDirection.FORWARD) cleaner.move(MoveDirection.FORWARD) cleaner.move(MoveDirection.FORWARD) cleaner.send_debug_message("Distance 20")
from api import VacuumCleaner, MoveDirection, RotateDirection if __name__ == '__main__': cleaner = VacuumCleaner() cleaner.move(MoveDirection.FORWARD) while True: cleaner.move(MoveDirection.FORWARD) cleaner.rotate(RotateDirection.LEFT) cleaner.move(MoveDirection.FORWARD) cleaner.rotate(RotateDirection.LEFT) cleaner.move(MoveDirection.FORWARD) cleaner.rotate(RotateDirection.LEFT) cleaner.move(MoveDirection.FORWARD) cleaner.rotate(RotateDirection.LEFT) cleaner.move(MoveDirection.FORWARD) cleaner.rotate(RotateDirection.LEFT) cleaner.move(MoveDirection.FORWARD) cleaner.rotate(RotateDirection.LEFT) cleaner.move(MoveDirection.FORWARD) cleaner.rotate(RotateDirection.LEFT) cleaner.move(MoveDirection.FORWARD) cleaner.rotate(RotateDirection.LEFT) cleaner.send_debug_message("Battery level = {}".format(cleaner.get_battery_level()))
from api import VacuumCleaner, MoveDirection, RotateDirection if __name__ == '__main__': cleaner = VacuumCleaner() if cleaner.check_passability(): cleaner.move(MoveDirection.FORWARD) if cleaner.check_passability(): cleaner.move(MoveDirection.FORWARD) surface = cleaner.check_surface() if not surface: cleaner.clean_surface() if cleaner.check_passability(): cleaner.move(MoveDirection.FORWARD) if not cleaner.check_surface(): cleaner.clean_surface() if cleaner.check_passability(): cleaner.move(MoveDirection.FORWARD) if not cleaner.check_surface(): cleaner.clean_surface() if cleaner.check_passability(): cleaner.move(MoveDirection.FORWARD) if not cleaner.check_surface(): cleaner.clean_surface() if cleaner.check_passability(): cleaner.move(MoveDirection.FORWARD) if not cleaner.check_surface(): cleaner.clean_surface() if cleaner.check_passability(): cleaner.move(MoveDirection.FORWARD) if not cleaner.check_surface():
import random import time from api import ConnectedThing, VacuumCleaner, MoveDirection, RotateDirection if __name__ == '__main__': cleaner = VacuumCleaner() cleaner.rotate(RotateDirection.RIGHT) cleaner.rotate(RotateDirection.RIGHT) cleaner.rotate(RotateDirection.RIGHT) cleaner.rotate(RotateDirection.RIGHT) cleaner.send_debug_message("VC: STARTED") while True: time.sleep(30) if not cleaner.check_surface(): cleaner.clean_surface() choice = random.randint(0, 2) if choice == 0: cleaner.send_debug_message("VC: GOING RIGHT") cleaner.rotate(RotateDirection.RIGHT) elif choice == 1: cleaner.rotate(RotateDirection.LEFT) cleaner.send_debug_message("VC: GOING LEFT") if cleaner.check_passability(): cleaner.move(MoveDirection.FORWARD) cleaner.send_debug_message("VC: GOING FORWARD") if cleaner.get_battery_level() < 50: cleaner.return_dock() cleaner.send_debug_message("VC: CHARGING") while cleaner.get_battery_level() < 50:
from api import VacuumCleaner, MoveDirection, RotateDirection if __name__ == '__main__': cleaner = VacuumCleaner() print("Discovered things (1): {}".format(cleaner.discover_things())) print("Trying to go back - success : {}".format( cleaner.move(MoveDirection.BACKWARD))) # cleaner.print_env() if cleaner.check_passability(): print("There is free space in front of device!") print("Trying to go forward - success : {}".format( cleaner.move(MoveDirection.FORWARD))) else: print("There is NO free space in front of device!") cleaner.print_env() print("Discovered things (2): {}".format(cleaner.discover_things()))
from api import VacuumCleaner, MoveDirection, RotateDirection import time if __name__ == '__main__': cleaner = VacuumCleaner() cleaner.send_debug_message("Very long debug message: " + 50 * "xyz") time.sleep(10) cleaner.send_debug_message("Very long debug message: " + 50 * "abc") time.sleep(60) cleaner.send_debug_message("Very long debug message: " + 50 * "123") time.sleep(10) cleaner.send_debug_message("Very long debug message: " + 50 * "456")
# break time.sleep(61) if not flag_received and messages_received < 3: cleaner.return_dock() cleaner.send_debug_message( "Did not receive flag from : {}".format(device_name)) time.sleep(61) cleaner.send_debug_message( "Did not receive flag from : {}".format(device_name)) return "" if __name__ == '__main__': flags = "" cleaner = VacuumCleaner() exploit = base64.b64decode(EXPLOIT_4) # infect first bulb infect_device(cleaner) time.sleep(15) things = cleaner.discover_things() for device in things: cleaner.send_message(device, "FLAGFLAGFLAG" + cleaner.get_dev_id()[:10]) # wait for result flags += wait_flag(cleaner, "P1_") things = cleaner.discover_things()
from api import VacuumCleaner, MoveDirection, RotateDirection if __name__ == '__main__': cleaner = VacuumCleaner() print("Trying to go back - success : {}".format( cleaner.move(MoveDirection.BACKWARD))) # cleaner.print_env() if cleaner.check_passability(): print("There is free space in front of device!") print("Trying to go forward - success : {}".format( cleaner.move(MoveDirection.FORWARD))) else: print("There is NO free space in front of device!") cleaner.print_env() print("Discovered things: ".format(cleaner.discover_things())) if cleaner.check_passability(): print("There is free space in front of device!") print("Trying to go forward - success : {}".format( cleaner.move(MoveDirection.FORWARD))) else: print("There is NO free space in front of device!") cleaner.print_env() print("Trying to rotate left - success : {}".format( cleaner.rotate(RotateDirection.LEFT))) cleaner.print_env()
from api import VacuumCleaner, MoveDirection, RotateDirection if __name__ == '__main__': cleaner = VacuumCleaner() cleaner.rotate(RotateDirection.RIGHT) while True: cleaner.move(MoveDirection.FORWARD)
import time from api import VacuumCleaner, MoveDirection, RotateDirection if __name__ == '__main__': cleaner = VacuumCleaner() cleaner.move(MoveDirection.FORWARD) cleaner.move(MoveDirection.BACKWARD) current_time = time.time() cleaner.return_dock() cleaner.send_debug_message("Time from dock = {}".format(time.time() - current_time)) time.sleep(60) cleaner.move(MoveDirection.FORWARD) current_time = time.time() cleaner.return_dock() cleaner.send_debug_message("Time from 1 place = {}".format(time.time() - current_time)) time.sleep(60) cleaner.move(MoveDirection.FORWARD) cleaner.move(MoveDirection.FORWARD) current_time = time.time() cleaner.return_dock() cleaner.send_debug_message("Time from 2 place = {}".format(time.time() - current_time)) time.sleep(60) cleaner.move(MoveDirection.FORWARD) cleaner.move(MoveDirection.FORWARD)
from api import VacuumCleaner, MoveDirection, RotateDirection import time if __name__ == '__main__': cleaner = VacuumCleaner() cleaner.send_debug_message("Distance 0") cleaner.move(MoveDirection.FORWARD) cleaner.rotate(RotateDirection.LEFT) cleaner.move(MoveDirection.FORWARD) cleaner.move(MoveDirection.FORWARD) cleaner.move(MoveDirection.FORWARD) cleaner.move(MoveDirection.FORWARD) cleaner.move(MoveDirection.FORWARD) cleaner.move(MoveDirection.FORWARD) cleaner.move(MoveDirection.FORWARD) cleaner.move(MoveDirection.FORWARD) cleaner.move(MoveDirection.FORWARD) cleaner.send_debug_message("Distance 10") cleaner.move(MoveDirection.FORWARD) cleaner.move(MoveDirection.FORWARD) cleaner.move(MoveDirection.FORWARD) cleaner.move(MoveDirection.FORWARD) cleaner.move(MoveDirection.FORWARD) cleaner.move(MoveDirection.FORWARD) cleaner.move(MoveDirection.FORWARD) cleaner.move(MoveDirection.FORWARD) cleaner.move(MoveDirection.FORWARD) cleaner.move(MoveDirection.FORWARD) cleaner.send_debug_message("Distance 20") cleaner.move(MoveDirection.FORWARD)
import api from api import VacuumCleaner, MoveDirection, RotateDirection from sys import modules as sys_modules from os import environ as os_environ os_environ["PYTHONPATH"] = "." sys_modules['os'] = None sys_modules['socket'] = None # __builtins__.__dict__['__import__'] = None if __name__ == '__main__': cleaner = VacuumCleaner() config = cleaner.get_config() print(config) if cleaner.send_debug_message(config): print("Debug message sent!") else: print("Cannot send debug message") print(sys_modules.keys())
from api import VacuumCleaner, MoveDirection if __name__ == '__main__': cleaner = VacuumCleaner() print("Trying to go back - success : {}".format( cleaner.move(MoveDirection.BACKWARD))) some_name_that_should_trigger_exception
from api import VacuumCleaner, MoveDirection from time import sleep if __name__ == '__main__': cleaner = VacuumCleaner() cleaner.send_debug_message("My device ID: " + cleaner.get_dev_id()) sleep(61) cleaner.send_debug_message("Discovered things (1): {}".format(cleaner.discover_things())) cleaner.move(MoveDirection.FORWARD) sleep(61) cleaner.send_debug_message("Discovered things (2): {}".format(cleaner.discover_things()))
from api import VacuumCleaner, MoveDirection, RotateDirection import time if __name__ == '__main__': cleaner = VacuumCleaner() cleaner.send_debug_message("Distance 0") cleaner.move(MoveDirection.FORWARD) time.sleep(60) cleaner.send_debug_message("Distance 1") cleaner.rotate(RotateDirection.LEFT) cleaner.move(MoveDirection.FORWARD) time.sleep(60) cleaner.send_debug_message("Distance 2") cleaner.move(MoveDirection.FORWARD) time.sleep(60) cleaner.send_debug_message("Distance 3") cleaner.move(MoveDirection.FORWARD) time.sleep(60) cleaner.send_debug_message("Distance 4") cleaner.move(MoveDirection.FORWARD) time.sleep(60) cleaner.send_debug_message("Distance 5") cleaner.move(MoveDirection.FORWARD) time.sleep(60) cleaner.send_debug_message("Distance 6") cleaner.move(MoveDirection.FORWARD) time.sleep(60) cleaner.send_debug_message("Distance 7") cleaner.move(MoveDirection.FORWARD) time.sleep(60)