Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Get SQLite Database information from game?
Goto page 1, 2  Next
 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine
View previous topic :: View next topic  
Author Message
TheAdmiester
How do I cheat?
Reputation: 0

Joined: 06 Mar 2017
Posts: 9

PostPosted: Mon Mar 06, 2017 3:13 pm    Post subject: Get SQLite Database information from game? Reply with quote

Hi, I'm not very experienced with Cheat Engine so bear with me if this sounds a bit odd/inaccurate.

I'm trying to work with a game that uses an encrypted database. The file extension is .slt, and I know from using IDA on the game that it is somehow transferred to an SQLite3 format database when the game runs. I can search for certain SQL queries and possibly even execute them using the string search on CE, but is there any way to actually get data FROM the database and/or export it?

I think what I'm basically looking for is a way to return the results of a query (for example, I can run "SELECT * FROM tablename" but I don't get to see the results) which would allow me to get the contents of the tables I want one by one, or export the whole thing.

Is this possible or is it too out-there?
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 471

Joined: 09 May 2003
Posts: 25817
Location: The netherlands

PostPosted: Mon Mar 06, 2017 3:55 pm    Post subject: Reply with quote

does the target use a sqlite3 library? If so, try finding the exports and place a hook there to get the data you need, and then use the other api's in there to do querries
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
TheAdmiester
How do I cheat?
Reputation: 0

Joined: 06 Mar 2017
Posts: 9

PostPosted: Mon Mar 06, 2017 4:29 pm    Post subject: Reply with quote

Dark Byte wrote:
does the target use a sqlite3 library? If so, try finding the exports and place a hook there to get the data you need, and then use the other api's in there to do querries


I think it is using SQLite3 somewhere (because like I said you can find a ton of "sqlite3_master" and so on in a CE string search or IDA Pro), but unfortunately since I'm not really sure what I'm doing, what you said doesn't really make any sense. Whereabouts would I start to try and do what you're saying?
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8587
Location: 127.0.0.1

PostPosted: Mon Mar 06, 2017 4:30 pm    Post subject: Reply with quote

With what DB said, if it uses sqlite3, you will want to look into hooking:
- sqlite3_key
- sqlite3_key_v2

Or look for references to 'PRAGMA key'. This is how the database encryption key is set which you can then use to open the database with an external editor.

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
TheAdmiester
How do I cheat?
Reputation: 0

Joined: 06 Mar 2017
Posts: 9

PostPosted: Mon Mar 06, 2017 4:42 pm    Post subject: Reply with quote

atom0s wrote:
With what DB said, if it uses sqlite3, you will want to look into hooking:
- sqlite3_key
- sqlite3_key_v2

Or look for references to 'PRAGMA key'. This is how the database encryption key is set which you can then use to open the database with an external editor.


I can't find any references to any of these either in CE or IDA. I can find "Pragma" on its own but nothing referring to a key.

There is a string in IDA that shows "?AVkeywrapper_gamedb_decryptionkey@@" but I have no idea how to find what it does or if it's any use at all since it could just be a dud or leftover.
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8587
Location: 127.0.0.1

PostPosted: Mon Mar 06, 2017 5:13 pm    Post subject: Reply with quote

Stuff usually marked like "?AVkeywrapper_gamedb_decryptionkey@@" is either an import or an export. See if the function is being imported from another file. It may be stored in a .dll rather than the main exe.
_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
TheAdmiester
How do I cheat?
Reputation: 0

Joined: 06 Mar 2017
Posts: 9

PostPosted: Mon Mar 06, 2017 5:44 pm    Post subject: Reply with quote

atom0s wrote:
Stuff usually marked like "?AVkeywrapper_gamedb_decryptionkey@@" is either an import or an export. See if the function is being imported from another file. It may be stored in a .dll rather than the main exe.


I'm guessing it's in the exe, because there's no reference to it in Exports or Imports. Only in the Strings window.

I don't think Exports/Imports are displaying incorrectly either, as they're showing things that are being used from dependencies such as VCLibs, Kernel32, and so on, as you'd expect.
Back to top
View user's profile Send private message
TheAdmiester
How do I cheat?
Reputation: 0

Joined: 06 Mar 2017
Posts: 9

PostPosted: Tue Mar 07, 2017 9:16 am    Post subject: Reply with quote

I've found more things alone the lines of "gamedb_obfuscation" and "obfuscationseed" - not sure if these would help at all because the database isn't obfuscated by the game, it's already pre-scrambled.

Does that help at all?

EDIT:

Found some mentions of RSA1024, TransformIT, and some other stuff I can't quite remember. Wishing it was possible to get this database out of memory.
Back to top
View user's profile Send private message
pellik
Advanced Cheater
Reputation: 0

Joined: 14 Jun 2013
Posts: 93

PostPosted: Tue Mar 07, 2017 5:32 pm    Post subject: Reply with quote

Does the game constantly pull from the database or does it just do it at a set time? Maybe you could use ultimap to find the database retrieval function and just hook that.
Back to top
View user's profile Send private message
TheAdmiester
How do I cheat?
Reputation: 0

