Comments (4)
Hmm it seems it's not looking at the first 4 bytes of the pcap, for this run i got:
bad magic: b'T\xe8\xc2\xdb'
While the pcap has:
00000000h: A1 B2 C3 D4 00 02 00 04 00 00 00 00 00 00 00 00 ; ¡²ÃÔ............
00000010h: 00 00 FF FF 00 00 00 7F 54 E8 C2 DB 00 01 24 6A ; ..ÿÿ...�TèÂÛ..$j
What happens is that in: scapy/utils.py:537 RawPcapReader()
It does this:
try:
self.f = gzip.open(filename,"rb")
magic = self.f.read(4)
except IOError:
self.f = open(filename,"rb")
magic = self.f.read(4)
Problem is that gzip.open, to detect if it is actually a gzip, consumes what it expects to be the header.
Since i'm trying to read from a pipe/stream, it's not seekable .. so the consumed header is gone .. and the next 4 bytes are read from the next part of the stream.
Edit:
However the python2 scapy code seems to be the same ..
from kamene.
Whoops accidently closed it .. sorry
from kamene.
On python2.7 gzip.open when reading from named pipe generates different exception even before reading 4 bytes:
Traceback (most recent call last):
File "", line 1, in
File "/usr/lib/python2.7/gzip.py", line 261, in read
self._read(readsize)
File "/usr/lib/python2.7/gzip.py", line 288, in _read
pos = self.fileobj.tell() # Save current position
IOError: [Errno 29] Illegal seek
from kamene.
I changed utils.py code to:
try:
if not stat.S_ISREG(os.stat(filename).st_mode):
raise IOError("GZIP detection works only for regular files")
self.f = gzip.open(filename,"rb")
magic = self.f.read(4)
except IOError:
self.f = open(filename,"rb")
magic = self.f.read(4)
It should work now for your case. You should check it using latest code from git.
Possible future improvement would be reading gzip over pipe, but I did not have any good ideas how to do it in a nice way.
from kamene.
Related Issues (20)
- converting a TCP packet with SAckOK option to a byte sequence fails
- SMTP connection problems
- how to set IP packet "options"?
- I encounter an error when I use the scapy-python3 in PyCharm(Windows) HOT 3
- ValueError: Unknown network interface 'wifi' on windows 10
- release 0.24 renamed module to scapy3k HOT 5
- Exception is thrown on sprintf("%TCP.flags%") with NS flag set HOT 2
- AttributeError: module 'pyx' has no attribute 'canvas' HOT 2
- DNS packet print() error HOT 3
- support for read and write pcapng will be added? HOT 3
- help required HOT 2
- compatibility with Anaconda HOT 18
- installation related help HOT 2
- help required HOT 7
- traceroute and mtr fail with NoneType' object has no attribute 'route'
- AttributeError 'NoneType' object has no attribute 'encode'
- kamene.bat will fail when the path including spaces
- WARNING: No IPv4 address found on en0 ! with MacOS HOT 1
- HTTP Layer HOT 1
- DNS - rdata field full payload not delivered HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from kamene.