Exetools

Exetools (https://forum.exetools.com/index.php)
-   Source Code (https://forum.exetools.com/forumdisplay.php?f=46)
-   -   Simple VMProtect Loader (C++) (https://forum.exetools.com/showthread.php?t=16276)

0x22 10-18-2014 23:08

Simple VMProtect Loader (C++)
 
Here is a simple VMProtect loader to avoid "The file has been modified or cracked" error you get if you modify vmprotect binaries.

I know that people has been using sleep to avoid both checks but this is really unstable as it will be "computer-speed" dependent.
This solution is much more sufficent.

As I'm quite new here i thought it might be the time to contribute a little :)


Code:

// ConsoleApplication.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <windows.h>

int _tmain(int argc, _TCHAR* argv[])
{

        #define ADDRESS (LPVOID)0x447E2A

        unsigned char buffer[1024] = { 0 };
        SIZE_T nSize;
        int fooo = 0;

        PROCESS_INFORMATION procInfo = { 0 };

        STARTUPINFO startupInfo = { 0 };
        startupInfo.cb = sizeof(startupInfo);

        fooo = CreateProcess(L"FILENAME.exe", NULL, NULL, NULL, FALSE, 0, NULL, NULL, &startupInfo, &procInfo);

        printf("%d\n", fooo);

        while (1)
        {
                //00A89010  E4 A6 42 00
                ReadProcessMemory(procInfo.hProcess, (LPVOID)0x00A89010, buffer, 12, &nSize);
                if ((buffer[0] == 0xE4) && (buffer[1] == 0xA6))
                {
                        printf("Unpacked.\n");
                        ReadProcessMemory(procInfo.hProcess, ADDRESS, buffer, 12, &nSize);
                        if ((buffer[0] == 0xE8) && (buffer[1] == 0x79))
                        {
                                buffer[0] = 0x90;
                                buffer[1] = 0x90;
                                buffer[2] = 0x90;
                                buffer[3] = 0x90;
                                buffer[4] = 0x90;
                                //Sleep(570);
                                printf("Address FOUND!\n");
                                WriteProcessMemory(procInfo.hProcess, ADDRESS, buffer, 12, &nSize);
                                exit(1);
                        }
                }
        }


        return 0;
}


Kla$ 10-19-2014 02:08

Reliable inline, if the correct code is not under VM :)

mr.exodia 10-19-2014 03:41

Hi,

Nice stuff, but could you also explain where you got the constants 0x447E2A and 0x00A89010 ?

Greetings

0x22 10-19-2014 04:11

Quote:

Originally Posted by mr.exodia (Post 95256)
Hi,

Nice stuff, but could you also explain where you got the constants 0x447E2A and 0x00A89010 ?

Greetings

0x00447E2A is the place where i patched(the crack itself), change it to where you wish to patch.
0x00A89010 is taken from the dump window, anywhere near your previous patch(explained above).
The loader will now know exactly when to patch, not a second before and not a second later(to avoid being caught by the VMP self checks)

In other words when 0x00A89010 is being read by the loader it will read the first bytes in the buffer 0xE4 and then second buffer 0xA6.
If this equals, it will know that "now is the time to insert patch".

Might also explain this:
buffer[0] = 0x90;
buffer[1] = 0x90;
buffer[2] = 0x90;
buffer[3] = 0x90;
buffer[4] = 0x90;

0x90 = nop as we all know,
It will now nop 5 times at 0x00447E2A, -> 90 90 90 90 90

Kla$ 10-19-2014 04:14

compile this source please

0x22 10-19-2014 04:58

sent you compiled version.

0x22 10-19-2014 05:19

Works fine for Safengine Shielden as well.

Kla$ 10-19-2014 06:01

you have made the permissions of the section where the patch if there is only writetable
I have this error
or code can not fully unpacked before patched?


---------------------------
Adrenalin.exe
---------------------------
File corrupted!. This program has been manipulated and maybe
it's infected by a Virus or cracked. This file won't work anymore.
---------------------------
ОК
---------------------------

0x22 10-19-2014 06:21

You misunderstood how this loader works. read my reply further up.
You need to tell the loader when the file is unpacked and ready to patch, i explained this very detailed in post number 3 in this thread.

Conquest 10-19-2014 12:50

This is unreliable method . Readprocessmemory passes through kernel calls and has no exact cycle count to estimate each loop time . I am not criticizing what you did, its a decent method of course . rather i will advice you to use proxy dll methods to detect it, its much faster and less chance to miss the spot as the dll can read the memory space directly.(i personally use proxy dll to trick themida bypassing the vmware checks .)

mr.exodia 10-19-2014 23:24

@Conquest: Maybe share your DLL source code with us then ;)

0x22 10-19-2014 23:43

Quote:

Originally Posted by Conquest (Post 95265)
This is unreliable method . Readprocessmemory passes through kernel calls and has no exact cycle count to estimate each loop time . I am not criticizing what you did, its a decent method of course . rather i will advice you to use proxy dll methods to detect it, its much faster and less chance to miss the spot as the dll can read the memory space directly.(i personally use proxy dll to trick themida bypassing the vmware checks .)

Well as long as it works every time and on any OS I wouldnt call it unrelieable, but ofcourse it isnt a "search and replace loader" so if addresses change it wont work ofcourse.

Carbon 10-19-2014 23:46

I don't like the snippet. You didn't give a real explanation.

0x00A89010 -> This memory is dynamically allocated. This can change with every process start. Using this as hardcoded address doesn't seem smart.

Why do you read and write 12 bytes? You need only 2 (5) bytes.

It even looks like you don't need a 2nd ReadProcessMemory. If it is unpacked, it is unpacked. Why check it 2 times?

0x22 10-19-2014 23:56

Quote:

Originally Posted by Carbon (Post 95273)
I don't like the snippet. You didn't give a real explanation.

0x00A89010 -> This memory is dynamically allocated. This can change with every process start. Using this as hardcoded address doesn't seem smart.

Why do you read and write 12 bytes? You need only 2 (5) bytes.

It even looks like you don't need a 2nd ReadProcessMemory. If it is unpacked, it is unpacked. Why check it 2 times?

0x00A89010 <- in the program i used this last time was a particular case where this did not change.
I do agree that memory addresses change which wouldnt work properly.

However you dont need to use memory addresses.


Code:

ReadProcessMemory(procInfo.hProcess, (LPVOID)0x00409605, buffer, 12, &nSize);
                if ((buffer[0] == 0xF6) && (buffer[1] == 0xC1))
                {
                        ReadProcessMemory(procInfo.hProcess, 0x409615, buffer2, 12, &nSize);
                        if ((buffer2[0] == 0x74) && (buffer2[1] == 0x0C))
                        {
                                buffer2[0] = 0x90;
                                buffer2[1] = 0x90;
                                //buffer2[2] = 0x01;
                                //buffer2[3] = 0xEB;
                                //buffer2[4] = 0x0B;
                                //buffer2[5] = 0x90;
                                //buffer2[6] = 0x90;
                                //buffer2[7] = 0x50;
                                //Sleep(570);
                                printf("Address FOUND and patched!\n");
                                WriteProcessMemory(procInfo.hProcess, ADDRESS2, buffer2, 12, &nSize);

                        }

You can also do it like this, this is entirely up to you.
If you don't like the way i did it, then make it better and post it here so that people can benefit from your inputs.

I agree on that you should dynamically set the bytes.
I do two ReadProcessMemory to make sure I'm at the correct place.

It's just something slapped together fast, and it works which is the most important thing for me.

I'm not a good coder so, I do thank you for your constructive feedback and i'm sorry if it doesnt appeal to your coding ideology
Please do your thing and post a better one, im sure both me and the community would be pleased.

Have a good day :)

Conquest 10-20-2014 00:18

Quote:

Originally Posted by 0x22 (Post 95272)
Well as long as it works every time and on any OS I wouldnt call it unrelieable, but ofcourse it isnt a "search and replace loader" so if addresses change it wont work ofcourse.

my bad for using wrong words. i didnt mean to offend you . what i meant was that its not always 100% working because in some cases the execution flow may pass the patch point already before the patching fries up (not going to explain why . its obvious that thread timings and thread priority is the biggest issue here. not to mention without a sleep delay the process will consume 100% of a single cpu thread ).
Its same with even if you do proxy dll methods as well .

@mr. exodia . i will try to find it out today. i used it for that "mushroom game" long ago when i couldnt make a working unpack out of themida

0x22 10-20-2014 00:27

Quote:

Originally Posted by Conquest (Post 95276)
my bad for using wrong words. i didnt mean to offend you . what i meant was that its not always 100% working because in some cases the execution flow may pass the patch point already before the patching fries up (not going to explain why . its obvious that thread timings and thread priority is the biggest issue here. not to mention without a sleep delay the process will consume 100% of a single cpu thread ).
Its same with even if you do proxy dll methods as well .

@mr. exodia . i will try to find it out today. i used it for that "mushroom game" long ago when i couldnt make a working unpack out of themida

Thanks for your input, im not a good coder, so maybe i will do it better next time :)

