Added 'goodfet.ccspi fastsniff' for REALLY fast sniffing.
git-svn-id: https://svn.code.sf.net/p/goodfet/code/trunk@1283
12e2690d-a6be-4b82-a7b7-
67c4a43b65c8
return None;
return buffer;
return None;
return buffer;
+ def RF_rxpacketrepeat(self):
+ """Gets packets from the radio, ignoring all future requests so as
+ not to waste time. Call RF_rxpacket() after this."""
+
+ self.writecmd(self.CCSPIAPP,0x91,0,None);
+ return None;
+
def RF_rxpacketdec(self):
"""Get and decrypt a packet from the radio. Returns None if
none is waiting."""
def RF_rxpacketdec(self):
"""Get and decrypt a packet from the radio. Returns None if
none is waiting."""
self.poke(0x03,choice);
self.maclen=len;
def printpacket(self,packet,prefix="#"):
self.poke(0x03,choice);
self.maclen=len;
def printpacket(self,packet,prefix="#"):
+ print self.packet2str(packet,prefix);
+ def packet2str(self,packet,prefix="#"):
s="";
i=0;
for foo in packet:
s="%s %02x" % (s,ord(foo));
s="";
i=0;
for foo in packet:
s="%s %02x" % (s,ord(foo));
- print "%s%s" % (prefix,s);
+ return "%s%s" % (prefix,s);
def printdissect(self,packet):
try:
def printdissect(self,packet):
try:
# Additions 2011-2012 Ryan Speers ryan@rmspeers.com
#N.B.,
# Additions 2011-2012 Ryan Speers ryan@rmspeers.com
#N.B.,
-#Might be CC2420 Specific
import sys;
import binascii;
import sys;
import binascii;
return ord(packet[4])+(ord(packet[5])<<8);
def isencrypted(packet):
"""Returns true if the packet is encrypted.""";
return ord(packet[4])+(ord(packet[5])<<8);
def isencrypted(packet):
"""Returns true if the packet is encrypted.""";
- return ord(packet[1])&0x08;
+ try:
+ return ord(packet[1])&0x08;
+ except:
+ return False;
def pktnonceseq(packet):
"""Returns the nonce sequence of a packet."""
nonce=0;
def pktnonceseq(packet):
"""Returns the nonce sequence of a packet."""
nonce=0;
print "\n%s surf" % sys.argv[0];
print "%s sniff [chan]" % sys.argv[0];
print "\n%s surf" % sys.argv[0];
print "%s sniff [chan]" % sys.argv[0];
+ print "%s fastsniff [chan]" % sys.argv[0];
print "%s sniffstrings [chan]" % sys.argv[0];
print "%s bsniff [chan]" % sys.argv[0];
print "%s sniffcrypt 0x$key [chan]" % sys.argv[0];
print "%s sniffstrings [chan]" % sys.argv[0];
print "%s bsniff [chan]" % sys.argv[0];
print "%s sniffcrypt 0x$key [chan]" % sys.argv[0];
print "\n%s txtoscount [-i|-r] TinyOS BlinkToLED" % sys.argv[0];
print "%s reflexjam [channel=11] [delay=0]" % sys.argv[0];
print "\n%s txtoscount [-i|-r] TinyOS BlinkToLED" % sys.argv[0];
print "%s reflexjam [channel=11] [delay=0]" % sys.argv[0];
+
+ print "\n%s txpiptest" % sys.argv[0];
+ print "%s txpipscapy" % sys.argv[0];
chan=chan+1;
if(sys.argv[1]=="sniff" or sys.argv[1]=="sniffdissect" or sys.argv[1]=="sniffstrings" or
chan=chan+1;
if(sys.argv[1]=="sniff" or sys.argv[1]=="sniffdissect" or sys.argv[1]=="sniffstrings" or
- sys.argv[1]=="sniffnonce"):
+ sys.argv[1]=="sniffnonce" or sys.argv[1]=="fastsniff"):
#Promiscuous mode.
client.RF_promiscuity(1);
client.RF_autocrc(1);
#Promiscuous mode.
client.RF_promiscuity(1);
client.RF_autocrc(1);
client.CC_RFST_RX();
print "Listening as %010x on %i MHz" % (client.RF_getsmac(),
client.RF_getfreq()/10**6);
client.CC_RFST_RX();
print "Listening as %010x on %i MHz" % (client.RF_getsmac(),
client.RF_getfreq()/10**6);
+ #If fastsniffing, then send that command.
+ if sys.argv[1]=="fastsniff":
+ client.RF_rxpacketrepeat();
+
#Now we're ready to get packets.
while 1:
#Now we're ready to get packets.
while 1:
- #client.setup(); #Really oughtn't be necessary, but can't hurt.
- client.CC_RFST_RX();
+ #client.CC_RFST_RX(); # Cop-out that confuses reception!
packet=None;
while packet==None:
packet=None;
while packet==None:
print packet;
elif sys.argv[1]=="sniffnonce":
if isencrypted(packet):
print packet;
elif sys.argv[1]=="sniffnonce":
if isencrypted(packet):
- print "%04x: %08x" % (srcadr(packet),pktnonceseq(packet));
+ try:
+ print "%04x: %08x -- %s" % (srcadr(packet),
+ pktnonceseq(packet),
+ client.packet2str(packet)
+ );
+ except:
+ pass;
else:
client.printpacket(packet);
sys.stdout.flush();
else:
client.printpacket(packet);
sys.stdout.flush();
client.RF_setfreq(freq);
else:
client.RF_setchan(freq);
client.RF_setfreq(freq);
else:
client.RF_setchan(freq);
- print "Transmitting on as %010x on %i MHz" % (
+ print "Transmitting on PIP injection as %010x on %i MHz" % (
client.RF_getsmac(),
client.RF_getfreq()/10**6);
client.RF_getsmac(),
client.RF_getfreq()/10**6);
- //debugstr("Chipcon SPI handler.");
-
switch(verb){
case PEEK:
cmddata[0]|=0x40; //Set the read bit.
switch(verb){
case PEEK:
cmddata[0]|=0x40; //Set the read bit.
);
txdata(app,verb,0);
break;
);
txdata(app,verb,0);
break;
+ case CCSPI_REPEAT_RX:
+
+ /* CCSPI_REPEAT_RX repeatedly requests new packets, forwarding
+ them to the server without waiting for the next request. This
+ allows for sniffing of packets that would otherwise overflow
+ the buffer.
+ */
+
+ //debugstr("Looping CCSPI_RX.");
+
+ //Loop forever in RX mode.
+ while(1){
+ ccspi_handle_fn(app,CCSPI_RX,0);
+ }
+ break;
case CCSPI_RX:
#ifdef FIFOP
//Has there been an overflow?
case CCSPI_RX:
#ifdef FIFOP
//Has there been an overflow?
if((!FIFO)&&FIFOP){
debugstr("Clearing overflow");
CLRSS;
if((!FIFO)&&FIFOP){
debugstr("Clearing overflow");
CLRSS;
txdata(app,verb,0); //no packet
return;
}
txdata(app,verb,0); //no packet
return;
}
/* Uncomment this to wait around a bit for the packet.
Might reduce dropped packet count.
i=1000; //Number of tries.
/* Uncomment this to wait around a bit for the packet.
Might reduce dropped packet count.
i=1000; //Number of tries.
#define CCSPI_RX 0x80
//Grab and decrypt a packet, if one is available.
#define CCSPI_RXDEC 0x90
#define CCSPI_RX 0x80
//Grab and decrypt a packet, if one is available.
#define CCSPI_RXDEC 0x90
+//Keep grabbing packets, ignoring further commands.
+#define CCSPI_REPEAT_RX 0x91
//Send a packet.
#define CCSPI_TX 0x81
//Flush RX
//Send a packet.
#define CCSPI_TX 0x81
//Flush RX