{"id":441,"date":"2024-11-07T08:55:43","date_gmt":"2024-11-07T07:55:43","guid":{"rendered":"https:\/\/hacking.museum\/?p=441"},"modified":"2024-11-07T08:59:48","modified_gmt":"2024-11-07T07:59:48","slug":"code-protection-battle-1980s-style-how-to-turn-basic-into-a-fortress-or-a-maze-of-despair","status":"publish","type":"post","link":"http:\/\/hacking.museum\/index.php\/2024\/11\/07\/code-protection-battle-1980s-style-how-to-turn-basic-into-a-fortress-or-a-maze-of-despair\/","title":{"rendered":"Code Protection Battle: 1980s Style! How to Turn BASIC Into a Fortress (or a Maze of Despair)"},"content":{"rendered":"\n<p>Ah, the 1980s. A time when hair was big, computers were small, and hackers weren\u2019t breaking into the mainframe but rather into each other&#8217;s cassette tapes and floppy disks. Fast forward to today, and the <strong>Hacking Museum\u2019s Retro CTF Challenge<\/strong> invites you to relive that glorious era of 8-bit mischief. Your mission? Protect your precious BASIC code from those devious rivals\u2014or prove your worth by cracking theirs. Welcome to the <strong>Code Protection Battle, 1980s Style!<\/strong><\/p>\n\n\n\n<p>But how, you ask, does one secure a BASIC program on ancient hardware like the ZX81 or CPC 6128? Fear not! We\u2019ve compiled a cheeky guide to some simple yet sneaky protection techniques you can employ, as well as a few ways hackers might try to weasel their way past them.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Protecting Your Code: The Retro Way<\/strong><\/h3>\n\n\n\n<p>In the 1980s, protection wasn\u2019t just about hiding your diary from your little brother; it was about making your friends sweat as they tried to break into your masterpiece. Here\u2019s how you can do the same, using only the most devious, yet BASIC-friendly, tricks.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>1. POKE Magic: Memory Manipulation for the Win!<\/strong><\/h4>\n\n\n\n<p>Let\u2019s face it, memory on the ZX81 is precious and limited. But you can still use a few POKE tricks to lock down your code like a digital Fort Knox.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Disable LIST Command:<\/strong> The easiest way to keep prying eyes out of your code is to disable the ability to list it. A simple POKE can make the LIST command useless, leaving hackers staring at a blank screen, wondering where they went wrong.<br><em>Just remember: a clever hacker always finds a way around this, usually by POKE-ing your POKE back to life.<\/em><\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>2. Self-Modifying Code: The Code That Erases Itself<\/strong><\/h4>\n\n\n\n<p>Who needs enemies when your own code can betray you? Self-modifying code can change parts of the program at runtime, making it impossible for intruders to read or save your masterpiece intact.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Auto-Sabotage:<\/strong> Imagine a program that, if tampered with, deletes its own source. It&#8217;s like your code saying, &#8220;If I can&#8217;t have me, no one can!&#8221;<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>3. Obfuscation: The Art of Confusion<\/strong><\/h4>\n\n\n\n<p>Make your code so unreadable that even you might have trouble understanding it after a week. Use complex expressions, nested calculations, and cryptic variable names. Remember, the goal is to make it as brain-melting as possible.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Example:<\/strong> Instead of using <code>LET A = 10<\/code>, try <code>LET A = (2+3)*2<\/code>. Sure, it does the same thing, but it\u2019ll leave would-be hackers scratching their heads and questioning their life choices.<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Creating a Bouncing or Scrolling Text Challenge<\/strong><\/h3>\n\n\n\n<p>But let\u2019s not forget the fun part: making your code entertaining, even if someone manages to break it. We\u2019ve created two simple programs that draw graphics and animate text. They are vulnerable by design, ready for a fierce protection makeover.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>ZX81 BASIC: Scrolling Text with a 3D Computer Graphic<\/strong><\/h4>\n\n\n\n<p>The ZX81 isn\u2019t exactly known for its graphical prowess, but that doesn\u2019t mean we can\u2019t get creative. This little gem creates a simple 3D computer using the ZX81\u2019s ASCII graphics and animates a scrolling player name.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">basicCopy code<code>10 CLS: REM Clear the screen\n20 PRINT AT 1,5;\"  _______ \": REM Top of the monitor\n30 PRINT AT 2,5;\" \/       \/|\": REM Side of the monitor\n40 PRINT AT 3,5;\"\/_______\/ |\": REM Front of the monitor\n50 PRINT AT 4,5;\"|       | |\": REM Front screen border\n60 PRINT AT 5,5;\"|       |\/ \": REM Screen and side\n70 PRINT AT 6,5;\"|_______|  \": REM Bottom of the monitor\n80 PRINT AT 7,5;\"   ||||     \": REM Base of the monitor\n90 PRINT AT 8,5;\"   ||||     \": REM Stand\n100 LET N$=\"Player1  \": REM Player name\n110 LET L=LEN N$\n120 FOR I=0 TO 31\n130 PRINT AT 14,0; \" \";: REM Erase the old text\n140 FOR J=1 TO L\n150 PRINT AT 14, 32-J;MID$(N$,J,1);: REM Display scrolling text\n160 NEXT J\n170 FOR K=1 TO 200: NEXT K: REM Short pause for smoother scrolling\n180 LET N$=RIGHT$(N$,L-1)+LEFT$(N$,1): REM Rotate the text\n190 GOTO 120: REM Loop forever\n<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Objective for the Hacker:<\/strong> Replace <code>\"Player1\"<\/code> with their nickname, proving they\u2019ve cracked the protection.<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>CPC 6128 BASIC: Bouncing Name with ASCII Art Computer<\/strong><\/h4>\n\n\n\n<p>The CPC 6128 offers more graphical flair, perfect for creating a simple but impressive &#8220;3D computer&#8221; and a bouncing player name.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">basicCopy code<code>10 MODE 1: REM High-resolution 4-color mode\n20 FOR I=10 TO 20: LOCATE I,5: PRINT CHR$(143); NEXT: REM Horizontal bar\n30 LOCATE 8,3: PRINT \"HACKING MUSEUM\": REM Title\n40 LOCATE 7,4: PRINT \"RETRO CTF CHALLENGE\": REM Subtitle\n50 FOR I=12 TO 18\n60 LOCATE 10,I: PRINT CHR$(143): REM Left vertical bar\n70 LOCATE 30,I: PRINT CHR$(143): REM Right vertical bar\n80 NEXT I\n90 LOCATE 10,18: FOR I=10 TO 30: PRINT CHR$(143); NEXT: REM Bottom bar\n100 N$=\"Player1\": REM Player name\n110 X=1: DIR=1: REM Initial position and direction\n120 WHILE TRUE\n130 LOCATE X,12: PRINT SPACE$(8);: REM Clear old text\n140 LOCATE X,12: PRINT N$: REM Display player name\n150 FOR I=1 TO 200: NEXT I: REM Short delay for animation\n160 X=X+DIR: REM Update position\n170 IF X&lt;1 OR X&gt;32 THEN DIR=-DIR: REM Reverse direction at edges\n180 WEND: REM Infinite loop\n<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Objective for the Hacker:<\/strong> Once they bypass the protection, they must replace <code>\"Player1\"<\/code> with their own nickname.<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Future-Proofing Your Retro Defense<\/strong><\/h3>\n\n\n\n<p>Sure, these techniques might seem rudimentary, but don\u2019t underestimate the power of retro ingenuity. You\u2019ll need to think like a 1980s hacker\u2014because even back then, clever tricks were king. For added flair, consider combining multiple protections, like hiding code in unused memory or employing checksum verification. But remember: <strong>don\u2019t make it so secure that even you can\u2019t break back in!<\/strong><\/p>\n\n\n\n<p>So, retro warriors, sharpen your BASIC skills, fortify your code, and prepare to defend or attack in the <strong>Hacking Museum\u2019s Retro CTF Challenge<\/strong>. Just remember, whether you\u2019re the hero or the villain of this 8-bit story, the spirit of the 1980s lives on in every line of code you write&#8230; or crack.<\/p>\n\n\n\n<p><strong>Hints &amp; Solutions: How to Protect Your BASIC Code from Being Listed<\/strong><\/p>\n\n\n\n<p>So, you&#8217;ve built your graphical BASIC masterpieces, and now you&#8217;re ready to protect them from snooping hackers who just can\u2019t resist typing <code>LIST<\/code> to expose your brilliant work. Here are some hints and (semi-)devious methods to make sure your code stays hidden:<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Hints for Protection:<\/strong><\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Memory Manipulation with POKE Commands<\/strong>\n<ul class=\"wp-block-list\">\n<li>Use the ZX81 or CPC 6128\u2019s memory locations to disable certain functionalities, like the <code>LIST<\/code> command. This makes it harder for hackers to inspect your code directly.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Obfuscation and Redirection<\/strong>\n<ul class=\"wp-block-list\">\n<li>Make your code confusing and misleading. Use decoy lines that don\u2019t do much or mislead anyone trying to reverse-engineer your program. Redirect sections of your code to give the impression it\u2019s doing something it\u2019s not.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Self-Modifying Code<\/strong>\n<ul class=\"wp-block-list\">\n<li>Write code that changes itself after being loaded. This way, even if someone gets access to the original lines, they won\u2019t be able to fully understand or save the modified version.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Checksum Validation<\/strong>\n<ul class=\"wp-block-list\">\n<li>Add a routine that checks if your code has been tampered with and causes the program to malfunction if it detects any changes. It won&#8217;t directly prevent <code>LIST<\/code>, but it\u2019ll frustrate anyone trying to modify your program.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Basic Solutions to Disable LIST Command:<\/strong><\/h3>\n\n\n\n<p>Here are some tricks you can use to block or interfere with the <code>LIST<\/code> command:<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>1. Using POKE to Disable LIST (ZX81 Example)<\/strong><\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>On the ZX81, you can use the POKE command to manipulate memory and disable the <code>LIST<\/code> command. A common address for this trick is <strong>16509<\/strong>.<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-preformatted\">basicCopy code<code>10 POKE 16509, 0: REM Disable LIST command\n20 PRINT \"Code Protected!\"\n30 REM Your main program here\n40 GOTO 40: REM Infinite loop to keep the program running\n<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>What It Does:<\/strong> The <code>POKE 16509, 0<\/code> command modifies a memory location responsible for handling the <code>LIST<\/code> command, effectively disabling it.<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>2. Disabling LIST on the CPC 6128<\/strong><\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>The Amstrad CPC 6128 allows for a more robust method of hiding your code using custom symbol tables or by manipulating firmware hooks.<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-preformatted\">basicCopy code<code>10 SYMBOL AFTER 32: REM Prevents access to character symbols\n20 FOR I = 0 TO 255: SYMBOL I, 255, 255, 255, 255, 255, 255, 255, 255: NEXT: REM Obscure characters\n30 PRINT \"Code Hidden from LIST!\"\n40 REM Your main program here\n50 WHILE TRUE: WEND: REM Infinite loop to keep the program running\n<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>What It Does:<\/strong> This code alters the CPC\u2019s symbol table, making characters appear as blank or solid blocks, preventing the code from being easily listed or read.<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Bypassing the Protection (Hints for Hackers):<\/strong><\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Memory PEEK and POKE<\/strong>\n<ul class=\"wp-block-list\">\n<li>If you\u2019re on the attack, remember that you can always try to reverse POKE commands. For instance, on the ZX81, if <code>POKE 16509, 0<\/code> disables <code>LIST<\/code>, you could try <code>POKE 16509, 255<\/code> to re-enable it.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Interrupting Auto-Run<\/strong>\n<ul class=\"wp-block-list\">\n<li>Hold down key combinations like <code>SHIFT + SPACE<\/code> while loading the program to interrupt auto-run features and possibly access the code before protection mechanisms kick in.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Using Emulators for Memory Dumps<\/strong>\n<ul class=\"wp-block-list\">\n<li>Many modern ZX81 and CPC emulators come with memory inspection tools. Use these to dump memory and search for hidden parts of the code that may reveal obfuscation tricks or protection methods.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>Remember, the fun of this challenge is in the game of cat and mouse between code protectors and crackers. Employ these techniques wisely, and may your BASIC creations remain secure&#8230; at least until a clever hacker comes along! Good luck, retro warriors!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Ah, the 1980s. A time when hair was big, computers were small, and hackers weren\u2019t breaking into the mainframe but rather into each other&#8217;s cassette tapes and floppy disks. Fast&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-441","post","type-post","status-publish","format-standard","hentry","category-non-classe"],"_links":{"self":[{"href":"http:\/\/hacking.museum\/index.php\/wp-json\/wp\/v2\/posts\/441","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/hacking.museum\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/hacking.museum\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/hacking.museum\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/hacking.museum\/index.php\/wp-json\/wp\/v2\/comments?post=441"}],"version-history":[{"count":1,"href":"http:\/\/hacking.museum\/index.php\/wp-json\/wp\/v2\/posts\/441\/revisions"}],"predecessor-version":[{"id":442,"href":"http:\/\/hacking.museum\/index.php\/wp-json\/wp\/v2\/posts\/441\/revisions\/442"}],"wp:attachment":[{"href":"http:\/\/hacking.museum\/index.php\/wp-json\/wp\/v2\/media?parent=441"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/hacking.museum\/index.php\/wp-json\/wp\/v2\/categories?post=441"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/hacking.museum\/index.php\/wp-json\/wp\/v2\/tags?post=441"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}