mIRC Home    About    Download    Register    News    Help

Print Thread
socks4 connection format #33821 03/07/03 03:36 PM
Joined: Dec 2002
Posts: 29
C
Charlie Offline OP
Ameglian cow
OP Offline
Ameglian cow
C
Joined: Dec 2002
Posts: 29
how is the format to connect mirc socket to irc through socks4?
i know, it must be ...

+----+----+----+----+----+----+----+----+----+----+....+----+
| VN | CD | DSTPORT | DSTIP | USERID |NULL|
+----+----+----+----+----+----+----+----+----+----+....+----+

where VN is the socks version, also 4
and CD is 1, socks command code for connect request
but, how with DSTPORT and DSTIP?
is it have the same format like other? also 6667 for DSTPORT and 127.0.0.1 for DSTIP?

but it doesn't help me.
anybody have an example remote or script, how to connect socket through socks4?
i also looked for example to connect through socks5 with sockets

thanks for your help guys


Charlie
Re: socks4 connection format #33822 03/07/03 04:20 PM
Joined: Feb 2003
Posts: 2,662
Raccoon Offline
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2003
Posts: 2,662
If I recall, DSTIP is a 32bit word, so you need to send just that.
$longip(127.0.0.1) will do the trick, but you can't just send these values as plain text... they have to be sent in binary form, using a &binvar. (because you have to handle NUL, CR, LF, etc characters)

This example basically shows you how to fill the first 4 values.
Code:
		+----+----+----+----+----+----+----+----+
		| VN | CD | DSTPORT |      DSTIP        |
		+----+----+----+----+----+----+----+----+
 # of bytes:	   1    1      2              4


/bset &bvar 8 0 <- first we create our 8 byte binvar, this step isn't important but it helps understand &binvars easier.

/bset &bvar 1 4 <- VN == 4
/bset &bvar 2 1 <- CD == 1

Now here's the tricky part, because mIRC doesn't have any built-in functions to simply drop 2-byte and 4-byte "words" and "longs" into &binvars, so we have to do it byte for byte.

/bset &bvar 3 $calc(6667 % 256)
/bset &bvar 4 $int($calc(6667 / 256))

You can also do $longip(6667) and use $gettok() to extract the last two tokens.

/bset &bvar 5 1
/bset &bvar 6 0
/bset &bvar 7 0
/bset &bvar 8 127

That fills your &bvar with the needed data. I haven't written a SOCKS4 proxy, only started on one, so I'm not sure if the USERID and NUL fields are required.

As for SOCKS5, that's getting pretty complicated with authentication methods, and you'll rarely find a proxy that uses it.

- Raccoon


Well. At least I won lunch.
Good philosophy, see good in bad, I like!