• Welcome to Valhalla Legends Archive.
 

Socks4

Started by MichaeL, March 30, 2004, 05:47 PM

Previous topic - Next topic

MichaeL

I'm posting this topic again, since I did not get much feedback from it last time.  Here it is: I need to have the option of connecting my battle.net bot (winbot) via socks4 proxy server.  Can anyone help with this.

Thank you.

Grok

Dude, you got 9 replies last time.  What was wrong with them?

Imperceptus

Quote from: MichaeL on March 30, 2004, 05:47 PM
I need to have the option of connecting my battle.net bot (winbot) via socks4 proxy server.  

http://archive.socks.permeo.com/protocol/socks4.protocol

Could try looking at firebot source.
Or go to google and search for SOCKSV4
http://twistedmatrix.com/documents/current/api/twisted.protocols.socks.html
Quote from: Hazard on August 07, 2003, 03:15 PM
Highlight your entire code. Press the delete key. Start over again using Cuphead's CSB tutorial and work your way from their rather than raping code from downloaded sources meant purely for learning purposes. If this does not fix the problem, uninstall Visual Basic and get a new hobby. I suggest Cricket.

FuzZ

#3
I just got mine successfully working.

Here's what I do.

I use a connect function.
In it I have

If BNet.Proxy Then
       frmBNet.sckBNet.RemoteHost = BNet.ProxyIP
       frmBNet.sckBNet.RemotePort = 1080
       frmBNet.sckBNet.Connect
       AddChat frmBNet.rtbChat, vbGreen, "SOCKS -> Connecting to " & frmBNet.sckBNet.RemoteHostIP
       Exit Function
   End If


Then, in my sockets connect event handler I have.

If BNet.Proxy = True Then
       Dim splt() As String, str As String, i As Integer
       BNet.Server = LCase$(BNet.Server)
       splt = Split(BNet.Server, ".")
       If IsNumeric(splt(0)) = False Then
           ' If server is not an ip.
           Dim a
           a = GetIPFromHostName(BNet.Server)
           splt = Split(a, ".")
       End If
       For i = 0 To UBound(splt)
           str = str & Chr(CStr(splt(i)))
       Next i
       sckBnet.SendData Chr(&H4) & Chr(&H1) & Chr(&H17) & Chr(&HE0) & str & "anonymous" & Chr(&H0)
       AddChat frmBNet.rtbChat, vbGreen, "Connecting to " & BNet.Server
       Exit Sub
   Else
       AddChat  frmBNet.rtbChat, vbGreen, "Connected to " & frmMain.sckBnet.RemoteHost
       Packet0x50
       Q.QClear
   End If


And my sockets DataArrival event handler


If BNet.Proxy And Mid$(TempRecv, 1, 1) = Chr(&H0) Then
       Select Case Mid(TempRecv, 2, 1)
           Case Chr(&H5A)
               AddChat frmBNet.rtbChat, vbGreen, "SOCKS -> Request granted."
               Packet0x50
               Exit Sub
           Case Chr(&H5B)
               AddChat frmBNet.rtbChat, vbRed, "SOCKS -> Request Rejected or Failed."
               sckBnet.Close
               Exit Sub
           Case Chr(&H5C)
               AddChat frmBNet.rtbChat, vbRed, "SOCKS -> Request Rejected because SOCKS server cannot IDENT on the client."
               sckBnet.Close
               Exit Sub
           Case Chr(&H5D)
               AddChat  frmBNet.rtbChat, vbRed, "SOCKS -> Request Rejected because the Client Program and the ID Report Different User-IDs."
               sckBnet.Close
               Exit Sub
       End Select
   End If


Edit-> From here

'SoupBotLoD code
Public Declare Function gethostbyname Lib "wsock32" _
 (ByVal hostname As String) As Long

Public Function GetIPFromHostName(ByVal sHostName As String) As String
  Dim nbytes As Long
  Dim ptrHosent As Long
  Dim ptrName As Long
  Dim ptrAddress As Long
  Dim ptrIPAddress As Long
  Dim sAddress As String
 
  sAddress = Space$(4)

   DoEvents
  ptrHosent = gethostbyname(sHostName & vbNullChar)

  If ptrHosent <> 0 Then
     ptrAddress = ptrHosent + 12
   
     CopyMemory ptrAddress, ByVal ptrAddress, 4
     CopyMemory ptrIPAddress, ByVal ptrAddress, 4
     CopyMemory ByVal sAddress, ByVal ptrIPAddress, 4

     GetIPFromHostName = IPToText(sAddress)

  End If
 
End Function
Private Function IPToText(ByVal IPAddress As String) As String

  IPToText = CStr(Asc(IPAddress)) & "." & _
             CStr(Asc(Mid$(IPAddress, 2, 1))) & "." & _
             CStr(Asc(Mid$(IPAddress, 3, 1))) & "." & _
             CStr(Asc(Mid$(IPAddress, 4, 1)))
             
End Function

These two functions are from SoupBotLoD source
Edit->To here

I used FireBot's source code to base mine off from.

If you want FireBot 1.8 source
www.bloodynub.com/files/bnet/bots/srcs/
(yes i realize i borrow alot of code, but i assure you that i DO write my own :P)
Hope this can help.