Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 'Written by Sixem
- Public Captcha_ID As String = Nothing
- Public Function Send_Captcha(ByVal Key As String, ByVal Captcha_Path As String)
- Captcha_ID = Nothing
- Dim Image_ As Image = Image.FromFile(Captcha_Path)
- 'Add System.Web as reference
- Dim Base64 As String = System.Web.HttpUtility.UrlEncode(ImageToBase64String(Image_, ImageFormat.Png))
- Dim Push As String = Post_Data(String.Format("method=base64&key={0}&body={1}", Key, Base64), "http://antigate.com/in.php")
- Dim CID As String = Push.Split("|").GetValue(1)
- Captcha_ID = CID
- Return CID
- End Function
- Public Function Captcha_Status(ByVal Key As String, ByVal CID As String)
- Dim request As HttpWebRequest = DirectCast(WebRequest.Create(String.Format("http://antigate.com/res.php?key={0}&action=get&id={1}", Key, CID)), HttpWebRequest)
- Dim response As HttpWebResponse = DirectCast(request.GetResponse(), HttpWebResponse)
- Dim reader As New StreamReader(response.GetResponseStream())
- Return reader.ReadToEnd
- End Function
- Public Function Post_Data(ByVal Post As String, ByVal URL As String)
- Dim postData As String = Post
- Dim encoding As New UTF8Encoding
- Dim byteData As Byte() = encoding.GetBytes(postData)
- Dim postReq As HttpWebRequest = DirectCast(WebRequest.Create(URL), HttpWebRequest)
- postReq.Method = "POST"
- postReq.KeepAlive = True
- postReq.ContentType = "application/x-www-form-urlencoded"
- postReq.Referer = URL
- postReq.UserAgent = "Mozilla/5.0 (Windows; U; Windows NT 6.1; ru; rv:1.9.2.3) Gecko/20100401 Firefox/4.0 (.NET CLR 3.5.30729)"
- postReq.ContentLength = byteData.Length
- Dim postreqstream As Stream = postReq.GetRequestStream()
- postreqstream.Write(byteData, 0, byteData.Length)
- postreqstream.Close()
- Dim postresponse As HttpWebResponse
- postresponse = DirectCast(postReq.GetResponse(), HttpWebResponse)
- Dim postreqreader As New StreamReader(postresponse.GetResponseStream())
- Return postreqreader.ReadToEnd
- End Function
- Public Shared Function ImageToBase64String(ByVal image As Image, ByVal imageFormat As Imaging.ImageFormat)
- Using memStream As New MemoryStream
- image.Save(memStream, imageFormat)
- Dim result As String = Convert.ToBase64String(memStream.ToArray())
- memStream.Close()
- Return result
- End Using
- End Function
Advertisement
Add Comment
Please, Sign In to add comment