这是一个DOS程序只支持在WINDOSXP系统和DOS系统下运行
Ping-Pong virus介绍
1988年3月1日,在都灵大学首次发现了乒乓病毒。原始版本的乒乓球病毒发现只在软盘上有,现在大概已经灭绝了。当然,后期也衍生出了一些变种,乒乓病毒用现在的话来讲就是“绿色无公害”,类似于原始的乒乓球游戏,用户倘若不小心将其激活,通过重启的方式就可以进行处理。
汇编代码如下(由于注释比较详细,文章中就不再做过多解释)
code segment
org 100h;com文件需要在开头预留100h字节的空间
assume cs:code , ds:code
main:
jmp start;要跳开数据部分,不能执行
welcome db '+---------------------------------------------------+' ,0ah ,0dh
db '+ PingPongVirus +' ,0ah ,0dh
db '+ ---write by caicaiwoshishui +' ,0ah ,0dh
db '+---------------------------------------------------+' ,0ah ,0dh ,'$'
old_int dd ?;保存被截获的中断
PingPongDirectionUpDown dw ?;乒乓球方向上下
PingPongDirectionLeftRight dw ?;乒乓球方向左右
PingPongPointCol dw ?;乒乓球位置X
PingPongPointRow dw ?;乒乓球位置Y
backScreenChar dw ?;备份乒乓球显示位置上的数据
timer dw ?
;;乒乓球 95h 25*80
TSR proc far
;保护现场
push ax
push bx
push cx
push dx
push si
push di
push bp
push sp
push es
push ds
sti
call disp
cli
;返回现场
pop ds
pop es
pop sp
pop bp
pop di
pop si
pop dx
pop cx
pop bx
pop ax
jmp cs:old_int
TSR endp
disp proc near
push ax
push cx
push dx
push es
push bx
;控制球的移动速度//每55mm*3移动一次
inc timer
mov ax,3
cmp ax,timer
jne timeJump
mov ax,0
mov timer,ax
;进行初始化
mov ax,0b800h
mov es,ax
;还原乒乓球覆盖的数据
mov ax,160
mov bx,PingPongPointRow
mul bx
mov bx,ax
mov ax,PingPongPointCol
mov cx,2
mul cx
add bx,ax
mov ax,backScreenChar
mov es:[bx],ax
;计算行
mov ax,0
cmp ax,PingPongDirectionUpDown
je eque;
cmp PingPongPointRow,ax
je decc
dec PingPongPointRow
jmp func
decc:
inc PingPongPointRow
mov PingPongDirectionUpDown,ax
jmp func
eque:;正向
mov ax,24
cmp PingPongPointRow,ax
je addc
inc PingPongPointRow
jmp func
addc:
dec PingPongPointRow
mov ax,1
mov PingPongDirectionUpDown,ax
;计算列
func:
mov ax,0
cmp ax,PingPongDirectionLeftRight
je eque1;
cmp PingPongPointCol,ax
je decc1
dec PingPongPointCol
jmp funcD
decc1:
inc PingPongPointCol
mov PingPongDirectionLeftRight,ax
jmp funcD
eque1:;正向
mov ax,79
cmp PingPongPointCol,ax
je addc1
inc PingPongPointCol
jmp funcD
addc1:
dec PingPongPointCol
mov ax,1
mov PingPongDirectionLeftRight,ax
;计算球体位置
funcD:
mov ax,160
mov bx,PingPongPointRow
mul bx
mov bx,ax
mov ax,PingPongPointCol
mov cx,2
mul cx
add bx,ax
mov ax,es:[bx]
;备份球体位置的数据
mov backScreenChar,ax
;显示一个黑底白字的乒乓球
mov ax,074fh
mov es:[bx],ax
;mov es:[bx],al
;mov es:[bx],ah
timeJump: pop bx
pop es
pop dx
pop cx
pop ax
ret
disp endp
start:
mov dx ,offset welcome
mov ah ,09h;
int 21h;显示欢迎语 DS:DX=字符串 '$'结束字符串
;初始化乒乓球位置属性
mov ax,0
mov PingPongDirectionUpDown,ax;初始化乒乓球方向上下
mov PingPongDirectionLeftRight,ax;初始化乒乓球方向左右
mov PingPongPointCol,ax;初始化乒乓球行位置
mov PingPongPointRow,ax;初始化乒乓球列位置
mov timer,ax;初始化时间计次--控制球的运行速度
;备份第一行第一列数据,因为乒乓球显示之前会先还原上个乒乓球覆盖的数据
mov ax,0b800h
mov es,ax
mov ax,es:0;
mov backScreenChar,ax;
;可以启用下面的代码在屏幕第一行第一列初始一个乒乓球
;显示一个黑底白字的乒乓球
;mov ax,074fh
;mov es:[bx],ax
;如果想要调试可以使用下面代码跟踪进乒乓球运算程序
;mov cx,500
;jm:call disp
;loop jm
mov ax ,351Ch
int 21h;读取中断向量 返回值ES:BX=中断向量
mov word ptr old_int , bx
mov word ptr old_int[2] , es
mov dx , offset TSR
push cs
pop ds
mov ax ,251Ch
int 21h;设置中断向量 DS:DX=中断向量
mov dx , offset start
int 27h;驻留程序
code ends
end main
环境要求
系统:WindowsXp 32位
编译约定
源码文件名: t.asm。后面用到的t.asm都代表源码文件。
编译命令
masm命令:masm t.asm(此时会生成t.obj文件)
link命令;link t.obj (此时会生成t.exe文件)
exe2bin命令:exe2bin t.exe t.com (此时会生成t.com文件)