一个完整的DLL远程注入函数

DLL加载器-远程线程注入(常规dll注入) 注入思路 先获取到LoadLibrary的函数地址,之后使用CreateRemoteThread加载这段地址即可 简单例子: D:\VS项目\Dll3\x64\Debug\Dll3.dll kernel.dll加载的地址在所有进程都是一样的 https://zhuanlan.zhihu.com/p/599915628?utm_id=0 DLL进程注入 dll注入器 生成dll-2-1.exe 这里注入的exe是notepad++,找到其进程,注入的dll是我cs生成的beacon.dll 主要思路是: 阅读详情

函数名称: CreateRemoteDll()

返加类型:BOOL

接受参数: DLL路径,注入进程ID

其完整代码如下:

 

BOOL CreateRemoteDll(const char *DllFullPath, const DWORD dwRemoteProcessId)
{


    HANDLE hToken;
    
if ( OpenProcessToken(GetCurrentProcess(),TOKEN_ADJUST_PRIVILEGES,&hToken) )
    
{
        TOKEN_PRIVILEGES tkp;
        
        LookupPrivilegeValue( NULL,SE_DEBUG_NAME,
&tkp.Privileges[0].Luid );//修改进程权限
        tkp.PrivilegeCount=1;
        tkp.Privileges[
0].Attributes=SE_PRIVILEGE_ENABLED;
        AdjustTokenPrivileges( hToken,FALSE,
&tkp,sizeof tkp,NULL,NULL );//通知系统修改进程权限
        
    }



    HANDLE hRemoteProcess;

    
//打开远程线程
    if( (hRemoteProcess = OpenProcess( PROCESS_CREATE_THREAD |    //允许远程创建线程
                            PROCESS_VM_OPERATION |                //允许远程VM操作
                            PROCESS_VM_WRITE,                    //允许远程VM写
                            FALSE, dwRemoteProcessId ) )== NULL )
    
{
        AfxMessageBox(
"OpenProcess Error!");
        
return FALSE;
    }


    
char *pszLibFileRemote;
    
//在远程进程的内存地址空间分配DLL文件名缓冲区
    pszLibFileRemote = (char *) VirtualAllocEx( hRemoteProcess, NULL, lstrlen(DllFullPath)+1, 
                            MEM_COMMIT, PAGE_READWRITE);
    
if(pszLibFileRemote == NULL)
    
{
        AfxMessageBox(
"VirtualAllocEx error! ");
        
return FALSE;
    }


    
//将DLL的路径名复制到远程进程的内存空间
    if( WriteProcessMemory(hRemoteProcess,
                pszLibFileRemote, (
void *) DllFullPath, lstrlen(DllFullPath)+1, NULL) == 0)
    
{
        AfxMessageBox(
"WriteProcessMemory Error");
        
return FALSE;
    }


    
//计算LoadLibraryA的入口地址
    PTHREAD_START_ROUTINE pfnStartAddr = (PTHREAD_START_ROUTINE)
            GetProcAddress(GetModuleHandle(TEXT(
"Kernel32")), "LoadLibraryA");

    
if(pfnStartAddr == NULL)
    
{
        AfxMessageBox(
"GetProcAddress Error");
        
return FALSE;
    }


    HANDLE hRemoteThread;
    
if( (hRemoteThread = CreateRemoteThread( hRemoteProcess, NULL, 0, 
                pfnStartAddr, pszLibFileRemote, 
0, NULL) ) == NULL)
    
{
        AfxMessageBox(
"CreateRemoteThread Error");
        
return FALSE;
    }


    
return TRUE;
}
 
DLL注入技术之一远程线程注入源码 widows平台下DLL注入的源码,启动远程线程的方法,力求代码简洁可复用。 立即下载

相关推荐

武希松大牛的dll Hook单元,delphi源代码加demo

delphi-hook-library, wr960204武稀松.2012.2 主页 http://www.raysoftware.cn 通用Hook库. 支持X86和X64. Get 使用了开源的BeaEngine反汇编引擎.BeaEngine的好处是可以用BCB编译成OMF格式的Obj, 被链接进Delphi的DCU和目标文件中.不需要额外带DLL. BeaEngin引擎 http://www.beaengine.org/ 限制: 1.不能Hook代码大小小于5个字节的函数. 2.不能Hook前五个字节中有跳转指令的函数. 希望使用的朋友们自己也具有一定的汇编或者逆向知识. Hook函数前请确定该函数不属于上面两种情况. 另外钩COM对象有一个技巧,如果你想在最早时机勾住某个COM对象, 可以在你要钩的COM对象创建前自己先创建一个该对象,Hook住,然后释放你自己的对象. 这样这个函数已经被下钩子了,而且是钩在这个COM对象创建前的.

