Main Menu
Main Page
Forums
New pages
Recent changes
Random page
Help

Glitches
Arbitrary code execution
Pokémon cloning
Pomeg glitch and Glitzer Popping
Tweaking and voiding
Glitches by generation
Other glitch categories

References/Resources
Databases
Disassembly projects
The Big HEX List
Interactive tools
Reference documents
Terminology

Affiliates
Legendary Star Blob 2 (Hakuda) (日本語/Japanese)
Pokémon Speedruns wiki (English)
PRAMA Initiative (Français/French)
MissingNo. Glitch City (Italiano/Italian)
Become an affiliate!

Technical
Site source code

Search Wiki

 

Search Forums

 

Author Topic: Korean TM49 arbitrary code execution thread  (Read 607 times)

0 Members and 1 Guest are viewing this topic.

Evie the Bird Mother 🌸 ☽

  • Veteran Contributor
  • *
  • Offline Offline
  • Gender: Female
  • ああ、紅茶がおいしい。 ~ ^^
    • View Profile
Korean TM49 arbitrary code execution thread
« on: August 23, 2019, 11:19:24 am »
Using this method, you can perform arbitrary code execution with wrong pocket TM49 (gift from Bugsy). You don't need a bootstrap Pokémon for this method as it runs PC items directly. It requires a Bellsprout and clearing the whole game without saving with the save cleared with Up+Select+B.

https://www.youtube.com/watch?v=pbSavUyFC_Y

