forked from andrewf/pcap2har
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
preliminary DNS support, more architecture changes
- Loading branch information
Andrew Fleenor
committed
Dec 31, 2010
1 parent
e751bd0
commit 603b7a3
Showing
7 changed files
with
81 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
class Processor: | ||
''' | ||
Processes and interprets DNS packets. | ||
Call its `add` method with each dpkt.dns.DNS from the pcap. | ||
''' | ||
def __init__(self): | ||
self.packets = [] | ||
def add(self, ts, pkt): | ||
self.packets.append((ts, pkt)) |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import dns | ||
import dpkt | ||
import logging as log | ||
|
||
class Processor: | ||
''' | ||
Processes and interprets UDP packets. | ||
Call its add(pkt) method with each dpkt.udp.UDP packet from the pcap or | ||
whatever. It will expose information from the packets, at this point mostly | ||
DNS information. It will automatically create a dns processor and expose it | ||
as its `dns` member variable. | ||
This class is basically a nonce, if I may borrow the term, for the sake of | ||
architectural elegance. But I think it's begging for trouble to combine it | ||
with DNS handling. | ||
''' | ||
def __init__(self): | ||
self.dns = dns.Processor() | ||
def add(self, ts, pkt): | ||
''' | ||
pkt = dpkt.udp.UDP | ||
''' | ||
#check for DNS | ||
if pkt.sport == 53 or pkt.dport == 53: | ||
dnspkt = dpkt.dns.DNS() | ||
self.dns.add(ts, dnspkt) | ||
else: | ||
log.warning('unkown UDP ports: %d->%d' % (pkt.sport, pkt.dport)) |