Hace unos días me motive con esto del VBS. Tiene mucho que mejorar, lo se, agradecería solo criticas constructivas, tampoco le voy a dedicar mas tiempo. Dejo parte de las URL porque no se como esta la normativa. El wget lo descarga porque tenia intención de hacer mas cosas pero aquí quedo la cosa.
Dim wDir
Dim url7z
Dim urlTor
Dim urlWget
Dim urlPolipo
wDir = pGetEnv("%USERPROFILE%") & "\YoYo\"
url7z = "http://www.7-zip.org/*/7z1604.exe"
urlTor = "https://www.torpro*/*/tor-win32-0.3.1.7.zip"
urlWget = "https://eternally*/*/wget.exe"
urlPolipo = "https://www.ir*/*/polipo-20140107-win32.zip"
pMkDir wDir
If Not pFileExist(wDir & "7z\7z.exe") Then
If pDownload(url7z, wDir) then
pMkDir wDir & "7z"
pExecute wDir & "7z1604.exe /S /D=" & wDir & "7z\", True
pDeleteFile wDir & "7z1604.exe"
End if
End If
If Not pFileExist(wDir & "tor\tor.exe") Then
If pDownload(urlTor, wDir) then
pUnZip wDir & "tor-win32-0.3.1.7.zip", wDir & "tor"
pDeleteFile wDir & "tor-win32-0.3.1.7.zip"
End if
End If
If Not pFileExist(wDir & "wget\wget.exe") Then
pMkDir wDir & "wget"
pDownload urlWget, wDir & "wget\"
End If
pExecute wDir & "tor\tor.exe", False
If Not pFileExist(wDir & "polipo\polipo.exe") Then
If pDownload(urlPolipo, wDir) then
pUnZip wDir & "polipo-20140107-win32.zip", wDir & "polipo"
pDeleteFile wDir & "polipo-20140107-win32.zip"
End if
End If
pExecute wDir & "polipo\polipo.exe socksParentProxy=localhost:9050 socksProxyType=socks5", False
WScript.Sleep 2000
MsgBox pTorGetPage("http://uj3wazyk5u4hnvtk.onion/")
pExecute "TSKILL POLIPO", False
pExecute "TSKILL TOR", False
Function pFileExist(pathFile)
Dim objFSO
Set objFSO = CreateObject("Scripting.FileSystemObject")
pFileExist = objFSO.FileExists(pathFile)
End Function
Function pDownload(strLink, pStrSaveTo)
strSaveName = Mid(strLink, InStrRev(strLink,"/") + 1, Len(strLink))
strSaveTo = pStrSaveTo + strSaveName
Set objHTTP = CreateObject("WinHttp.WinHttpRequest.5.1")
objHTTP.Open "GET", strLink, False
' objHTTP.SetCredentials "User", "Password", HTTPREQUEST_SETCREDENTIALS_FOR_SERVER
objHTTP.Send
Set objFSO = CreateObject("Scripting.FileSystemObject")
If objFSO.FileExists(strSaveTo) Then
objFSO.DeleteFile(strSaveTo)
End If
If objHTTP.Status = 200 Then
Dim objStream
Set objStream = CreateObject("ADODB.Stream")
With objStream
.Type = 1 'adTypeBinary
.Open
.Write objHTTP.ResponseBody
.SaveToFile strSaveTo
.Close
End With
Set objStream = Nothing
End If
Set objHTTP = Nothing
pDownload = False
If objFSO.FileExists(strSaveTo) Then
pDownload = True
End If
Set objFSO = Nothing
End Function
Sub pMkDir(pDirectory)
Dim oFSO
Dim directory
Dim sDirectory
directory = pDirectory
Set oFSO = CreateObject("Scripting.FileSystemObject")
If Mid(directory, Len(directory), 1) = "\" Then
directory = Left(directory, Len(directory)-1)
End If
If Mid(directory, Len(directory), 1) <> ":" And Mid(directory, Len(directory), 1) <> "%" Then
sDirectory = Left(directory, InStrRev(directory, "\") - 1)
If Not oFSO.FolderExists(sDirectory) Then
pMkDir sDirectory
End If
If Not oFSO.FolderExists(directory) Then
oFSO.CreateFolder directory
End If
End If
Set oFSO = Nothing
End Sub
Sub pExecute(pathExe, wait)
Dim objShell
Dim objFSO
Set objShell = WScript.CreateObject("WScript.Shell")
objShell.Run "cmd.exe /c " & Chr(34) & pathExe & Chr(34), 0, wait
Set objShell = Nothing
End Sub
Sub pDeleteFile(pahtFile)
Dim oFSO
Set oFSO = CreateObject("Scripting.FileSystemObject")
If oFSO.FileExists(pahtFile) Then
oFSO.DeleteFile pahtFile
End If
Set oFSO = Nothing
End Sub
Sub pUnZip(pathZip, dest)
Dim unZip
unZip = wDir + "7z\7z.exe"
If pFileExist(pathZip) And pFileExist(unZip) Then
pExecute unZip & " e " & pathZip & " -o" & dest, True
End If
End Sub
Function pTorGetPage(strUrl)
Set WinHttpReq = CreateObject("WinHttp.WinHttpRequest.5.1")
WinHttpReq.SetProxy 2, "127.0.0.1:8123"
WinHttpReq.Open "GET", strUrl, False
WinHttpReq.Send
pTorGetPage = WinHttpReq.ResponseText
End Function
Function pGetEnv(strEnv)
Dim oShell
Set oShell = CreateObject("WScript.Shell")
pGetEnv = oShell.ExpandEnvironmentStrings(strEnv)
End Function