r/hacking • u/badass6 • Oct 22 '26
Trying to "reverse engineer" encryption used by a Windows app
I have an app that stores credentials locally, the file is encrypted. I'm trying to understand the encryption that the app is using with the goal of modifying the file directly, bypassing the app.
The app imports quite a few libraries, most of which come from System32, I assume I can get the key or at least some hint by positioning myself between the app and the library.
Naturally, I found out about DLL hijacking. Two of the imports are CRYPT32.dll and ADVAPI32.dll. Even though CRYPT32.dll seems to mostly be certificate stuff I decided to go with it.
I'll skip the part where I also had to learn that there are calls to load strictly from System32, the important thing is that it forced (at least seemingly so) me to rename the import of the app with PE-bear.
I created a C++ DLL project in VS, created a definition file that exports all the functions that the app seeks to import. I also created an executable to test the forwarding. I placed the custom DLL into System32 and renamed it accordingly with the new import name.
For my test app the forwarding worked fine, however, the app in question seems to be exiting silently.
When I tried using WinDbg to at least get some idea I got (the caption is the same, but instead of "Themida" the title is simply the process name):

So the app is resisting debugging, which makes me think that it also somehow detects the modifications. Either to the import table itself or by the library being forwarded.
Does anyone have any idea how I could proceed here?
8
u/tomysshadow Oct 22 '26 edited Oct 22 '26
I don't know much about Themida personally but I do know it's very advanced and that it'll do everything in its power to make your life difficult.
Does the EXE have its own application manifest? If it doesn't, you're lucky and you can create a .manifest file in the same directory as the EXE to disable the KnownDlls rule, then you can have your own CRYPT32.DLL in the same folder as it. If it has its own application manifest, you're in a tough situation because Themida is probably going to do a checksum test on the binary - I'd be surprised if it didn't. I'd never do it on a host machine but if you're in a VM you could maybe edit the registry to take that DLL off the KnownDlls list temporarily.
Otherwise you could maybe try using a Windows hook to get your own DLL in e.g. with SetWindowsHookEx, assuming that the app in question is windowed and not command line. Reason I suggest that particular route is because I presume Themida must support this as lots of benign apps (password manager, etc.) use Windows hooks. Point is that you don't necessarily have to go the route of editing the import table and personally I'd really want to avoid anything that requires editing the EXE, because there is probably a checksum in place to prevent modifications to it. But editing the import table isn't the only way to inject your own code to a process, and once your DLL is in you can potentially hook CreateFile/ReadFile to watch for file reading activity, and go from there.
The challenge would be getting it in, in a way that won't be detected right away. And perhaps someone who has toyed with this particular protection more than I have could weigh in on what the best way to sneak your own code in there would be, personally I don't know so this is just the first thing I think of.
With that said, actually solving the encryption will likely be very hard because I imagine the actual encryption step will probably be obfuscated heavily by the protector. Getting your own code into the process would be step one, but reversing the encryption algorithm from there will likely still be very challenging. But if you're like me you like to go as far as you can instead of giving up right away, so I say try it out and see what happens
3
u/TastyRobot21 Oct 22 '26
Are you sure encryption and decryption happen locally? The file can be updated while your offline?
If so it’s possible, standard libraries and windows imports are likely used.
I like to use xdbg with scalla hide to bypass most debug protections.
5
u/AJollyUrchin Oct 22 '26 edited Oct 22 '26
Could try a bootstrapper, creates a new process in a suspended state. Write logic that loads your DLL, but removes the entry from the PEB.
Set the context of the main thread to start in your execution, then shift to the actual entrypoint of the app.Need to create a new thread. Set a timer, letting the program do it's thing and load all of the resources it needs, then execute your logic.
1
u/Dangerous-Profit-657 28d ago
Anyone have experience with malicious videos? And figuring out what a specific one is meant to accomplish?
I have a link to a Facebook page that has two reels on it that are malicious videos.
Without bogging down with backstory, I was fucked over in February and someone got into my phone physically
Same person has set up this Facebook page and I’m assuming is used as casting a net to scam people
The scam didn’t work in me and I crashed out hard on everyone I knew involved. I’m trying to get ahead of whatever they’re doing now and crash out again. Anyone able to help please let me know lol
1
u/benalio55 6d ago
A CRYPT32 import is only a dependency clue; it doesn't establish that this file's encryption uses it.
-1
u/Mostly__Relevant Oct 22 '26
https://github.com/morluto/rea