quygia128 10-20-2014 03:07

Yes, it shouldn't work for other Packed file.

Your Loader need add code loop(for/while) to detect WMProtect have been decrypted your app code(Real code you need patch), verify it then byte is exist, you will be suspend process and patch code before resume process.
That's all

BR,
quygia128

0x22 10-20-2014 03:21

Quote:

Originally Posted by quygia128 (Post 95278)
Yes, it shouldn't work for other Packed file.

Your Loader need add code loop(for/while) to detect WMProtect have been decrypted your app code(Real code you need patch), verify it then byte is exist, you will be suspend process and patch code before resume process.
That's all

BR,
quygia128

It works as long as you insert the correct offsets. It works on all VMProtect with self-checks as well as Safengine's selfcheck, tested on multiple protected files and i have cracks released with this loader for weeks without complains.

Carbon 10-20-2014 04:01

Quote:

Originally Posted by 0x22 (Post 95279)
It works as long as you insert the correct offsets. It works on all VMProtect with self-checks as well as Safengine's selfcheck, tested on multiple protected files and i have cracks released with this loader for weeks without complains.

It still depends on the hardware (CPU power) of the machine. I have done a VMP loader myself in the past and I had to use Sleep() with a certain amount of time. The good thing is that you can automatically bruteforce the correct Sleep time more or less for a specific machine.

