-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Packet viewer #2603
Packet viewer #2603
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2603 +/- ##
==========================================
- Coverage 88.20% 87.69% -0.51%
==========================================
Files 254 266 +12
Lines 54349 55006 +657
==========================================
+ Hits 47936 48235 +299
- Misses 6413 6771 +358
|
Some infos for cf = conf.color_theme
conf.color_theme = BlackAndWhite()
self.detail_text.set_text(packet.show(dump=True))
self.hex_text.set_text(hexdump(packet, dump=True))
conf.color_theme = cf The DetailsView should be scroll-able and detail_text and hex_text should have fixed areas |
Actually, the cf = conf.color_theme
conf.color_theme = BlackAndWhite()
loop = MainLoop(main_window, palette)
main_window.base_widget.main_loop = loop
main_window.base_widget.packet_view.main_loop = loop
loop.run()
conf.color_theme = cf This solves some presentation issues for me. |
Too bad it relies on platform specific dependencies ( However I'm wondering if this shouldn't be a different project from scapy alltogether (I'm open to discussion, don't know what the other maintainers think). Isn't it a bit.. out of space? The "tools" folder was rather more for scapy development than a place to host people's script. I'm stretching it a bit here: this PR is really cool, but it's a general thought. What do you think? |
@gpotter2 Thanks for opening this discussion. I will share some of my opinions, because I'm somehow involved in this PR.
What do you think? |
I just did some testing for urwid+scapy on Windows. cygwinurwid works, but scapy does not: WSL 1urwid also works and so does scapy: From the weird question marks in each line mitmproxy suffered as well. They fixed it with this: But while scapy itself works fine, there are problems with the sockets. It works fine with virtual PythonCAN since everything happens in userspace and is virtual. Traceback (most recent call last):
File "scapy/start_packet_viewer.py", line 15, in <module>
socket = L2Socket("eth0")
File "/home/andreas/scapy/scapy/arch/linux.py", line 448, in __init__
self.ins = socket.socket(socket.AF_PACKET, socket.SOCK_RAW, socket.htons(type)) # noqa: E501
File "/usr/lib/python3.8/socket.py", line 231, in __init__
_socket.socket.__init__(self, family, type, proto, fileno)
OSError: [Errno 97] Address family not supported by protocol Working with TCP works because this does not require RAW Sockets. Tested with following code: from scapy.supersocket import StreamSocket
from scapy.packet import Raw
from scapy.tools.packet_viewer.viewer import viewer
import socket
s = socket.socket()
ss = StreamSocket(s, Raw)
def start():
s.connect(("example.org", 80))
ss.send(Raw("GET /\r\n"))
viewer(ss, started_callback=start)
ss.close() Since WSL is intended to implement Linux userspace, not Linux kernelspace, the modules for CAN and ISOTP are not available: andreas@DESKTOP-0JLP9RQ:~$ sudo modprobe can
modprobe: FATAL: Module can not found in directory /lib/modules/4.4.0-18362-Microsoft
andreas@DESKTOP-0JLP9RQ:~$ sudo modprobe vcan
modprobe: FATAL: Module vcan not found in directory /lib/modules/4.4.0-18362-Microsoft
andreas@DESKTOP-0JLP9RQ:~$ sudo modprobe peak_pci
modprobe: FATAL: Module peak_pci not found in directory /lib/modules/4.4.0-18362-Microsoft This situation will improve with WSL 2 which will probably support RAW sockets and a more complete linux kernel.
Thus we can't be sure what will be possible with CAN stuff on WSL 2 but I'm pretty sure at least the ConclusionI see two possibilities what we can do.
This was a lot of information, but I wanted it to be documented. |
b44aaf0
to
815ee09
Compare
a6555d2
to
b62f91f
Compare
I now have WSL2 and was able to test it. Some thoughts:
it gives no result. Am i doing something wrong?
|
@gpotter2 At the moment, there is a basecls filtering implemented. Try:
|
@gpotter2 >>> a = conf.L2socket()
>>> sniff(opened_socket=a, prn=type)
<class 'scapy.layers.l2.Ether'>
<class 'scapy.layers.l2.Dot3'>
<class 'scapy.layers.l2.Dot3'>
<class 'scapy.layers.l2.Ether'>
<class 'scapy.layers.l2.Ether'> Thanks for your great feedback! import platform
platform.platform() I'm glad you like it 😄 |
07a79cb
to
ce4d59a
Compare
36a63b2
to
4087e99
Compare
I didn't removed the |
344b415
to
8fd58b9
Compare
Dear maintainers, could you please have a look at the packet viewer in the current version? We will do unit tests and minor refactorings, but the we want to fix the features. load_module("packet_viewer.viewer")
s = L3PacketSocket("wlan0")
a = viewer(s) |
The viewer is more robust and complete now. |
7c85617
to
f73f712
Compare
Since 2.4.4 is out now, can we merge this PR to either |
9afa953
to
02b3c54
Compare
We're using For the creation of packets we validate the input and shrink its execution context to the only necessary requirements. Since the filter is easier, there we only shrinked the execution context. Question to the mantainers, is this sufficient? |
8190dd9
to
c61d294
Compare
4928411
to
f42326e
Compare
06de276
to
2968c29
Compare
2e15ee1
to
cba72e4
Compare
I added some development documentation to Scapy -> Development -> Packet Viewer. Is this the correct place to put it? @guedou |
a8c5515
to
396f9a2
Compare
Dear maintainers, is there any possibility to move forward with this PR? |
Hi, we moved to a stand-alone project for now. If this becomes stable enough, maybe we can merge it one day into mainline. https://pypi.org/project/scapy-packet-viewer/ |
You should consider adding a reference to this code into https://github.com/secdev/awesome-scapy. You can add a visualization section before the misc one. |
@TabeaSpahn
@polybassa
We would be interested in the opinions of the maintainers.
It took some time but we think it's finally stable enough to be shown in a PR.
Python 2 and Python 3 supported.
Things that probably have to be changed:
Requirements:
pip3 install urwid
Cool feature I want to highlight:
It's a TUI working fully over ssh which means also mouse interaction is possible over ssh.