Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Windows Malware Analysis Essentials

You're reading from  Windows Malware Analysis Essentials

Product type Book
Published in Sep 2015
Publisher
ISBN-13 9781785281518
Pages 330 pages
Edition 1st Edition
Languages
Author (1):
Victor Marak Victor Marak
Profile icon Victor Marak

Encoding/decoding – XOR Deobfuscation


You will come across the XOR Boolean operation being used for initialization of variables as xor eax,eax or as an elementary obfuscation device. In the following simple C code, you can trace through sample XORing de-obfuscation of an ASCII string with a single static key and a dynamic key. You can also make use of string matches and brute-forcing (static key in this sample, you can easily replace it or embellish it with the dynamic key using one line of code, try it) function to get an idea as to how it may be used by malware. Use the locals window in VC++ to check the variable values within the loop and function scopes:

#include "stdafx.h"
#include <conio.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

void dynaXor(char *p, int key){
  int l=strlen(p);
  for (int i =0; i< l; i++) {

    printf("%c",p[i]^key);
    key+=1;   //the key is incremented for every subsequent byte xor
  }
  printf...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}