Hallo,
ich bin gerade dabei manuell ein Socks5 Handshake durch zu führen und bin dabei auf das Problem gestoßen das in Wiki folgendes steht
Was ist mit
Mein Code
Spoiler anzeigen
Edit:
auf grund dieses bildes ist mir nun klar, was gemeint ist, nur weiß ich dann nicht, wieso ich ein 0x5 0x0 0x0 0x1 0x0 0x0 0x0 0x0 0x0 0x0 bekomme abwohl in der Wiki docu was anderes steht Oo
*Topic verschoben*
ich bin gerade dabei manuell ein Socks5 Handshake durch zu führen und bin dabei auf das Problem gestoßen das in Wiki folgendes steht
field 5: destination address of4 bytes for IPv4 address
1 byte of name length followed by 1–255 bytes the domain name
16 bytes for IPv6 address
destination address
, ist das dann sowas wie google.de Oo, denn so ganz versteh ich [nicht]
wie das gemeint ist, den der Socks läuft local
auf Port 9050
und da bin ich schon per TCP verbunden
Oo.Was ist mit
destination address
gemeint? Geklärt - Sieh Edit Mein Code
C#-Quellcode
- //call
- Socks5.Create("127.0.0.1", 9050);
- public class Socks5
- {
- public static void Create(string hostname, int port, CommandCodeType commandCode = CommandCodeType.TcpIpStream, SocksType type = SocksType.Socks5)
- {
- TcpClient client = new TcpClient(hostname, port);
- NetworkStream networkStream = client.GetStream();
- BinaryWriter writer = new BinaryWriter(networkStream);
- BinaryReader reader = new BinaryReader(networkStream);
- Ping ping = new Ping();
- PingReply reply = ping.Send(hostname);
- IPAddress address = reply.Address;
- byte[] valAdress = address.GetAddressBytes();
- byte[] valPort = BitConverter.GetBytes(port);
- writer.Write(new[] { (byte)type, (byte)0x01, (byte) AuthenticationType.NoAuthentication});
- byte[] response = reader.ReadBytes(2);
- if (response[1] != 0xFF)
- {
- //writer.Write(new[]{
- // (byte)0x01,
- // (byte)0x01,
- // (byte)0x01,
- // (byte)0x01,
- // (byte)0x01,
- //});
- //Console.WriteLine(string.Concat(reader.ReadBytes(2)));
- writer.Write(new[] {
- (byte)type,
- (byte)commandCode,
- (byte)0x00,
- (byte)TargetAddressType.Domain
- });
- writer.Write((byte) "google.de".Length);
- writer.Write(Encoding.Default.GetBytes("google.de"));
- writer.Write(new[] {
- (byte) (80>>8),
- (byte) (80 & 0xff)
- });
- //valAdress[0],
- //valAdress[1],
- //valAdress[2],
- //valAdress[3],
- Console.WriteLine(string.Concat(reader.ReadBytes(10)));
- }
- else
- {
- Console.WriteLine("Connection error");
- }
- }
- }
- public enum SocksType : byte
- {
- Socks5 = 0x5
- }
- public enum AuthenticationType : byte
- {
- NoAuthentication = 0x00,
- GSSAPI = 0x1,
- Login = 0x02,
- NoAcceptableMethods = 0xff
- }
- public enum CommandCodeType : byte
- {
- TcpIpStream = 0x1,
- TcpIpPortBinding = 0x2,
- UdpAssociate = 0x3
- }
- public enum TargetAddressType
- {
- IPV4 = 0x01,
- Domain = 0x03,
- IPv6 = 0x04
- }
Edit:
auf grund dieses bildes ist mir nun klar, was gemeint ist, nur weiß ich dann nicht, wieso ich ein 0x5 0x0 0x0 0x1 0x0 0x0 0x0 0x0 0x0 0x0 bekomme abwohl in der Wiki docu was anderes steht Oo
Server response:
field 1: SOCKS protocol version, 1 byte (0x05 for this version)
field 2: status, 1 byte:0x00: request granted
0x01: general failure
0x02: connection not allowed by ruleset
0x03: network unreachable
0x04: host unreachable
0x05: connection refused by destination host
0x06: TTL expired
0x07: command not supported / protocol error
0x08: address type not supported
field 3: reserved, must be 0x00, 1 byte
field 4: address type, 1 byte:0x01: IPv4 address
0x03: Domain name
0x04: IPv6 address
field 5: server bound address of4 bytes for IPv4 address
1 byte of name length followed by 1–255 bytes the domain name
16 bytes for IPv6 address
field 6: server bound port number in a network byte order, 2 bytes
*Topic verschoben*
Dieser Beitrag wurde bereits 2 mal editiert, zuletzt von „Marcus Gräfe“ ()