• Welcome to Valhalla Legends Archive.
 

Question about SOCKS4

Started by I_Smell_Tuna, February 14, 2005, 09:33 PM

Previous topic - Next topic

I_Smell_Tuna

If the third and fourth bytes are supposed to be for the destination port how do you split up the port number between those two bytes?

shout

Very carefully with alot of practice.

You need to convert the value to a byte array, then stick it in.

Converting it depends on your langauge.

I_Smell_Tuna


tA-Kane

A method that a lot of beginning Visual Basic users use is to convert the port (an integer) to a hexadecimal value using the Hex() function, then use Val() for each byte (meaning twice), using a different part of the result from Hex().

Dim Result As String // the result goes into here, to be written to the network stream
Dim HexStr As String // temporary buffer for hexadecimal string
Dim Port As Integer // the port you want to write to the network stream

Port = 6112
HexStr = Right("000" & Hex(Port), 4)
Result = Val("&h" & Left(HexStr, 2)) & Val("&h" & Right(HexStr, 2))


Note that this does not consider endianness, which may be incorrect for most Visual Basic implementations trying to make use of the SOCKS protocol.
Macintosh programmer and enthusiast.
Battle.net Bot Programming: http://www.bash.org/?240059
I can write programs. Can you right them?

http://www.clan-mac.com
http://www.eve-online.com

NetNX


tA-Kane

0x0001 is 1 on one platform, whereas it's 65536 on another platform.
Macintosh programmer and enthusiast.
Battle.net Bot Programming: http://www.bash.org/?240059
I can write programs. Can you right them?

http://www.clan-mac.com
http://www.eve-online.com

Kp

No, it isn't. ;)  65536 = 2**16 = 0x10000.  You forgot a zero. :)
[19:20:23] (BotNet) <[vL]Kp> Any idiot can make a bot with CSB, and many do!

tA-Kane

Oh well, I was slightly distracted when I posted that. Here's the corrected statement:
Quote from: tA-Kane on February 18, 2005, 06:45 PM0x0001 is 1 on one platform, whereas it's 256 on another platform.
Macintosh programmer and enthusiast.
Battle.net Bot Programming: http://www.bash.org/?240059
I can write programs. Can you right them?

http://www.clan-mac.com
http://www.eve-online.com