• Welcome to Valhalla Legends Archive.
 

Some questions Concerning Socks4/5 Proxies - Update #1

Started by BaDDBLooD, September 19, 2004, 01:09 PM

Previous topic - Next topic

BaDDBLooD

How do you send the Address/Port you want to connect to?

Example:

Socks 4 Proxy

I want to connect to USEast.Battle.Net:6112

Thanks!
There are only two kinds of people who are really fascinating: people who know absolutely everything, and people who know absolutely nothing.

UserLoser.

#1
Look here


You'll have to resolve useast.battle.net to an IP, then using a function such as inet_addr(), you can convert the dotted string, IP address into a 4 byte value.  Using htons() may be useful also for converting the port into a 2 byte value.

BaDDBLooD

#2
Thanks, the api calls was what i needed.

EDIT:

When i connect to a proxy, this is what i am sending



Chr(&H4) & Chr(&H1) & htons("6112") & inet_addr(Bot.Server) & "anonymous" & Chr(&H0)



Using These:



Public Declare Function inet_addr Lib "wsock32.dll" (ByVal cp As String) As Long
Public Declare Function htons Lib "wsock32.dll" (ByVal hostshort As Long) As Integer



This is what it looks like:



[1:54:22 PM] 0000:  04 01 2D 38 31 36 39 2D 32 31 30 30 36 32 39 34   -8169-21006294
0010:  34 31 61 6E 6F 6E 79 6D 6F 75 73 00               41anonymous.....



That doesn't look right, does it?
There are only two kinds of people who are really fascinating: people who know absolutely everything, and people who know absolutely nothing.

LordNevar

Here this my make it easier for ya.

This is my API call.


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


Here's my decode.


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


Forgot who the original author was or where I got this from, but thanxs to whoever it was.

A good fortune may forbode a bad luck, which may in turn disguise a good fortune.
The greatest trick the Devil ever pulled, was convincing the world he didn't exsist.

BaDDBLooD

I Just wanted to know how to send the Remote IP Address/Port for the proxy to connect to.  Thanks for that tidbit though.
There are only two kinds of people who are really fascinating: people who know absolutely everything, and people who know absolutely nothing.

Banana fanna fo fanna

Looks to me like you're sending it in ascii instead of binary.

BaDDBLooD

Thanks for the info, unfortunately i did not comprehend what you just said!
There are only two kinds of people who are really fascinating: people who know absolutely everything, and people who know absolutely nothing.

shadypalm88

Quote from: BaDDBLooD on September 19, 2004, 02:59 PM
I Just wanted to know how to send the Remote IP Address/Port for the proxy to connect to.  Thanks for that tidbit though.
Chr(&H4) & Chr(&H1) & htons("6112") & inet_addr(Bot.Server) & "anonymous" & Chr(&H0)This was right for the most part.  There's one big problem with it, however.  inet_addr converts a readable IP address (e.g. 127.0.0.1) to its 4-byte machine readable form.  It will choke on a domain name like useast.battle.net.  To do this, you have to use something like the function LordNevar posted, only don't run it through IPToText.  For IP addresses, you should still use inet_addr.

You can use something like this to check if a given address is an IP:'Checks if the given address is a dotted-quad
'IP by seeing if the string only contains
'periods (.) and numbers.
Public Function IsIPAddress(Address As String) As Boolean
   Dim i&, a%
   IsIPAddress = False
   For i = 1 To Len(Address)
       a = Asc(Mid$(Address, 1, 1))
       If (a <> 46) And ((a > 57) Or (a < 48)) Then _
           Exit Function
   Next i
   IsIPAddress = True
End Function


P.S. htons("6112") Only put a number in quotes if you are going to be directly displaying it to the user.  If you ever want to get into strongly-typed languages (e.g. C, C++, Java) you'll have to break that habit.

BaDDBLooD

There are only two kinds of people who are really fascinating: people who know absolutely everything, and people who know absolutely nothing.

shadypalm88


UserLoser.

Quote from: BaDDBLooD on September 19, 2004, 01:34 PM
That doesn't look right, does it?

Use RtlMoveMemory, convert the result of htons() to two bytes, along with result of inet_addr to 4 bytes, don't insert the value as a string

UserLoser.

#11
Quote from: shadypalm88 on September 19, 2004, 03:42 PM
Quote from: BaDDBLooD on September 19, 2004, 02:59 PM
I Just wanted to know how to send the Remote IP Address/Port for the proxy to connect to.  Thanks for that tidbit though.
Chr(&H4) & Chr(&H1) & htons("6112") & inet_addr(Bot.Server) & "anonymous" & Chr(&H0)This was right for the most part.  There's one big problem with it, however.  inet_addr converts a readable IP address (e.g. 127.0.0.1) to its 4-byte machine readable form.  It will choke on a domain name like useast.battle.net.  To do this, you have to use something like the function LordNevar posted, only don't run it through IPToText.  For IP addresses, you should still use inet_addr.

You can use something like this to check if a given address is an IP:'Checks if the given address is a dotted-quad
'IP by seeing if the string only contains
'periods (.) and numbers.
Public Function IsIPAddress(Address As String) As Boolean
   Dim i&, a%
   IsIPAddress = False
   For i = 1 To Len(Address)
       a = Asc(Mid$(Address, 1, 1))
       If (a <> 46) And ((a > 57) Or (a < 48)) Then _
           Exit Function
   Next i
   IsIPAddress = True
End Function


P.S. htons("6112") Only put a number in quotes if you are going to be directly displaying it to the user.  If you ever want to get into strongly-typed languages (e.g. C, C++, Java) you'll have to break that habit.

Note that inet_addr will return INADDR_NONE (0xFFFFFFFF) if the value given is not a valid IP address

BaDDBLooD

There are only two kinds of people who are really fascinating: people who know absolutely everything, and people who know absolutely nothing.