Exetools  

Go Back   Exetools > General > General Discussion

Notices

Reply
 
Thread Tools Display Modes
  #1  
Old 05-15-2006, 19:35
swlepus
 
Posts: n/a
Is it possible to encrypt a .sys file?

Just like exe encrypt.
Is it possible to make this encrypt?
Please also intro some tools.

Thanks!
Reply With Quote
  #2  
Old 05-16-2006, 00:40
OHPen's Avatar
OHPen OHPen is offline
Friend
 
Join Date: Aug 2003
Location: lost in code...
Posts: 92
Rept. Given: 0
Rept. Rcvd 0 Times in 0 Posts
Thanks Given: 0
Thanks Rcvd at 0 Times in 0 Posts
OHPen Reputation: 0
Hi,

yes it is possible to encrypt sys files. Protector Themida for example using a custom encryption routine to protect several parts of its code.

I don't know exactly what you mean with "intro tools" but if you think about
adding other binaries like pebundle does forget about it...

Cheers,

PAPiLLiON
Reply With Quote
  #3  
Old 05-16-2006, 04:41
deroko's Avatar
deroko deroko is offline
cr4zyserb
 
Join Date: Nov 2005
Posts: 217
Rept. Given: 13
Rept. Rcvd 30 Times in 14 Posts
Thanks Given: 7
Thanks Rcvd at 33 Times in 16 Posts
deroko Reputation: 30
yes, you may append your code to .sys but make sure to update checksum in PE header and to make code section writable. Any exception in r0 will cause bsod
__________________
http://accessroot.com
Reply With Quote
  #4  
Old 05-16-2006, 05:13
MarkusO
 
Posts: n/a
The PE-checksum will be your smallest problem if you plan to encrypt *.SYS files.

You must take care of what sections are loaded at which time, you must take care of the init callbacks, you will run into some big problems when trying to allocate memory and some other nasty problems. Just to name one, how do you plan to call LoadLibrary or GetProcAddres from Ring-0? KERNEL32 is not present and you can't use SEH to find the imports by trial and error.
Reply With Quote
  #5  
Old 05-16-2006, 06:35
OHPen's Avatar
OHPen OHPen is offline
Friend
 
Join Date: Aug 2003
Location: lost in code...
Posts: 92
Rept. Given: 0
Rept. Rcvd 0 Times in 0 Posts
Thanks Given: 0
Thanks Rcvd at 0 Times in 0 Posts
OHPen Reputation: 0
He have to use native api, but thats obvious...
Reply With Quote
  #6  
Old 05-17-2006, 07:55
deroko's Avatar
deroko deroko is offline
cr4zyserb
 
Join Date: Nov 2005
Posts: 217
Rept. Given: 13
Rept. Rcvd 30 Times in 14 Posts
Thanks Given: 7
Thanks Rcvd at 33 Times in 16 Posts
deroko Reputation: 30
Quote:
Originally Posted by MarkusO
Just to name one, how do you plan to call LoadLibrary or GetProcAddres from Ring-0? KERNEL32 is not present and you can't use SEH to find the imports by trial and error.
Simple, find ptr to ntoskrnl.exe from IDT and then cycle backward till you find ntoskrnl.exe base then locate ZwQuerySystemInformation to receive addresses of needed drivers and write GetProcAddress by yourself walking trough exports of needed .sys files At least that's how I would do it.
__________________
http://accessroot.com
Reply With Quote
  #7  
Old 05-17-2006, 08:34
swlepus
 
Posts: n/a
Quote:
Originally Posted by MarkusO
The PE-checksum will be your smallest problem if you plan to encrypt *.SYS files.

You must take care of what sections are loaded at which time, you must take care of the init callbacks, you will run into some big problems when trying to allocate memory and some other nasty problems. Just to name one, how do you plan to call LoadLibrary or GetProcAddres from Ring-0? KERNEL32 is not present and you can't use SEH to find the imports by trial and error.
I do not think make a PE checksum will encrypt the .sys file.
It only prevent some modifications.
Encrypt file can not be analyzed by static disassemble tool such as IDA pro.

And as we know, VMProtect can make protection on .sys file but not encrypt, even compress.
Reply With Quote
  #8  
Old 05-17-2006, 19:19
adaptor adaptor is offline
Friend
 
Join Date: Jan 2006
Posts: 27
Rept. Given: 0
Rept. Rcvd 0 Times in 0 Posts
Thanks Given: 0
Thanks Rcvd at 0 Times in 0 Posts
adaptor Reputation: 0
Dont' forget about MmGetSystemRoutineAddress routine Of couse if it works only for routines exported by ntoskrnl or HAL.. But in some cases it's enough.

Here is a plan how to make simple native encryptor Very common.
1) Get some user mode PE encryptor\compressor sources (better in asm)
2) Change GetProcAddress to MmGetSystemRoutineAddress
3) Change VirtualAlloc\VirtualFree to ExAllocatePool\ExFreePool
4) Debug

P.S. Classical compression based on possibility of making VirualSize of PE section bigger than PhisicalSize will work only in case Section alignment= 1000, File alignment= 200. Any other combination does'nt work for me.

Anyway compression in drivers it's not a good idea coz memory in pool is very
valuable resource.

Last edited by adaptor; 05-17-2006 at 19:47.
Reply With Quote
  #9  
Old 05-17-2006, 20:18
deroko's Avatar
deroko deroko is offline
cr4zyserb
 
Join Date: Nov 2005
Posts: 217
Rept. Given: 13
Rept. Rcvd 30 Times in 14 Posts
Thanks Given: 7
Thanks Rcvd at 33 Times in 16 Posts
deroko Reputation: 30
agree, thats why small decryption code(xor/add/sub/rol/ror etc) is much better, import rebuilding code and compression is just wast of r0 memory
__________________
http://accessroot.com
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Encrypt and Decrypt with public key and private key(RSA based) CarrotStickCam Source Code 2 01-16-2023 14:53


All times are GMT +8. The time now is 07:55.


Always Your Best Friend: Aaron, JMI, ahmadmansoor, ZeNiX, chessgod101
( 1998 - 2024 )