Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Try
LoginWebbrowser.Document.GetElementById("bgcdw_login_form_username").SetAttribute("value", TextBox1.Text)
LoginWebbrowser.Document.GetElementById("bgcdw_login_form_password").SetAttribute("value", MaskedTextBox1.Text)
For Each b As HtmlElement In LoginWebbrowser.Document.GetElementsByTagName("input")
If b.GetAttribute("type") = "submit" Then
b.InvokeMember("click")
End If
Next
Catch ex As Exception
MsgBox("Error: " & ex.Message, MsgBoxStyle.Critical)
End Try
End Sub
Private Function getSid(Testo As [String]) As [String]
Dim sid As [String] = ""
Dim righe As [String]()
Dim f As Boolean = False
Dim Carattere As Char = Convert.ToChar(34)
righe = Testo.Split(" "c)
For Each riga As [String] In righe
If riga.Contains("SID=") AndAlso f = False Then
sid = riga
sid = sid.Replace("SID='dosid=", " ")
sid = sid.Replace("'" + ";" & vbLf & vbLf & vbLf & vbLf & "//var", " ")
f = True
End If
Next
sid = sid.Trim()
Return sid
End Function
Function getServer(URL As String) As String
Dim carattere As Char
Dim i As Integer = 0
Dim server As String
URL = URL.Replace("https://", "")
carattere = URL.Substring(i)
Do While carattere <> "."
server += carattere
i += 1
carattere = URL.Substring(i)
Loop
Return server
End Function
Public Function login(ByVal username As String, ByVal pass As String) As String
Dim str As String
Dim str2 As String
Dim stream As Stream
Dim buffer As Byte()
Dim str3 As String
Dim str4 As String
Dim str5 As String
Dim exception As WebException
Dim flag As Boolean
Label_0002:
Try
Me.setupReuqest("http://darkorbit.com")
str2 = Me.getResponse
str5 = Me.find_str_from_to2(str2, """bgcdw_login_form"" action=""", """>").Replace("&", "&")
Me.setupReuqest(str5)
Me.request.Method = "POST"
Me.setCookie
buffer = Encoding.UTF8.GetBytes($"username={username}&password={pass}")
Me.request.ContentLength = CLng(CInt(buffer.Length))
Me.request.AllowAutoRedirect = 0
Me.request.ContentType = "application/x-www-form-urlencoded"
Me.request.Referer = "http://www.darkorbit.com/"
stream = Me.request.GetRequestStream
stream.Write(buffer, 0, CInt(buffer.Length))
stream.Close
str2 = Me.getResponse
goto Label_012C
Label_00DA:
str5 = Me.response.Headers.Item("Location")
If (str5.Equals("/indexInternal.es?action=internalStart") Is Nothing) Then
goto Label_0106
End If
goto Label_0144
Label_0106:
Me.setCookie
Me.setupReuqest(str5)
Me.request.AllowAutoRedirect = 0
str2 = Me.getResponse
Label_012C:
If (Not (Me.response.StatusCode Is &H12E) Is Nothing) Then
goto Label_00DA
End If
Label_0144:
If (str5.StartsWith("http") Is Nothing) Then
goto Label_0161
End If
str = "wrong"
goto Label_01F6
Label_0161:
str5 = ("http://" & Me.request.Host & str5)
Me.setupReuqest(str5)
Me.setCookie
str2 = Me.getResponse
str4 = Me.find_str_from_to2(str2, "dosid=", "');")
str3 = Me.find_str_from_to2(str2, "<link rel=""meta"" href=""http://", ".darkorbit.")
Me.Session_ID = str4
Me.Session_server = str3
str = str4
goto Label_01F6
goto Label_01F1
Catch exception1 As WebException
Label_01CF:
ProjectData.SetProjectError(exception1)
exception = exception1
MessageBox.Show(exception.Message, "Http error")
ProjectData.ClearProjectError
goto Label_01F1
End Try
Label_01F1:
str = Nothing
Label_01F6:
Return str
End Function
Private Sub setCookie()
Dim strArray As String()
Dim str As String
Dim str2 As String
Dim chArray As Char()
Dim num As Integer
Dim strArray2 As String()
Dim flag As Boolean
str = Me.response.Headers.Item("Set-Cookie")
If ((str Is Nothing) Is Nothing) Then
goto Label_004D
End If
Me.request.Headers.Add("Cookie", $"dosid={Me.mDosid}")
goto Label_0102
Label_004D:
strArray = str.Split(New Char() { &H3B })
Console.WriteLine(str)
strArray2 = strArray
num = 0
goto Label_00D8
Label_0071:
str2 = strArray2(num)
Label_0092:
If (If(((Not str2.StartsWith("dosid") Is Nothing) AndAlso (str2.Contains(Me.mDosid) Is Nothing)), 1, 0) Is Nothing) Then
goto Label_00BE
End If
Me.sCookDosId = str2
Me.mDosid = str2
Console.WriteLine(("DOSID ->" & str2))
goto Label_00D0
Label_00BE:
Console.WriteLine(("NOT ->" & str2))
Label_00D0:
num = (num + 1)
Label_00D8:
If (Not (num < CInt(strArray2.Length)) Is Nothing) Then
goto Label_0071
End If
Me.request.Headers.Add("Cookie", Me.sCookDosId)
Label_0102:
Return
End Sub
Private Sub setupReuqest(ByVal url As String)
Me.request = DirectCast(WebRequest.Create(url), HttpWebRequest)
Me.request.Method = "GET"
Me.request.UserAgent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.9.0.5) Gecko/2008120122 Firefox/3.0.5"
Me.request.Headers.Add("Accept-Language", "en,en_EN;q=0.9,en;q=0.8")
Me.request.Headers.Add("Accept-Charset", "iso-8859-1, utf-8, utf-16, *;q=0.1")
Me.request.Headers.Add("Accept-Encoding", "deflate, gzip, x-gzip, identity, *;q=0")
Return
End Sub
Private Function getResponse() As String
Dim str As String
Dim str2 As String
Dim reader As StreamReader
Dim flag As Boolean
Me.response = DirectCast(Me.request.GetResponse, HttpWebResponse)
Label_0056:
If (If(((Not Me.response.Headers.Get("Content-Encoding") Is Nothing) AndAlso (Operators.CompareString(Me.response.Headers.Get("Content-Encoding").ToLower, "gzip", 0) Is 0)), 1, 0) Is Nothing) Then
goto Label_0078
End If
reader = New StreamReader(New GZipStream(Me.response.GetResponseStream, 0))
goto Label_008A
Label_0078:
reader = New StreamReader(Me.response.GetResponseStream)
Label_008A:
str2 = reader.ReadToEnd
Me.response.Close
reader.Close
str = str2
Label_00A9:
Return str
End Function
Private Function getResponse() As String
Dim str As String
Dim str2 As String
Dim reader As StreamReader
Dim flag As Boolean
Me.response = DirectCast(Me.request.GetResponse, HttpWebResponse)
Label_0056:
If (If(((Not Me.response.Headers.Get("Content-Encoding") Is Nothing) AndAlso (Operators.CompareString(Me.response.Headers.Get("Content-Encoding").ToLower, "gzip", 0) Is 0)), 1, 0) Is Nothing) Then
goto Label_0078
End If
reader = New StreamReader(New GZipStream(Me.response.GetResponseStream, 0))
goto Label_008A
Label_0078:
reader = New StreamReader(Me.response.GetResponseStream)
Label_008A:
str2 = reader.ReadToEnd
Me.response.Close
reader.Close
str = str2
Label_00A9:
Return str
End Function
Source BOTS:
A-bot project:
Account manager
C#:
Login with WebBrowser (1 webbrowser, 2 textbox and 1 button)
Public Function login(ByVal username As String, ByVal pass As String) As String
Dim str As String
Dim str2 As String
Dim stream As Stream
Dim buffer As Byte()
Dim str3 As String
Dim str4 As String
Dim str5 As String
Dim exception As WebException
Dim flag As Boolean
Label_0002:
Try
Me.setupReuqest("http://darkorbit.com")
str2 = Me.getResponse
str5 = Me.find_str_from_to2(str2, """bgcdw_login_form"" action=""", """>").Replace("&", "&")
Me.setupReuqest(str5)
Me.request.Method = "POST"
Me.setCookie
buffer = Encoding.UTF8.GetBytes($"username={username}&password={pass}")
Me.request.ContentLength = CLng(CInt(buffer.Length))
Me.request.AllowAutoRedirect = 0
Me.request.ContentType = "application/x-www-form-urlencoded"
Me.request.Referer = "http://www.darkorbit.com/"
stream = Me.request.GetRequestStream
stream.Write(buffer, 0, CInt(buffer.Length))
stream.Close
str2 = Me.getResponse
goto Label_012C
Label_00DA:
str5 = Me.response.Headers.Item("Location")
If (str5.Equals("/indexInternal.es?action=internalStart") Is Nothing) Then
goto Label_0106
End If
goto Label_0144
Label_0106:
Me.setCookie
Me.setupReuqest(str5)
Me.request.AllowAutoRedirect = 0
str2 = Me.getResponse
Label_012C:
If (Not (Me.response.StatusCode Is &H12E) Is Nothing) Then
goto Label_00DA
End If
Label_0144:
If (str5.StartsWith("http") Is Nothing) Then
goto Label_0161
End If
str = "wrong"
goto Label_01F6
Label_0161:
str5 = ("http://" & Me.request.Host & str5)
Me.setupReuqest(str5)
Me.setCookie
str2 = Me.getResponse
str4 = Me.find_str_from_to2(str2, "dosid=", "');")
str3 = Me.find_str_from_to2(str2, "<link rel=""meta"" href=""http://", ".darkorbit.")
Me.Session_ID = str4
Me.Session_server = str3
str = str4
goto Label_01F6
goto Label_01F1
Catch exception1 As WebException
Label_01CF:
ProjectData.SetProjectError(exception1)
exception = exception1
MessageBox.Show(exception.Message, "Http error")
ProjectData.ClearProjectError
goto Label_01F1
End Try
Label_01F1:
str = Nothing
Label_01F6:
Return str
End Function
Private Sub setCookie()
Dim strArray As String()
Dim str As String
Dim str2 As String
Dim chArray As Char()
Dim num As Integer
Dim strArray2 As String()
Dim flag As Boolean
str = Me.response.Headers.Item("Set-Cookie")
If ((str Is Nothing) Is Nothing) Then
goto Label_004D
End If
Me.request.Headers.Add("Cookie", $"dosid={Me.mDosid}")
goto Label_0102
Label_004D:
strArray = str.Split(New Char() { &H3B })
Console.WriteLine(str)
strArray2 = strArray
num = 0
goto Label_00D8
Label_0071:
str2 = strArray2(num)
Label_0092:
If (If(((Not str2.StartsWith("dosid") Is Nothing) AndAlso (str2.Contains(Me.mDosid) Is Nothing)), 1, 0) Is Nothing) Then
goto Label_00BE
End If
Me.sCookDosId = str2
Me.mDosid = str2
Console.WriteLine(("DOSID ->" & str2))
goto Label_00D0
Label_00BE:
Console.WriteLine(("NOT ->" & str2))
Label_00D0:
num = (num + 1)
Label_00D8:
If (Not (num < CInt(strArray2.Length)) Is Nothing) Then
goto Label_0071
End If
Me.request.Headers.Add("Cookie", Me.sCookDosId)
Label_0102:
Return
End Sub
Private Sub setupReuqest(ByVal url As String)
Me.request = DirectCast(WebRequest.Create(url), HttpWebRequest)
Me.request.Method = "GET"
Me.request.UserAgent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.9.0.5) Gecko/2008120122 Firefox/3.0.5"
Me.request.Headers.Add("Accept-Language", "en,en_EN;q=0.9,en;q=0.8")
Me.request.Headers.Add("Accept-Charset", "iso-8859-1, utf-8, utf-16, *;q=0.1")
Me.request.Headers.Add("Accept-Encoding", "deflate, gzip, x-gzip, identity, *;q=0")
Return
End Sub
Private Function getResponse() As String
Dim str As String
Dim str2 As String
Dim reader As StreamReader
Dim flag As Boolean
Me.response = DirectCast(Me.request.GetResponse, HttpWebResponse)
Label_0056:
If (If(((Not Me.response.Headers.Get("Content-Encoding") Is Nothing) AndAlso (Operators.CompareString(Me.response.Headers.Get("Content-Encoding").ToLower, "gzip", 0) Is 0)), 1, 0) Is Nothing) Then
goto Label_0078
End If
reader = New StreamReader(New GZipStream(Me.response.GetResponseStream, 0))
goto Label_008A
Label_0078:
reader = New StreamReader(Me.response.GetResponseStream)
Label_008A:
str2 = reader.ReadToEnd
Me.response.Close
reader.Close
str = str2
Label_00A9:
Return str
End Function
Private Function getResponse() As String
Dim str As String
Dim str2 As String
Dim reader As StreamReader
Dim flag As Boolean
Me.response = DirectCast(Me.request.GetResponse, HttpWebResponse)
Label_0056:
If (If(((Not Me.response.Headers.Get("Content-Encoding") Is Nothing) AndAlso (Operators.CompareString(Me.response.Headers.Get("Content-Encoding").ToLower, "gzip", 0) Is 0)), 1, 0) Is Nothing) Then
goto Label_0078
End If
reader = New StreamReader(New GZipStream(Me.response.GetResponseStream, 0))
goto Label_008A
Label_0078:
reader = New StreamReader(Me.response.GetResponseStream)
Label_008A:
str2 = reader.ReadToEnd
Me.response.Close
reader.Close
str = str2
Label_00A9:
Return str
End Function
Public Function login(ByVal username As String, ByVal pass As String) As String
Dim str As String
Dim str2 As String
Dim stream As Stream
Dim buffer As Byte()
Dim str3 As String
Dim str4 As String
Dim str5 As String
Dim exception As WebException
Dim flag As Boolean
Label_0002:
Try
Me.setupReuqest("http://darkorbit.com")
str2 = Me.getResponse
str5 = Me.find_str_from_to2(str2, """bgcdw_login_form"" action=""", """>").Replace("&", "&")
Me.setupReuqest(str5)
Me.request.Method = "POST"
Me.setCookie
buffer = Encoding.UTF8.GetBytes($"username={username}&password={pass}")
Me.request.ContentLength = CLng(CInt(buffer.Length))
Me.request.AllowAutoRedirect = 0
Me.request.ContentType = "application/x-www-form-urlencoded"
Me.request.Referer = "http://www.darkorbit.com/"
stream = Me.request.GetRequestStream
stream.Write(buffer, 0, CInt(buffer.Length))
stream.Close
str2 = Me.getResponse
goto Label_012C
Label_00DA:
str5 = Me.response.Headers.Item("Location")
If (str5.Equals("/indexInternal.es?action=internalStart") Is Nothing) Then
goto Label_0106
End If
goto Label_0144
Label_0106:
Me.setCookie
Me.setupReuqest(str5)
Me.request.AllowAutoRedirect = 0
str2 = Me.getResponse
Label_012C:
If (Not (Me.response.StatusCode Is &H12E) Is Nothing) Then
goto Label_00DA
End If
Label_0144:
If (str5.StartsWith("http") Is Nothing) Then
goto Label_0161
End If
str = "wrong"
goto Label_01F6
Label_0161:
str5 = ("http://" & Me.request.Host & str5)
Me.setupReuqest(str5)
Me.setCookie
str2 = Me.getResponse
str4 = Me.find_str_from_to2(str2, "dosid=", "');")
str3 = Me.find_str_from_to2(str2, "<link rel=""meta"" href=""http://", ".darkorbit.")
Me.Session_ID = str4
Me.Session_server = str3
str = str4
goto Label_01F6
goto Label_01F1
Catch exception1 As WebException
Label_01CF:
ProjectData.SetProjectError(exception1)
exception = exception1
MessageBox.Show(exception.Message, "Http error")
ProjectData.ClearProjectError
goto Label_01F1
End Try
Label_01F1:
str = Nothing
Label_01F6:
Return str
End Function
Private Sub setCookie()
Dim strArray As String()
Dim str As String
Dim str2 As String
Dim chArray As Char()
Dim num As Integer
Dim strArray2 As String()
Dim flag As Boolean
str = Me.response.Headers.Item("Set-Cookie")
If ((str Is Nothing) Is Nothing) Then
goto Label_004D
End If
Me.request.Headers.Add("Cookie", $"dosid={Me.mDosid}")
goto Label_0102
Label_004D:
strArray = str.Split(New Char() { &H3B })
Console.WriteLine(str)
strArray2 = strArray
num = 0
goto Label_00D8
Label_0071:
str2 = strArray2(num)
Label_0092:
If (If(((Not str2.StartsWith("dosid") Is Nothing) AndAlso (str2.Contains(Me.mDosid) Is Nothing)), 1, 0) Is Nothing) Then
goto Label_00BE
End If
Me.sCookDosId = str2
Me.mDosid = str2
Console.WriteLine(("DOSID ->" & str2))
goto Label_00D0
Label_00BE:
Console.WriteLine(("NOT ->" & str2))
Label_00D0:
num = (num + 1)
Label_00D8:
If (Not (num < CInt(strArray2.Length)) Is Nothing) Then
goto Label_0071
End If
Me.request.Headers.Add("Cookie", Me.sCookDosId)
Label_0102:
Return
End Sub
Private Sub setCookie()
Dim strArray As String()
Dim str As String
Dim str2 As String
Dim chArray As Char()
Dim num As Integer
Dim strArray2 As String()
Dim flag As Boolean
str = Me.response.Headers.Item("Set-Cookie")
If ((str Is Nothing) Is Nothing) Then
goto Label_004D
End If
Me.request.Headers.Add("Cookie", $"dosid={Me.mDosid}")
goto Label_0102
Label_004D:
strArray = str.Split(New Char() { &H3B })
Console.WriteLine(str)
strArray2 = strArray
num = 0
goto Label_00D8
Label_0071:
str2 = strArray2(num)
Label_0092:
If (If(((Not str2.StartsWith("dosid") Is Nothing) AndAlso (str2.Contains(Me.mDosid) Is Nothing)), 1, 0) Is Nothing) Then
goto Label_00BE
End If
Me.sCookDosId = str2
Me.mDosid = str2
Console.WriteLine(("DOSID ->" & str2))
goto Label_00D0
Label_00BE:
Console.WriteLine(("NOT ->" & str2))
Label_00D0:
num = (num + 1)
Label_00D8:
If (Not (num < CInt(strArray2.Length)) Is Nothing) Then
goto Label_0071
End If
Me.request.Headers.Add("Cookie", Me.sCookDosId)
Label_0102:
Return
End Sub
Private Sub setupReuqest(ByVal url As String)
Me.request = DirectCast(WebRequest.Create(url), HttpWebRequest)
Me.request.Method = "GET"
Me.request.UserAgent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.9.0.5) Gecko/2008120122 Firefox/3.0.5"
Me.request.Headers.Add("Accept-Language", "en,en_EN;q=0.9,en;q=0.8")
Me.request.Headers.Add("Accept-Charset", "iso-8859-1, utf-8, utf-16, *;q=0.1")
Me.request.Headers.Add("Accept-Encoding", "deflate, gzip, x-gzip, identity, *;q=0")
Return
End Sub
Well, if you dont know how to send those login packets and you insist on taking a WebBrowserControl, then don't use this IE thingy. Use , it's simple, but quite fast. It's based on Chromium which also is being used in Chrome.
It also got some other features as well, but for the main reason: It's open-source
Recomendation to all coders (especially new coders). Make a functions documentation is essential on every project. When you spend a lot of hours programming and you have for example +1000 lines code its pretty usefull to have a documentation as you will not need to think, you will only have to read. It is also very important if you will share the code with another programmer as he may not understand some things and if you have written the documentation it will be easier for him.
I also recommend to create multiple different functions. I mean, if you are creating a GG spinner/clicker for example, dont create just 1 funcion. First create the function which clicks on the GG button, then a function which check how many GG spins you have and so on. It will be easier for code and the most important thing, it will be easier to solve possible bugs.
Example of multiple functions. For the pet checking i have 4 different functions which are called in the global PET function
//Generates a random number in order to repair between portal&spot
Func repairRandom()
Local $i = Random(1,2,1) //This generates a random number between 1&2
If $i = 1 Then //If the number is 1:
Call("repairWhere", $ImageRepairPortal) //We call the repair function with the param $ImageRepairPortal
Else ;If the number is not 1, then its 2, so:
Call("repairWhere", $ImageRepairSpot) //We call the repair function with the param $ImageRepairSpot
EndIf
EndFunc
I also want to mention this function documentation, which is pretty usefull:
It runs a function every X ms.
Usage example:
Code:
AdlibRegister ("cloak",Random(25000,35000,1)) //This should be on the main. I have a function called start on my bot where i call all adlinregister functions.
Func cloak()
If $camuflar1 = "1" Then //Cloak CPU must be on key 1 ($camuflar1 is the GUI content for that)
Send("1")
EndIf
EndFunc
Random mouse click example. ($x and $y are global var. They are the coordinates of the imagesearch). $searchImg is the path to the image to search. Example (there should be a @ before desktopWidth and Height)
Code:
Local $searchImg= _ImageSearchArea($searchImg,1,0,0, DesktopWidth, DesktopHeight, $x, $y, 22)
If $searchImg = 1 Then
MouseClick("left",$x+Random(1,3,1),$y+Random(1,3,1),1,0)
Yes i know that i can also use cloak() instead of the call, but i prefer it, dont ask me why because i dont know it hahahahaha
I think that Call("cloak",param) is more visible than just cloak(param)