Delphi进程注入的部分代码

 //-------------------------注入代码的函数----------------------------{参数说明:InHWND:被注入的窗口句柄Func:注入的函数的指针Param:参数的指针ParamSize:参数的大小}procedure InjectFunc(InHWND: HWND; Func: Pointer; Param: Point

编程资料收集与共享交流 1939

5G移动网络运维(优化)

5G 网络优化现状 移动通信行业属于技术密集型行业,是国民经济的重要支柱以及整个社会经济运转体系中不可或缺的基础。2019 年年底 5G 开始商用,截止到 2020 年3月,我国三大运营商建设了 16.1 万个 5G 基站,我国成为目前全球 5G 基站最多的国家。预计到 2020 年年底,我国运营商会建设大概 70 万个 5G 基站。基于 5G高频段的特性,信号覆盖距离会低于ins 基站,再加上 5G 万物互联的巨大经济潜力价值需求,后续三大运营商在 5G 基站建设数量上势必会超过当前 LTE 基站数量的

2301_78171382的博客 1327

Delphi写的一个函数的Hook类

 unit HookFuncLib;interfaceuses Windows,SysUtils,Classes;const CHookJump_LEN = 5; //要修改的函数的跳转5字节,一个Jmp指令,一个函数地址type TFuncHookList = class; TFuncHook = class private OldProtect

编程资料收集与共享交流 1094

DIY一个SM2262ENG 2TB Nvme固态硬盘,慧荣SM2262EN主控

网友订做的 材料: 慧荣科技的62en,2片1G 三星DDR4缓存,4颗PF29F04T2AOCTH1,8CE B17A。SM2262EN属于慧荣第二代PCIe SSD主控,支持PCIe G3×4通道和全新的NVMe 1.3规范、8个NAND通道设计,并提供完整固件设计,最大循序读取速度高达3.5GB/s,循序写入速度达3.0GB/s,随机读写则高达420K IOPS和420K IOPS。此外,还采用目前最先进的低功耗设计,无论是在待机还是在工作状态下,均展现超低功耗,有效减少30%的功耗,满足用户追求超

m0_55207244的博客 1万+

inline hook(一)demo篇

inline hook demo

卑鄙的我 355

C#集成Bartender:动态图片标签打印的实战与优化

本文详细介绍了在C#程序中集成Bartender实现动态图片标签打印的实战方法与优化策略。通过具名数据源绑定、图片对象尺寸控制等核心技巧,解决了动态图片显示/隐藏的难题,并提供了从模板设计、代码架构到性能优化、错误处理的全流程指南,帮助开发者构建稳定高效的工业级标签打印系统。

weixin_29216957的博客 440

利用武稀松版HtmlParser解析Html,使用CSS选择器定位节点

