Code Monkey home page Code Monkey logo

dll_inject's Introduction

Breakdown of each step:

Import Libraries: Import ctypes for calling C functions in DLLs, and sys and os for handling system-specific operations.

Define Constants: Define constants for process access rights (PROCESS_ALL_ACCESS), memory allocation (MEM_COMMIT, MEM_RESERVE), and memory protection (PAGE_EXECUTE_READWRITE).

Load Windows API Functions: Load kernel32.dll to access Windows API functions for process and memory management.

Define the inject_dll Function: Create a function to handle the entire DLL injection process into the target process.

Open Target Process: Use OpenProcess to get a handle to the target process with all necessary access rights.

Allocate Memory in Target Process: Allocate memory within the target process using VirtualAllocEx to store the DLL path.

Write DLL Path to Allocated Memory: Use WriteProcessMemory to write the DLL path into the allocated memory in the target process.

Get Address of LoadLibraryA: Retrieve the address of the LoadLibraryA function from kernel32.dll using GetProcAddress.

Create Remote Thread in Target Process: Create a remote thread in the target process with CreateRemoteThread to execute LoadLibraryA with the DLL path as an argument.

Wait for Remote Thread to Complete: Use WaitForSingleObject to wait for the remote thread to complete the DLL loading.

Clean Up: Free the allocated memory with VirtualFreeEx and close all handles with CloseHandle.

Main Function to Execute the Script: Parse command-line arguments for the process ID and DLL path, validate the DLL path, and call the inject_dll function to perform the injection.

dll_inject's People

Contributors

d3ndr1t30x avatar

Stargazers

Mendel Zeev Volf Gorovets avatar Λ卩卩ㄥ乇-千尺丨ㄒㄒ乇尺 эпл-фриттер avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.