Posted in Debugging,Programming by Mr. Novocain on August 5, 2010 at 11:09

Simple XOR encryption and nibble switch

Hey! You should read Programming PHP.

Just to make it a bit confusing.

When encrypting, first xor and then swap the nibbles.
When decrypting, first swap the nibbles and then xor.

How it works
Say we have string “AXE” (hex 41 58 45)
We start with A.

A = 0×41 = 65 = 0100 0001

In this example code our key is 0x7A
z = 0x7A = 122 = 0111 1010

'A' XOR 0x45 = 59

First we XOR it..
0x41 = 0100 0001
0x7A = 0111 1010
----------------
X OR = 0011 1011

And then we swap the nibbles by pushing both ways..
a = a >> 4
a = 0000 0011

c = c << 4
c = 1011 0000

a|c = 1011 0011

So ‘A’ becomes 0xB3 (179).
‘X’ becomes 0×22 (34)
and ‘E’ becomes 0xF3 (243)

So now we have B3 22 F3 instead of 41 58 45 ;)

To decrypt, just do the opposite. Swap the nibbles and then XOR by 0x7A

Source code

  1. class PacketSecurity
  2. {
  3.     // simple xor cipher
  4.     private byte cipher(byte c)
  5.     {
  6.         c ^= 0x7A; // 122 is ‘key’, change to anything
  7.         return c;
  8.     }
  9.  
  10.     // nibble swap
  11.     private byte swap(byte c)
  12.     {
  13.         byte a = (byte)(c >> 4); // add 4 0′s before c so we get high nibble as low
  14.         c = (byte)(c << 4); // add 4 0′s after c so we get low nibble as high
  15.         return (byte)(a|c); // use OR to add them together
  16.     }
  17.  
  18.     public byte[] encrypt(string s)
  19.     {
  20.         byte[] b = new byte[s.Length];
  21.  
  22.         for(int i = 0; i < s.Length; i++)
  23.         {
  24.             b[i] = cipher((byte)s[i]);
  25.             b[i] = swap(b[i]);
  26.         }
  27.  
  28.         return b;
  29.     }
  30.  
  31.     public string decrypt(byte[] b)
  32.     {
  33.         string s = "";
  34.  
  35.         for (int i = 0; i < b.Length; i++)
  36.         {
  37.             b[i] = swap(b[i]);
  38.             s += cipher(b[i]);
  39.         }
  40.  
  41.         return s;
  42.     }
  43. }
 
 
Posted in Debugging,Gamehacking by Mr. Novocain on November 18, 2007 at 14:26

Call of Duty 4

This might interest you: Cheap PHP + MySQL Ebook!


So Call of Duty 4 finally arrived.. good singleplay aswell as multiplay!
Last night I started looking at the multiplay-aspect from a hackers POV.. (more…)

Incoming search terms for the article:

 
 
Posted in Cracking,Debugging,Programming by Mr. Novocain on September 18, 2007 at 20:01

C++ Anti-Cracking “hide” your WinAPI-calls

This might interest you: Complete Beginners PHP 101 Ebook and Video Course

_20050908_canapa_mariuana_droga_droghe.jpg
If you’re a software-programmer and/or reverse-engineer you should know that using Windows API-calls is a easy way to write code, and also in many cases a good point for reverse-engineers to trace to/from while removing potential protections.. (more…)

 
 
Posted in Debugging,Gamehacking by Mr. Novocain on September 8, 2007 at 03:04

API’s that GameGuard hook

Are you interested in A Quick And Easy Ebook That Introduces Readers To Computer Programming In A Jargon Free, Easy To Understand Way.?

hitman2_w.jpg
A complete list of the Windows API’s that GameGuard hook in Ring3 (usermode) and Ring0 (kernelmode).. (more…)

Incoming search terms for the article:

 
 
Posted in Debugging by Mr. Novocain on September 2, 2007 at 15:47

Debugging Video-Lesson #3 Byte-signatures

Get Simple PHP - Learn Php In 17 Hours now!

punisher_4.png
Lesson #3 in the Debugging-class..

In this lesson I answer the following questions about byte-signatures;
- What are they?
- What good do they do?
- How to make them? (more…)