Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Establish a TCP session without the need to manipulate the firewall #24

Open
xhdix opened this issue Jan 4, 2022 · 0 comments
Open
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed priority/medium question Further information is requested

Comments

@xhdix
Copy link
Contributor

xhdix commented Jan 4, 2022

To do better what we did here #22, one solution is to use Socket itself directly. As a result, we do not need to configure the firewall to prevent instant RST packets from being sent by our kernel. Although this problem does not appear to exist in the new Linux kernels (version 5), it may still be worth considering.
An incomplete and slightly wrong code is:

try:
    s=socket.socket()
    s.settimeout(3)
    s.connect(("1.0.0.1",443))
    s2=socket.socket(socket.AF_INET, socket.SOCK_RAW, socket.IPPROTO_ICMP)
    s2.bind(('',0))
    s.setsockopt(socket.SOL_IP, socket.IP_TTL, 1)
    print(s.getsockname())
    print(s.getpeername())
    ss=StreamSocket(s,Raw)
    ans,unans=ss.sr(TCP(import_hexcap()),timeout=3)
    print(ans)
    print(unans)
    if len(ans) == 0:
        data, curr_addr = s2.recvfrom(1500)
        IP(data) # won't work here. ;)
        print(curr_addr)
finally:
    s.setsockopt(socket.SOL_IP, socket.IP_TTL, 68)
    s.close()
    s2.close()

But the main unsolvable problem I saw is that we in Python could not change TCP_RTO_MIN to prevent consecutive retransmissions (every 200 milliseconds). This can increase false positives as well as unpredictable behavior.

some good resources:

@xhdix xhdix added enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed question Further information is requested labels Jan 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed priority/medium question Further information is requested
Projects
None yet
Development

No branches or pull requests

1 participant