The following code from PC item 5 will let you warp to the Safari Zone gate for instance once you use TM49 from the wrong pocket:

 
X Accuracy x1
TM27 x1 (Return, Goldenrod Department Store gift)
Ultra Ball x2
Great Ball x45
Great Ball x45
Great Ball x45
Great Ball x45
Full Restore x3
Energypowder x4
Focus Band x1 (Saffron City Fighting Dojo)
Ultra Ball x2
Great Ball x44
Super Potion x80
Ultra Ball x4
Heal Powder x4
Leaf Stone x1 (Sea Cottage (from Bill's grandfather) or possibly Mystery Gift)
Ultra Ball x2
TM10 x(any) (Get from Lake of Rage or buy from Celadon Department Store)

I'm going to try and make a code to fill the Pokédex and a wild Pokémon mod, given that in VC Korean Gold/Silver it seems to be normally impossible. Watch this space :).
« Last Edit: August 23, 2019, 11:25:10 am by Princess Torchic Owl Lover ☽ ❤ »
(I was former joint head admin but stepped down)
✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿
Here have some free flowers on every post. ^^
✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿
Love, faith, hope are free. If all is lost friends save us.
Thanks fans for lovely Torchic artwork. ♡ First image thanks Nyapon.

bwill11

  • pleb with a big brain and nothing to do with it
  • GCLF Member
  • *
  • Offline Offline
  • Gender: Male
    • View Profile
Re: Korean TM49 arbitrary code execution thread
« Reply #1 on: August 23, 2019, 11:39:50 am »
Why is it necessary to not have a save file?
What if you wanted to research glitches but the opponent said
Enem.
Enem.
Enem.
Enem.
Enem.
Enem.
Enem.
Enem.
Enem.
Enem.

Evie the Bird Mother 🌸 ☽

  • Veteran Contributor
  • *
  • Offline Offline
  • Gender: Female
  • ああ、紅茶がおいしい。 ~ ^^
    • View Profile
Re: Korean TM49 arbitrary code execution thread
« Reply #2 on: August 23, 2019, 07:02:35 pm »
Why is it necessary to not have a save file?

Saving the game any other way than entering the Hall of Fame initialises the box data, making the 'free bad clone' this way impossible.

Here is a code to complete the Pokédex with TM49, from PC item 5. You need any wrong pocket copy of TM49.

PC item 5 and below:

X Accuracy x2
Ultra Ball x46
Great Ball x1
Great Ball x4
Poké Doll x94
X Accuracy x1
TM28 x1
Poke Ball x5
Nevemeltice x1
Antidote x9
Great Ball x62
TM04 x1
Burn Heal x10
TM42 x1
TM24 x1
(Any item) x2
Full Restore x1
Paralyz Heal x13
Energypowder x12
Full Restore x1
Escape Rope x19
Protein x27
Repel x20
TM19 x1
Calcium x1
Great Ball x4
Full Restore x7
Energypowder x38
TM29 x1
Full Heal x38
Fresh Water x1
Full Restore x1
Paralyz Heal x4
Stick x1
Great Ball x4
Leaf Stone x1
Bicycle x1
Fresh Water x32
Spell Tag x1
Great Ball x4
TM10 x1
Great Ball x4

To get 251 seen/own instead of x0, swap the items starting from Full Restore x7 to item 5 and up and use TM47 again, or just toss everything above it.

To get multiple of the same stack, the same method as EN Gold (buy two 99 stacks and toss from them after depositing them) may work.

Code at D2D6:

2102022E04010404255E2101DC0105056B01090904
3EC2010A0AEA01D70102010E010D0D790C0E01131
31B1B1414D2011F0104040E077926DD0126262E010
E010D0469010404220107012E2071010404C9010404FF

This is annoying for now, but hopefully it should work on Virtual Console too.



Edit on August 25 2019: Sorry I made an error with this code. The code by mistake, assumed the TM28 x1 was the glitched unusable one (ID 0xDC), which you can only get with cheats. You may still be able to get this (e.g. swapping from expanded Balls pocket, another ACE) but use it with the normal TM28 and your party names will be corrupted instead.

At first glance, there wasn't a work around other than the following. Assuming you have the normal TM28 (0xDB) instead; use (any item) x2 below the TM24, instead of Ultra Ball x1. This adds 256 to the FF fill length, which now starts at DB01 instead of DC01; ensuring the same Pokédex data is touched. In other words, both your party names and Pokédex will be corrupted, so be sure to use this with party Pokémon you don't want, which can be released later. The PC Pokémon names will be fine.
« Last Edit: August 24, 2019, 08:26:58 pm by Princess Torchic Owl Lover ☽ ❤ »
(I was former joint head admin but stepped down)
✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿
Here have some free flowers on every post. ^^
✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿
Love, faith, hope are free. If all is lost friends save us.
Thanks fans for lovely Torchic artwork. ♡ First image thanks Nyapon.

CasualPokePlayer

  • GCLF Member
  • Offline Offline
  • Gender: Male
  • My name is a lie
    • View Profile
Re: Korean TM49 arbitrary code execution thread
« Reply #3 on: January 31, 2020, 01:17:56 am »
Old thread, but I noticed how very long the Pokedex Completion item list is and the need to use stacks of the same item. So I looked into it and made a more optimized item list (all item stacks unique, all items are re-obtainable, it's much shorter and easier to obtain, and it will check all seen data and caught data out of the box, and no corruption in other areas).

Items starting at PC Item 2 (yes I said it right, 2, look at the code to see why)

Any Item x24
Repel xAny
Any xAny
PP Up x01
X Accuracy x32
TM29 x01
Poke Ball x31
Portrait Mail x03
Awakening x95
Energypowder x50
Dragon Scale x02
Ultra Ball x34
Max Repel x02
X Special x43
Lovely Mail x05
Potion x32
TM32 x01
Antidote x31
Paralyz Heal x11
Carbos x02
Burn Heal x40
TM38 x02
TM10 xAny


Code: [Select]
jr $14 ; jump to the ld (bc),a after the sub a,a
~~
ld a,01 ; execution starts here
ld hl,DD20 ; the end of Pokedex Seen Data, code will write the flags backwards
ld bc,1F05
or a,a ; filler           
inc bc ; bc = $1F06             
inc c ; c = $07             
ld e,a ;  e = $01             
ld a,c ; a = $07             
ld (hld),a ; (hl) = $07
sub a,a ; a = $00
ld (bc),a ; filler             
ld (bc),a ; filler
ld (hli),a ; (hl) = $00
dec hl ; undo the inc hl from previous instruction
ld (bc),a ; filler
dec (hl) ; (hl) = $FF
dec hl ; go to next byte to write
cp a,b ; filler
dec b ; decrease loop counter
ld (de),a ; filler
jr nz,$E0 ; jump to the jr $14, jump taken until b = $00
ld bc,1F09
dec c ; c = $08
dec bc ; bc = $1F07
dec e ; decrease e for a 1 time loop
ld (bc),a ; filler
ld a,(bc) ; filler
jr z,$E6 ; jump to the ld a,c when e = $00, jump only taken 1 time
ld (bc),a ; filler
ret

EDIT: Added comments to code
« Last Edit: March 03, 2020, 05:05:11 pm by CasualPokePlayer »

Evie the Bird Mother 🌸 ☽

  • Veteran Contributor
  • *
  • Offline Offline
  • Gender: Female
  • ああ、紅茶がおいしい。 ~ ^^
    • View Profile
Re: Korean TM49 arbitrary code execution thread
« Reply #4 on: February 01, 2020, 02:00:14 pm »
Thanks for all this! ^^ This looks it'll be great for future Korean Gold/Silver players. (Even though I've spent a lot of time with ACE I'm still a poor programmer)
(I was former joint head admin but stepped down)
✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿
Here have some free flowers on every post. ^^
✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿
Love, faith, hope are free. If all is lost friends save us.
Thanks fans for lovely Torchic artwork. ♡ First image thanks Nyapon.

Parzival

  • The Laziest Malware Enthusiast
  • Banned
  • *
  • Offline Offline
  • Gender: Male
  • who posted nudes in upstream
    • View Profile
    • (null)
Re: Korean TM49 arbitrary code execution thread
« Reply #5 on: February 01, 2020, 06:04:01 pm »
couldn't one just loop through the applicable part of WRAM/SRAM and write FF to the entire area? To my knowledge, it's just a straight-up bitfield...

i'm also on keybase and bitchute but i don't have nifty buttons for those. Bitchute isn't ready yet, but will be eventually.

mood

CasualPokePlayer

  • GCLF Member
  • Offline Offline
  • Gender: Male
  • My name is a lie
    • View Profile
Re: Korean TM49 arbitrary code execution thread
« Reply #6 on: February 02, 2020, 04:44:12 am »
WRAM is far more simple to do as save data in SRAM protected under a checksum, and it's also locked so you would have to unlock it. Looping through the WRAM part of Pokedex data is (mostly) what I do, however, there is a slight caveat as the end of the Pokedex data is $07 instead of $FF, since there are only 251 mons in the game. But that is fairly simple to get around (just make it so once loop 1 finishes/before it starts (depending on if you go forwards or backwards, I decided to go backwards because items restrictions made it more favorable), it writes $07 instead of $FF, then make loop 1 loop once more so you can get seen/owned data too (again, depending on whether you go forwards or backwards).
« Last Edit: February 02, 2020, 04:49:09 am by CasualPokePlayer »

Parzival

  • The Laziest Malware Enthusiast
  • Banned
  • *
  • Offline Offline
  • Gender: Male
  • who posted nudes in upstream
    • View Profile
    • (null)
Re: Korean TM49 arbitrary code execution thread
« Reply #7 on: February 02, 2020, 10:25:20 am »
WRAM is far more simple to do as save data in SRAM protected under a checksum, and it's also locked so you would have to unlock it. Looping through the WRAM part of Pokedex data is (mostly) what I do, however, there is a slight caveat as the end of the Pokedex data is $07 instead of $FF, since there are only 251 mons in the game. But that is fairly simple to get around (just make it so once loop 1 finishes/before it starts (depending on if you go forwards or backwards, I decided to go backwards because items restrictions made it more favorable), it writes $07 instead of $FF, then make loop 1 loop once more so you can get seen/owned data too (again, depending on whether you go forwards or backwards).
Unlocking SRAM is as simple as writing any byte ending in A to 0000 (additionally, it's often unlocked as bank 0 is used for buffer space,) and the game calculates the checksum when saving, so we should be able to reuse that code, in theory.
Does this version use the same memory setup as US GS? (It's in WRAM in US GS, which is nice.)
« Last Edit: February 02, 2020, 02:23:28 pm by Parzival »

i'm also on keybase and bitchute but i don't have nifty buttons for those. Bitchute isn't ready yet, but will be eventually.

mood

CasualPokePlayer

  • GCLF Member
  • Offline Offline
  • Gender: Male
  • My name is a lie
    • View Profile
Re: Korean TM49 arbitrary code execution thread
« Reply #8 on: February 02, 2020, 03:17:31 pm »
You kinda proved my point on SRAM being more complicated lol, sure you could do that but that adds more items to the item list.

It doesn't have the same memory layout as US GS,  sadly. Heck the box names seem to use 2 bytes instead of 1 (so it's not optimal for ACE payloads). Although, I haven't looked into the mail buffer, maybe that could be used for longer ACE payloads?

EDIT: when I mean different layout, I mean different locations for memory addresses, the structure is *mostly* the same as US GS tho.
« Last Edit: February 02, 2020, 03:28:10 pm by CasualPokePlayer »

Parzival

  • The Laziest Malware Enthusiast
  • Banned
  • *
  • Offline Offline
  • Gender: Male
  • who posted nudes in upstream
    • View Profile
    • (null)
Re: Korean TM49 arbitrary code execution thread
« Reply #9 on: February 02, 2020, 04:00:41 pm »
Found it:
Continuous memory block from DCE2 to DD22, total of 3F bytes. Owned data from DCE2 to DD01, seen data from DD02 to DD22.

That was an interesting game of Battleship...

EDIT: ok so i'm stupid, seen data's the latter half. Fixed.

EDIT 2: oh ok so apparently doing it like this allows for glitch mons to have their pokedex entries seen. That was weird to see while flicking through the list...
gastly, haunter, gengar, gengar confetti, onix...
« Last Edit: February 02, 2020, 04:10:08 pm by Parzival »

i'm also on keybase and bitchute but i don't have nifty buttons for those. Bitchute isn't ready yet, but will be eventually.

mood

CasualPokePlayer

  • GCLF Member
  • Offline Offline
  • Gender: Male
  • My name is a lie
    • View Profile
Re: Korean TM49 arbitrary code execution thread
« Reply #10 on: February 02, 2020, 04:09:23 pm »
Yeah, as I said, the end of the seen/owned data both have a $07 byte at the end as only 251 slots are valid (with 5 invalid slots).
« Last Edit: February 02, 2020, 04:20:27 pm by CasualPokePlayer »