Results 1 to 12 of 12
  1. #1
    xKarma's Avatar
    Join Date
    May 2012
    Gender
    male
    Posts
    3
    Reputation
    10
    Thanks
    2

    DLL Injection - Getting started

    What is DLL injection?

    DLL injection is a powerful technique where we inject a DLL inside another process in order to execute our own code from within that process.

    For example, if we injected a DLL with this code...

    Code:
    MessageBox(NULL, L"Message Text", L"Message Title", MB_OK);
    ...into notepad, it would make notepad call that code, thus show the messagebox. And this is exactly what we're going to do in this tutorial.

    Heed my words...

    ...DLL injection is anything but a safe method, and not knowing what you're doing could very easily result into a system wide disaster. Therefore it is highly recommended that you have at least a basic understanding of the Windows operating system and the c++ programming language before you continue.

    Setup

    With that out of the way, we can finally get started! Download our DLL injector here.

    You will also need a c++ compiler to create the DLL to inject. I use Microsoft's Visual C++ IDE in this tutorial, but are free to use any compiler you like.

    Create a new Win32 project and name it 'InjectDLL'.



    For type, select 'DLL' and click 'Finish'.



    A new project is created. Tap 'dllmain.cpp' open.



    You should now see this piece of code:

    Code:
    // dllmain.cpp : Defines the entry point for the DLL application.
    #include "stdafx.h"
    
    BOOL APIENTRY DllMain( HMODULE hModule,
                           DWORD  ul_reason_for_call,
                           LPVOID lpReserved
                                             )
    {
            switch (ul_reason_for_call)
            {
            case DLL_PROCESS_ATTACH:
            case DLL_THREAD_ATTACH:
            case DLL_THREAD_DETACH:
            case DLL_PROCESS_DETACH:
                    break;
            }
            return TRUE;
    }
    As you can see, the compiler has generated the DllMain function for you. This is the very function that first gets called by a process when your DLL is injected into it. More precisely, the
    Code:
    case DLL_PROCESS_ATTACH:
    part. So let's write the code for our MessageBox there.

    Code:
    case DLL_PROCESS_ATTACH:
            MessageBox(NULL, L"Hello from notepad!", L"notepad", MB_OK);
    Build the project.



    Fire up notepad and the DLL injector. Hit the browse button of 'DLL Path' and find your "InjectDLL.dll". Click OK.



    Now we're all set to inject, so click "Inject". This is what should happen:



    Notepad shows a MessageBox 'Hello from notepad!'. Notepad's UI is frozen until you click "OK", just like any other application that shows a MessageBox. InjectDLL.dll is added to the injector's list of injected DLLs. From that list you can eject the DLL by selecting it and clicking the "Uninject" button. When you uninject a DLL, the 'case DLL_PROCESS_DETACH:' part of your DLL's code gets called. That's where you do all the required cleanup. In this case, we don't need any.

    Conclusion

    You now have successfully injected a DLL with your own code into an external process to manipulate it's behavior, forcing the poor notepad to create a MessageBox of your your liking.

    But you have just scratched the surface here. Think outside the box. Like I said, with this technique you can wreak unlimited havoc inside a process. When you think about what you can/can't do with DLL injection, think about what you can/can't do with creating a function inside your own program and callintg it. There is no limits. You can, for example, call or intercept the functions that already exist(this is called hooking).

    Remember to take great care when you use this technique. Like I said earlier, doing it wrong can cause unexpected, disastrous behavior.

    Tutorial from:
    UGSoft - Game Hacking Tutorials

  2. The Following 2 Users Say Thank You to xKarma For This Useful Post:

    Bartender (08-09-2017),TheExtremelyBadHacker (07-10-2019)

  3. #2
    Darkzz12's Avatar
    Join Date
    Aug 2011
    Gender
    male
    Posts
    48
    Reputation
    10
    Thanks
    12
    Ill try It...

  4. #3
    ObeA's Avatar
    Join Date
    Aug 2012
    Gender
    male
    Posts
    2
    Reputation
    10
    Thanks
    1
    Lol.
    Idk why but it doesn't work ._.

  5. #4
    Reflex-'s Avatar
    Join Date
    Mar 2011
    Gender
    male
    Location
    192.168.1.01
    Posts
    6,625
    Reputation
    584
    Thanks
    2,267
    My Mood
    Dead
    Quote Originally Posted by ObeA View Post
    Lol.
    Idk why but it doesn't work ._.
    What did you try doing?

  6. #5
          ( ° ͜ʖ͡°)╭∩╮
    Former Staff
    MarkHC's Avatar
    Join Date
    Nov 2011
    Gender
    male
    Location
    127.0.0.1
    Posts
    2,750
    Reputation
    66
    Thanks
    14,533
    My Mood
    Angelic
    Quote Originally Posted by ObeA View Post
    Lol.
    Idk why but it doesn't work ._.
    you obviously did something wrong then...


    CoD Minion from 09/19/2012 to 01/10/2013

  7. #6
    ObeA's Avatar
    Join Date
    Aug 2012
    Gender
    male
    Posts
    2
    Reputation
    10
    Thanks
    1
    Code:
    // dllmain.cpp : Defines the entry point for the DLL application.
    #include "stdafx.h"
    
    BOOL APIENTRY DllMain( HMODULE hModule,
                           DWORD  ul_reason_for_call,
                           LPVOID lpReserved
    					 )
    {
    	switch (ul_reason_for_call)
    	{
    	case DLL_PROCESS_ATTACH:
            MessageBox(NULL, L"Hello from notepad!", L"notepad", MB_OK);
    	case DLL_THREAD_ATTACH:
    	case DLL_THREAD_DETACH:
    	case DLL_PROCESS_DETACH:
    		break;
    	}
    	return TRUE;
    }
    == my code.

  8. #7
    PopupsAndRegistrationSuck's Avatar
    Join Date
    Apr 2013
    Gender
    male
    Location
    Gaping your mother
    Posts
    9
    Reputation
    10
    Thanks
    3
    My Mood
    Doh
    Quote Originally Posted by ObeA View Post
    Code:
    // dllmain.cpp : Defines the entry point for the DLL application.
    #include "stdafx.h"
    
    BOOL APIENTRY DllMain( HMODULE hModule,
                           DWORD  ul_reason_for_call,
                           LPVOID lpReserved
    					 )
    {
    	switch (ul_reason_for_call)
    	{
    	case DLL_PROCESS_ATTACH:
            MessageBox(NULL, L"Hello from notepad!", L"notepad", MB_OK);
    	case DLL_THREAD_ATTACH:
    	case DLL_THREAD_DETACH:
    	case DLL_PROCESS_DETACH:
    		break;
    	}
    	return TRUE;
    }
    == my code.
    Same, doesn't work for me either:/

  9. #8
    Olevnik's Avatar
    Join Date
    Jul 2013
    Gender
    male
    Posts
    96
    Reputation
    10
    Thanks
    4
    My Mood
    Psychedelic
    You've got some kind of error guys?
    It's probably because you're trying to inject it to 64bit notepad, try injecting it into 32bit application, Notepad++ for example.

  10. #9
    Boost4lol's Avatar
    Join Date
    Jan 2014
    Gender
    male
    Posts
    21
    Reputation
    10
    Thanks
    0
    I really need to get read this, thanks.

  11. #10
    rats487's Avatar
    Join Date
    Jan 2014
    Gender
    male
    Posts
    12
    Reputation
    10
    Thanks
    0
    My Mood
    Doubtful
    Cool, 1 qeustion though: How would one see the source code of the game, isn't it needed to know how variables and such are named?

  12. #11
    Express.'s Avatar
    Join Date
    May 2013
    Gender
    male
    Location
    College.
    Posts
    2,635
    Reputation
    293
    Thanks
    335
    My Mood
    Lurking
    Thanks for the tutorial, even though you're banned.
    Member Since: 05-21-2013
    Donator Since: 03-13-2014
    (Credits to @Jov)
     
    Vouches.[36]

    [+3]NotaGMghost- He went first.
    [+2]paparas1398- He went first 2x!
    [+2]ahmedTC- He went first!
    [+3]Silke Vanden Abeele- She went half first.
    [+3]Poxer- I went first 3 times.
    [+1]raow25- I went first.
    [+1]Andyl- I went first. Very trusted!
    [+2]Devil™- I went first,legit!(Maxedout as OMM).
    [+1]Tonylx4- Used OMM.
    [+1]Maxedout- I went first.(Great deal and Great guy.)!
    [+1]Abber- He went first.
    [+2]himekami- Used Maxedout.
    [+1]Heat.- I went first w/o OMM.
    [+2]bannanaman- He went first.(Over 220$ deal)
    [+1]igocham- Used Maxedout.
    [+2]Jeremychubby-Used Busted!
    [+1]jaber006- Went first.
    [+1]silverarc- Went first with a steam key.
    [+1]hidudeshi - Bought a steam key.
    [+1]karlamwood- Refunded the payment 4 times and made a report no reason.
    [+1]Raple's Sheep- !Busted.
    [+1]lol1505- He went first.
    [+1]Flux*- He went first.
    [+1]RobyGenius- He went first.

  13. #12
    medo.soleman's Avatar
    Join Date
    Jul 2015
    Gender
    male
    Posts
    16
    Reputation
    10
    Thanks
    0
    thanks alot for your work

Similar Threads

  1. when i inject my DLL. i get a couldnt find patc and crash
    By atomisticxkid in forum Vindictus Help
    Replies: 3
    Last Post: 08-04-2011, 04:49 AM
  2. Crash at Dll inject
    By CyberStriker in forum WarRock - International Hacks
    Replies: 1
    Last Post: 08-13-2008, 06:51 AM
  3. Need help getting started
    By skittlznick2 in forum Combat Arms Hacks & Cheats
    Replies: 2
    Last Post: 08-03-2008, 12:53 AM
  4. Got VB 6, I see new Adress thread, how to get started?
    By soulbind4 in forum WarRock - International Hacks
    Replies: 10
    Last Post: 01-24-2008, 07:38 PM
  5. DLL injection Failled
    By aynal in forum WarRock - International Hacks
    Replies: 1
    Last Post: 01-15-2006, 09:41 PM

Tags for this Thread