• Welcome to Valhalla Legends Archive.
 

[VB] Proxy Support Help

Started by Spilled, September 10, 2005, 11:46 PM

Previous topic - Next topic

Spilled

Adding proxy support to my bot i have ran into a problem, I am using the tutorial that Pianka wrote but i keep getting an unknown response.
Heres my Code:

- My Initiation Packet -


ElseIf UseProxy = True Then
        'We will assume that this connection is for uswest.battle.net
        'on port 6112, although these variables are easy to change
        Dim Send As String, Port As String * 2
        Dim IP As String * 4, Splt() As String
            Send = Chr(&H4)     'Our first byte, the version
            Send = Send & Chr(&H1)  'Our second byte, the command
            'CopyMemory Port, htons(6112), 2
            Port = Left(htons(6112), 2)
            Send = Send & Port  'Next two bytes, the port
            Splt() = Split(GetIPFromHostName(strServer), ".")
            IP = Chr(CInt(Splt(0))) & Chr(CInt(Splt(1))) & Chr(CInt(Splt(2))) & Chr(CInt(Splt(3)))
            Send = Send & IP    'Next four bytes, the IP of "uswest.battle.net"
            Send = Send & Chr(&H0)  'Last null terminating byte for the username that we aren't using
            wSock.SendData Send   'Sending the initiation packet
End If


- My DataArrival -


Dim recv As String
Dim Result As Integer
            wSock.GetData recv        'Get data from socket
            Result = Asc(Mid(recv, 1, 1))   'Extract value of second byte
            Select Case Result
                Case &H5A
                    'Request granted
                        MsgBox "Request granted!"
                Case &H5B
                    'Request rejected or failed
                        MsgBox "rejected!"
                Case &H5C
                    'Request rejected because server cannot connect to identd on the client
                    MsgBox "Server rejected!"
                Case &H5D
                    'Request rejected because usernames did not match
                    MsgBox "Username rejected!"
                Case Else
                    'Unknown response (probably rejected)
                    MsgBox "Unknown response!"
            End Select


I am getting a result of 0. Any ideas?

Hdx

Result = Asc(Mid(recv, 1, 1))   'Extract value of second byte
thats your problem
Your extracting the 1st byte. Not the second, the 1st byte is always zero, so thats it.
~-~(HDX)~-~

Proud host of the JBLS server www.JBLS.org.
JBLS.org Status:
JBLS/BNLS Server Status

Spilled

#2
Ok, i fix that problem

            Result = Asc(Mid(recv, 2, 1))   'Extract value of second byte


Now im getting  a rejected result on every proxy i try using and ive tested the proxies and they are good.
Any ideas?

Spilled

Still unsolved guys. Any ideas? Sorry about the double post didn't want to create new post to get the topic back up top.

l2k-Shadow

Did you try using "anonymous" for the username?
Quote from: replaced on November 04, 2006, 11:54 AM
I dunno wat it means, someone tell me whats ix86 and pmac?
Can someone send me a working bot source (with bnls support) to my email?  Then help me copy and paste it to my bot? ;D
Já jsem byl určenej abych tady žil,
Dával si ovar, křen a k tomu pivo pil.
Tam by ses povídaj jak prase v žitě měl,
Já nechci před nikym sednout si na prdel.

Já nejsem z USA, já nejsem z USA, já vážně nejsem z USA... a snad se proto na mě nezloběj.

Spilled

How would i do that? I was told a username wasn't neccesary.

UserLoser.

Quote from: Spilled[DW] on September 13, 2005, 01:33 AM
How would i do that? I was told a username wasn't neccesary.

For SOCKS4, correct.

In attempt to solve your problem, try swapping these, putting byte #4 first, then #3, #2, #1:

IP = Chr(CInt(Splt(3))) & Chr(CInt(Splt(2))) & Chr(CInt(Splt(1))) & Chr(CInt(Splt(0)))


Or this basically does it for you:

IP = inet_addr(GetIPFromHostName(strServer))

Spilled

#7
Quote from: UserLoser on September 13, 2005, 07:35 AM
Quote from: Spilled[DW] on September 13, 2005, 01:33 AM
How would i do that? I was told a username wasn't neccesary.

For SOCKS4, correct.

In attempt to solve your problem, try swapping these, putting byte #4 first, then #3, #2, #1:

IP = Chr(CInt(Splt(3))) & Chr(CInt(Splt(2))) & Chr(CInt(Splt(1))) & Chr(CInt(Splt(0)))


Or this basically does it for you:

IP = inet_addr(GetIPFromHostName(strServer))

Hrmm, i tried swapping the byte's as you said, but still unsuccessful and ive tried multiple proxies. Knowing they are still alive. Any more ideas userloser?

UserLoser.

Using my method, still try that but do htons(57367)

Spilled


Port = Left(htons(57367), 2)


Causes an overflow.

NetNX

1)Specifiy a username
2)I've seen this code before...
3)Try a LONG

Spilled

#11
Quote from: NetNX on September 13, 2005, 09:10 PM
1)Specifiy a username
2)I've seen this code before...
3)Try a LONG

Ive changed port variable to long and tried that before. Still causing an overflow when i use htons(57367) like UserLoser said.
Any more ideas? I appreciate the help so far!