Joined: 06 Mar 2017
Posts: 9

PostPosted: Tue Mar 07, 2017 7:05 pm    Post subject: Reply with quote

pellik wrote:
Does the game constantly pull from the database or does it just do it at a set time? Maybe you could use ultimap to find the database retrieval function and just hook that.


It pulls from a database whenever it needs to. I can trigger it myself (e.g. clicking on one of the shop menus makes it essentially run a "SELECT * FROM") but I don't know the exact queries it's doing, as doing a string search is just guesswork.

EDIT:

I think this might be helpful:

i imgur com/9ZajtoB png (replace the spaces with . as I can't post URLs yet)

I scanned with Ultimap, and among a lot of FMOD (audio I believe) calls, I found the above.

The game seems to make at least a few calls to Crypt32.dll when I select a menu item (causing an interaction with the database). These calls to functions relating to keys could be promising but I'm still a beginner and wouldn't know how to follow them or get anything valuable.
Back to top
View user's profile Send private message
pellik
Advanced Cheater
Reputation: 0

Joined: 14 Jun 2013
Posts: 93

PostPosted: Tue Mar 07, 2017 8:39 pm    Post subject: Reply with quote

I'm not at all knowledgeable on databases or crypt32, so I can't help you do anything useful with this, but-

BOOL WINAPI CryptImportPublicKeyInfo(
_In_ HCRYPTPROV hCryptProv,
_In_ DWORD dwCertEncodingType,
_In_ PCERT_PUBLIC_KEY_INFO pInfo,
_Out_ HCRYPTKEY *phKey
);

So if you set a break point on the call then the stack will contain those calling variables in whatever convention order, and if you step over it then there will be the hcryptkey pointer. I hope that's the key you're looking for.

*edit
I just noticed your snippit is inside of crypt32. First find a ret out of crypt32 and see what in the program called it (or look for the return pointer in stack view).
Back to top
View user's profile Send private message
TheAdmiester
How do I cheat?
Reputation: 0

Joined: 06 Mar 2017
Posts: 9

PostPosted: Tue Mar 07, 2017 9:07 pm    Post subject: Reply with quote

pellik wrote:
So if you set a break point on the call then the stack will contain those calling variables in whatever convention order, and if you step over it then there will be the hcryptkey pointer. I hope that's the key you're looking for.

*edit
I just noticed your snippit is inside of crypt32. First find a ret out of crypt32 and see what in the program called it (or look for the return pointer in stack view).


Sorry for being dumb but I'm totally clueless on this. I can do what you want but you'd need to explain a bit more layman-y.
Back to top
View user's profile Send private message
pellik
Advanced Cheater
Reputation: 0

Joined: 14 Jun 2013
Posts: 93

PostPosted: Tue Mar 07, 2017 10:18 pm    Post subject: Reply with quote

I'll try, but hopefully we're not getting into an example of the blind leading the deaf. I'm not sure where the cut-off on explaining stuff is, so apologies in advance if I'm off the joe. [/disclaimer]

So first off if you set a breakpoint at the address you posted in the image you can get all the state information. Then the stack view is in the bottom right. Right clicking and setting to full stack is helpful.

If you don't know how the stack works learn that first.

Next you need to get back into your games address space. The crypt32.somethingsomething means the instructions you see are inside of crypt32 which is windows stuff and not part of your game. To get back you can either look back through the stack for what might be the return address, or you can just step all the way through until you find a ret that takes you back to the game.

Now you need to know about calling conventions. Stdcall is the choice for windows api stuff. Knowing that, if you set your breakpoint on the call to crypt32 you can see the arguments right there at the top of the stack. Step over the call and there is the return value I think in eax.

Of course the call to crypt32 may not be interesting at all, but either way you're learning.
Back to top
View user's profile Send private message
TheAdmiester
How do I cheat?
Reputation: 0

Joined: 06 Mar 2017
Posts: 9

PostPosted: Wed Mar 08, 2017 8:00 am    Post subject: Reply with quote

I'm not sure if you're the blind or deaf but I think you might in fact be leading the deaf, blind, and dumb Razz

I've been fiddling with the Ultimap and breakpoint abilities but I'm still going nowhere. I can occasionally find some plaintext stuff in the stack (like a filepath broken up over a few lines/addresses) that looks kinda interesting but I have no idea what to do with any of it.
Back to top
View user's profile Send private message
pellik
Advanced Cheater
Reputation: 0

Joined: 14 Jun 2013
Posts: 93

PostPosted: Wed Mar 08, 2017 8:21 am    Post subject: Reply with quote

You've got to apply your knowledge of programming to start reading assembly. It follows the same general structure as a program (function calls, loops, etc.), but it's much more verbose. So much more so that figuring out what it's doing is usually not worth it, so instead try to gleam the structure of the code.

Although cheat engine is a great place for learning assembly as a self teaching method, there aren't a lot of good tutorials out there. Maybe start with ollydbg instead. The tutorial series by lena151 is a good place to start.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine All times are GMT - 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites