[C++] The Road To Hacking MapleStory - Part 1

Discussion in 'Tutorials & Source Codes' started by TheNullz, Feb 19, 2010.

Thread Status:
Not open for further replies.
  1. TheNullz

    TheNullz Godly Hacker

    Post Count:
    698
    Likes Received:
    13
    Stats
    Below is a coded guide to writing a DLL for injection into MapleStory. The principles and lesson taught here actually applies to creating a DLL for injection into any process.

    These are just the very basics (creating the DLL skeleton and the reasons why we use DLL for certain types of hacking.). The more advanced stuff will be coming soon.

    This is a working example. That means you can copy it, paste it, compile it, and inject it if you want to see it work.

    The code below is in C++. If you are unfamiliar with the language please check out these resources:

    Code:
    //
    // DllExample.cpp (by The Nu||z)
    //
    // 1. Open Microsoft Visual Studio, or Visual C++ Express:
    // 2. Go to File > New > Project.
    // 3. Select 'Win32 Project' as your project type.
    // 4. In the next dialog, go to setting and check 'DLL',
    //    and 'Empty Project'.
    // 5. Write your code.
    // 6. Go to Build > Build Solution.
    //
    
    // This statement includes the standard Windows
    // header file. It contains many #includes that
    // will include (usually) most, if not all, the
    // header that you'll need.
    #include <windows.h>
    
    // This is just a dummy function that will be the code
    // executed as our thread. It will popup a message box
    // letting us know that it has been injected.
    void WINAPI MyThread ( )
    {
        // All code in our DLL will be executed in the same address space
        // as the process that we've been attached to. This means that we
        // can manipulat process memory and do any task that requires
        // the code to be execute from the same process.
        //
        // NOTE: When declaring string literals always put an L before the string.
        // This tells the compiler that the string is going to be interpreted as
        // Unicode and not ANSI (Unicode is the default encoding for most modern
        // MS Windows OSs).
        MessageBox(NULL, L"I've just been injected into MapleStory", L"Hello, World!", MB_OK | MB_ICONWARNING | MB_SETFOREGROUND);
    }
    
    // DllMain is an optional function for you to declare.
    // It serves as the entry point for any DLL and is called every time
    // the DLL receive a message.
    //
    // NOTE: Notice how WINAPI is put between our returned type and the identifier
    // of our functions. This is a safe guard that will make sure your functions are all
    // using the same calling convention as the windows API itself. WINAPI is most commonly
    // defined as __stdcall in most modern version of the OS.
    
    // HMODULE hModule - This is just a handle (both a pointer type, and a integral value)
    // to the current instance of your DLL Note: For DLLs, the a handle is also their base
    // address in loaded memory.
    
    // DWORD dwReason -  A value that tells you why the DllMain function was called.
    // (the _reason_ for the function call, lol)
    
    BOOL WINAPI DllMain ( HMODULE hModule, DWORD dwReason, LPVOID lpvReserved )
    {
        // Your standard DllMain function will usually consist of a switch statement
        // if you are going to handle multiple values for the dwReason variable. Or
        // just an if statement if you'll be handling just one value.
        
        switch ( dwReason ) {
            // The DLL has been attached (linked) to a process.
            // If you plan on making a DLL that i going to be injected into
            // another process, then this is the only value you'll be handling.
            case DLL_PROCESS_ATTACH:
                // Make a call to DisableThreadLibraryCalls with the hModule variable
                // as its argument; Doing this is an optimization trick to prevent
                // needless thread attach/detach messages from triggering further calls
                // to our DllMain function.
                DisableThreadLibraryCalls(hModule);
    
                //
                // If you're code is only doing a few tasks once attached:
                //         This is where you would either place your could to be run, OR more pragmatically
                // call some function you've defined elsewhere.
                //
                // If  you're code is doing things that need to happen persistently over the life of the
                // process then youw ould include something similar like the code below.
                //
    
                // We're calling CreateThread to create a thread that will execute alongside the process
                // we've been attached to. The reason why DLLs are so great for hacking is because all of
                // their code is executed in the same address space of the process that they're injected
                // in to.
                //
                // NOTE: Notice how we check for to see if the returned value is NULL and not 0.
                // Some people will check to see if CreateThread returns 0, this is a bad practice.
                // NULL is defined differently depending on the settings of your compiler. Notably,
                // NULL will be defined as 0 in C++, and as (void*)0 in C.
                if ( CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)MyThread, NULL, 0, NULL) == NULL ) {
                    // We did not successfully create a thread.
                    return FALSE;
                }
    
                // We successfully created a thread of execution.
                // Now we can break the switch statement and return.
                break;
                
            // The DLL has been detached (unlinked) from a process.
            case DLL_PROCESS_DETACH:
                break;
                
            // These values will never occur because we called DisableThreadLibraryCalls.
    
            // The current process (the one we're attached to) is creating a thread.
            case DLL_THREAD_ATTACH:
                break;
                
            // The current process (the one we're attached to) has a thread that is exiting.
            case DLL_THREAD_DETACH:
                break;
        }
    
        // Although the return value doesn't actually matter. You typically
        // return the value TRUE or FALSE indicatinng success or failure.
        return TRUE;
    }
    

    I've also uploaded my source to pastebin:
     
    Ofel likes this.

    Mr. Ad Advertisement

     
  2. Bacardi

    Bacardi United States Lurker

    Post Count:
    5
    Likes Received:
    0
    Stats
    Re: [C++] The Road To Hacking MapleStory - Pa

    Wow, thanks a lot! I'm always looking for useful references ^^
     
  3. TYDIRocks

    TYDIRocks Informed Hacker

    Post Count:
    62
    Likes Received:
    0
    Stats
    Re: [C++] The Road To Hacking MapleStory - Pa

    Very good tutorial. Thanks will defintily use this when I start C++.
     
  4. jw6282000

    jw6282000 Informed Hacker

    Post Count:
    70
    Likes Received:
    0
    Stats
    Re: [C++] The Road To Hacking MapleStory - Pa

    Thank you very much! This will help me when I get into programming.
     
  5. bobcoleman

    bobcoleman Informed Hacker

    Post Count:
    50
    Likes Received:
    0
    Stats
    Re: [C++] The Road To Hacking MapleStory - Pa

    whens part 2 coming?
     
  6. TheNullz

    TheNullz Godly Hacker

    Post Count:
    698
    Likes Received:
    13
    Stats
    Re: [C++] The Road To Hacking MapleStory - Pa

    When I find the time, lol. I have a life, and then I also have hacks/bots that I create for GK. So I don't have all that much time for writing tutorials.
     
  7. Vlad33

    Vlad33 Veteran Hacker

    Post Count:
    195
    Likes Received:
    0
    Stats
    how about ASM best C++ coder in the world cant hack sheeet without someone elses scripts,etc (that "someone" else , would be an ASM pro).
     
  8. Trigger

    Trigger Veteran Hacker

    Post Count:
    151
    Likes Received:
    0
    Stats
    sweet tut
     
  9. Exile

    Exile Banned banned

    Post Count:
    535
    Likes Received:
    0
    Stats
    Nice. I'm Gonna start learning atm. This isnt simple
     
  10. Hackssssf

    Hackssssf Informed Hacker

    Post Count:
    87
    Likes Received:
    0
    Stats
    I need some help. My internet explorer is messed up, so when ever I click the "Free Download" button, my internet explorer stops responding. Could you please give me a direct link to the download or help me download it?

    PS: I use your Nu||s Gateway and Party Quest Bot and they are GREAT!
     
  11. VariiaLz

    VariiaLz The New Guy

    Post Count:
    45
    Likes Received:
    0
    Stats
    awesome now someone should make a DLL with like 1000x exp rate :P
     
  12. TheNullz

    TheNullz Godly Hacker

    Post Count:
    698
    Likes Received:
    13
    Stats
    What "Free Download" button are you referring to?
     
  13. Hackssssf

    Hackssssf Informed Hacker

    Post Count:
    87
    Likes Received:
    0
    Stats
    When you click the link you have and it lists all the downloads, one of the buttons says Free Download

    In this link you gave look where it says "FREE DOWNLOAD" and I am just looking for a direct link or mirror link...
     
    Last edited: Apr 4, 2010
  14. Flyte

    Flyte Elitist Prick

    Post Count:
    85
    Likes Received:
    0
    Stats
    1. This is C, not C++.
    2. Your function prototype for the thread entry is incorrect.
     
  15. ヘ(^_^ヘ)(ノ^_^)ノ

    ヘ(^_^ヘ)(ノ^_^)ノ Fanatic Hacker

    Post Count:
    217
    Likes Received:
    3
    Stats
    If this is all that is of part one, it will be a very long road. Looking forward to see part two.
     
  16. Nic

    Nic Prominent Hacker

    Post Count:
    471
    Likes Received:
    0
    Stats
    Yea this could be hard to get into but Id still like to see part two
     
  17. TheNullz

    TheNullz Godly Hacker

    Post Count:
    698
    Likes Received:
    13
    Stats

    1. C and C++ are interchangle to almost all compilers surpporting the C99 standard (shows that you have no idea how a compiler actually works).
    2. The function for the thread is correct. Compile it and see.
    In C/C++, when a function is cast to a function pointer, the actual return type and argument list of the function pointed at is a non-issue. It only produces an error in the event that the return value is accessed (and one doesn't exist), or if an argument is pushed on to the stack (and the function isn't expecting one). So please, go learn the actual rules of C/C++ you goddamn n00b.
     
  18. c99

    c99 The New Guy

    Post Count:
    32
    Likes Received:
    0
    Stats
    Well in Advance I am a new to this program, I was wondering where I copy and paste this code? C++ is really hard, and by the way in the next tutorial do we will learn how to add a CE script into a check box? And thank you the Nullz for this awesome tutorial you are the best teacher ever, thank you so much, that was cool.
     
  19. spunge

    spunge Informed Hacker

    Post Count:
    55
    Likes Received:
    0
    Stats
    Just because a compiler supports backwards compatibility does not mean that C is equivalent to C++. This has nothing to do with knowledge of compilers. Do not judge a language based on its compilers, there are many out there and correct implementation of the standard is not guaranteed. If you aren't using C++ features, it isn't C++. I really would not be talking about not knowing C++.
     
    Last edited: May 9, 2010
  20. mumsy

    mumsy The New Guy

    Post Count:
    37
    Likes Received:
    0
    Stats
    hmm is it possible to intergrate ASM scripts in C# too? or use dll with C#? is the c++ dlls injection the same as C# ones?
    i look forward to next part..=)
     
Thread Status:
Not open for further replies.

Share This Page

  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies.
    Dismiss Notice
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies.
    Dismiss Notice