home *** CD-ROM | disk | FTP | other *** search
- ; -----------------------------------------------------------
- ; Programm DISKPRO.ASM
- ; Funktion: Schutz des Partitionssektors vor Viren
- ; Autor: Sven Letzel in Zusammenarbeit mit Knut Pfefferkorn
- ; Compiler: MASM,TASM
- ; ASM -> OBJ: TASM DISKPRO
- ; OBJ -> COM: TLINK /t DISKPRO
- ; Datum: 12.04.1993
- ; ----------------------------------------------------------
-
- CODE SEGMENT BYTE
- ASSUME CS: CODE
- ASSUME DS: CODE
- ORG 100H ; wegen .COM
-
- DiskPro:
- JMP @@Install
-
- @@Bootstrap:
- ;Beginn des Bootstrap-Programms
- ;Diese Stelle wird dann später auf die Festplatte kopiert
- ;und bei jedem Booten ausgeführt
- JMP SHORT @@Start
-
- _Ausgabe PROC
- ;Ausgabe einer Zeichenkette über Funktion 0Eh des Int 10h,
- ;denn beim Booten gibt es noch keine DOS-Interrupts
- @@Schleife1:
- LODSB ;Ein Byte laden
- OR AL, AL ;auf Null testen
- JZ SHORT @@AusgabeOk
- MOV AH, 0EH ;Funktion Zeichenausgabe
- INT 10H
- JMP SHORT @@Schleife1
- @@AusgabeOk:
- RET ;Rücksprung
- _Ausgabe ENDP
-
- _ReadSektor PROC
- ;Lesen eines Sektors über Funktion 2 des Int 13h
- MOV DI, 3 ;3 Versuche
- @@Schleife2:
- MOV AX, 0201H ;Funktion einen Sektor lesen
- INT 13H
- JNB SHORT @@ReadOk
- XOR AX, AX ;mov ax,0
- INT 13H ;Plattensystem zurücksetzen
- DEC DI
- JNZ SHORT @@Schleife2
- LEA SI, LoadError + 4FDH
- ;Adresse für "Ladefehler"
- CALL _Ausgabe
- @@Ewig:
- JMP SHORT @@Ewig
- ;Endlosschleife
- @@ReadOk:
- RET ;zurück zum Aufrufer
- _ReadSektor ENDP
-
- @@Start: ;Einsprungpunkt Bootstrap
- CLI ;keine Interrupts
- XOR AX, AX
- MOV SS, AX ;Stacksegment initial.
- MOV SP, 7C00H ;Stackpointer setzen
- ;Das Bootstrapprogramm wird immer an Adresse 7C00h geladen
- MOV SI, SP ;SP=7C00h
- MOV ES, AX ;ES=0
- MOV DS, AX ;DS=0
- STI ;Interrupts an
- CLD ;Direct.flag setzen
- ;bei Stringoperationen wird auf-
- ;wärts gezählt
- MOV DI, 0600H ;Zieladresse zum Kopieren
- MOV CX, 0100H ;256 Words (1 Sektor)
- REPNZ MOVSW ;Programm kopiert sich
- PUSH 0
- PUSH OFFSET @@Jump + 4FDH
- RETF
- ;FAR Sprung auf sich selbst
- ;damit wird CS initialisiert
- @@Jump:
- LEA SI, StatusMsg + 4FDH
- CALL _Ausgabe
- MOV SI, 07BEH ;Partitiontabelle laden
- MOV BL, 04 ;maximal 4 Partitionen
- @@Repeat:
- CMP BYTE PTR [SI],80H
- ;aktive Partition ?
- JZ SHORT @@Gefunden
- CMP BYTE PTR [SI],0
- ;oder inaktiv ?
- JNZ SHORT @@Unbekannt
- ADD SI, 10H ;nächste Partition
- DEC BL
- JNZ SHORT @@Repeat
- INT 18H ;ROM-BASIC starten
- ;ist zwar Quatsch, aber üblich
- @@Unbekannt:
- LEA SI, BadTableError + 4FDH
- CALL _Ausgabe
- JMP SHORT @@Endlos
- @@Gefunden:
- MOV DX, [SI]
- MOV CX, [SI+2] ;Daten laden
- PUSH CX
- PUSH DX
- MOV CX, 0001H ;ersten Sektor, Spur 0
- MOV DX, 0080H ;Kopf 0, erste Platte
- MOV BX, 7C00H
- PUSH BX
- CALL _ReadSektor
-
- MOV CX, 100H ; 128 Words, d.h. ein Sektor
- MOV DI, 0600H ; hier steht dieses Programm
- MOV SI, 7C00H ; hier steht der Partitionssektor
-
- @@Gleichtest:
- REPZ CMPSW
- OR CX, CX
- JNZ SHORT @@VirusDa
-
- MOV BX, 13H*4 ; Überprüfen, ob INT 13h
- CMP WORD PTR [BX+02], 0C000H ; im ROM liegt
- JC SHORT @@VirusDa
-
- LEA SI, NoVirusMsg + 4FDH
- CALL _Ausgabe
- JMP SHORT @@AllesOk
- @@VirusDa:
- MOV AX, 1000H ; pallettenregister ändern
- MOV BX, 0400H ; schwarz --> rot
- INT 10H ; ausführen
- MOV BX, 0007H ; weiß --> schwarz
- INT 10H
- LEA SI, WarningMsg + 4FDH
- CALL _Ausgabe
- IN AL, 60H
- MOV BL, AL
- @@Taste: ; auf Taste warten
- IN AL, 60H
- CMP BL, AL
- JZ @@Taste
- @@AllesOk:
- POP BX ; BX=7C00h
- POP DX ;Daten vom Stack holen
- POP CX
- CALL _ReadSektor
- MOV DI, 7DFEH
- CMP WORD PTR [DI],0AA55H
- ;Anwesenheit eines (DOS)-Boots-
- ;trapprogrammes prüfen
- JZ @@IstOk
- LEA SI, NoSystemError + 4FDH
- CALL _Ausgabe
- @@Endlos:
- JMP SHORT @@Endlos
- @@IstOk:
- PUSH 0000
- PUSH 7C00H
- RETF
-
- NoSystemError DB 'Kein Betriebssystem.',0
- LoadError DB 'Betriebssystemladefehler.',0
- BadTableError DB 'Ungültige Partitionstabelle.',0
- StatusMsg DB 'Prüfe Partitionstabelle...',10,13,0
- NoVirusMsg DB 'Alles Ok.',10,13,0
- WarningMsg DB 7,'Warnung! Virus in Partitionssektor.',10,13,7
- DB 'Warte auf X-beliebige Taste !',10,13,0
- B1 DB 50H DUP (0)
- B2 DB 200H DUP (?)
- Msg DB '┌─────────────────────────────────────────╖',0AH,0DH
- DB '│ Anti-Viren-Loader ║',0AH,0DH
- DB '│ (C) 1993 Sven Letzel & te-wi Verlag ║',0AH,0DH
- DB '╘═════════════════════════════════════════╝',0AH,0DH
- DB 0
- StandBy DB 'Bitte warten. Das System wird in 5 sec. neu gestartet.'
- DB 0AH,0AH,0AH,0DH, 7,0
- Info DB 'Dieses Programm dient zum Schutz der Partitions'
- DB 'tabelle',0AH,0DH
- DB 'vor Virenbefall.',0AH,0DH
- DB 'Drücken Sie eine beliebige Taste, '
- DB 'um fortzusetzen...',0AH,0DH,'<ESC> = Abbruch.'
- DB 0AH,0DH,0AH,0
- Abbruch DB 'Programm nicht installiert.',0AH,0DH,0
- Neustart DB 'Entfernen Sie nun alle Disketten und drücken dann '
- DB 0AH,0DH,'eine beliebige Taste um den Computer neu '
- DB 'zu starten.',0AH,0DH,'(ESC=Abbruch)', 10,10,13,0
- Warnung DB ' W A R N U N G !!!', 07H, 0AH, 0DH
- DB '==================', 0AH, 0DH, 0AH
- DB 'Der Virusschutz wird erst nach einem Neustart des '
- DB 'Computers wirksam.', 0AH, 0DH, 0AH
- DB 'Drücken Sie Ctrl-Alt-Del (Strg-Alt-Entf), um den '
- DB 'Computer neu zu starten oder', 0AH, 0DH
- DB 'arbeiten Sie normal weiter, dann wird der Schutz '
- DB 'beim nächsten Einschalten', 0AH, 0DH
- DB 'wirksam.', 0AH, 0DH, 0
-
- @@UserBreak:
- LEA SI, Abbruch ; ' nicht installiert...'
- CALL _Ausgabe
- MOV AL, 01 ; ExitCode 1
- MOV AH, 4CH ; Programm beenden
- INT 21H
-
- @@Noreset: ; falls kein Warmstart ausgeführt werden soll
- LEA SI, Warnung
- CALL _Ausgabe
- MOV AL, 02 ; Exitcode 2
- MOV AH, 4CH ; Beenden
- INT 21H
-
- @@Install:
- LEA SI, Info ; Infomeldung
- CALL _Ausgabe
- XOR AX, AX
- INT 16H ;auf Taste warten
- XOR AL, 1BH ;ist <ESC> ?
- JZ @@UserBreak
- MOV CX, 1 ; Spur 0, Sektor 1
- MOV DX, 80H ; Kopf 0, erste Platte
- PUSH CS
- POP ES
- LEA BX, B2
- CALL _ReadSektor ;Festplatten-Partitionssektor lesen
- LEA DI, @@Bootstrap+1BEH
- ;1BEh ist Offsetadresse der Partitionstabelle
- LEA SI, B2+1BEH
- MOV CX, 22H
- CLD
- REPNZ MOVSW ;diese hinter Bootstrapprogramm kopieren
- MOV DI, 4
- @@18:
- DEC DI
- JZ @@Exit
- LEA BX, @@Bootstrap
- MOV AX, 0301H
- MOV CX, 1
- MOV DX, 80H
- INT 13H ; Bootstrapprogramm auf Festplatte schreiben
- JNC SHORT @@Exit
- XOR AX, AX
- INT 13H ; bei Fehler System zurücksetzen
- JMP SHORT @@18
- @@Exit:
- LEA SI, Msg ; Statusmeldung ausgeben
- CALL _Ausgabe
- LEA SI, Neustart ; 'Disketten raus...'
- CALL _Ausgabe
- XOR AX, AX
- INT 16H ; auf Taste warten
- XOR AL, 1BH ; ist <ESC> ?
- JZ @@Noreset ; kein Warmstart
- LEA SI, StandBy
- CALL _Ausgabe
-
- XOR BX, BX
- MOV ES, BX
- MOV BX, 46CH
- MOV AX, WORD PTR ES:[BX]
- ADD AX, 50H ;Das entspricht etwa 5 Sekunden Pause
- @@Warte:
- CMP AX, WORD PTR ES:[BX]
- JNC @@Warte
- MOV BX, 0472H
- MOV DX, 1234H
- MOV ES:[BX], DX ;für Warmstart sorgen
-
- PUSH 0FFFFH
- PUSH 0
- RETF ;Booten
-
- CODE ENDS
-
- END DiskPro
-
-