Edit:
Current Initiation packet coding:

        'We will assume that this connection is for uswest.battle.net
        'on port 6112, although these variables are easy to change
        Dim Send As String, Port As String * 2
        Dim IP As String * 4, Splt() As String
            Send = Chr(&H4)     'Our first byte, the version
            Send = Send & Chr(&H1)  'Our second byte, the command
            'CopyMemory Port, htons(6112), 2
            Port = Left(htons(57367), 2)
            Send = Send & Port  'Next two bytes, the port
            Splt() = Split(GetIPFromHostName(strServer), ".")
            IP = Chr(CInt(Splt(3))) & Chr(CInt(Splt(2))) & Chr(CInt(Splt(1))) & Chr(CInt(Splt(0)))
            'IP = Chr(CInt(Splt(0))) & Chr(CInt(Splt(1))) & Chr(CInt(Splt(2))) & Chr(CInt(Splt(3)))
            Send = Send & IP    'Next four bytes, the IP of "uswest.battle.net"
            Send = Send & Chr(&H0)  'Last null terminating byte for the username that we aren't using
            wSock.SendData Send   'Sending the initiation packet


Packet Log when i use htons(6112)

1  Hide  Hide  9  Send 
0000  04 01 2D 38 6E 53 F1 3F 00                         ..-8nS.?.

2  Hide  Hide  8  Recv 
0000  00 5B 2D 38 6E 53 F1 3F                            .[-8nS.?


Ringo

Quote from: Spilled[DW] on September 14, 2005, 02:09 AM
Quote from: NetNX on September 13, 2005, 09:10 PM
1)Specifiy a username
2)I've seen this code before...
3)Try a LONG

Ive changed port variable to long and tried that before. Still causing an overflow when i use htons(57367) like UserLoser said.
Any more ideas? I appreciate the help so far!

Edit:
Current Initiation packet coding:

        'We will assume that this connection is for uswest.battle.net
        'on port 6112, although these variables are easy to change
        Dim Send As String, Port As String * 2
        Dim IP As String * 4, Splt() As String
            Send = Chr(&H4)     'Our first byte, the version
            Send = Send & Chr(&H1)  'Our second byte, the command
            'CopyMemory Port, htons(6112), 2
            Port = Left(htons(57367), 2)
            Send = Send & Port  'Next two bytes, the port
            Splt() = Split(GetIPFromHostName(strServer), ".")
            IP = Chr(CInt(Splt(3))) & Chr(CInt(Splt(2))) & Chr(CInt(Splt(1))) & Chr(CInt(Splt(0)))
            'IP = Chr(CInt(Splt(0))) & Chr(CInt(Splt(1))) & Chr(CInt(Splt(2))) & Chr(CInt(Splt(3)))
            Send = Send & IP    'Next four bytes, the IP of "uswest.battle.net"
            Send = Send & Chr(&H0)  'Last null terminating byte for the username that we aren't using
            wSock.SendData Send   'Sending the initiation packet


Packet Log when i use htons(6112)

1  Hide  Hide  9  Send 
0000  04 01 2D 38 6E 53 F1 3F 00                         ..-8nS.?.

2  Hide  Hide  8  Recv 
0000  00 5B 2D 38 6E 53 F1 3F                            .[-8nS.?



Looks like the socks server is rejecting because its unable to connect to the server on the port you specifyed.
Try this:

Dim i As Long, SP() As String, tmpPort As String, tmpP As String
SP = Split("213.248.106.204", ".")
tmpPort = Right("0000" & Hex(6112), 4)
For i = 0 To UBound(SP)
    If i = 0 Then
        tmpP = MakeWORD(&H104) 'chr(4) & chr(1)
        tmpP = tmpP & Chr(Val("&H" & Mid(tmpPort, 1, 2))) & _
                      Chr(Val("&H" & Mid(tmpPort, 3, 2)))
    End If
    tmpP = tmpP & CStr(Chr(SP(i)))
Next i
tmpP = tmpP & Chr(0)
Ws1.SendData tmpP
Erase SP()

Hope this helps

UserLoser.

#13
Heh, I don't get what the big deal is.. All you need is inet_addr and htons.  You're doing unnecessary stuff. 

Quote
Packet Log when i use htons(6112)

1  Hide  Hide  9  Send 
0000  04 01 2D 38 6E 53 F1 3F 00                         ..-8nS.?.

2  Hide  Hide  8  Recv 
0000  00 5B 2D 38 6E 53 F1 3F                            .[-8nS.?

Correct me if I'm wrong, but it should be (that's what I'm getting, but it's untested, so hardcode this byte array and send it~):

04 01 17 e0 3f f1 53 6e cc 00

Spilled

#14
Quote from: UserLoser on September 14, 2005, 03:22 PM
Heh, I don't get what the big deal is.. All you need is inet_addr and htons.  You're doing unnecessary stuff. 

Quote
Packet Log when i use htons(6112)

1  Hide  Hide  9  Send 
0000  04 01 2D 38 6E 53 F1 3F 00                         ..-8nS.?.

2  Hide  Hide  8  Recv 
0000  00 5B 2D 38 6E 53 F1 3F                            .[-8nS.?

Correct me if I'm wrong, but it should be (that's what I'm getting, but it's untested, so hardcode this byte array and send it~):

04 01 17 e0 3f f1 53 6e cc 00


hrm, htons(6112) is returning me -8169.... i dont think that is correct..... any ideas on that?
i Can hardcore the byte array you have provided Userloser but the 2 bytes of htons(6112) is always different then yours.