Run data as code?

My client asked me to write my own encrypted executable file to prevent an easy crack of the licensing system. Now I understand that this is a false sense of security, but despite this, he insisted on it.

So, I dug up my knowledge of portable executables and came up with this idea:

  • Encrypt executable file
  • Stick to this end of the bootloader executable along with its size
  • Loader decrypts data
  • It copies the code to the page allocated by VirtualAlloc, which has execute rights.
  • He finds the entry point of the application
  • Jumps over there, and we're all set.

I have a problem with jumping there. How can i do this? If I needed to set a pointer to a function, what would be the signature? Signature of loaded main () executable? Or do I need to resort to assembly?

I understand that it may be necessary to fix absolute addresses after downloading the code. How can I check if I need to and how to do it?

Edit: Working with windows and compiling with GCC. I can switch the Microsoft compiler if necessary.

Edit2: Clarify: I KNOW this is basically pointless. I believe this means any type of DRM. It depends on my client, and he still wants him, even though I warn him about it.

Thanks in advance.

+5
8

, EXE - ; , .

EXE; ( ). -; . , , . , , , .

PE, , , , Windows .

, , - , , . , , , PE .

+4

, . Portable Executable (PE) ( , EXE DLL Windows) - , , . PE :

  • PE .

  • DLL, EXE.

  • .

, , . , , , EXE-.

: Google , :

- .

:

MSDN " Win32 Portable" ( 1, 2). PE, . : Microsoft, -, EXE. , , , , , EXE- EXE. , EXE , , , EXE.

PE -. , , , , , , .

+11

PE- , .

, .

+4

, ? , , , .

, - :

  • encypted dll
  • tmp
  • do LoadLibrary
  • DLL ?
+1

-.

, (, , ) .

, , .

, , " "?

, , , ?

+1

. - - .

+1

c- :

typedef void (*MyPtr)();

MyPtr p = (MyPtr)1234;
p();
0

You cannot execute data such as code on most operating systems, thanks to gdt, the global descriptor table that divides data from code. If you are trying to execute data, then the processor handles the exception.

-3
source

All Articles