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 


[C] UNERL

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
appalsap
Moderator
Reputation: 0

Joined: 27 Apr 2006
Posts: 6753
Location: Pakistan

PostPosted: Mon Apr 30, 2007 11:02 am    Post subject: [C] UNERL Reply with quote

UNERL is an npgl.erl decrypter, a port from uzeils' asm program to C. (with modifications made to make it easier to read and understand) Some credits to Uligor for his leet asm debugging skills.

Code:

#include <stdio.h>
#include <windows.h>

DWORD FindKey(BYTE Test);

DWORD i, pKeys[] = {0xC5F1F435, 0x83A3A023, 0x4E626C2E, 0x89818809,
      0xCAF2F83A, 0xD2D416C6, 0x9C1D8D91, 0x64264662, 0x39497178, 0x1A0A1218, 0};

int main(int argc, char* argv[])
{
   HANDLE hERL; DWORD dwSize, z, k; char *ERLBuf;
   
   if (argc <= 2) {
      puts("UNERL Erl-Decryptor. Usage: UNERL [infile] [outfile]");
      return 1;
   }
   
   if (GetFileAttributes(argv[1]) == -1) {
      printf("cannot find %s\n", argv[1]);
      return 2;
   }
   
   hERL = CreateFile(argv[1], FILE_READ_DATA, 4|1|2, NULL, 3, 128, NULL);
   if (hERL == (HANDLE)-1) {
      printf("unable to open %s\n", argv[1]);
      return 3;
   }
   
   dwSize = GetFileSize(hERL, NULL);
   if (dwSize == -1) {
      puts("file too big!");
      CloseHandle(hERL);
      return 4;
   }
   
   ERLBuf = malloc(dwSize);
   
   if (!ReadFile(hERL, ERLBuf, dwSize, &z, NULL)) {
      printf("unable to read from %s\n", argv[1]);
      free(ERLBuf);
      CloseHandle(hERL);
      return 5;
   }
   
   k = FindKey(ERLBuf[4]);
   if (!k) {
      puts("unable to retrieve key");
      return 6;
            }
   
   for(z = 0; z < 4; ERLBuf[z] = 61, z++);
   for(;z < dwSize - 4; z++) {
          k = k + (k * 2) + 1; (BYTE)ERLBuf[z] ^= ((BYTE)k + 0x76);
            }
      
   CloseHandle(hERL);
   hERL = CreateFile(argv[2], FILE_WRITE_DATA, 4|1|2, NULL, 2, 128, NULL);
   if (hERL == (HANDLE)-1) {
      printf("unable to create new %s\n", argv[1]);
      free(ERLBuf);
      return 7;
   }
   
   if (!WriteFile(hERL, ERLBuf, dwSize, &z, NULL)) {
      puts("unable to write decrypted content!");
      free(ERLBuf);
      return 8;
   }   
      
   free(ERLBuf);
   CloseHandle(hERL);
   printf("Successfully decrypted %s\n", argv[1]);
   return 0;
}

DWORD FindKey(BYTE Test)
{
      for(i = 0; pKeys[i] != 0; i++) {
         if (Test ^ ((BYTE)(pKeys[i] + (pKeys[i] * 2) + 1) + 0x76) == '=')
       return pKeys[i];            
      }  return 0;     
}


[code] messed up some brackets, ignore that
Back to top
View user's profile Send private message
Krloz
Grandmaster Cheater
Reputation: 0

Joined: 25 May 2006
Posts: 525
Location: Mexic00l

PostPosted: Mon Apr 30, 2007 1:18 pm    Post subject: Reply with quote

Great now I have a source for debugging o.o might learn something from it
_________________
Pin Skipper
Banned by x0r on Tue May 69, 3662 24:09 am. Expires: ForeVa
Reason: Copying gamesguru sig
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
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