r/programming • • Aug 13 '17

Arbitrary code execution in Pokemon Yellow

http://tasvideos.org/5384S.html
1.2k Upvotes

74 comments sorted by

View all comments

Show parent comments

80

u/Alphaetus_Prime Aug 13 '17

If you think that would have blown people's minds, check this out.

25

u/[deleted] Aug 14 '17

I hate reading blocks of text in videos (always wondering if I'll have enough time before the text changes), especially when there are visual elements I don't want to miss. But definitely really cool stuff. I hope GameBoys become commonplace again and this virus gets a chance to make its rounds.

15

u/Alphaetus_Prime Aug 14 '17

The virus works with the 3DS virtual console release of Pokemon Red/Blue, so it could happen!

1

u/ThrowawayusGenerica Aug 15 '17

Is the virtual console cycle accurate, though?

1

u/Alphaetus_Prime Aug 15 '17

There are some emulation differences, but the virus was created with them in mind (or it was modified to accommodate them, anyway).

4

u/salgat Aug 14 '17

He said he would have to fix it so that it doesn't get wiped when the hall of fame comes up, so for practical purposes this virus wouldn't spread far unless it was intentionally done by victims.

5

u/jfb1337 Aug 14 '17

If this existed while the GB was in its prime I think it would have spread fairly far, if given to enough people to spread intentionally, since a lot of people trade pokemon more often than they enter the hall of fame.

5

u/salgat Aug 14 '17

You may not remember but in Red/Blue the only way to power level Pokemon was either glitching rare candies with MissingNo. or leveling through the elite 4. My friends and I were all either making new games or leveling through the elite 4 most of the time.

7

u/mirhagk Aug 14 '17

That's a really neat idea. I kinda hope someone does this with a modern game, just to confuse the heck out of the devs

3

u/maskedbyte Aug 14 '17

Usually not possible unless the game is programmed at a very low level.

1

u/mirhagk Aug 14 '17

Usually not yes, just as most software is usually not exploitable, but there certainly have been cases. But it certainly does happen where a buffer overflow or some careless development leads to an open exploit.

Also quite a lot of games are developed using C++ for performance reasons, which is extra susceptible to exploits (due to manual memory management)

1

u/maskedbyte Aug 15 '17

Arbitrary code execution without some sort of external software (like Cheat Engine) on modern games is in most cases, sadly not possible. Arbitrary code execution usually (I think, I haven't looked very far into it, something close to this though) works by taking advantage of the input bytes and using them as opcodes, since they were read into a byte or 2 on old game consoles. The way input is polled now is very different, it goes through multiple hardware / software layers and is read at a high level, usually with callbacks. Also, there's DEP on Windows.

1

u/mirhagk Aug 15 '17

Like I said, in most cases it's not going to be. But a buffer overflow could still allow for it. Or a sloppy developer could screw up the mod/command engine

6

u/Klathmon Aug 14 '17

Holy fucking shit. This is fucking incredible! I can't even imagine my little 10 year old head if someone managed to do something like this in the 2000

4

u/[deleted] Aug 14 '17

How does the virus cause Mew to become accessible?

22

u/RenaKunisaki Aug 14 '17
  • Exploits transfer protocol to get code uploaded and executed

  • Hooks a routine in memory to be able to run in the background at all times

  • When game is saved, patches the map script pointer in the save data to point to a bootstrap routine

  • When game is started, it executes the map script (really just a function pointer) and thus loads the virus again

  • When player is in the dock map, at certain coordinates, has Strength, and presses the right direction, runs an animation and triggers wild Mew encounter

  • When player is connected to another player for trading, hijacks the link to propagate itself, then restores the normal link function to cover its tracks and not interfere with the game

2

u/yawnful Aug 14 '17

Beautiful! 😭🙂