Exemplo n.º 1
0
def test_socks5_request_ipv4(authenticated_conn: SOCKS5Connection,
                             command: SOCKS5Command) -> None:
    cmd_request = SOCKS5CommandRequest.from_address(command, "127.0.0.1:1080")
    authenticated_conn.send(cmd_request)

    data = authenticated_conn.data_to_send()

    assert len(data) == 10
    assert data[0:1] == b"\x05"
    assert data[1:2] == command
    assert data[2:3] == b"\x00"
    assert data[3:4] == b"\x01"
    assert data[4:8] == b"\x7f\x00\x00\x01"
    assert data[8:] == (1080).to_bytes(2, byteorder="big")
Exemplo n.º 2
0
def test_socks5_request_domain_name(authenticated_conn: SOCKS5Connection,
                                    command: SOCKS5Command) -> None:
    cmd_request = SOCKS5CommandRequest.from_address(command, "localhost:1080")
    authenticated_conn.send(cmd_request)

    data = authenticated_conn.data_to_send()

    assert len(data) == 16
    assert data[0:1] == b"\x05"
    assert data[1:2] == command
    assert data[2:3] == b"\x00"
    assert data[3:4] == b"\x03"
    assert data[4:5] == (9).to_bytes(1, byteorder="big")
    assert data[5:14] == b"localhost"
    assert data[14:] == (1080).to_bytes(2, byteorder="big")
Exemplo n.º 3
0
def test_socks5_request_ipv6(authenticated_conn: SOCKS5Connection,
                             command: SOCKS5Command) -> None:
    cmd_request = SOCKS5CommandRequest.from_address(
        command, address="[0:0:0:0:0:0:0:1]:1080")
    authenticated_conn.send(cmd_request)

    data = authenticated_conn.data_to_send()

    assert len(data) == 22
    assert data[0:1] == b"\x05"
    assert data[1:2] == command
    assert data[2:3] == b"\x00"
    assert data[3:4] == b"\x04"
    assert (
        data[4:20] ==
        b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01")
    assert data[20:] == (1080).to_bytes(2, byteorder="big")