Implement HTTP 1.0 & fix TCP_client#1925
Implement HTTP 1.0 & fix TCP_client#1925guedou merged 16 commits intosecdev:masterfrom gpotter2:sessions
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1925 +/- ##
=========================================
+ Coverage 87.12% 87.3% +0.18%
=========================================
Files 198 199 +1
Lines 44679 45078 +399
=========================================
+ Hits 38926 39356 +430
+ Misses 5753 5722 -31
|
|
@guedou This is ready for review. p-l- has already reviewed a version (not the latest, but there have only been slight bug fixes since). It appears that |
|
Do we need to add the pcap files? They are quite big. |
|
I can probably reduce the size of the pcaps. |
|
@guedou I've compressed the bigger pcap ( I'm not sure if I can spare more space :/ I would have liked to keep real examples for our HTTP tests.
|
|
This test: https://github.com/secdev/scapy/blob/master/test/linux.uts#L11 >>> load_layer("http")
>>> a = TCP_client.tcplink(HTTP, "www.google.com", 80)
>>> a.send(b"HEAD / HTTP/1.0\r\n\r\n")
>>> a.sniff(session=TCPSession)
<Sniffed: TCP:1 UDP:0 ICMP:0 Other:0>
>>> _[0]
<Ether dst=[...] src=[...] type=IPv4 |<IP version=4 ihl=5 tos=0x0 len=None id=32140 flags= frag=0 ttl=121 proto=tcp chksum=None src=[...] dst=[...] |<TCP sport=http dport=54773 seq=1135001053 ack=1005612689 dataofs=5 reserved=0 flags=A window=60720 chksum=None urgptr=0 |<HTTP |<HTTPResponse Http_Version='HTTP/1.0' Status_Code='200' Reason_Phrase='OK' Accept_Ranges='none' Cache_Control='private, max-age=0' Content_Type='text/html; charset=ISO-8859-1' Date='Sun, 09 Jun 2019 19:22:39 GMT' Expires='-1' P3P='CP="This is not a P3P policy! See g.co/p3phelp for more info."' Server='gws' Set_Cookie='NID=185=kq_kBczt9GkdFomd4pTsi8yue5UIAoODedJ8g7DHFYS1a5M2gGWzGRjXJ6uZgKs4Yim-KtnKEhqzg3pFLVngRtcGj0NQaHzEvkbzMyMDnrmUMaEVYSfVLUZPrX0PgNUOxg2n7_HPmULQ27vBSREWyPTu46QToUwZ8OGGRlBX5bM; expires=Mon, 09-Dec-2019 19:22:39 GMT; path=/; domain=.google.com; HttpOnly' Vary='Accept-Encoding' X_Frame_Options='SAMEORIGIN' X_XSS_Protection='0' |>>>>>
>>>I also updated the dissection method (removed a ton of junk). I've moved more stuff into |
p-l-
left a comment
There was a problem hiding this comment.
That's great! I have a couple of minor suggestions.
|
@guedou your call. |
|
A last small fix & one improvement. This now works properly (it will also follow chunks...): load_layer("http")
req = HTTP()/HTTPRequest(Accept_Encoding=b'gzip, deflate', Cache_Control=b'no-cache', Connection=b'keep-alive', Host=b'www.secdev.org', Pragma=b'no-cache')
a = TCP_client.tcplink(HTTP, "www.secdev.org", 80)
payload = a.sr1(req)
open("www.secdev.org.html", "wb").write(payload.load)feel free to try it out on your platform 👍 I only tested the automatons on Windows, but they should work as well elsewhere. This should be ready to merge. |
|
@guedou Tests now pass. this is mergeable |
|
@gpotter2 do you want me to squash the commits or keep them? |
|
Squashing will be better. There has been some stuff that was reverted |
|
@guedou this is OK for me. |
guedou
left a comment
There was a problem hiding this comment.
Cool PR. I made some simple comments.
|
I had actually been so focused on HTTP dissection that I overlooked if the build was always correct. Sorry for the last-minute commits |
|
I will try to release v2.4.3rc3 by Wednesday. |

This PR implements:
scapy_httpbut:TCP_client& Automaton: fixes for Automaton: support_ATMT_Supersocketon Windows. Also update it to h'share theStringBufferof theTCPSession, so that it can also handle TCP fragmentation.Note: because of Python 2-3 compatibility, several utils were needed:
gzip_decompress/gzip_compress:gzip.decompress/gzip.compressisn't available on Python 2.7.Important note:(done)sr()is NOT supported YET, because it would require to changesndrcv()to handle Sessions. This is done in #1999. (The 2 PRs must be merged before it may be implemented)This code was able to decode a JPEG image sent through several HTTP chunks, despite TCP re-transmission. You can check it out by yourself by un-commenting a line in the chunked-image test
Rationale
scapy_http?It has been around for quite some time. It allows users/projects that were using it to migrate seamlessly, to use the new features.
I do not want to change the API, and it allowed to start on an existing basis.
This PR should be able to fully replace
scapy_httpwhich development has been paused (stopped?). That would allow to deprecatescapy_httpand continue any further development here.I've asked the maintainers if they want to merge the projects, therefore release a last
scapy_httpversion with a warning deprecating it. I doubt they want to invest more time into maintaining it 😄See invernizzi/scapy-http#46