From 9a4a36dce625e3dffbd7f354dda2cfdd8f0c2733 Mon Sep 17 00:00:00 2001 From: FalsePhilosopher <108245223+FalsePhilosopher@users.noreply.github.com> Date: Thu, 30 Jun 2022 01:14:35 -0600 Subject: [PATCH] Add files via upload These were in the toolbox folder I tried to upload but I guess sub modules don't work like how they think I do, idk i'm new to git so idk what i'm doin haha. --- wetox scripts/ReadMe.md | 2 ++ wetox scripts/changefreq.py | 50 ++++++++++++++++++++++++++++++++ wetox scripts/draw_subghz.py | 55 ++++++++++++++++++++++++++++++++++++ wetox scripts/json_to_nfc.py | 55 ++++++++++++++++++++++++++++++++++++ 4 files changed, 162 insertions(+) create mode 100644 wetox scripts/ReadMe.md create mode 100644 wetox scripts/changefreq.py create mode 100644 wetox scripts/draw_subghz.py create mode 100644 wetox scripts/json_to_nfc.py diff --git a/wetox scripts/ReadMe.md b/wetox scripts/ReadMe.md new file mode 100644 index 00000000..c5d85e8f --- /dev/null +++ b/wetox scripts/ReadMe.md @@ -0,0 +1,2 @@ +From wetox with love +https://github.com/wetox-team/flipperzero-goodies/tree/master/scripts/fff diff --git a/wetox scripts/changefreq.py b/wetox scripts/changefreq.py new file mode 100644 index 00000000..b1fdc7c6 --- /dev/null +++ b/wetox scripts/changefreq.py @@ -0,0 +1,50 @@ +# script to change the frequency of the Flipper SubGhz file + +# sample: python changefreq.py -f tesla.sub -o tesla_new.sub -r 433.92 + +import os +import argparse + +# parse input options: +parser = argparse.ArgumentParser(description="Change the frequency of the SubGhz FFF file.") +parser.add_argument("-f", "--file", help="input file") +parser.add_argument("-o", "--outfile", help="output file") +parser.add_argument("-r", "--newfreq", help="new frequency, can be decimal or whole: 433.92, 315, etc.") +args = parser.parse_args() + +# check if all arguments present +if args.file is None or args.outfile is None or args.newfreq is None: + parser.print_help() + exit() + +# check if input file exists +if not os.path.isfile(args.file): + print("File not found:", args.file) + exit() + +# convert the fractional frequency to the whole number +# example: 433.92 becomes 433920000 +if "." in args.newfreq: + freqs = args.newfreq.split(".") + newfreq = freqs[0] + freqs[1] + ("0" * (6 - len(freqs[1]))) +else: + newfreq = args.newfreq + ("0" * 6) + +# open file +f = open(args.file, 'r') + +# read file and copy it to the new one +# if the line contains the frequency, replace it with the correct one +fout = open(args.outfile, 'w') + +for line in f: + if 'Frequency' in line: + fout.write('Frequency: %s\n' % newfreq) + else: + fout.write(line) + +# close files +f.close() +fout.close() + +print("Successfully wrote file", args.outfile) diff --git a/wetox scripts/draw_subghz.py b/wetox scripts/draw_subghz.py new file mode 100644 index 00000000..035aa8fa --- /dev/null +++ b/wetox scripts/draw_subghz.py @@ -0,0 +1,55 @@ +# Script that imports a FFF subghz file and draws a timing graph + +# Example line: +# RAW_Data: 379 -798 807 -404 377 -798 805 -802 405 -396 393 -396 397 -394 +# Where the numbers are the timings between changes from 0 to 1 and vice versa +# Positive numbers are rising edges, negative numbers are falling edges + +# Setup dependencies +import matplotlib.pyplot as plt + +# Setup arguments +import argparse +parser = argparse.ArgumentParser(description='Draw a subghz file') +parser.add_argument('-f', '--file', help='Subghz file to draw', required=True) +args = parser.parse_args() + +# Read in the file +with open(args.file, 'r') as f: + lines = f.readlines() + +# Trim the lines +data = [] +for line in lines: + if "RAW_Data:" in line: + data.append(line.split("RAW_Data: ")[1].strip()) + +# Split the data into a list of individual timings +timings = [] +for line in data: + timings.append(line.split()) + +# Convert the list of lists into a single list of numbers +timings = [int(x) for x in timings[0]] + +# Convert timings to a stream of 0s and 1s +stream = [] +for timing in timings: + if timing > 0: + for i in range(timing): + stream.append(1) + else: + for i in range(abs(timing)): + stream.append(0) + +# Draw the graph +plt.plot(stream) + +#Show the graph +plt.show() + +# End of script + + + + diff --git a/wetox scripts/json_to_nfc.py b/wetox scripts/json_to_nfc.py new file mode 100644 index 00000000..84e94981 --- /dev/null +++ b/wetox scripts/json_to_nfc.py @@ -0,0 +1,55 @@ +# Script to convert proxmark JSON output to Flipper Mifare Classic NFC File Format + +import json +import argparse + + +def add_spaces_to_hex(in_str): + # converts something like "AB00BA" to "AB 00 BA" + out_str = "" + for i in range(0, len(in_str), 2): + out_str += in_str[i:i+2] + " " + return out_str.strip() + +def guess_mifare_size_by_sak(SAK): + if SAK == "18": + return "4K" + elif SAK == "08": + return "1K" + else: + return "idk" + +parser = argparse.ArgumentParser(description='Convert proxmark JSON output to Flipper Mifare classic NFC File Format') +parser.add_argument('-i', '--input', help='Input file', required=True) +parser.add_argument('-o', '--output', help='Output file', required=True) +parser.add_argument('-v', '--verbose', help='Verbose output', action='store_true') +parser.add_argument('-k', '--keys-only', help='Only output keys', action='store_true') +args = parser.parse_args() + +with open(args.input, 'r') as f: + data = json.load(f) + +if args.keys_only: + # just output the keys to a file + with open(args.output, 'w') as f: + for sector in data['SectorKeys']: + f.write(data) + +else: + with open(args.output, 'w') as f: + f.write('Filetype: Flipper NFC device\n') + f.write('Version: 2\n') + f.write('# Nfc device type can be UID, Mifare Ultralight, Mifare Classic, Bank card\n') + f.write('Device type: Mifare Classic\n') + f.write('# UID, ATQA and SAK are common for all formats\n') + f.write('UID: ' + add_spaces_to_hex(data['Card']['UID']) + '\n') + f.write('ATQA: ' + add_spaces_to_hex(data['Card']['ATQA']) + '\n') + f.write('SAK: ' + add_spaces_to_hex(data['Card']['SAK']) + '\n') + f.write('# Mifare Classic specific data\n') + if guess_mifare_size_by_sak(data['Card']['SAK']) == "4K": + f.write('Mifare Classic type: 4K\n') + elif guess_mifare_size_by_sak(data['Card']['SAK']) == "1K": + f.write('Mifare Classic type: 1K\n') + f.write('# Mifare Classic blocks\n') + for block in range(0, len(data['blocks'])): + f.write('Block ' + str(block) + ': ' + add_spaces_to_hex(data['blocks'][str(block)]) + '\n') \ No newline at end of file