Quake 2 - temp ticket patch

mrdude

Developer
OP
Developer
Joined
Dec 11, 2015
Messages
3,071
Trophies
1
Age
56
XP
8,227
For those with a quake 2 dump that only has a temp ticket, this gets removed once you reboot your switch and then you can't decrypt the game nca files to launch it, you can fix this with a simple patch to the nsp file.

Scroll to offset: 0xB15 - change 00 10 to 10 00

Uninstall the old game, then reinstall with the newly patched NSP file, and your ticket will be a perm ticket. Thanks to @Tokiwa for helping with this.

patch.png


Probably this same trick can be used on other nsp files with similar temp ticket files.

NOTE: you will still need to use in airplane mode, or patch that requirement out of the game.

PS, the only other game I found with this same issue is warhammer 40k boltgun - which gets patched in the same way but at offset 0xB55.
Post automatically merged:

On further inverstigation it seems that on this nsp the offset 0xB15 is the master key revision and offset 0xB16 is the licence type, here's the different licence types you can have by changing the hex at 0xB16:

00 - perm
01 - pre inst
02 - shared title
03 - pre inst shared title
04 - all contents
05 - pre inst all contents
06 - shared title all contents
07 - pre inst shared title all contents
08 - device link independant
09 - pre inst device link independant
0a - shared title device link independant
0b - pre inst shared title device link independant
0c - all contents device link independant
0d - pre inst all contents device link independant
0e - shared title all contents device link independant
0f - pre inst shared title all contents device link independant
10 - temporary
11 - pre inst temporary
.... (from here same as above but just temporary)
20 - elicense required
.... (from here same as above but requires elicense)
30 - temporary elicense required
.... (from here same as above but just temp with elicense required)
40 - not used from here

For online play such as Local, Local Wireless and LAN - start the game in Airplane mode, once you get to the game menu, select mulitplayer - then turn airplane mode off and you can create and join lan games.
 
Last edited by mrdude,

Thorhax

Well-Known Member
Member
Joined
Apr 15, 2020
Messages
477
Trophies
0
Age
43
XP
2,138
Country
Canada
Thank you very much, I was able to fix it by exporting the ticket, editing the hex value you mentioned above, and installing the ticket, I rebooted my switch and finally Quake2 opens like a normal game again.
 

mrdude

Developer
OP
Developer
Joined
Dec 11, 2015
Messages
3,071
Trophies
1
Age
56
XP
8,227
Or you can just use dbi which does this on the fly since version 557
I love DBI, it's a great bit of software so thanks for continuing to update it. I did try installing with DBI and installing the unmodded ticket - but the newest version I got from the github release page didn't patch this for quake 2, I didn't try on any other games though. Maybe there was an issue at my end, but others have also said it didn't work for them.
You can easily check by putting the quake 2 nsp offset at 0xb16 to 10, then installing the NSP - the game will work until you reboot the switch and after a reboot the ticket will be missing and you won't be able to launch the game because you won't be able to decrypt it. By modding the nsp and changing the offset above to 00, the game will still pass all the integrity checks and you don't need to worry in a years time when you instal the game with a different installer.
 
Last edited by mrdude,

lol_lmao_even

New Member
Newbie
Joined
Aug 23, 2023
Messages
3
Trophies
0
Age
25
XP
14
Country
United States
it's because some dumper somewhere that people are using to share dumps online was incompetently programmed and it puts master key revision in the wrong place in the fake ticket. probably a off-by-one error. a *lot* of dumps online are affected by this, but it never mattered until just now we are reaching master key revision 0x10
 

mrdude

Developer
OP
Developer
Joined
Dec 11, 2015
Messages
3,071
Trophies
1
Age
56
XP
8,227
it's because some dumper somewhere that people are using to share dumps online was incompetently programmed and it puts master key revision in the wrong place in the fake ticket. probably a off-by-one error. a *lot* of dumps online are affected by this, but it never mattered until just now we are reaching master key revision 0x10
What dumper do you think it is? and why does it only happen on a tiny amount of games? I checked all my installed games and quake2 and warhammer were the only ones I found with this issue.
 

