原文:http://www.pediy.com/kssd/index.html -- 病毒技术 -- 病毒知识 -- Anti Virus专题
如何编写病毒代码?
首先我把最重要的两个方面列举出来。
1. 处理病毒各个绝对地址的重定位。
2. 所有需调用的api函数地址,均通过动态搜索来获得。
做到以上2点,我们的病毒代码就可以移植到任意的程序中。没错,就和我们写shellcode一样。
先来看一些代码的优化方法:
(1)测试寄存器是否为0
cmp eax,00000000h ; 6 bytes
jz bribriblibli ; 2 bytes (if jz is short)
optimization:
or eax,eax ; 2 bytes
jz bribriblibli ; 2 bytes (if jz is short)
xchg eax,ecx ; 1 byte
jecxz bribriblibli ; 2 bytes (if it is short)
(2)测试寄存器是否为-1
cmp eax,0FFFFFFFFh ; 6 bytes
jz insumision ; 2 bytes (if short)
optimization:
inc eax ; 1 byte
xchg eax,ecx ; 1 byte
jecxz insumision ; 2 bytes (if short)
dec ecx ; 1 byte
inc eax ; 1 byte
jz insumision ; 2 bytes
dec eax

本文探讨了如何编写病毒代码,强调了处理绝对地址重定位和API动态搜索的重要性,同时提供了一些代码优化技巧,如寄存器测试、字符串操作和堆栈管理的优化方法,旨在实现病毒代码的可移植性。
最低0.47元/天 解锁文章
3429

被折叠的 条评论
为什么被折叠?



