hexen.py 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  1. import socket
  2. import struct
  3. import psutil
  4. import time
  5. from collections import deque # Add this import
  6. import sys # Add this import
  7. import os # Add this import
  8. try:
  9. import msvcrt # For non-blocking input on Windows
  10. except ImportError:
  11. msvcrt = None # Will be None on non-Windows OS
  12. MCAST_GRP = '239.192.55.1'
  13. MCAST_PORT = 1681
  14. MAGIC = '/Users/crt/Documents/bodeting/research/bad-bruteforcing/attempt-1.txt'
  15. def get_default_ipv4():
  16. # Get the first non-loopback IPv4 address on an active interface
  17. for iface, addrs in psutil.net_if_addrs().items():
  18. for addr in addrs:
  19. if addr.family == socket.AF_INET and not addr.address.startswith("127."):
  20. return addr.address
  21. raise RuntimeError("Steck Ether Portal Kabel ih din PC ned ih din arsch du huso!")
  22. def save_to_magic_file(value_to_save, filepath):
  23. if not value_to_save:
  24. print("No value provided to save.", flush=True)
  25. return
  26. directory = os.path.dirname(filepath)
  27. # Check if directory exists, create if not (optional, but good for robustness)
  28. # For now, as per prompt, just check and error if not exists or unwritable.
  29. if directory and not os.path.isdir(directory):
  30. print(f"Error: Directory '{directory}' does not exist. Kann dir nicht aufs Bett kaggern", flush=True)
  31. return
  32. try:
  33. with open(filepath, 'a') as f:
  34. f.write(value_to_save + "\n")
  35. print(f"Hab dir ins Bett geschissen '{value_to_save}' to {filepath}", flush=True)
  36. except IOError as e:
  37. print(f"Kann nicht stimmen '{filepath}'. Vielleicht solltest du deine Pillen nehmen. Details: {e}", flush=True)
  38. except OSError as e:
  39. print(f"Error: Zu grosser Hurensohn Erkannt. PC von ihm hat ihn rejected '{filepath}'. Lol : {e}", flush=True)
  40. try:
  41. LOCAL_INTERFACE_IP = get_default_ipv4()
  42. except RuntimeError as e:
  43. print(f"ach weisch was ich ha eif kei bock meh lol: {e}")
  44. exit(1)
  45. # Create UDP socket
  46. sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP)
  47. sock.setsockopt(socket.IPPROTO_IP, socket.IP_MULTICAST_TTL, 1)
  48. # Bind to correct interface
  49. sock.setsockopt(socket.IPPROTO_IP, socket.IP_MULTICAST_IF, socket.inet_aton(LOCAL_INTERFACE_IP))
  50. print(f"So Sportsfreund jetzt weiss ich wo du wohnst : {LOCAL_INTERFACE_IP} — Lass deine Mami hier ficken gehen : {MCAST_GRP}:{MCAST_PORT} \n\n")
  51. print("Wallah billahmius ich mach hier Verzauberus, gib Hexen spruch in HEX ein, 'brute <hex_prefix>' für Bruteforce, oder 'exit' um dich zu verpissen vom Zauberstab.\n")
  52. while True:
  53. user_input = input("HEXEREI > ").strip()
  54. if user_input.lower() in ("exit", "quit"):
  55. break
  56. if user_input.lower().startswith("brute "):
  57. parts = user_input.split(" ", 1)
  58. if len(parts) < 2 or not parts[1]:
  59. print("Zum Hexensprüche zu Lernen brauchst de nen Prefix. Beispiel: brute 4d454c00")
  60. continue
  61. hex_prefix = parts[1]
  62. try:
  63. # Validate prefix by attempting conversion
  64. bytes.fromhex(hex_prefix)
  65. except ValueError:
  66. print("Also ehm das stimmt nix wirklich")
  67. continue
  68. # Get bruteforce parameters
  69. brute_mode = ""
  70. while brute_mode not in ['1', '2', '3']:
  71. brute_mode = input("Wähle den Hexenspruch Lernmodus: (1) Manuel, (2) Magisch Absteigend, (3) Magisch Aufsteigend: ").strip()
  72. if brute_mode not in ['1', '2', '3']:
  73. print("Sprich Deutsch du Hurensohn! 1, 2, oder 3.")
  74. delay_seconds_str = ""
  75. delay_seconds = 1.0 # Default delay
  76. while True:
  77. delay_seconds_str = input(f"Wie geduldig willst du sein in Sekunden? (Zum Beispel 0.5, standart ist {delay_seconds} warten): ").strip()
  78. if not delay_seconds_str: # User pressed enter, use default
  79. break
  80. try:
  81. delay_seconds = float(delay_seconds_str)
  82. if delay_seconds < 0:
  83. print("Hast du einen Schlaganfall? Gib eine richtige Zahl ein, es gibt keine negativen Zahlen, das sind Fake News")
  84. else:
  85. break
  86. except ValueError:
  87. print("Bist du bekloppt? (Junge schreib doch einfach wie normaler mensch : 0.5, 1, 2.3).")
  88. print(f"So jetzt wird {hex_prefix} mal so richtig hart vergewaltigt :3")
  89. print(f"Modi: {'Manuel Neuer' if brute_mode == '1' else ('Absturz' if brute_mode == '2' else 'Von Afrika bis zum Nordpol')}, Delay: {delay_seconds}s")
  90. if brute_mode in ['2', '3'] and msvcrt: # If Auto Ascending or Auto Descending and on Windows
  91. print("During auto mode: press 'c' to cancel, 'r' to retry last 3, 'p' to pause/resume.", flush=True)
  92. # auto_mode is True if brute_mode is '2' or '3'
  93. # manual_mode is True if brute_mode is '1'
  94. manual_mode = (brute_mode == '1')
  95. sent_history = deque(maxlen=3) # History for 'retry' functionality
  96. bruteforce_successful = False
  97. bruteforce_stopped_by_user = False
  98. last_iteration_completed = False
  99. paused = False # Pause state for auto modes
  100. iteration_range_list = list(range(256)) # Default for mode '1' and '2'
  101. if brute_mode == '3': # Auto Degrading
  102. iteration_range_list = list(range(255, -1, -1))
  103. num_iterations = len(iteration_range_list)
  104. for i_val_idx, i in enumerate(iteration_range_list): # Retardmode 0x00 to 0xFF or 0xFF to 0x00
  105. last_byte_hex = format(i, '02x')
  106. full_hex_string = hex_prefix + last_byte_hex
  107. try:
  108. payload = bytes.fromhex(full_hex_string)
  109. except ValueError:
  110. print(f"Sorry bin leider Schwerbehindert: {full_hex_string}")
  111. continue
  112. if not manual_mode and msvcrt: # Check for input in auto modes on Windows
  113. while True: # Loop for handling pause and other inputs
  114. if paused:
  115. if msvcrt.kbhit():
  116. try:
  117. char = msvcrt.getch().decode(errors='ignore').lower()
  118. if char == 'p':
  119. paused = False
  120. print("\nBin wieder wach...", flush=True)
  121. break # Break from pause check loop, continue outer loop
  122. elif char == 'c':
  123. print("\nNah du kleins Bumsfotzengesicht hast den Spruch rausgefunden?", flush=True)
  124. bruteforce_stopped_by_user = True
  125. break # Break from pause check loop
  126. except Exception as e:
  127. print(f"\nSorry bin blind geworden: {e}", flush=True)
  128. time.sleep(0.1) # Sleep briefly while paused and checking keys
  129. if bruteforce_stopped_by_user: # If 'c' was pressed during pause
  130. break # Break from the while True input check loop
  131. continue # Continue pause check loop
  132. # If not paused, check for regular input once
  133. if msvcrt.kbhit():
  134. try:
  135. char = msvcrt.getch().decode(errors='ignore').lower()
  136. if char == 'c':
  137. print("\nMarcel Davis will remember that.", flush=True)
  138. bruteforce_stopped_by_user = True
  139. # No break here, let the outer loop's check handle it
  140. elif char == 'r':
  141. if not sent_history:
  142. print("\nChill alter, hast ja noch gar nix probiert.", flush=True)
  143. else:
  144. retry_packets_auto = list(sent_history)
  145. print(f"\nEsy probiere die lezten {len(retry_packets_auto)} Zaubersprüche: {', '.join(retry_packets_auto)}", flush=True)
  146. for hist_hex_string_auto in retry_packets_auto:
  147. try:
  148. hist_payload_auto = bytes.fromhex(hist_hex_string_auto)
  149. print(f"Retrying: {hist_hex_string_auto} ({len(hist_payload_auto)} bytes)", flush=True)
  150. time.sleep(delay_seconds)
  151. sock.sendto(hist_payload_auto, (MCAST_GRP, MCAST_PORT))
  152. except ValueError:
  153. print(f"Sorry bin dumm: {hist_hex_string_auto}", flush=True)
  154. print("Und hat das was gebracht?", flush=True)
  155. # After retry, we don't break, just continue with the current packet
  156. elif char == 'p':
  157. paused = True
  158. print("\nZeit Angehalten. Drück 'p' to um Zeit wieder zu starten, 'c' um dich Abzutreiben.", flush=True)
  159. continue # Go back to start of while True to enter pause handling
  160. except Exception as e:
  161. print(f"\nError reading keyboard input: {e}", flush=True)
  162. break # Break from the while True input check loop if not paused or no key pressed initially
  163. if bruteforce_stopped_by_user:
  164. break
  165. time.sleep(delay_seconds) # Use user-defined delay
  166. sock.sendto(payload, (MCAST_GRP, MCAST_PORT))
  167. # Ensure this print is on a new line if a key was pressed and printed something.
  168. # The \n in prints above should handle this.
  169. print(f"Sent: {full_hex_string} ({len(payload)} bytes)", flush=True)
  170. sent_history.append(full_hex_string) # Add to history after sending
  171. if i_val_idx == num_iterations - 1:
  172. last_iteration_completed = True
  173. if not manual_mode: # Auto modes ('2' or '3')
  174. if last_iteration_completed:
  175. print(f"Bruteforce {'auto-ascending' if brute_mode == '2' else 'auto-descending'} hat fertig geballert.", flush=True)
  176. continue # Continue to next i without asking
  177. # Manual mode (brute_mode == '1'): ask for feedback
  178. while True:
  179. feedback_prompt = "Hats was getan? (y/n/auto/stop/r=retry last 3/c=cancel): "
  180. feedback = input(feedback_prompt).strip().lower()
  181. if feedback == 'y':
  182. print(f"OHAA jetzt kannst du auch wie ich zaubern mit {full_hex_string}! (Meine Frau hat mich verlassen, bin in der geschlossenen Klinik Glanzenberg und leide an starker Schizophrenie, aber egal, ich bin jetzt Hexe!)")
  183. bruteforce_successful = True
  184. break
  185. elif feedback == 'n':
  186. break
  187. elif feedback == 'auto':
  188. manual_mode = False
  189. print("Tja da ist dir wohl die Lust vergangen. Du weisst was das Heute Abend bedeutet? Du bist jetzt im Auto-Modus direkt in meinen Keller, du kleiner Hurensohn.")
  190. if last_iteration_completed:
  191. print("Und wie ists in meinem Keller?")
  192. break
  193. elif feedback == 'stop' or feedback == 'c':
  194. print(f"Bruteforce {'stopped' if feedback == 'stop' else 'cancelled'} by mr hurensohn.")
  195. bruteforce_stopped_by_user = True
  196. break
  197. elif feedback == 'r':
  198. if not sent_history:
  199. print("No packets in history to retry.")
  200. continue # Re-prompt for current packet
  201. retry_packets_manual = list(sent_history)
  202. print(f"Probier da mal die hier {len(retry_packets_manual)} von vorher: {', '.join(retry_packets_manual)}")
  203. for hist_hex_string_manual in retry_packets_manual:
  204. try:
  205. hist_payload_manual = bytes.fromhex(hist_hex_string_manual)
  206. print(f"Probiere: {hist_hex_string_manual} ({len(hist_payload_manual)} bytes)") # Manual mode input implies flush
  207. time.sleep(delay_seconds)
  208. sock.sendto(hist_payload_manual, (MCAST_GRP, MCAST_PORT))
  209. except ValueError:
  210. print(f"Die Stimmen wurden zu laut: {hist_hex_string_manual}")
  211. print(f"War es doch nur ein Traum? : {full_hex_string}")
  212. continue
  213. else:
  214. print("Junge! Ich schlage dich mit Gürtel wenn du mir jetzt nicht richtig antwortest 'y', 'n', 'auto', 'stop', 'r', or 'c'.")
  215. if bruteforce_successful or bruteforce_stopped_by_user:
  216. break
  217. if manual_mode and not bruteforce_successful and not bruteforce_stopped_by_user and last_iteration_completed:
  218. print("Schau mal da, ein Hurensohn, der nicht mal den Hexenspruch rausbekommt. Vielleicht solltest du es mit Aufgeben versuchen, mistvieh.")
  219. # Message for auto_mode completion is handled inside the loop or after switching from manual
  220. # After bruteforce attempt (success, cancel, or finish)
  221. if bruteforce_successful:
  222. # full_hex_string at this point is the one that was successful
  223. print(f"Glückwunsch, du darfst deine Familie wieder sehen mit dem Zauberspruch '{full_hex_string}', Spass (nicht).", flush=True)
  224. save_to_magic_file(full_hex_string, MAGIC)
  225. else:
  226. # If not successful (cancelled or completed all iterations without success)
  227. manual_entry_suffix = input(f"Kein Zauber hat gewirkt oder du hast abgebrochen. Gib den Suffix für '{hex_prefix}' ein, um ihn ins Buch zu kritzeln (oder Enter zum Überspringen): ").strip()
  228. if manual_entry_suffix:
  229. combined_value_to_save = hex_prefix + manual_entry_suffix
  230. print(f"Der Zauberspruch '{combined_value_to_save}' wird dir aufs Bett gesprühschissen !", flush=True)
  231. save_to_magic_file(combined_value_to_save, MAGIC)
  232. else: # Original hex string sending logic
  233. hex_string = user_input # Use the full user_input as the hex_string
  234. try:
  235. payload = bytes.fromhex(hex_string)
  236. except ValueError:
  237. print("Tja hast halt geschissen bist halt keine Hexe oder was?")
  238. continue
  239. sock.sendto(payload, (MCAST_GRP, MCAST_PORT))
  240. print(f"Hexenspruch mit {len(payload)} bytes wurde gezaubert.")
  241. sock.close()
  242. print("Marcel Davis, leiter für Kundenzufriedenheit! Er geht erst wieder wenn die Checksum so hart ausgeschalgen wurde bis Sie aufgibt!.")