ke vinsID:iiprogram
1113951次访问,排名20好友0人,关注者34
残云收夏暑,新雨带秋岚!
iiprogram的文章
原创 1197 篇
翻译 0 篇
转载 1234 篇
评论 334 篇
Kevins的公告
    留言


自2005年07月20日

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


天氣預報


最近评论
BLUE:好牛..收下了...
xlb_115:你好坏啊!
静思语:请问:开机时出现加载C:\windows\MSNSR7~DLL  时出错是怎么回事?怎么解决呢?谢谢!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!……
doom_dota:这位大哥很牛,虽然有一些地方我看不太懂希望以后多多指教!
杨:大哥。。这个是远程溢出的吗。
文章分类
收藏
相册
1
test
美女
*NUX技术
delphij
hitbsecconf2005
knoppix-std
linux admin
linuxsir
LWN.net
最爱chinaunix
HOT SITES
cnbeta
et8论坛
eyeos 中文
ntdebugging
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
msdn magazine
network code
newhua_deve
ntkernel.com
osronline
pcvc
planet-source-code
putty code
reactos
RECON
reverse-engineering
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
scitech.susx
soft8
source520
tooooold_searcj
torrentreactor.net
VCBOOK
xpbook
卡饭
文学ebook
核心编程
水电
源码天空
绿色下载
计算机与信息技术杂志
超好电子书籍站
非凡绿色下载
高校教材
硬件系统
hri.sourceforge.net
juniper mannel
资讯安全国内站
艾克索夫實驗室
0GINR
0ginr论坛
51tiger.com安全
5eCur!ty Labs
5iliby
6code
77169
aloner
Alter's home page
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
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
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)
中国信息安全组织
中国协议分析网
中国安全信息网-企业安全方案
冷漠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

原创 看nt下无驱执行ring0代码收藏

新一篇: awdBIOS 镜像结构简单分析 | 旧一篇: Do All In One EXE File Under Win32

X86平台上,cpu可以工作在三个特权级别下,ring0—ring3,其中ring0具有最高权限,可以执行任何指令而无限制,ring3受到cpu保护机制限制,只能执行非特权指令。当在ring3下执行特权指令如lgdtiret等时,会触发general protection异常(也就是出错啦,跳转到相应得错误处理程序)。

nt平台下,普通应用程序运行在ring3下,操作系统运行于ring0。如果在程序中需要执行一些特权指令的话,程序必须转入到ring0。由于用户程序执行特权指令可能会破坏系统资源,故出于保护和稳定的目的,操作系统通过“门”机制向用户态程序提供必要的服务。在x86种有四种门:中断门、陷阱门、调用门、任务门。

先描述一下门的概念,个人认为就是两种不同状态之间的通道,换句话说,也就是不同环(特权级)之间切换的通道。

一般在操作系统初始化时,由real mode进入保护模式(pmode)后,cpu就处于ring0状态,在完成各种初始化后,系统转入用户态并创建用户进程。用户程序需要特权服务时,通过系统调用进入ring0,由系统完成指定的、在提供的服务范围内的请求。这样可以避免恶意程序破坏系统。但是如果我们想执行一些“特殊的”操作时怎么办?

这个问题有几个解决方法,第一种方法是安装驱动;驱动程序作为内核的辅助模块为用户程序提供服务,它与操作系统一样工作在ring0,而且他是可以根据自己需编写。所以可以通过编写一个“自定义的”驱动程序来执行ring0代码,这种方法在nt下和linux下应该都可,(不好意思,本人没实践过,忙着“好好学习”,有时间再说)。第二种限定于nt平台,通过“自定义门”来实现执行ring0代码。

由于nt平台的特性,导致用户可以通过操作Section对象\\device\PhysicalMemory来操作物理内存。这样就可通过找到全局描述符表GDT或中断描述符表IDT并修改其内容来构造自己的“门”,甚至使用自定义代码来覆盖内核代码,。。。通过这些方法来达到执行ring0代码的目的。说得有点混乱下面将一些预备知识,以便为后面理解作基础….

