🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.atari.st
Article #32172

*** VIRUS KILLER *** (Source code Rainer)

#32172
From: unpowell
Date: Tue, 26 Apr 1988 18:30
420 lines
8826 bytes

	Recently I posted a virus killer to comp.sys.atari.st. A certain
Rainer Klute, commented that he would only use it if he had the source for
it. The source, in 68000 assembly language, follows....
	This program allows examination of floppy disks, for auto executing
boot sectors, and allows such boot sectors to be disabled. It also allows
an "anti-virus" to be installed on a disk (which is what, I think, Rainer
was wary about). This is simply a program on the boot sector, which on boot
up informs the user that the disk doesn't have a virus on it. This is done
by turning the screen red (on a colour monitor), reversing the screen (on
a monochrome monitor), printing the message "Virus free disk", making
the "bell" sound or any combination of those three. So on boot up, with a disk
with an anti virus installed, if your screen changes colour and/or the message
is printed and/or the bell sounds you know that the anti-virus is still
installed on your disk and it hasn't "yet" been written over by a virus.
If you boot up with a disk with the anti-virus on it and you don't get your
audio, visual or textual message than you know that something or other has
written over your boot sector, possibly a virus. This can then be dealt
with.
	The anti-virus does not stay resident after boot up, it simply executes
during boot up and no other time.
	Does this put your mind at ease, Rainer?

	Mark Powell

********************************************************************************

 "...I hate the white	JANET unpowell@uk.ac.liv.csvax
  man, and the man	UUCP  {backbone}!mcvax!ukc!mupsy!liv-cs!unpowell
  who turned you all	ARPA  unpowell%csvax.liv.ac.uk@nss.cs.ucl.ac.uk
  loose..." R. Harper

********************************************************************************

-----------------------------------Cut here-------------------------------------

*	ST Virus Killer
*	Copyright Mark Powell 18/4/1988
*	Permission is granted to copy this source, provided no profits
*	are obtained from such copying
*	Written for Devpac assembler, GenST, by Hisoft 

begin
	clr.l	-(sp)
	move	#32,-(sp)
	trap	#1
	addq.l	#6,sp
	move.l	d0,-(sp)
	move	$484.w,-(sp)
	bclr	#1,$484.w

	dc.w	$a00a

start	lea	mess0(pc),a0
	bsr	print
	bsr	prntant
	lea	mess01(pc),a0
	bsr	print	

wait	bsr	getkey
	cmp	#'1',d0
	beq.s	examine
	cmp	#'2',d0
	beq	remove
	cmp	#'3',d0
	beq	install
	cmp	#'4',d0
	beq	alterc
	cmp	#'5',d0
	beq	changdr
	cmp	#'6',d0
	beq	save
	cmp	#'7',d0
	bne.s	wait

	move	(sp)+,$484.w
	move	#32,-(sp)
	trap	#1
	addq.l	#6,sp
	clr	-(sp)
	trap	#1

changdr	cmp	#1,$4a6.w
	beq.s	wait
	eor	#1,drive
	bra.s	start

examine	bsr	cls
	bsr	read
	bsr	getchk
	add	(a5)+,d1
	cmp	#$1234,d1
	bne.s	noboot

	cmp	#$601c,(a6)
	bne.s	notanti
	lea	$1e(a6),a5
	lea	code(pc),a0
	move	#endcode-code-1,d0
chkcode	move.b	(a0)+,d1
	cmp.b	(a5)+,d1
	bne.s	notanti
	dbra	d0,chkcode
	lea	anti(pc),a0
	bsr	print
	lea	info-code+$1e(a6),a3
	bsr	prntan1
	bsr	anykey
	bra	start

notanti	lea	is(pc),a0
	bra.s	prntres

noboot	lea	isnt(pc),a0
prntres	bsr	print
	bsr	anykey
	bra	start	

install	bsr	cls
	bsr	read
	lea	$1e(a6),a0
	move.l	a0,a1
	move	#480/4-1,d0
clrboot	clr.l	(a0)+
	dbra	d0,clrboot

	lea	code(pc),a0
	move	#endcode-code-1,d0
movecd	move.b	(a0)+,(a1)+
	dbra	d0,movecd

	move	#$601c,(a6)
 	bsr	getchk
	sub	#$1234,d1
	neg	d1
	move	d1,(a5)
	bra.s	write

