Monday, January 12, 2015

The mind of a hacker

So today I figured I would talk about well programming and hacking.  Something I have dabbled in and would like to share to get people started on the right path.

So, first of all there are many many different types of hacking. I am only going to talk about 1 specific type and that is hacking desktop applications written with a .NET language i.e. C# , VB.

So to do this, you first need to be able to recognize if something was written in a .NET language. For some this is not easy, but it can be found out quickly.  First you need a decompiler. Also if you see .jar files then its written in Java, and while a similar process exists, I will not be covering it here.

Go grab one here.  https://www.jetbrains.com/decompiler/

Second you open the .dll's and .exe's from the program's directory in it.

  • If it is a C++ or C dll it will not open here. So if it opens then it is .NET
  • In some cases they will use both .NET and C++. In this scenario its most likely that they have .NET wrappers for external components, much like what OpenTK is for OpenGL.
  • In this case save those dlls that you can't open as they are probably referenced by some of the .NET ones. 


Export the .dlls and .exe's to projects.  Do not create a solution for each one. You do not need pdb files for this process either.

Download Visual Studio if you don't already have it.

Create a solution, and add all of the projects you exported into the solution.
From there you now have the source code to the program, and you can make changes, though it will take real investigative work to find out what everything does as they may have used an obfuscator.

Now once you know what you are going to change simply recompile that specific project in Visual Studio.  And you replace the dll the program uses with your modified one.  This can allow you to change the way the program functions, such as removing copy protection.


Now all of that being said, there is a reason I code with F#.  I wrote this code in F#. Something I know damn well would be incredibly annoying if not impossible to convert to C# by hand

open System
[<EntryPoint>]
let main argv = 


    let func1 input1 =  input1.ToString() :>  Object

    let func2 input1 = input1.GetType().ToString() :>  Object

    let func3 input3 =input3.GetType().ToString() + input3.ToString() :>  Object

    let list _ = [func1;func2;func3] :>  Object

    let list2 = [func1;func2;func3;list] :> Object

    list2.ToString() |> Console.WriteLine
    Console.WindowWidth <- 94

    printfn "%A" argv
    () |> Console.ReadLine |> ignore
    0 // return an integer exit code


So when I tried decompiling it. It generated bogus code in C# that does not compile :) This is how I will safeguard my future programs by writing them in a language that doesn't decompile well.