Real release groups don't allow "loader" cracks for obvious reasons.

ZeNiX 10-20-2014 09:28

For VMProtect and Themida/WinLicense,
Here is my method for loader.

1. Hook the API near OEP or near your patch point.
2. Check the return address from stack.

Then, you know when your target is unpacked.

0x22 10-20-2014 09:41

Quote:

Originally Posted by Carbon (Post 95280)
It still depends on the hardware (CPU power) of the machine. I have done a VMP loader myself in the past and I had to use Sleep() with a certain amount of time. The good thing is that you can automatically bruteforce the correct Sleep time more or less for a specific machine.

Real release groups don't allow "loader" cracks for obvious reasons.

Are you talking about my loader?
I'm not sure if i understood you correctly, because the source i posted here does not depend on hardware/CPU becuase it does not use sleep.
Sleep is a method i would never use at all, its shit, cuz yes as you said CPU.

I accept your critizism but i released my source to be nice, so that people that may not be "that" expericed with this, might solve it with my working method as well as giving people an idea to work on, and on how it could done.

To be honest i couldnt give two shits about what real release groups allow or not.
In my eyes, a working method is a working method, as long as the program opens, I'm happy and the users that use it will remain happy.

Good day.

fmtx 10-20-2014 11:53

0x22:

Easy tiger. I know your good intention of bringing the loader source here (although imho it doesn't help much). But honestly I think you should improve your code, and make it more universal, make it available on more machines.

It works on your computer, well ok. It fits your needs, ok.

The people just state here that they think you need to do more than that. Slapping a little bit on your ego isn't comfortable for you, but do accept it as a challenge. Don't be a kid or you will forever stay at your "level".

You can listen to my advice or not, it depends on you. However, satisifying yourself with little achievement won't take you far.

My two cents.

ZeNiX 10-20-2014 14:35

I am not a good coder, too.
So, if I share my source codes, they will surely be ugly.

But I think we share source codes, methods. And with help from more friends here, we work out new and better solutions together.

0x22 10-20-2014 22:19

Quote:

Originally Posted by fmtx (Post 95288)
0x22:

Easy tiger. I know your good intention of bringing the loader source here (although imho it doesn't help much). But honestly I think you should improve your code, and make it more universal, make it available on more machines.

It works on your computer, well ok. It fits your needs, ok.

The people just state here that they think you need to do more than that. Slapping a little bit on your ego isn't comfortable for you, but do accept it as a challenge. Don't be a kid or you will forever stay at your "level".

You can listen to my advice or not, it depends on you. However, satisifying yourself with little achievement won't take you far.

My two cents.

I love to learn, i have no issues with learning, i learn every day and i enjoy it.
One of the cracks i used this loader on has 8291 unique logins in my php panel as we speak, and not a single complaint.
So i dont see the reason to rip on something that work.

Newbie_Cracker 10-24-2014 07:40

Quote:

Originally Posted by ZeNiX (Post 95285)
For VMProtect and Themida/WinLicense,
Here is my method for loader.

1. Hook the API near OEP or near your patch point.
2. Check the return address from stack.

Then, you know when your target is unpacked.

Yeah, It is very useful especially for patching child process created by father process; such as Armadillo, SDProtect, etc.

I always use hook method when loaders like dUP2 fails to patch on time.

So if the VMProtect does not check for API hooking, this method is the best.

Conquest 10-24-2014 13:46

Quote:

Originally Posted by Newbie_Cracker (Post 95353)
Yeah, It is very useful especially for patching child process created by father process; such as Armadillo, SDProtect, etc.

I always use hook method when loaders like dUP2 fails to patch on time.

So if the VMProtect does not check for API hooking, this method is the best.

Problem is ,like themida, vmp uses emulated api as well . so normally its hard to predict which api is "universally free" from api emulation and thus hooking doesnt work in all cases

0x22 10-24-2014 18:11

Quote:

Originally Posted by Conquest (Post 95363)
Problem is ,like themida, vmp uses emulated api as well . so normally its hard to predict which api is "universally free" from api emulation and thus hooking doesnt work in all cases

This has worked bulletproof on VMProtect, Themida and Safengine for several dozen of loaders for me, never had any problems with using this method tbh.

b30wulf 10-24-2014 19:18

As title says "SIMPLE" so thst is what this is.... simple loader. But as I can see after so many suggestions and criticism maybe some of you could show user 0x22 how to "ADVANCE" it...
;)

Conquest 10-24-2014 23:55

Quote:

Originally Posted by 0x22 (Post 95370)
This has worked bulletproof on VMProtect, Themida and Safengine for several dozen of loaders for me, never had any problems with using this method tbh.

i dont see any link between your message and my statement . it doesnt apply to your method at all .

0x22 10-25-2014 01:34

Quote:

Originally Posted by Conquest (Post 95375)
i dont see any link between your message and my statement . it doesnt apply to your method at all .

I'm sorry i must've misunderstood, my apologies :o

niculaita 11-01-2014 14:26

how to load a sys vmprotected sys PC tied? Any ideas to make HW customised virtual machine ? Gratias!

menglv 11-16-2014 12:33

Has anyone tested this can load common?

leetone 11-19-2014 13:26

Nice topic 0x22, I will have a look at this and comment later....need to read the past 3 pages of discussion!

Glad to see you are welcomed here....I knew you were the right person to get invited!


All times are GMT +8. The time now is 06:19.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2026, vBulletin Solutions, Inc.
Always Your Best Friend: Aaron, JMI, ahmadmansoor, ZeNiX