Added the option to automatically re-inject packets that we have fuzzed and injected...
[goodfet] / client / GoodFETMCPCANCommunication.py
index 6aee2ef..7d13ae7 100644 (file)
@@ -29,6 +29,7 @@ class GoodFETMCPCANCommunication:
        self.client.serInit()
        self.client.MCPsetup();
        self.DATALOCATION = "../../contrib/ThayerData/"
+       self.INJECTDATALOCATION  = self.DATALOCATION+"InjectedData/"
        
 
     
@@ -173,10 +174,11 @@ class GoodFETMCPCANCommunication:
                     print "Message in RXB0; message type is %02x (0x00 is standard data, 0x08 is standard remote)." %messagetype
                 elif(messagestat == 0x00):
                     print "No messages in buffers."
-            
+            #check to see if there was a packet
+            if( packet != None):
+                packetcount+=1;
             if (packet!=None and writeToFile == True):
                 
-                packetcount+=1;
                 row = [];
                 row.append("%f"%time.time());
                 
@@ -237,8 +239,8 @@ class GoodFETMCPCANCommunication:
                 for byte in packet:
                     row.append("%02x"%ord(byte));
                 dataWriter.writerow(row);
-        
-        outfile.close()
+        if(writeToFile == True):
+            outfile.close()
         print "Listened for %d seconds, captured %d packets." %(duration,packetcount);
         return packetcount
         
@@ -509,9 +511,9 @@ class GoodFETMCPCANCommunication:
             if period != None:
                 for i in range(0,writes):
                     self.client.MCPrts(TXB0=True);
-                    tic = time.time()
+                    #tic = time.time()
                     time.sleep(period/1000) # pause for period ms before sending again
-                    print time.time()-tic
+                    #print time.time()-tic
                 #starttime = time.time();
                 #while((time.time()-starttime < duration)):
                 #    self.client.MCPrts(TXB0=True);
@@ -568,8 +570,10 @@ class GoodFETMCPCANCommunication:
             SIDhigh = (sID >> 3) & 0xFF; # get SID bits 10:3, rotate them to bits 7:0
             packet = [SIDhigh,SIDlow,0x00,0x00,0x08]
             #dlc = row[2]
-            for i in range(4,dlc+4):
+            dlc = 8
+            for i in range(3,dlc+3):
                 packet.append(row[i])
+            print packet
             self.client.txpacket(packet)