[red]兄弟,你的运气太好了!我一直在研究这个问题。
我现在能做到在所有的操作系统(包括XP)下获得Ring0特权。
看看下面完整的代码先,觉得好一定要给分呀
如果想要在其它操作系统下实现的代码,可以给我来个Mailto:mingtao@sina.com[/red]
[blue]//------- 在Win9X下实现硬盘写保护 -----------[/blue]
program nuke; //Programmed by Manfeel ! 转载请注明作者及出处!
uses
windows,sysutils;
const
MyIntNum=$9;
type
IFS_CallBack=function(pfn
ointer; fn, Drive, ResType,CodePage, pir:Integer):Longword;cdecl;
var
_IDTR,SavedGate:Int64;
MyGate:array[0..3] of word=(0,$28,$ee00,0);
origin_ifs_hook:array[0..12] of byte=
($55,$8B,$EC,$FF,$75,$1C,$FF,$55,$08,$8B,$E5,$5D,$C3);
//0028:C013FC7A 55 PUSH EBP
//0028:C013FC7B 8BEC MOV EBP,ESP
//0028:C013FC7D FF751C PUSH DWORD PTR [EBP+1C]
//0028:C013FC80 FF5508 CALL [EBP+08]
//0028:C013FC83 8BE5 MOV ESP,EBP
//0028:C013FC85 5D POP EBP
//0028:C013FC86 C3 RET
PrevHook:IFS_CallBack;
Success:Integer;
function MyIfsHook(pfn
ointer; fn, Drive, ResType,CodePage, pir:Integer):Longword;cdecl;
begin
if((fn=31{IFSFN_DELETE}) or (fn=37{IFSFN_RENAME})) then
Result:=1 //返回系统已经处理的假相
else
Result:=PrevHook(pfn, fn, Drive, ResType, CodePage, pir);
end;
procedure Ring0proc;stdcall;
begin
asm
pushad
push $0000000F //Flags = PAGEUSEALIGN
push 0 //phym Address
push $0000000F //Max Address
push $00000000 //Min Address
push $00000000 //AlignMask , Physical address is a multiple of 4K
push $00000000 //hVm = 0 Access to all VM
push $00000001 //type = PG_SYS
push $00000001 //just 1 page
int $20 //VxDCall
dd $00010053 //Call ID _PageAllocate
add esp,32 //-------------------------Manfeel
or eax,eax
mov Success,eax
jz @@quit
mov ecx,1000 //我不知道我的代码有多少字节,但1000肯定足够了:-(
mov edx,offset MyIfsHook
mov edi,eax
@@trans:
cmp word ptr [edx],$15ff //Delphi不支持 Call [address],只好写机器码 opc: FF 15
jnz @@goon
mov dword ptr [edi],$15ff
mov dword ptr [edi+2],1000
add [edi+2],eax
add edi,6
add edx,6
@@goon:
mov bl,[edx]
mov [edi],bl
inc edx
inc edi
loopnz @@trans
push eax
int $20
dd $00400067 //VxDCall : IFSMGR_InstallFileSystemApiHook
pop eax
add eax,1004
mov dword ptr [eax-4],eax
mov edi,eax
mov esi,offset origin_ifs_hook
mov ecx,13
rep movsb
@@quit:
popad
iretd
end;
end;
begin
asm
pushad
mov eax,OFFSET Ring0proc //注意:@在Inline Asm中有特殊含义,
// 只能用OFFSET来取得偏移地址
mov [offset MyGate],ax //必须要用offset,下同
shr eax,16
mov [offset MyGate+6],ax
sidt [offset _IDTR]
mov ebx,dword ptr [offset _IDTR+2]
add ebx,8*MyIntNum
mov edi,offset SavedGate
mov esi,ebx
movsd
movsd
mov edi,ebx
mov esi,offset MyGate
movsd
movsd
int MyIntNum
mov edi,ebx
mov esi,offset SavedGate
movsd
movsd
popad
end;
if (Success=0) then
MessageBoxA(0,PChar('Installed FAILED!!!'),
PChar('Install My IFS Hook!'),MB_OK)
else
MessageBoxA(0,PChar('Installed Successfully!!!'),
PChar('Install My IFS Hook!'),MB_OK);
end.