-
Notifications
You must be signed in to change notification settings - Fork 515
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
期望能够添加 下载远程文件 和 批量执行的功能 #43
Labels
enhancement
New feature or request
Comments
下载远程文件的功能,本来最初确实在计划中,但是没想到一个好些的UI,所以就搁置了。 |
那我就先这样凑合用吧 >_< let processScript = `
Sub KillProcess(ByVal ProcessName)
DIM oProcMgmt, oProcess
Set oProcMgmt = GetObject("winmgmts:\\\\.\\root\\cimv2")
Set oProcesses = oProcMgmt.ExecQuery("SELECT * FROM win32_process WHERE name='" & ProcessName & "'")
For each oItem in oProcesses
oItem.terminate()
Next
WScript.Sleep(500)
End Sub
Sub StartProcess(ByVal ExeFile)
Dim Wsh
Set Wsh = WScript.CreateObject("WScript.Shell")
Wsh.CurrentDirectory = "${workPath}"
WScript.Sleep(500)
Wsh.Run ExeFile, 0, False
Set Wsh = NoThing
WScript.quit
End Sub
`; let downloadScript = `Dim WorkPath, Fs
Set Fso = CreateObject("Scripting.FileSystemObject")
WorkPath="${workPath}"
If Not Fso.FolderExists(WorkPath) Then
Fso.CreateFolder(WorkPath)
End If
Function HttpDownload(ByVal remoteUrl, ByVal DistPath)
Set Post = CreateObject("Msxml2.XMLHTTP")
Post.Open "GET", remoteUrl, 0
Post.Send()
Set writer = CreateObject("ADODB.Stream")
writer.Mode = 3
writer.Type = 1
writer.Open
writer.Write(Post.responseBody)
writer.SaveToFile DistPath, 2
writer.Close
End Function
Function readBinaryFile(strPath)
With CreateObject("ADODB.Stream")
.Open
.type = 1
.LoadFromFile(strPath)
readBinaryFile = .Read()
.close()
End With
End Function
Function bytesToHex(aBytes)
Dim hexStr, I
for I = 1 to lenb(aBytes)
hexStr = hex(ascb(midb( (aBytes), I, 1)))
if len(hexstr) = 1 then hexStr = "0" & hexStr
bytesToHex = bytesToHex & hexStr
next
End Function
Function md5sum(aBytes)
Dim MD5: Set MD5 = CreateObject("System.Security.Cryptography.MD5CryptoServiceProvider")
MD5.Initialize()
md5sum = MD5.ComputeHash_2((aBytes))
End Function
Sub UnZip(ByVal myZipFile, ByVal myTargetDir)
Set fso = CreateObject("Scripting.FileSystemObject")
If NOT fso.FileExists(myZipFile) Then
Exit Sub
ElseIf fso.GetExtensionName(myZipFile) <> "zip" Then
Exit Sub
ElseIf NOT fso.FolderExists(myTargetDir) Then
fso.CreateFolder(myTargetDir)
End If
Set objShell = CreateObject("Shell.Application")
Set objSource = objShell.NameSpace(myZipFile)
Set objFolderItem = objSource.Items()
Set objTarget = objShell.NameSpace(myTargetDir)
intOptions = 256
objTarget.CopyHere objFolderItem, intOptions
End Sub
REM 文件有更改,删除 重新下载
If Fso.FileExists("${zipFullFilePath}") Then
zipMd5 = bytesToHex(md5sum(readBinaryFile("${zipFullFilePath}")))
If zipMd5 <> "${zipFileMd5sum}" Then
Fso.DeleteFile("${zipFullFilePath}")
Call HttpDownload ("${zipRemoteUrl}", "${zipFullFilePath}")
End If
Else
Call HttpDownload ("${zipRemoteUrl}", "${zipFullFilePath}")
End If
REM 文件有更改,删除 解压
If Fso.FileExists("${exeFullFilePath}") Then
exeMd5 = bytesToHex(md5sum(readBinaryFile("${exeFullFilePath}")))
If exeMd5 <> "${exeFileMd5sum}" Then
Fso.DeleteFile("${exeFullFilePath}")
Call UnZip ("${zipFullFilePath}", WorkPath)
End If
Else
Call UnZip ("${zipFullFilePath}", WorkPath)
End If
`; result = await client.processSearch(item, "wscript.exe")
if (result.length > 0) {
console.log(item.substring(0, 8) +" 更新程序中!")
} else {
result = await client.fileExists(item, vbCommon.defines.exeFullFilePath)
if (result) {
result = await client.processSearch(item, vbCommon.defines.exeFileName)
console.log(item.substring(0, 8) +" 当前启动数:" + result.length)
if (result.length < processNum) {
let startNum = processNum - result.length;
while (startNum > 0) {
await client.runScript(item, vbscript);
console.log(item.substring(0, 8) +" 启动爬虫程序!")
await sleep(1);
startNum --;
}
}
} else {
}
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Please make sure of the following things.
Describe the feature / 需求描述
我这边的场景时爬虫,因为一台一台上传执行太困难,所以找到了这个项目,很惊喜
使用过程中发现了一些问题,所以需要能够批量执行的功能。
期望功能:
Suggested solution / 实现思路
No response
Additional information / 附加说明
下面时使用中遇到的问题,可以忽略哈。。
第一个遇到的问题就是 客户端报毒,这个我用了 Linux 下的
upx
加了个壳子绕过了第二个问题是 要批量执行命令,终端机器系统有 win7 的 不能很好的执行 powershell 脚本,遂用了 vbs,
但是吧。。这东西被 杀软报 Downloader 病毒。。
The text was updated successfully, but these errors were encountered: