Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Pure-python library allowing to read the Warts file format produced by Scamper (an Internet measurement tool from CAIDA)
pywarts
is a pure-python parsing library for the Warts format.
Warts is an extensible binary format produced by
Scamper, an
Internet measurement tool from CAIDA, to store measurement results
such as traceroutes and pings.
This library started off from the Python implementation from CMAND, by Robert Beverly, but has now vastly diverged. The parsing architecture is loosely inspired from the Ryu packet parser, although it is less complex because the requirements are less stringent.
pip install scamper-pywarts
For now, the only public API is very low-level: it simply reads from a stream (for instance a file) and returns Warts records as Python objects.
To read records, call warts.parse_record
repeatedly until it returns
None
. Remember to open your input Warts files in binary mode!
The returned value of warts.parse_record
is an instance of an
appropriate subclass (e.g. Traceroute
), depending on the record type.
Be aware that all optional attributes are set to None if not present in
the input file. You should always check for this possibility in your user
code.
Here is an example that opens a file, and repeatedly parses records until it finds a Traceroute record (warts files usually have a few initial records with mostly uninteresting data).
import warts
from warts.traceroute import Traceroute
with open('my_file.warts', 'rb') as f:
record = warts.parse_record(f)
while not isinstance(record, Traceroute):
record = warts.parse_record(f)
if record.src_address:
print("Traceroute source address:", record.src_address)
if record.dst_address:
print("Traceroute destination address:", record.dst_address)
print("Number of hops:", len(record.hops))
print(record.hops)
To know which attributes are available, look at the definition of the
relevant class (there will be real documentation at some point). For
instance, for Traceroute
, almost all attributes are optional and defined
here:
traceroute.py.
Some attributes are not optional and are defined in the parse()
method
of the class. For instance, a traceroute object t
always provides a
list of TracerouteHop
objects in t.hops
.
If parsing fails, an instance of errors.ParseError
is thrown.
pywarts
generally tries to clean up after itself, so the file
descriptor should point to the next record even after a parsing error.
Of course, this is not always possible, especially if the input file
is incorrectly formatted.
Here is some points on which pywarts
improves from the code from
https://github.com/cmand/scamper:
read()
repeatedly on very small amount of data.However, there are some areas where the CMAND code does more things:
pywarts
does not implement the deprecated address format (it is
quite complex and has been deprecated for several years)Some currently unanswered questions:
ipaddr
objects for addresses? Some times are
expressed in centiseconds, some in microseconds, some in seconds.
Should we normalize that to a common base? Are floats acceptable
for time values?Please open issues if you have ideas and thoughts on these questions.
FAQs
Pure-python library allowing to read the Warts file format produced by Scamper (an Internet measurement tool from CAIDA)
We found that scamper-pywarts demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.