{ Html解析器. 最近因为用到Html解析功能.在网上找了几款Delphi版本的,结果发现解析复杂的HTML都有一些问题. 没办法自己写了一款,经测试到现在没遇到任何解析不了的Html. wr960204 武稀松 2013 http://www.raysoftware.cn/?p=370 感谢牛人杨延哲在HTML语法和CSS语法方面的帮助. Thank Yang Yanzhe. http://www.pockhero.com/ 本版本只支持DelphiXE.

重楼的博客 689

32GB Jetson Orin SOM 不能刷机问题排查

拿到了一个新的Orin SOM,当用orin Devkit CVB或定制的CVB不能用Linux_For_Tegra刷机,flash日志(JetPack5.0DP和5.0.1DP都失败了) 2. 确认mb2配置中将CVB的eeprom读取大小设置是否为0 ? 已经确认是正常的 在定制的orin cvb flash上使用Orin devkit som,启动是成功的。但新得到的Orin som并不工作可以排除理由:使用Orin Devkit CVB和Orin SOM(不是Devkit SOM)仍然不能

jzwjzw19900922的博客 1499

智算中心建设项目初步设计方案

本项目面向区级政府、智算中心及文旅从业者,聚焦某区智算中心一期建设,响应数字经济与智慧城市建设政策,推动文旅产业升级。遵循统筹规划、数据驱动原则,目标打造智慧文旅样板。建设内容涵盖云网数据底座(以租代建)、数据中台(全生命周期管理)、智慧文旅平台(含“一机游”电商)及气象监测等配套,采用前后端架构与低代码开发,强化三级等保与纵深防御,实现安全可控。方案融合多类资源目录,提供从设计到运营的完整技术支撑,助力区域智算与文旅深度融合。

cdfunlove的博客 116

让自己的dll注入到其他进程中运行

下面是一个简单的mydll.dll注入到QQ中运行的wg

错位竞争,单点突破。 1万+

Python爬虫实战:如何抓取POI信息(公共场所)位置信息

获取公共场所的信息:如餐厅、商店、医院、景点等。抓取POI的基本信息:如名称、类别、地址、评分等。获取POI的地理坐标:经度和纬度信息。存储POI数据:将抓取到的POI信息存储到本地数据库中。通过本篇文章,我们详细介绍了如何使用Python爬虫抓取POI信息。通过Google Maps API和OpenStreetMap(Overpass API),我们展示了如何获取餐厅、商店、医院等公共场所的位置信息,并进一步探讨了如何处理分页、存储数据以及反爬虫策略。

2201_76125261的博客 384

9.4 其他常用的侦测方法

9.4 其他常用的侦测方法

qq_36314864的博客 507

Data-Structures-and-Algorithm-Analysis-in-Java.pdf

作者: Weiss, Mark A. 出版社: Addison Wesley Data Structures and Algorithm Analysis in Java is an “advanced algorithms” book that fits between traditional CS2 and Algorithms Analysis courses. In the old ACM Curriculum Guidelines, this course was known as CS7. This text is for readers who want to learn good programming and algorithm analysis skills simultaneously so that they can develop such programs with the maximum amo...

精雕软件(JDpaint) 5.5 绿色版

精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版

DLL Inject Porcess Code

实现dll注入到explorer进程 #include #include  // 声明快照函数的头文件 #include "stdio.h" #include "tchar.h"    // _tcsrchr // 插入dll目标进程 LPTSTR Target="iexplore.exe"; DWORD FindProcess(LPTSTR lpszProNam

多媒体编程、网络编程、系统编程、网络安全编程、驱动编程 658

Devexpress16.2.6破解工具

Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具

C++实现DLL注入的完整过程

1 简介 网上确实有关于DLL注入的过程,但是很多写的都不全,或者内容有点老旧。 DLL文件注入的原理是:接管被注入应用的控制权,并在应用程序运行的内存中开辟一条线程运行DLL文件中的入口函数的代码。 项目需求:向一个.txt文件注入dll,然后会自动弹出一个窗口 工具:VS2019 2 DLL动态链接库的编写 在VS2019中新建项目-选择【动态链接库(DLL)】 不要勾选:【将解决方案和项目放在同一目录中】 创建完项目后,会有四个文件 framework.h pch. h dllmain.

qq_43851684的博客 1万+

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

【第38节】windows原理:DLL注入与Hook是什么

Hook 技术,中文叫钩子技术,本质上是在程序运行过程中,拦截特定事件或函数调用,改变其执行路径,插入自定义代码,来实现特定功能的一种编程技术。Hook在程序设计中是一种灵活多变的技术手段,它主要用于改变程序原有的执行流程,让程序执行开发者自己定义的代码。在Windows系统下,Hook有两种含义,一是系统提供的消息Hook机制,由一系列API提供服务,通过这些API可以对大多数应用程序的关键节点进行Hook操作,Windows会为每种Hook类型维护一个钩子链表;

攻城狮7号的博客 5217

软件安全之代码注入技术 向目标 PE 文件注入 DLL notepad lpk.dll 远程线程函数 提权函数 OpenProcess VirtualAllocEx

实验 4 代码注入技术 引言 1、实验说明 代码注入是将用户代码注入到其他进程或者可执行文件中,实现拦截目标进程运行过程的关键信息、改变目标进程或可执行文件原本执行流程等目的 2、实验目的 本实验通过远程线程和输入表注入,向目标进程注入代码、向目标 PE 文件注入 DLL,以加深对代码注入技术的理解。 3、实验原理 课程第 6 讲代码注入技术 4、实验环境 Windows 7 系统、Visual Studio 6.0 及以上版本 5、实验内容 (1)远程线程注入 (2)利用 Detours 实现输入表注入

SKPrimin的博客 3737

DLL远程注入代码详解

DLL远程注入代码详解 首先,四个你要知道的东西: 1.“远程线程‘’是指跨进程,而不是跨计算机。 2.计算机每个进程的地址空间都是独立隔离的。 3.简单说,进程A在进程B创建一个线程就叫远程线程。 4.多用在木马外Gua等注入,dll文件的运行不会单独创建一个进程,它的运行被加载到进程的地址空间中,因此其隐蔽性相对较好。 主要的函数如下: - 一. CreatRemoteThread()//创建...

qq_41853215的博客 1917

远程线程DLL注入

DLL注入是一项在Windows开发和安全研究中常见的技术,它允许一个进程将动态链接库加载到另一个进程的地址空间中。远程线程注入是其中最为经典和广泛应用的方法之一。这篇文章将深入探讨其原理、实现细节以及实际应用中的注意事项。

静下心来,做好每一件事 619
上一篇: 木马服务端生成技术详解
下一篇: 技术讨论关于零管道CMD后门
iiprogram
博客等级 码龄25年 1068粉丝 1515原创
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值
⌂ 换网址