```python import itertools import time import sys RED = "\033[91m" GREEN = "\033[92m" YELLOW = "\033[93m" BLUE = "\033[94m" MAGENTA = "\033[95m" CYAN = "\033[96m" WHITE = "\033[97m" RESET = "\033[0m" BOLD = "\033[1m" DIM = "\033[2m" worm_frames = [ r""" ___ (o__""", r""" __.-----. (o__.---.""", r""" .----. __/ .--. \__ (o__.' '.))_)""", r""" .-. / _ \ __) | | (__ (o__.' '.))_)""", r""" .----. __/ .--. \__ (o__.' '.))_)""", r""" .---. __/ .-. \___ (o__/ \_))_)""", r""" _____________ o_________))_) """, r""" __.-------.___ o__'-----'_))_) """, r""" .---. _/ .-. \___o__/ \_))_) """, r""" .---._/ .-. \__ o_.' '.))_) """, r""" .-. / _ \__) | | (__ o__.' '.))_) """, r""" .----. __ \__.' '.))_) """, r""" ---.__ -._))_) """, r""" ___ ))_) """ ] injkt_frames = [ r""" \ /\ \ / /\ /\/\ /{MAGENTA}N{RESET}// / / \/ {RED},{RESET} / {RED}.{RESET} / {RED}*{RESET}/{RED}. '{RESET} [{BLUE}EUSC{RESET}]""".format(BLUE=BLUE, RED=RED, MAGENTA=MAGENTA, RESET=RESET), r""" \ \ /\ /\ / /\ /\/ /{MAGENTA}N{RESET}/ \/ / {RED}.{RESET} / {RED}.,{RESET} {YELLOW}[WO{RESET}{BLUE}SC]{RESET}' {RED}.{RESET} {RED}.{RESET}""".format(RED=RED, BLUE=BLUE, YELLOW=YELLOW, MAGENTA=MAGENTA, RESET=RESET), r""" \\ /\\ / /\ / / /\/ \/ / /{RED}.{RESET}[{YELLOW}WORM{RESET}]{RED}'{RESET} {RED}'{RESET} {RED}.{RESET} {RED}'{RESET} {RED}.;. ,*.{RESET} """.format(YELLOW=YELLOW, RED=RED, RESET=RESET), ] def slow_print(text, delay=0.02): """ Print text one character at a time with a slight delay to mimic a "hacker terminal" style. """ for char in text: print(char, end="", flush=True) time.sleep(delay) print() def progress_bar(duration=3, bar_length=30, msg="Decoding"): """ A simple progress bar that runs for 'duration' seconds. """ start_time = time.time() while True: elapsed = time.time() - start_time if elapsed >= duration: break fraction = elapsed / duration filled = int(fraction * bar_length) bar = "#" * filled + "-" * (bar_length - filled) percent = int(fraction * 100) print(f"\r{msg}: [{bar}] {percent}%", end="", flush=True) time.sleep(0.05) print(f"\r{msg}: [{'#' * bar_length}] 100%") def animate_worm_v2(frames, delay=0.15, repetitions=1): """ Animates the worm using ANSI escape codes. Uses \033[<N>A (Cursor Up) and \r (Carriage Return) for potentially better terminal compatibility and revised logic. """ max_lines = 0 cleaned_frames = [] for frame in frames: cleaned_frame = frame.strip('\n') cleaned_frames.append(cleaned_frame) max_lines = max(max_lines, cleaned_frame.count('\n') + 1) if max_lines == 0: return sys.stdout.write("\n" * max_lines) sys.stdout.flush() sys.stdout.write(f"\033[{max_lines}A") sys.stdout.flush() cursor_on_start_line = True for _, frame in itertools.product(range(repetitions), cleaned_frames): if not cursor_on_start_line: sys.stdout.write(f"\033[{max_lines}A") sys.stdout.flush() lines = frame.split('\n') for i in range(max_lines): sys.stdout.write("\r") if i < len(lines): sys.stdout.write(f"{lines[i]}\033[K") else: sys.stdout.write("\033[K") sys.stdout.write("\n") sys.stdout.write(f"\033[{max_lines - 1}A") cursor_on_start_line = True sys.stdout.flush() time.sleep(delay) sys.stdout.write("\r") for i in range(max_lines): sys.stdout.write("\033[K") if i < max_lines - 1: sys.stdout.write("\n") print() sys.stdout.flush() def animate_injkt(frames, delay=0.2, repetitions=1): """ Animates the inject sequence using ANSI escape codes, overwriting frames. Based on the logic of animate_worm_v2. """ max_lines = 0 cleaned_frames = [] for frame in frames: cleaned_frame = frame.strip('\n') cleaned_frames.append(cleaned_frame) max_lines = max(max_lines, cleaned_frame.count('\n') + 1) if max_lines == 0: return sys.stdout.write("\n" * max_lines) sys.stdout.flush() sys.stdout.write(f"\033[{max_lines}A") sys.stdout.flush() cursor_on_start_line = True for _, frame in itertools.product(range(repetitions), cleaned_frames): if not cursor_on_start_line: sys.stdout.write(f"\033[{max_lines}A") sys.stdout.flush() lines = frame.split('\n') for i in range(max_lines): sys.stdout.write("\r") if i < len(lines): sys.stdout.write(f"{lines[i]}\033[K") else: sys.stdout.write("\033[K") sys.stdout.write("\n") sys.stdout.write(f"\033[{max_lines - 1}A") cursor_on_start_line = True sys.stdout.flush() time.sleep(delay) sys.stdout.write("\r") for i in range(max_lines): sys.stdout.write("\033[K") if i < max_lines - 1: sys.stdout.write("\n") print() sys.stdout.flush() def convert_pattern_to_ascii(pattern): """ Convert a pattern of + and - symbols to ASCII text by: 1. Converting + to 1 and - to 0 2. Reading each column as a 7-bit binary number 3. Converting each binary number to decimal 4. Converting each decimal to an ASCII character Returns the resulting ASCII text. """ slow_print(f"\n{BLUE}{BOLD}Step 1: Convert '+' to '1' and '-' to '0'{RESET}") binary_pattern = [] for row in pattern: binary_row = row.replace("+", "1").replace("-", "0") binary_pattern.append(binary_row) for i, row in enumerate(binary_pattern): print(f"{YELLOW}Row {i + 1}:{RESET} {row}") progress_bar(2, msg="Converting pattern") binary_columns = [] if not binary_pattern: return "Error: Empty pattern" num_cols = len(binary_pattern[0]) num_rows = len(binary_pattern) for col in range(num_cols): binary_column = "".join( binary_pattern[row][col] if col < len(binary_pattern[row]) else '0' for row in range(num_rows) ) binary_columns.append(binary_column) for i, column in enumerate(binary_columns): print(f"{YELLOW}Column {i + 1}:{RESET} {column}") progress_bar(2, msg="Arranging columns") decimal_values = [] for i, binary in enumerate(binary_columns): if not binary: continue try: decimal_val = int(binary, 2) decimal_values.append(decimal_val) if i == 0: slow_print(f"{GREEN}Column 1 ({binary}): Detailed breakdown{RESET}") for j, bit in enumerate(binary): power = len(binary) - 1 - j if bit == "1": value = 2 ** power print(f" 1 × 2^{power} = {value}") else: print(f" 0 × 2^{power} = 0") print(f" Sum = {decimal_val}") else: print(f"{GREEN}Column {i + 1} ({binary}) = {decimal_val}{RESET}") except ValueError: print(f"{RED}Error converting binary column {i+1}: '{binary}'{RESET}") progress_bar(2, msg="Calculating decimals") ascii_chars = [] for i, decimal_val in enumerate(decimal_values): try: if 0 <= decimal_val <= 127: char = chr(decimal_val) ascii_chars.append(char) print(f"{YELLOW}Column {i + 1}:{RESET} {decimal_val} = '{char}'") else: print(f"{RED}Warning: Decimal {decimal_val} out of standard 7-bit ASCII range (0-127). Skipping.{RESET}") except ValueError: print(f"{RED}Error converting decimal {decimal_val} to char.{RESET}") continue print(f"\n{MAGENTA}{BOLD}Complete ASCII message:{RESET} {ascii_message}") return ascii_message def main(): banner = f"""{GREEN}{BOLD} ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ ░ ░░░ ░░ ░░░░ ░░ ░░░░░░░░ ░░░░░░░░░ ░░░ ░░ ░░░░ ░░ ▒ ▒▒ ▒▒ ▒▒▒▒ ▒▒ ▒▒▒▒▒▒▒▒ ▒▒▒▒▒▒▒▒ ▒▒▒▒▒▒▒▒▒▒▒ ▒▒▒▒▒ ▒▒▒▒ ▒▒ ▒▒▒▒ ▒ ▓ ▓ ▓ ▓▓ ▓▓▓▓ ▓▓ ▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▓▓▓ ▓▓▓▓ ▓ █ ██ ██ ████ ██ ████████ ██████████████ █████ █████ ███ ███ █ █ ███ ███ ███ ██ ███ ██████ █████ ████ ██ ████ █ ████████████████████████████████████████████████████████████████████████████████ {RESET}""" slow_print(f"{GREEN}{BOLD}--- [WAKE]//INJKT::squirmy_wormy.py ---{RESET}", 0.03) animate_worm_v2(worm_frames, delay=0.15, repetitions=2) slow_print(f"{DIM}Preparing to decode pattern...{RESET}", 0.03) time.sleep(0.5) "++++++------", "------++++++", "+-+-----+---", "-----+-+-+-+", "++-+++-+-+--", "--++++----+-", "-++--+-+-+-+-" pattern[6] = pattern[6][:12] print(f"{BOLD}Original pattern:{RESET}") for i, row in enumerate(pattern): print(f"{CYAN}Row {i + 1}:{RESET} {row}") print() ascii_message = convert_pattern_to_ascii(pattern) if len(ascii_message) >= 6: slow_print(f"\n{BLUE}{BOLD}Step 5: Reverse the text{RESET}") first_six = ascii_message[:6] reversed_text = first_six[::-1] print(f"{YELLOW}First 6 characters:{RESET} {first_six}") print(f"{YELLOW}Reversed:{RESET} {reversed_text}") print("Starting inject sequence...") animate_injkt(injkt_frames, delay=0.4, repetitions=3) print("Inject sequence complete.") print(f"{MAGENTA}The coded message is:{RESET} {first_six}") print(f"{MAGENTA}When reversed:{RESET} {reversed_text}\n") else: print(f"\n{RED}{BOLD}Warning: Decoded message '{ascii_message}' is shorter than 6 characters. Cannot perform Step 5.{RESET}") slow_print(f"{GREEN}{BOLD}--- DECODING COMPLETE ---{RESET}", 0.03) if __name__ == "__main__": main() ```