还有几个寄存器,这里就乱说了….下面给出相应得结构:

 

/* 中断描述符结构 */

 

typedef struct IDT_ITEM__

 

{

 

  unsigned short offset_low ;        // 偏移量的0~15

 

  unsigned short seg_selector ;      // 段选择符

 

  unsigned char reserved1 ;          // 未使用,须设为全零

 

  unsigned char saved_1_1_0 : 3 ;    // 类型/中断门14/陷阱门15

 

  unsigned char d : 1 ;          // D

 

  unsigned char reserved2 : 1 ; // 保留,需设为0

 

  unsigned char dpl : 2 ;        // 特权ring3

 

  unsigned char p : 1 ;          // P 位存在/有效

 

  unsigned short offset_high ;   // 偏移量的16~31

 

}IDT_ITEM ;

 

/* 调用门结构 */

 

typedef struct InvokeGate__

 

{

 

unsigned short Offset_0_15 ;/* 偏移量的 0~15 */

 

unsigned short SegSelector ;/* 段选择符 */

 

unsigned char reserved1;   

 

unsigned char Type : 4 ;    /* 类型字段,调用门需为 1100 ( 0xC ) */

 

unsigned char DT_0 : 1 ;    /* 需为 0 , 以表明这是一个系统用的描述符 */

 

unsigned char DPL : 2 ;     /* 特权级 */  ring3

 

unsigned char P : 1 ;       /* 存在位 */

 

unsigned short Offset_16_31 ; /* 偏移量的 16~31 */

 

}INT_GATE;

 

 

讲到这里,问题好像还没解决的样子.

 

预备知识:

 

1)   Windows NT将开始512MB物理内存连续映射到0x8000 0000 开始到0xa000 0000(暂时不考虑大于/小于512MB)//这里在暂时对winnt 5.0 5.1

 

2)   ZwMapViewOfSection()函数可以将物理内存映射到当前进程地址空间,并返回映射的虚拟地址

 

3)   Sidt指令和sgdt指令是非特权及指令,用户态可执行

 

4)   Windows Nt使用平坦模式的内存段,即段基址0

 

说到这里,问题的基本可以解决了,这就是网上流传的“无驱执行ring0代码” 的基础。

 

预备知识:

预备知识:

ring3“使用”门要求门的描述符特权级=3,这样这个门才能被用户态程序所使用,

也就是上面结构中DPL域的值=3

 

构造中断门:

将中断描述符指向你的中断处理程序,里面填写你的ring0代码,至于参数可以通过寄存器eax/ebx/ecx…/esi/edi传递,就跟linux系统调用类似

调用时:

Mov eax,param1

Mov ebx,param2

…..

Int 中断向量号

 

构造陷阱门与中断门类似。。。。。

 

构造调用门:

将描述符指向你的ring0要执行的函数

word sel[3];

Sel[0]=sel[1]=0;

Sel[2]=调用门选择

_Asm call fword ptr [sel]           //调用调用门,进入ring0

//这里没有试验过

//估计  ushort[3]è 

//struct

//{

//     Ulong offset;

//    Ushort selector;

//};

这里糊涂啊….有待研究….

 

到这里,你应该基本了解了为什么“无驱执行ring0了,流程图如下:

到这里问题因该很简单了,代码我就不贴了,老早以前的东西了…..

本次只是更新一下本人对这这些的认识,上面有很多错误,暂时摆到这里,以后有时间再修改吧,懒啊….

需要代码在百度查:无驱执行ring0代码就可以查到…..

 

发表于 @ 2007年10月25日 08:39:00|评论(loading...)|编辑

新一篇: awdBIOS 镜像结构简单分析 | 旧一篇: Do All In One EXE File Under Win32

评论

#herx 发表于2008-05-01 15:54:29  IP: 222.221.167.*
X86平台上,cpu可以工作在三个特权级别下,不对是四个吧
发表评论  


登录
Csdn Blog version 3.1a
Copyright © Kevins