remove	bsr	cls
	bsr	read
	bsr	getchk
	sub	#$1235,d1
	neg	d1
	move	d1,(a5)
write	pea	1.w
	pea	$10000
	move	d7,-(sp)
	subq.l	#4,sp
	pea	(a6)
	move	#9,-(sp)
	trap	#14
	lea	20(sp),sp
	tst	d0
	beq	start
	bsr	error
	beq	start
	bra.s	write

save	lea	insert(pc),a0
	bsr	print
	bsr	anykey
open	clr	-(sp)
	pea	name(pc)
	move	#$3d,-(sp)
	trap	#1
	addq.l	#8,sp
	tst	d0
	bpl.s	sokay
	moveq	#-18,d0
	bsr	error
	bne.s	open
	bra	start
sokay	move	d0,d6
	clr	-(sp)
	move	d6,-(sp)
	pea	(info-begin+$1c).w
	move	#$42,-(sp)
	trap	#1
	lea	10(sp),sp
	pea	info(pc)
	pea	3.w
	move	d6,-(sp)
	move	#$40,-(sp)
	trap	#1
	lea	12(sp),sp
	move	d6,-(sp)
	move	#$3e,-(sp)
	trap	#1
	addq.l	#4,sp
	bra	start

alterc	lea	alter(pc),a0
	bsr.s	print
	lea	info(pc),a3
	lea	coloryn(pc),a0
	bsr.s	getyn
	lea	textyn(pc),a0
	bsr.s	getyn
	lea	soundyn(pc),a0
	bsr.s	getyn
	bra	start

getyn	bsr.s	print
	move.b	#1,(a3)
getynw	bsr.s	getkey
	bclr	#5,d0
	cmp	#'Y',d0
	beq.s	ynokay
	cmp	#'N',d0
	bne.s	getynw
	clr.b	(a3)
ynokay	lea	yn(pc),a0
	move.b	d0,(a0)
	addq.l	#1,a3
	bra.s	print

cls	lea	clear(pc),a0
	bra.s	print

getkey	pea	$10002
	trap	#13
	addq.l	#4,sp
	tst	d0
	beq.s	keyget
	bsr.s	keyget
	bra.s	getkey	
keyget	pea	$20002
	trap	#13
	addq.l	#4,sp
	move.l	d0,d1
	swap	d1
	rts

print	pea	(a0)
	move	#9,-(sp)
	trap	#1
	addq.l 	#6,sp
	rts

getchk	move.l	a6,a5
	clr	d1
	move	#255-1,d0
chklp	add	(a5)+,d1
	dbra	d0,chklp
	rts

anykey	lea	any(pc),a0
	bsr.s	print
	bra.s	getkey

read	moveq	#0,d7
	move.b	drive(pc),d7
	sub	#'A',d7
	lea	buffer(pc),a6
readag	pea	1.w
	pea	$10000
	move	d7,-(sp)
	subq.l	#4,sp
	pea	(a6)
	move	#8,-(sp)
	trap	#14
	lea	20(sp),sp
	tst	d0
	bpl.s	okayr
	bsr	error
	bne.s	readag
	addq.l	#4,sp
	bra	start
okayr	rts

prntant	lea	info(pc),a3
prntan1	moveq	#0,d6
	tst.b	(a3)+
	beq.s	nocol
	lea	color(pc),a0
	bsr.s	print
	moveq	#1,d6
nocol	tst.b	(a3)+
	beq.s	notext
	lea	text+1(pc),a0
	tst	d6
	beq.s	first1
	subq.l	#1,a0
first1	bsr.s	print
	moveq	#1,d6
notext	tst.b	(a3)+
	beq.s	nosound
	lea	sound+1(pc),a0
	tst	d6
	beq.s	first2
	subq.l	#1,a0
first2	bra	print
nosound	rts

*	This is the actual anti-virus code, that is written
*	to the boot sector.
	
code	lea	info(pc),a3
	tst.b	(a3)+
	beq.s	nocolq
	btst	#7,$fa01.w
	bne.s	colour
	move.l	$456.w,a0	* If monochrome then set up
	lea	vbl(pc),a1	* VBL to set reverse screen
	move.l	a1,28(a0)
colour	move	#$700,$8240.w
nocolq	tst.b	(a3)+
	beq.s	notext1
	pea	mess(pc)
	move	#9,-(sp)
	trap	#1
	addq.l	#6,sp
