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

Implement TCP server Automaton #3690

Closed
wants to merge 1 commit into from
Closed

Conversation

jabbate19
Copy link

As a child class of TCP_client, new TCP_server automatically completes a TCP handshake when a client connects and is integrated with supersocket. Inspiration was taken from #2409

Anything that could be removed due to parent class was removed. States were required to stay due to Automaton design.

While working on this, I found/fixed a bug within TCP_client that would cause the ACK number of a response from data to be wrong when a small amount of data was sent. Padding was being considered in the length for the ack number when it is not in the protocol.

Part of #399

As a child class of TCP_client, server automatically completes a TCP handshake when a client connects and is integrated with supersocket. Anything that could be removed due to parent class was removed. States were required to stay due to Automaton design.
@codecov
Copy link

codecov bot commented Jul 15, 2022

Codecov Report

Merging #3690 (9961fa9) into master (2c92b03) will decrease coverage by 0.06%.
The diff coverage is 33.33%.

@@            Coverage Diff             @@
##           master    #3690      +/-   ##
==========================================
- Coverage   86.23%   86.16%   -0.07%     
==========================================
  Files         296      296              
  Lines       66907    66987      +80     
==========================================
+ Hits        57698    57722      +24     
- Misses       9209     9265      +56     
Impacted Files Coverage Δ
scapy/layers/inet.py 65.28% <33.33%> (-1.95%) ⬇️
scapy/arch/windows/__init__.py 67.73% <0.00%> (-0.57%) ⬇️
scapy/contrib/automotive/ecu.py 94.33% <0.00%> (-0.34%) ⬇️
scapy/layers/ntp.py 84.55% <0.00%> (-0.28%) ⬇️
scapy/fields.py 90.72% <0.00%> (-0.06%) ⬇️
scapy/layers/l2.py 76.90% <0.00%> (+0.69%) ⬆️

@polybassa
Copy link
Contributor

Thanks for your PR. Looks good, so far. Could you please provide some unit-tests?

Copy link
Member

@gpotter2 gpotter2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for the PR & your interest in Scapy !
This is an interesting topic and it's really nice to see what you did.

Unfortunately though, I believe it would need a bit of refactoring: we want to support multiple clients, so you probably would need to implement TCBs of some sort. There is a bit of refactoring to do :p


@ATMT.action(incoming_data_received)
def receive_data(self, pkt):
super().receive_data(pkt)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This won't work on Python 2 (super(TCP_server, self)). Did you test it? same elsewhere
(sorry this should be the last release to support it :p)

self.l4 = IP(src=ip) / TCP(sport=self.sport, flags=0,
seq=random.randrange(0, 2**32))
self.src = self.l4.src
self.sack = self.l4[TCP].ack
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a bit cheap: you handled only a single client at the time. I must say I envisioned something a bit more useful, handling multiple streams.
Did you have a look at Transmission Control Block?

@jabbate19
Copy link
Author

I will continue this soon, been out of town for a bit so please don't close

@stryngs
Copy link

stryngs commented Dec 6, 2022

Still working on this @jabbate19 ?

@gpotter2
Copy link
Member

gpotter2 commented Feb 5, 2024

Closing for inactivity.

@gpotter2 gpotter2 closed this Feb 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants