omegastripes

simple_host_text_upload_octet_stream.vbs

Nov 29th, 2016
320
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Option Explicit
  2.  
  3. Dim strUplURL, strUplText, strUplStatus, strUplResponse
  4.  
  5. strUplURL = "http://vhost4353.cpsite.ru/upload.php"
  6. strUplText = "TEST STRING" & vbCrLf & "Этот текст загружен c помощью скрипта http://pastebin.com/Z3Yyu7e4"
  7. UploadText strUplURL, strUplText, strUplStatus, strUplResponse
  8. MsgBox strUplStatus & vbCrLf & strUplResponse
  9.  
  10. Sub UploadText(strURL, strText, strStatus, strResponse)
  11.    
  12.     Dim strBoundary, bytPayLoad
  13.    
  14.     On Error Resume Next
  15.     strBoundary = String(6, "-") & Replace(Mid(CreateObject("Scriptlet.TypeLib").Guid, 2, 36), "-", "")
  16.     With CreateObject("ADODB.Stream")
  17.         .Mode = 3
  18.         .Charset = "Windows-1251"
  19.         .Open
  20.         .Type = 2
  21.         .WriteText "--" & strBoundary & vbCrLf
  22.         .WriteText "Content-Disposition: form-data; name=""upload_file""; filename=""content.txt""" & vbCrLf
  23.         .WriteText "Content-Type: octet/stream" & vbCrLf & vbCrLf
  24.         .WriteText strText
  25.         .WriteText vbCrLf & "--" & strBoundary & "--"
  26.         .Position = 0
  27.         .Type = 1
  28.         bytPayLoad = .Read
  29.     End With
  30.     With CreateObject("MSXML2.ServerXMLHTTP")
  31.         .SetTimeouts 0, 60000, 300000, 300000
  32.         .Open "POST", strURL, False
  33.         .SetRequestHeader "Content-type", "multipart/form-data; boundary=" & strBoundary
  34.         .Send bytPayLoad
  35.         If Err.Number <> 0 Then
  36.             strStatus = Err.Description & " (" & Err.Number & ")"
  37.         Else
  38.             strStatus = .StatusText & " (" & .Status & ")"
  39.         End If
  40.         strResponse = .ResponseText
  41.     End With
  42.    
  43. End Sub
Add Comment
Please, Sign In to add comment