diff --git a/FR24csv.py b/FR24csv.py deleted file mode 100755 index a7ab15d..0000000 --- a/FR24csv.py +++ /dev/null @@ -1,57 +0,0 @@ -#!/usr/bin/env python3 -# -# Will take a FR24 CSV and make a ADSB_Encoder CSV -import csv -import os -import argparse -import configparser - -def auto_int(x): - """Parses HEX into for argParser""" - return int(x, 0) - -def argParser(): - description = 'This script will take a FR24 CSV file and convert it into a format for FR24csv.py' - parser = argparse.ArgumentParser(description=description) - parser.add_argument('-i', '--icao', action='store', type=auto_int, dest='icao', default=cfg.get('plane', 'icao'), help='The ICAO number for the plane in hex. Ensure the ICAO is prefixed with \'0x\' to ensure this is parsed as a hex number. This is 24 bits long. Default: %(default)s') - parser.add_argument('--csv', '--csvfile', '--in', '--input', action='store', type=str, dest='csvfile', help='The name of the FR24 CSV file', required=True) - return parser.parse_args() - -def reverseCSV(csvfile): - """Reverse a CSV. Returns a dictionary of the CSV""" - data = [] - with open(csvfile, newline='') as csvfilein: - reader = csv.DictReader(csvfilein, delimiter=',') - for row in reader: - data.append(row) - csvfilein.close() - return reversed(data) - -def main(): - global cfg - cfg = configparser.ConfigParser() - cfg.read('config.cfg') - - arguments = argParser() - - csvFilename = 'fr24.csv' - - time = 0 - #Need to reverse the FR24 CSV as it is in reverse order i.e. the most recent record is row 2 and the first ADS-B message of the flight is the last row in the CSV - data = reverseCSV(arguments.csvfile) - with open(csvFilename, 'w', newline='') as csvfileout: - fieldnames = ['timestamp', 'icao', 'latitude', 'longitude', 'altitude'] - output = csv.DictWriter(csvfileout, delimiter=',', quotechar='"', quoting=csv.QUOTE_MINIMAL, fieldnames=fieldnames) - output.writeheader() - for row in data: - if time == 0: - time = int(row['Timestamp']) - rowtime = int(row['Timestamp']) - time - position = row['Position'].split(',') - newrow = {'timestamp':rowtime, 'icao':hex(arguments.icao), 'latitude':position[0], 'longitude':position[1], 'altitude':row['Altitude']} - output.writerow(newrow) - csvfileout.close() - - -if __name__ == "__main__": - main() \ No newline at end of file diff --git a/README.md b/README.md deleted file mode 100644 index 7319d5f..0000000 --- a/README.md +++ /dev/null @@ -1,135 +0,0 @@ -Firstly if you use this code or are doing anything with ADS-B broadcast, I would be interested in hearing what you are up to. Get in touch on @nzkarit on twitter or adsb (AT) karit [dot] nz - -# "ADS-B Out" add-on for SoftRF-Emu, Stratux, etc... - -This repository contains "ADS-B Out" encoder for Tx-capable SDR hardware. - -It is currently written in architecture independent Python language and can be used as an add-on for existing -open source "ADS-B In" solutions. One known good example is [Stratux](https://github.com/cyoung/stratux). - -# Disclaimer -The source code is published for academic purpose only. - -# Instructions -1. Execute *ADSB_Encoder.py* all the options have defaults so none are needed to generate with defaults. Running help will show you the optiosn you can change: -``` -$ ./ADSB_Encoder.py - -$ ./ADSB_Encoder.py -h -usage: ADSB_Encoder.py [-h] [-i ICAO] [--lat LATITUDE] [--lon LONGITUDE] - [-a ALTITUDE] [--ca CAPABILITY] [--tc TYPECODE] - [--ss SURVEILLANCESTATUS] [--nicsb NICSUPPLEMENTB] - [--time TIME] [-s SURFACE] [-o OUTPUTFILENAME] - [-r REPEATS] [--csv CSVFILE] - -This tool will generate ADS-B data in a form that a hackRF can broadcast. In -addition to providing the information at the command the defaults can be -changed in the config.cfg file and the the loggin config changed in -logging.cfg. - -optional arguments: - -h, --help show this help message and exit - -i ICAO, --icao ICAO The ICAO number for the plane in hex. Ensure the ICAO - is prefixed with '0x' to ensure this is parsed as a - hex number. Default: 0xABCDEF - --lat LATITUDE, --latitude LATITUDE - Latitude for the plane in decminal degrees. Default: - 12.34 - --lon LONGITUDE, --long LONGITUDE, --longitude LONGITUDE - Longitude for the place in decminal degrees. Default: - 56.78 - -a ALTITUDE, --alt ALTITUDE, --altitude ALTITUDE - Altitude in decminal feet. Default: 9876.5 - --ca CAPABILITY, --capability CAPABILITY - The capability. (Think this is always 5 from ADSB - messages. More info would be appreciate). Default: 5 - --tc TYPECODE, --typecode TYPECODE - The type for the ADSB messsage. See https://adsb- - decode-guide.readthedocs.io/en/latest/content/introduc - tion.html#ads-b-message-types for more information. - Default: 11 - --ss SURVEILLANCESTATUS, --surveillancestatus SURVEILLANCESTATUS - The surveillance status. (Think this is always 0 from - ADSB messages. More info would be appreciate). - Default: 0 - --nicsb NICSUPPLEMENTB, --nicsupplementb NICSUPPLEMENTB - The NIC supplement-B.(Think this is always 0 from ADSB - messages. More info would be appreciate). Default: 0 - --time TIME The time. (Think this is always 0 from ADSB messages. - More info would be appreciate). Default: 0 - -s SURFACE, --surface SURFACE - If the plane is on the ground or not. Default: False - -o OUTPUTFILENAME, --out OUTPUTFILENAME, --output OUTPUTFILENAME - The iq8s output filename. This is the file which you - will feed into the hackRF. Default: Samples_256K.iq8s - -r REPEATS, --repeats REPEATS - How many repeats of the data to perform. Default: 1 - --csv CSVFILE, --csvfile CSVFILE, --in CSVFILE, --input CSVFILE - Import a CSV file with the plane data in it. Default: - -``` -2. Transmit the signal into air: -``` -$ hackrf_transfer -t Samples_256K.iq8s -f 915000000 -s 2000000 -x 10 -call hackrf_sample_rate_set(2000000 Hz/2.000 MHz) -call hackrf_baseband_filter_bandwidth_set(1750000 Hz/1.750 MHz) -call hackrf_set_freq(915000000 Hz/915.000 MHz) -Stop with Ctrl-C - 3.9 MiB / 1.000 sec = 3.9 MiB/second - 0.5 MiB / 1.000 sec = 0.5 MiB/second - -User cancel, exiting... -Total time: 2.00039 s -hackrf_stop_tx() done -hackrf_close() done -hackrf_exit() done -fclose(fd) done -exit -$ -``` - * -t is the input file to transmit - * -f is the frequency in hertz. In the real world this would be 1090000000 but do not use that - * -s is the sample rate in hertz - * -x is the gain -3. Receive the Signal -``` -$ sudo ./dump1090 --net --freq 915000000 -... -``` -![](https://github.com/lyusupov/ADSB-Out/raw/master/documents/images/dump1090.JPG) - -# Generate CSV files -These CSV files can be used for input into the application -## generateAllICAO.py -This script will generate a CSV with all the different ICAO numbers in it. - -# Import FlightRadar24 CSV files -This script will take a FR24 CSV files and convert it ready for import into ADSB_Encoder.py. It outputs a file called fr24.csv. -``` -$ ./FR24csv.py --csv -$ ./ADSB_Encoder.py --csv fr24.csv - -$ ./FR24csv.py --help -usage: FR24csv.py [-h] [-i ICAO] --csv CSVFILE - -This script will take a FR24 CSV file and convert it into a format for -FR24csv.py - -optional arguments: - -h, --help show this help message and exit - -i ICAO, --icao ICAO The ICAO number for the plane in hex. Ensure the ICAO - is prefixed with '0x' to ensure this is parsed as a - hex number. This is 24 bits long. Default: 0x75008F - --csv CSVFILE, --csvfile CSVFILE, --in CSVFILE, --input CSVFILE - The name of the FR24 CSV file -``` -# References -1. "*Gr-Air-Modes*", **Nick Foster**, 2012 -1. "*EXPLOITING THE AUTOMATIC DEPENDENT SURVEILLANCE BROADCAST SYSTEM VIA FALSE TARGET INJECTION*", **Domenic Magazu III**, 2012 -1. "*ADS-B out by HACKRF and received over the air by rtl-sdr dongle and dump1090*", **Jiao Xianjun**, 2014 -1. "*Ghost in the Air(Traffic): On insecurity of ADS-B protocol and practical attacks on ADS-B devices*", **Andrei Costin and Aurelien Francillon**, 2015 -1. "*ADS-B Decoding Guide*", **Junzi Sun**, 2017 -1. "*Inside Radio: An Attack and Defense Guide*", **Qing Yang & Lin Huang**, 2018 - -# History -This is a fork orginally from https://github.com/lyusupov/ADSB-Out in September 2017. diff --git a/config.cfg b/config.cfg deleted file mode 100644 index 7e84d35..0000000 --- a/config.cfg +++ /dev/null @@ -1,22 +0,0 @@ -[general] -outputfilename = Samples_256K.iq8s -repeats = 1 -csvfile = -# Currently in PPM.py one message is 48 dead air, 8 preamble, 112 message, 100 dead air, 8 preamble, 112 message, 48 dead air leaves us with 99564 microseconds to make a second -intermessagegap = 99564 -# This is the message length from PPM.py -messagelength = 436 -realtime = false - -[plane] -icao = 0x75008F -latitude = 12.34 -longitude = 56.78 -altitude = 9876.5 -capability = 5 -typecode = 11 -surveillancestatus = 0 -nicsupplementb = 0 -time = 0 -surface = false -callsign = karit \ No newline at end of file diff --git a/documents/BH_US_12_Costin_Ghosts_In_Air_WP.pdf b/documents/BH_US_12_Costin_Ghosts_In_Air_WP.pdf deleted file mode 100644 index ea06b3e..0000000 Binary files a/documents/BH_US_12_Costin_Ghosts_In_Air_WP.pdf and /dev/null differ diff --git a/documents/adsb-decode-guide.pdf b/documents/adsb-decode-guide.pdf deleted file mode 100644 index a301607..0000000 Binary files a/documents/adsb-decode-guide.pdf and /dev/null differ diff --git a/documents/images/dump1090.JPG b/documents/images/dump1090.JPG deleted file mode 100644 index 68fc7ef..0000000 Binary files a/documents/images/dump1090.JPG and /dev/null differ diff --git a/documents/ref15_magazu_usaf.pdf b/documents/ref15_magazu_usaf.pdf deleted file mode 100644 index ccb0e29..0000000 Binary files a/documents/ref15_magazu_usaf.pdf and /dev/null differ diff --git a/example.csv b/example.csv deleted file mode 100644 index 117b69e..0000000 --- a/example.csv +++ /dev/null @@ -1,3 +0,0 @@ -icao,altitude,callsign -0x123456,50000,karit -0xABCDEF,1000,notkarit diff --git a/generateAllAlt.py b/generateAllAlt.py deleted file mode 100755 index 678d935..0000000 --- a/generateAllAlt.py +++ /dev/null @@ -1,79 +0,0 @@ -#!/usr/bin/env python3 -# -# Will generate a CSV with all Latitudes -import csv -import os - -def writeFile(directory, filename, filenameExtension, data, count): - csvFilename = os.path.join(directory, "%s-%s.%s"%(filename, count, filenameExtension)) - with open(csvFilename, 'w', newline='') as csvfile: - output = csv.writer(csvfile, delimiter=',', quotechar='"', quoting=csv.QUOTE_MINIMAL) - output.writerow(['altitude']) - for row in data: - output.writerow([row]) - csvfile.close() - return "{'csv':'%s', 'out':'%s-%s.iq8s'},"%(csvFilename, filename, count) - -def main(): - directory = 'generated' - filename = 'allAlt' - filenameExtension = 'csv' - scriptFilename = 'allAlt.py' - hackRFScriptFilename = 'hackRFAllAlt.sh' - - minAlt = -1100 - maxAlt = 100000 - splitNumber = 1000 - step = 1 - - try: - os.stat(directory) - except: - os.mkdir(directory) - - script = open(scriptFilename, 'w') - script.write('#!/usr/bin/env python3\n') - script.write('import time\n') - script.write('import threading\n') - script.write('from ADSB_Encoder import *\n') - - hackRFScript = open(hackRFScriptFilename, 'w') - hackRFScript.write('#!/bin/bash\n') - - - i = minAlt - j = 0 - k = 0 - data = [] - - files = '' - while i <= maxAlt: - if j == splitNumber: - files += writeFile(directory, filename, filenameExtension, data, k) - data = [] - hackRFScript.write("hackrf_transfer -t %s-%s.iq8s -f 915000000 -s 2000000 -x 10\n" % (filename, k)) - k += 1 - j = 0 - data.append(i) - i += step - j += 1 - files += writeFile(directory, filename, filenameExtension, data, k) - data = [] - hackRFScript.write("hackrf_transfer -t %s-%s.iq8s -f 915000000 -s 2000000 -x 10\n" % (filename, k)) - k += 1 - j = 0 - files = files[:-1] - script.write('files = [%s]\n' % (files)) - script.write('for file in files:\n') - script.write(' t = threading.Thread(target=threadingCSV, args=(file,))\n') - script.write(' t.start()\n') - script.write(' print(file)\n') - script.write(' time.sleep(1)\n') - script.close() - hackRFScript.close() - -if __name__ == "__main__": - main() - - - diff --git a/generateAllICAO.py b/generateAllICAO.py deleted file mode 100755 index 0254b8d..0000000 --- a/generateAllICAO.py +++ /dev/null @@ -1,78 +0,0 @@ -#!/usr/bin/env python3 -# -# Will generate a CSV with all ICAOS -import csv -import os - -def writeFile(directory, filename, filenameExtension, data, count): - csvFilename = os.path.join(directory, "%s-%s.%s"%(filename, count, filenameExtension)) - with open(csvFilename, 'w', newline='') as csvfile: - output = csv.writer(csvfile, delimiter=',', quotechar='"', quoting=csv.QUOTE_MINIMAL) - output.writerow(['icao']) - for row in data: - output.writerow([row]) - csvfile.close() - return "{'csv':'%s', 'out':'%s-%s.iq8s'},"%(csvFilename, filename, count) - -def main(): - directory = 'generated' - filename = 'allICAO' - filenameExtension = 'csv' - scriptFilename = 'allICAO.py' - hackRFScriptFilename = 'hackRFAllICAO.sh' - - minICAO = 0x0 - maxICAO = 0x3E8 - splitNumber = 1000 - - try: - os.stat(directory) - except: - os.mkdir(directory) - - script = open(scriptFilename, 'w') - script.write('#!/usr/bin/env python3\n') - script.write('import time\n') - script.write('import threading\n') - script.write('from ADSB_Encoder import *\n') - - hackRFScript = open(hackRFScriptFilename, 'w') - hackRFScript.write('#!/bin/bash\n') - - - i = minICAO - j = 0 - k = 0 - data = [] - - files = '' - while i <= maxICAO: - if j == splitNumber: - files += writeFile(directory, filename, filenameExtension, data, k) - data = [] - hackRFScript.write("hackrf_transfer -t %s-%s.iq8s -f 915000000 -s 2000000 -x 10\n" % (filename, k)) - k += 1 - j = 0 - data.append(hex(i)) - i += 1 - j += 1 - files += writeFile(directory, filename, filenameExtension, data, k) - data = [] - hackRFScript.write("hackrf_transfer -t %s-%s.iq8s -f 915000000 -s 2000000 -x 10\n" % (filename, k)) - k += 1 - j = 0 - files = files[:-1] - script.write('files = [%s]\n' % (files)) - script.write('for file in files:\n') - script.write(' t = threading.Thread(target=threadingCSV, args=(file,))\n') - script.write(' t.start()\n') - script.write(' print(file)\n') - script.write(' time.sleep(1)\n') - script.close() - hackRFScript.close() - -if __name__ == "__main__": - main() - - - diff --git a/generateAllLat.py b/generateAllLat.py deleted file mode 100755 index 96945b7..0000000 --- a/generateAllLat.py +++ /dev/null @@ -1,79 +0,0 @@ -#!/usr/bin/env python3 -# -# Will generate a CSV with all Latitudes -import csv -import os - -def writeFile(directory, filename, filenameExtension, data, count): - csvFilename = os.path.join(directory, "%s-%s.%s"%(filename, count, filenameExtension)) - with open(csvFilename, 'w', newline='') as csvfile: - output = csv.writer(csvfile, delimiter=',', quotechar='"', quoting=csv.QUOTE_MINIMAL) - output.writerow(['latitude']) - for row in data: - output.writerow([row]) - csvfile.close() - return "{'csv':'%s', 'out':'%s-%s.iq8s'},"%(csvFilename, filename, count) - -def main(): - directory = 'generated' - filename = 'allLat' - filenameExtension = 'csv' - scriptFilename = 'allLat.py' - hackRFScriptFilename = 'hackRFAllLat.sh' - - minLat = -90 - maxLat = 90 - splitNumber = 1000 - step = 0.05 - - try: - os.stat(directory) - except: - os.mkdir(directory) - - script = open(scriptFilename, 'w') - script.write('#!/usr/bin/env python3\n') - script.write('import time\n') - script.write('import threading\n') - script.write('from ADSB_Encoder import *\n') - - hackRFScript = open(hackRFScriptFilename, 'w') - hackRFScript.write('#!/bin/bash\n') - - - i = minLat - j = 0 - k = 0 - data = [] - - files = '' - while i <= maxLat: - if j == splitNumber: - files += writeFile(directory, filename, filenameExtension, data, k) - data = [] - hackRFScript.write("hackrf_transfer -t %s-%s.iq8s -f 915000000 -s 2000000 -x 10\n" % (filename, k)) - k += 1 - j = 0 - data.append(i) - i += step - j += 1 - files += writeFile(directory, filename, filenameExtension, data, k) - data = [] - hackRFScript.write("hackrf_transfer -t %s-%s.iq8s -f 915000000 -s 2000000 -x 10\n" % (filename, k)) - k += 1 - j = 0 - files = files[:-1] - script.write('files = [%s]\n' % (files)) - script.write('for file in files:\n') - script.write(' t = threading.Thread(target=threadingCSV, args=(file,))\n') - script.write(' t.start()\n') - script.write(' print(file)\n') - script.write(' time.sleep(1)\n') - script.close() - hackRFScript.close() - -if __name__ == "__main__": - main() - - - diff --git a/logging.cfg b/logging.cfg deleted file mode 100644 index ac7b647..0000000 --- a/logging.cfg +++ /dev/null @@ -1,28 +0,0 @@ -[loggers] -keys=root - -[handlers] -keys=consoleHandler, timedRotatingFileHandler - -[formatters] -keys=simpleFormatter - -[logger_root] -level=DEBUG -handlers=consoleHandler, timedRotatingFileHandler - -[handler_timedRotatingFileHandler] -class=handlers.TimedRotatingFileHandler -level=DEBUG -formatter=simpleFormatter -args=('ADSB_Encoder.log', 'H', 1, 72) - -[handler_consoleHandler] -class=StreamHandler -level=WARNING -formatter=simpleFormatter -args=(sys.stdout,) - -[formatter_simpleFormatter] -format=%(asctime)s - %(name)s - %(levelname)s - %(message)s -datefmt=