mrdude

Developer
OP
Developer
Joined
Dec 11, 2015
Messages
3,071
Trophies
1
Age
56
XP
8,227
Just checked - missed line in english translation caused exception, whit was silently catched and no patch was applied. Will fix in next release.
I have a question for you regarding tickets.

Do all NSP files only ever have 1 ticket file?
Are all ticket files the same size or do they differ depending on the game, update etc?

The reason I ask is that I was looking at tinwwo installer and other installers that share the same code such as AtmoXL, Awoo etc and I see that the bit of code that deals with importing the tickets is here:

Code:
void NSPInstall::InstallTicketCert()
    {
        // Read the tik files and put it into a buffer
        std::vector<const PFS0FileEntry*> tikFileEntries = m_NSP->GetFileEntriesByExtension("tik");
        std::vector<const PFS0FileEntry*> certFileEntries = m_NSP->GetFileEntriesByExtension("cert");

        for (size_t i = 0; i < tikFileEntries.size(); i++)
        {
            if (tikFileEntries[i] == nullptr) {
                LOG_DEBUG("Remote tik file is missing.\n");
                THROW_FORMAT("Remote tik file is not present!");
            }

            u64 tikSize = tikFileEntries[i]->fileSize;
            auto tikBuf = std::make_unique<u8[]>(tikSize);
            LOG_DEBUG("> Reading tik\n");
            m_NSP->BufferData(tikBuf.get(), m_NSP->GetDataOffset() + tikFileEntries[i]->dataOffset, tikSize);

            if (certFileEntries[i] == nullptr)
            {
                LOG_DEBUG("Remote cert file is missing.\n");
                THROW_FORMAT("Remote cert file is not present!");
            }

            u64 certSize = certFileEntries[i]->fileSize;
            auto certBuf = std::make_unique<u8[]>(certSize);
            LOG_DEBUG("> Reading cert\n");
            m_NSP->BufferData(certBuf.get(), m_NSP->GetDataOffset() + certFileEntries[i]->dataOffset, certSize);

            // Finally, let's actually import the ticket
            ASSERT_OK(esImportTicket(tikBuf.get(), tikSize, certBuf.get(), certSize), "Failed to import ticket");
        }
    }

Now I see that the ticket is stored in a buffer before being written, It should be possible to mod the buffer at the address where the ticket type is stored and write that modded code into the switch when installing. Does DBI do it like that or do you use a different method? I am just asking out of interest but I understand if you don't want to answer.
 
  • Like
Reactions: gamba66

duckbill007

Well-Known Member
Member
Joined
May 5, 2011
Messages
691
Trophies
1
XP
2,482
Country
Russia
Do all NSP files only ever have 1 ticket file?
Are all ticket files the same size or do they differ depending on the game, update etc?
There can be more than one ticket and ticket size depends of it's type. You can check this on switchbrew there are 5 or 6 ticket signature sizes.
Post automatically merged:

Btw, code above does not check that cert matches ticket.
 
  • Like
Reactions: mrdude

mrdude

Developer
OP
Developer
Joined
Dec 11, 2015
Messages
3,071
Trophies
1
Age
56
XP
8,227
There can be more than one ticket and ticket size depends of it's type. You can check this on switchbrew there are 5 or 6 ticket signature sizes.
Post automatically merged:

Btw, code above does not check that cert matches ticket.
Thanks, I was just going to add this bit of code before the ticket is written:

Code:
if (tikBuf.get()[646] == 16)
{
 tikBuf.get()[646] = 0;
}

That would have just zero'd out that address but if the sizes are all different I will need to look into this more. Thanks for replying though. Also can you post a link to that switchbrew page, I couldn't find anything to do with different ticket types.
 
Last edited by mrdude,

duckbill007

Well-Known Member
Member
Joined
May 5, 2011
Messages
691
Trophies
1
XP
2,482
Country
Russia
Just use search keyword ticket there
Post automatically merged:

