Jump to content

curl & GTS emulation - convert 336-byte response into 220-byte PKM file?


Recommended Posts

Update: problem solved, info a little further down!

Hi all,

I'm a Linux dev by profession and a lifelong Pokemon fan :)

I was getting irritated trying to receive a certain Pokemon from a popular GTS distribution so I decided to run an experiment... I used the awesome GTS & pkm struct wikis hosted here (incredible job by the community!), modified ir-gts-bw and captured & studied the headers from a GTS transfer. After more experimentation I figured if I captured the output from the following, I should be able to get a .pkm file data back from the server:

$ curl 'http://<distro_server>/worldexchange/result.asp?' 

Well, I do get what looks some .pkm data, but it's 336 bytes. I dd'd the first 236 bytes of the response to a file, and this file is indeed a valid .pkm file - it opens in PokeGen and everything seems cool with it.

So I scripted downloading all unique .pkm from this distro server by this method and have 60+ files to deal with...

At this point, I can save one of these files in PokeGen as a 236-byte non-encrypted pkm file (which is actually only 220 bytes for B/W) and this can then be sent to my game via ir-gts-bw.

I tried trimming the last 16 bytes from my 236 byte files to make them 220 bytes, but these aren't valid .pkm files. I could open them all up in PokeGen and save them, but would rather not spend the time doing so if I don't have to.

TL;DR - Is there a script to convert a GenV 236-byte .pkm into a 220-byte file? I know I can do it in PokeGen but I'm a script kinda guy.

I'd be happy to provide more info if someone can help.

Thanks!

Edited by bpk59
Link to comment
Share on other sites

For anyone who cares, I figured out how to deal with the PKM data that came back from a curl to a GTS server. I wrote a script that uses the ir-gts-bw code library - put it in the src/ folder and it should pickup the necessary imports. See the attached for the script and for the example .pkm file I created with this method :)

1. Do the curl, redirect output to a file:

$ curl -s 'http://75.18.142.225/worldexchange/result.asp?' > curl.pkm

2. Bonus points - make sure it's a 336 byte file:

$ ls -l curl.pkm 
-rw-r--r-- 1 bpk59 bpk59 336 2011-06-02 18:00 curl.pkm

3. Use the prep_gts_pkm.py script on curl.pkm - the script will make a new file called "<pkm_file>.136.decoded.pkm":

ir-gts-bw/src$ ./prep_gts_pkm.py curl.pkm 
curl.pkm does not equal 136 bytes, trimming ...
Writing new pkm file: curl.136.decoded.pkm
ir-gts-bw/src$ ls -l curl.136.decoded.pkm 
-rw-r--r-- 1 bpk59 bpk59 136 2011-06-02 18:07 curl.136.decoded.pkm

4. This file, now 136 bytes, is a decoded .pkm file. It can now be sent via ir-gts-bw!

curl_prep_pkm..zip

curl_prep_pkm..zip

Edited by bpk59
uploaded scripts
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...