SOCKS 5 protocol

The SOCKS 5 protocol is an extension of the SOCKS 4 protocol that is defined in RFC 1928. It offers more choices of authentication, adds support for IPv6 and UDP that can be used for DNS lookups. The initial handshake now consists of the following:

* Client connects and sends a greeting which includes a list of authentication methods supported.
* Server chooses one (or sends a failure response if none of the offered methods are acceptable).
* Several messages may now pass between the client and the server depending on the authentication method chosen.
* Client sends a connection request similar to SOCKS 4.
* Server responds similar to SOCKS 4.

The authentication methods supported are numbered as follows:

* 0×00 – No authentication
* 0×01 – GSSAPI [5]
* 0×02 – Username/Password [6]
* 0×03-0x7F – methods assigned by IANA [7]
* 0×80-0xFE – methods reserved for private use

The initial greeting from the client is:

* field 1: SOCKS version number (must be 0×05 for this version)
* field 2: number of authentication methods supported, 1 byte
* field 3: authentication methods, variable length, 1 byte per method supported

The server’s choice is communicated:

* field 1: SOCKS version, 1 byte (0×05 for this version)
* field 2: chosen authentication method, 1 byte, or 0xFF if no acceptable methods were offered

The client’s authentication request is:

* field 1: version number, 1 byte (must be 0×01)
* field 2: username length, 1 byte
* field 3: username
* field 4: password length, 1 byte
* field 5: password

The client’s connection request is:

* field 1: SOCKS version number, 1 byte (must be 0×05 for this version)
* field 2: command code, 1 byte:
o 0×01 = establish a TCP/IP stream connection
o 0×02 = establish a TCP/IP port binding
o 0×03 = associate a UDP port
* field 3: reserved, must be 0×00
* field 4: address type, 1 byte:
o 0×01 = IPv4 address
o 0×03 = Domain name
o 0×04 = IPv6 address
* field 5: destination address of
o 4 bytes for IPv4 address
o 1 byte of name length followed by the name for Domain name
o 16 bytes for IPv6 address
* field 6: port number in a network byte order, 2 bytes

Server response:

* field 1: SOCKS protocol version, 1 byte (0×05 for this version)
* field 2: status, 1 byte:
o 0×00 = request granted
o 0×01 = general failure
o 0×02 = connection not allowed by ruleset
o 0×03 = network unreachable
o 0×04 = host unreachable
o 0×05 = connection refused by destination host
o 0×06 = TTL expired
o 0×07 = command not supported / protocol error
o 0×08 = address type not supported
* field 3: reserved, must be 0×00
* field 4: address type, 1 byte:
o 0×01 = IPv4 address
o 0×03 = Domain name
o 0×04 = IPv6 address
* field 5: destination address of
o 4 bytes for IPv4 address
o 1 byte of name length followed by the name for Domain name
o 16 bytes for IPv6 address
* field 6: network byte order port number, 2 bytes

Incoming search terms:

No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URL

Leave a comment