notext1	tst.b	(a3)+
	beq.s	nosund1
	move	#7,-(sp)
	pea	$30002
	trap	#13
	addq.l	#6,sp
nosund1	rts

vbl	move.l	$44e.w,a0	* VBL to set screen to white on black
	tst.l	31992(a0)	* when desktop finally appears
	beq.s	scrclr
	move.l	$456.w,a0
	clr.l	28(a0)
	clr	$8240.w
scrclr	rts

mess	dc.b	27,'EVirus free disk',0
info	dc.b	1,0,0
endcode

*	Anti-virus code ends here

error	neg	d0
	add	d0,d0
	lea	errpnt-2(pc,d0),a3
	lea	messe(pc),a0
	bsr	print
	moveq	#0,d0
	move	(a3),d0
	lea	e1(pc,d0),a0
	bsr	print
	lea	messe1(pc),a0
	bsr	print
	bsr	getkey
	cmp	#1,d1
	rts

errpnt	dc.w	0,e2-z,e3-z,e4-z,e5-z,e6-z,e7-z,e8-z,e9-z,e10-z,e11-z
	dc.w	e12-z,e13-z,e14-z,e15-z,e16-z,e17-z,e18-z

z
e1	dc.b	'#1 General error'
e3
e5
e7
e9
e14
e16	dc.b	0
e2	dc.b	'#2 Drive not ready',0
e4	dc.b	'#4 CRC error. Read error',0
e6	dc.b	'#6 Seek error, track not found',0
e8	dc.b	'#8 Sector not found. Read error',0
e10	dc.b	'#10 Write error',0
e11	dc.b	'#11 Read error',0
e12	dc.b	'#12 General error',0
e13	dc.b	'#13 Disk write protected',0
e15	dc.b	'#15 Unknown device',0
e17	dc.b	'#17 Insert disk',0
e18	dc.b	'Couldn',39,'t access disk',0

mess0	dc.b	27,'E            ST Virus Killer',13,10,13,10
	dc.b	'    Copyright 18/4/1988 by M.S.Powell',13,10
	dc.b	'Permission granted to copy for no profit',13,10,13,10
	dc.b	'1. Examine a disk',13,10
	dc.b	'2. Remove auto executing boot sector',13,10
	dc.b	'3. Install anti virus: ',0
mess01	dc.b	13,10,'4. Alter anti virus characteristics',13,10
	dc.b	'5. Drive '
drive	dc.b	'A',13,10
	dc.b	'6. Save defaults',13,10
	dc.b	'7. Exit',0

any	dc.b	13,10,13,10,'Press any key',0

anti	dc.b	'Disk has an anti virus installed,',13,10
	dc.b	'with characteristics: ',0

is	dc.b	'Disk has an executable boot sector',13,10
	dc.b	'Possibly a virus.',13,10
	dc.b	'Could also be entirely innocent',0

isnt	dc.b	'Boot sector isn',39,'t executable',0

color	dc.b	'Colour',0
text	dc.b	':Text',0
sound	dc.b	':Sound',0

coloryn	dc.b	'Colour (y/n)? ',0
textyn	dc.b	'Text (y/n)? ',0
soundyn	dc.b	'Sound (y/n)? ',0

clear	dc.b	27,'E',0

yn	dc.b	'@',13,10,0

insert	dc.b	27,'EInsert the disk that this program was',13,10
	dc.b	'loaded from',0

alter	dc.b	27,'EAnti virus characteristics are:',13,10,13,10,0

messe	dc.b	13,10,'Error occurred:- ',0

messe1	dc.b	13,10,'Esc to abort. Any other key to try again',13,10,0

name	dc.b	'viruskil.prg',0
	even
buffer
Technical Details
Message-ID: <961@csvax.liv.ac.uk>
Path: arc1-ca.pugleaf.net!utzoo!mnetor!uunet!mcvax!ukc!mupsy!liv-cs!unpowell

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!mnetor!uunet!mcvax!ukc!mupsy!liv-cs!unpowell
From: unpowell@csvax.liv.ac.uk
Newsgroups: comp.sys.atari.st
Subject: *** VIRUS KILLER *** (Source code Rainer)
Message-ID: <961@csvax.liv.ac.uk>
Date: 26 Apr 88 18:30:47 GMT
Lines: 419
Organisation: Computer Science CSVAX (VAX1), Liverpool University