You need to determine signature type, then size and only after that get offset. Also you need not only zero props, but also correct keygeneration
 
  • Like
Reactions: mrdude

mrdude

Developer
OP
Developer
Joined
Dec 11, 2015
Messages
3,071
Trophies
1
Age
56
XP
8,227
Rainbow skies does the same thing ;installed with DBI(latest version,598,i think)
Can you try installing with this to see if it fixes it for you. Then let me know. Thanks
Post automatically merged:

Just use search keyword ticket there
Post automatically merged:

You need to determine signature type, then size and only after that get offset. Also you need not only zero props, but also correct keygeneration
I must be missing something, the page I found shows the ticket size to be 0x2C0, and the offset for the license to be at 0x144. I find that wiki to be confusing with the addresses as I am using windows and the endianness on that page is for linux if I am honest and it doesn't tell you all the different license types on it.

https://switchbrew.org/wiki/Ticket

All the tickets I checked have the license type in the same place, for the game nsp files. I'll do some more checking though. Thanks for your help though.
 
Last edited by mrdude,

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
  • BigOnYa @ BigOnYa:
    I don't trust the free ones, but ipvanish I've used for couple years now, n like
  • Psionic Roshambo @ Psionic Roshambo:
    I wonder if they could get CPUs to run that hot then use the heat to power a steam turbine to power the CPUs....
  • BigOnYa @ BigOnYa:
    Good idea, or at least power the GPU
  • Psionic Roshambo @ Psionic Roshambo:
    It's not the movies or games downloads that I would worry about, like breaking into networks, downloading encrypted things, spying on network traffic. I have seen so many "Top Secret" seals on files when I was a kid
  • Psionic Roshambo @ Psionic Roshambo:
    I was obsessed with finding UFOs, a surprising amount of US files where stashed on computers in other countries, China back in the early 90s omg sooo much
  • BigOnYa @ BigOnYa:
    Yea that crazy, I've never tried hack into anything, I just pirate, and my ISP have send me 3-4 letters, so had to VPN it
  • Psionic Roshambo @ Psionic Roshambo:
    Ship to ship communication software for the Navy although without access to the encrypting chips it was mostly useless
  • Psionic Roshambo @ Psionic Roshambo:
    I bet now a 4090 could probably crack it? Hmmm maybe not even back then I'm pretty sure they where using like 1024 bit encryption
  • Psionic Roshambo @ Psionic Roshambo:
    Yayyy the one set finished 324GBs lol
  • Psionic Roshambo @ Psionic Roshambo:
    Compressed....
  • Psionic Roshambo @ Psionic Roshambo:
    I wonder how many years that would have taken on a 56K modem lol
  • Psionic Roshambo @ Psionic Roshambo:
    18000 hours lol
  • Psionic Roshambo @ Psionic Roshambo:
    750 days lol
    +1
  • Psionic Roshambo @ Psionic Roshambo:
    So Internet is very much faster now lol
  • BigOnYa @ BigOnYa:
    "Time Remaining- 2 years, 9 girlfriends, 6 hairstyles, please standby..."
    +1
  • Psionic Roshambo @ Psionic Roshambo:
    I remember one time I downloaded like a 500MB ISO file on 56K and that literally took like 2 days
  • Psionic Roshambo @ Psionic Roshambo:
    I had some sort of resume thing, I remember the software had chains
  • Psionic Roshambo @ Psionic Roshambo:
    Damned if I can't remember.the name though
  • Psionic Roshambo @ Psionic Roshambo:
    Some sort of download management app
  • BigOnYa @ BigOnYa:
    Ok good chatting, I'm off to the bar, to shoot some pool, nighty night.
    +1
  • BakerMan @ BakerMan:
    hey psi
  • BakerMan @ BakerMan:
    i call your girl lyndon the way she b on my johnson
    BakerMan @ BakerMan: i call your girl lyndon the way she b on my johnson