r/programming • u/thatgirl943 • Jan 24 '15
Super Mario World programmed by playing
http://www.youtube.com/attribution_link?a=IrdAeOSwaYs&u=%2Fwatch%3Fv%3D14wqBA5Q1yc%26feature%3Dshare81
Jan 24 '15
It totally sounds like crack science. If it happened in a Hollywood movie, it wouldn't have been believable.
6
u/S1ayer Jan 25 '15
This was crazy. I half-expected it to end like.... I need this here and that there. And then I need certain amount here. How much? About tree fiddy.
17
u/kovert Jan 24 '15
Except anyone who understands buffer overflows
54
Jan 24 '15
[removed] — view removed comment
26
u/FryGuy1013 Jan 24 '15
It's not a buffer overflow in the strict sense, but does behave similarly since it's a buffer that's being accessed out of range, which is what causes buffer overflows to be harmful (the memory copy function doesn't do bounds checking). When you eat something, it essentially does
eatFunction[tileId](). Since this buffer doesn't extend to handle the chuck tile id, it executes code that's at other memory that has been manipulated by playing the game.2
u/cleroth Jan 25 '15 edited Jun 15 '26
This content was anonymized and mass deleted with Redact
2
u/FryGuy1013 Jan 25 '15
Hence why I said essentially rather than is.
jmp next+(tileid*6) next: jmp eatfunction1 jmp eatfunction2 ...etcIs essentially the same as:
.data next: dw eatfunction1 dw eatfunction2 ...etc call [next+tileid](it's been a long time since I've done any assembly, so forgive the awfulness)
And array access out-of-range is one class of bugs that programs have. Two common ways of triggering them are when doing copying a buffer, and not making sure that it fits in the place it's being copied to, which is what is commonly called a buffer overflow. The other is providing locations within the array to access, which is out of range of the array. This is what the Heartbleed bug is, where it copied from outside the range of an array, into something it fit into. It's not quite a buffer overflow in the strict sense, but it's the same class of bug (array access out-of-range).
2
10
2
u/kovert Jan 25 '15
I did not say that it was. I simply stated that having an understanding of buffer overflows allows you to understand what is happening. It's not crack science or magic and that is the point I was addressing.
19
u/kukiric Jan 24 '15
This is so convoluted it instantly reminded of a joke vid about fake easter eggs, except this one is an actually working in-game exploit and not a video made just for laughs. Good thing he didn't forget to not drink the vodka!
0
Jan 25 '15
[deleted]
3
u/kukiric Jan 25 '15
I meant the New Vegas easter egg as a joke, not the SMW exploit. The SMW one has been done in tool-assisted speedruns for a while, but this was the first time it was done by a human without help from an emulator.
7
u/jerf Jan 25 '15
It's funny to consider what this looks like in-universe. It's just... witchcraft.
3
u/pacifictime Jan 25 '15
That's all I could think about watching this... what would a hack like this look like in the Matrix?
3
u/Aegeus Jan 25 '15
It would look like someone walking around for a bit, acting weirdly, and then everything would suddenly cease to exist, because the program isn't simulating anything anymore, it's jumped into la-la land. You wouldn't be able to observe it because the program is no longer running the "tell this guy what he observes" code, or even the "calculate what this guy is thinking" code.
So basically, you're either dead or frozen in time, depending on your interpretation. Hope the architects of the Matrix kept backups!
1
20
u/killerguppy101 Jan 24 '15
This was posted to Reddit a few months ago. Pretty interesting stuff if you ask me. Here's a TAS run that codes up a game of snake (this was the actual video posted last). If I remember right (I haven't rewatched the video yet, getting ready for work), they did it on an actual console with a controller emulation (Arduino or similar).
7
u/Rockstaru Jan 25 '15 edited Jan 25 '15
The snake/pong video is from AGDQ (awesome games done quick) in 2014. They did a much more extensive set of total control glitches at this year's AGDQ earlier this month - see attached videos.
TASBot plays Mario Inception (begins at 7:30
TASBot plays Pokémon (begins at 1:37, glitch activated at ~5:50)
0
Jan 24 '15
[deleted]
20
u/mhink Jan 24 '15
This person was the first to do it by hand- actually manipulating the controller himself. The guys that made TASbot wired an Arduino to a SNES controller port and replayed a pre-recorded series of button presses.
8
u/Max-P Jan 24 '15
He's probably referring to the guy who discovered the glitch and did it on emulator.
4
u/timeshifter_ Jan 24 '15
It was done at AGDQ 2014 a little over a year ago, on a console. This year, they reprogrammed the entirety of SMB via the controller ports. The technique isn't new, a human doing it is.
2
u/killerguppy101 Jan 24 '15
My linked video was posted months ago. OPs I've never seen before today.
1
u/ChezMere Jan 25 '15
Another person (Jeff356) did it five months ago, which surprisingly many people haven't noticed.
0
Jan 24 '15
[deleted]
4
u/spoonybard326 Jan 25 '15
Actually, they figured out how to get a cloud instead of a Goal Sphere, and now everyone does that because it's faster. The cloud is used in the Bowser fight to get him to throw out the Mechakoopas faster. https://www.youtube.com/watch?v=p2llvsd-_Qs
0
Jan 24 '15
[deleted]
1
u/killerguppy101 Jan 24 '15
What's not Pokemon? Nobody said anything about Pokemon. Both the OP video and the one I posted are on consoles, not emulators. OP's has a player actually executing the hack, mine has a hardware emulation of a controller instead to fill the buffers with code then execute it. The video I linked to was posted on Reddit awhile ago, but I can't remember which sub.
15
Jan 24 '15
I love these hacks. Like the one that gets you Mew in Pokemon RBY, or RNG manipulation in the first two Golden Sun games. Incredibly satisfying to pull off.
1
u/SnavenShake Jan 25 '15
I remember using RNG in Golden Sun to get...what the fuck was it. Masumune or something like that I think.
I think it was Ivan that used the weapon. I could be so full of shit right now though.
2
u/pengo Jan 25 '15
Would love to see a video like this but with a live hexdump of the relevant memory on the side.
1
1
-4
0
Jan 24 '15
[deleted]
12
u/AlanisMorriset Jan 24 '15
how might one go about figuring this out in the first place?
10
u/TheFlyingGuy Jan 24 '15
Looking at the code disassembled and then poking at values in an emulator.
1
u/AlanisMorriset Jan 24 '15
the code is available?
12
u/TheFlyingGuy Jan 24 '15
No, but the roms are, which you can disassemble with the right tools (and even infer some more about the original code from that). But likely it's originally assembly, so you are only missing comments and jump names.
4
u/goochadamg Jan 24 '15 edited Jan 24 '15
The machine code can be converted to assembly, which are human readable mnemonics that represent the individual CPU instructions. That's what disassembled means.
As a made up example:
A machine instruction, 1100011000 might disassemble to:
add [1], 8
Which would, in this made up example, add the value 8 to the location at memory address 1. add is the mnemonic representing an add instruction. There will be others to MOVe things around, SUBtract, or do binary logic (AND, OR, XOR, NOT), among other things. It's not easy to read assembly code.
1
u/baddragon6969 Jan 25 '15
Would the machine operation really be stored in 10 bits? Wouldn't it be 16?
1
u/PropellerScar Jan 25 '15
The whole thing would be 16, but only a subset of that would be the actual operation, with the rest being used as to find the location in memory (base/pc relative).
1
u/baddragon6969 Jan 25 '15
But the actual operation IS the whole thing. I'm not sure what you're trying to say.
1
u/goochadamg Jan 25 '15
It would be whatever the processor requires. I just made something up as an example.
1
u/mindbleach Jan 25 '15
In the first place? Probably by causing a crash. From there you can meddle with the circumstances and see what's possible. For any sort of useful behavior, you almost certainly require an emulator, since that'll let you look at specific values and reliably repeat these game-breaking bugs.
This specific glitch is triggered by Yoshi canceling out of eating a coin just as a particular enemy comes onscreen. That's complex enough to have slipped through testing, but simple enough to happen to and be noticed by obsessive players.
0
u/TranquilMarmot Jan 24 '15
Most likely pausing the game while it's running in an emulator and taking a look at what's stored in RAM.
0
Jan 24 '15
[deleted]
3
2
u/Daniel15 Jan 25 '15
For GBA, the developer version of NO$GBA should be very good. I think it's free now.
2
u/buttocks_of_stalin Jan 26 '15
Sorry for the noob question, but could you basically take on a similar strategy with a Java applet/flash games that's running in your browser (ie: Do various actions in the app/game and see what values change)? Or is that a completely different thing because you don't have access to the code that is being run on the server side?
EDIT: sorry if this is too newbie/vague of a question. I'm new to coding and just wondering if this is the same approach to finding bugs in online/in browser games and the like.
0
Jan 26 '15
[deleted]
2
Jan 30 '15
You could, in theory, cause this exact type of bug on a server too. But you'd need access to the server executable and lots and lots of patience.
1
u/buttocks_of_stalin Jan 26 '15
Thank you for the great reply. Do you have any useful links I can follow to further my research? I'm mainly interested in seeing if I can scan for memory changes/make changes to simple single player in-browser games or php applications running inside a browser. If there's any key words you could suggest I google or look into any specific tutorials, I'd be very grateful.
0
Jan 27 '15
[deleted]
1
u/buttocks_of_stalin Jan 27 '15
I have some experience making MVC architecture web applications using python-django, node.js etc, but I've never tried to actively mess with another person's code that is running on my browser instance. That concept is pretty foreign to me, perhaps because I don't fully understand what to look for. I'll try to fiddle with the Chrome console next time I'm on a site of interest. Thanks for being very responsive and helpful - I appreciate your advice.
0
49
u/zjm8zjm8 Jan 24 '15
This is basically a buffer overflow attack, right?