Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 19 additions & 19 deletions aircraft.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,22 @@


class Aircraft:
def __init__(self, tail_n, msn=None, call=None, \
latitude=None, longitude=None, craft_type=None, \
origin=None, destination=None, altitude=None, \
manufacturer=None, icao=None,notes=None):
def __init__(self, tail_n, msn=None, call=None,
latitude=None, longitude=None, craft_type=None,
origin=None, destination=None, altitude=None,
manufacturer=None, icao=None, notes=None):

self.tail_n = tail_n
self.msn = msn
self.call = call
self.origin = origin
self.manufacturer = manufacturer
self.destination = destination
self.altitude = altitude
self.latitude = latitude
self.longitude = longitude
self.icao = icao
self.notes = notes
self.tail_n = tail_n
self.msn = msn
self.call = call
self.origin = origin
self.manufacturer = manufacturer
self.destination = destination
self.altitude = altitude
self.latitude = latitude
self.longitude = longitude
self.icao = icao
self.notes = notes

def __str__(self):
return self.__repr__()
Expand All @@ -38,8 +38,8 @@ def __repr__(self):
Last known position: %s
Last known altitude: %s

Notes:
Notes:
%s
""" % (self.manufacturer, self.msn, self.icao,
self.tail_n, self.call, (self.latitude, self.longitude),
self.altitude, self.notes)
""" % (self.manufacturer, self.msn, self.icao, self.tail_n,
self.call, (self.latitude, self.longitude), self.altitude,
self.notes)
100 changes: 62 additions & 38 deletions avosint.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,19 @@
# Implement ADS-B
# Implement news source, location API, and search based on location name
import os
import sys
import requests
import random as rand
import json
import logging
import argparse
import time
import socket
import csv

from registers import *
from tail_to_register import *
from investigation_authorities import *
from aircraft import Aircraft
from monitor import monitor
from wiki_api import search_wiki_commons
from opensky_api import OpenSkyApi
from bs4 import BeautifulSoup
from threading import Thread


# Data sources
Expand All @@ -40,7 +35,7 @@
# News source
AP = 'Associated Press'
AFP = 'Agence France Presse'
AP_KEY = 'API KEY HERE'
AP_KEY = 'API KEY HERE'


# Docker
Expand All @@ -62,7 +57,8 @@ class bcolors:

class NoIntelException(Exception):
""" Raised when no information has been found in registers"""
pass
pass



def printok(str):
Expand Down Expand Up @@ -93,15 +89,16 @@ def check_config():
check_config_file_coherence = False
check_docker_connectivity = False


def check_config():
print("[*] Checking config")

# Tests connectivity to the docker container
timeout_seconds=1
timeout_seconds = 1
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.settimeout(timeout_seconds)
result = sock.connect_ex((DOCKER_HOST, DOCKER_PORT))
sock.close()
docker_result = result

if result == 0:
printok("Parsr docker container is reachable")
Expand All @@ -111,12 +108,12 @@ def check_config():
return False



def getInterestingPlaces():
# Get news feed about things that could require a plane flyover
# Wildfire, traffic accidents, police intervention, natural disasters, etc.
return None


def intel_from_ICAO(icao):
"""
Gather intel starting with icao number
Expand All @@ -127,8 +124,8 @@ def intel_from_ICAO(icao):
def opensky(tail_n):
print("[*] Gathering infos from opensky network database. This can take some time")
headers = {
'User-Agent': 'AVOSINT - CLI tool to gather aviation OSINT.'\
'Infos and contact: https://github.com/n0skill/AVOSINT'
'User-Agent': 'AVOSINT - CLI tool to gather aviation OSINT.'
'Infos and contact: https://github.com/n0skill/AVOSINT'
}

if os.path.exists('/tmp/opensky.cache') \
Expand All @@ -147,7 +144,8 @@ def opensky(tail_n):
for data in r.iter_content(chunk_size=8192*4):
dl += len(data)
f.write(data)
print('\r[*] Downloading {:2f}'.format((dl/total_l)*100), end='')
print('\r[*] Downloading {:2f}'.format((dl/total_l)*100),
end='')
print('\r[*] Done loading !')
else:
printwarn(r.status_code)
Expand All @@ -167,7 +165,6 @@ def opensky(tail_n):
icao=icao,
manufacturer=manufacturer,
msn=msn), Owner(owner)
return None


def intel_from_tail_n(tail_number):
Expand Down Expand Up @@ -198,7 +195,7 @@ def intel_from_tail_n(tail_number):

# First, from official registers
try:
owner_infos, aircraft_infos = tail_to_register_function[tail_prefix](tail_number)
owner_infos, aircraft_infos = tail_to_register_function[tail_prefix](tail_number)
except Exception as e:
printverbose("[!] Exception while calling tail_to_register: {}".format(e))

Expand Down Expand Up @@ -232,6 +229,20 @@ def intel_from_tail_n(tail_number):
# Last changes of ownership
# TODO

# Last known position
icao = os_aircraft.icao.lower()
api = OpenSkyApi()
s = api.get_states(icao24=icao)

try:
if s is not None and len(s.states) > 0:
last_lat = (s.states)[0].latitude
last_lon = (s.states)[0].longitude
os_aircraft.latitude = last_lat
os_aircraft.longitude = last_lon
except Exception as e:
printko(e)

# Detailled info (pictures etc)
# TODO

Expand All @@ -250,27 +261,35 @@ def intel_from_tail_n(tail_number):
return owner_infos, aircraft_infos, wiki_infos



def main():
# 1 - Check OSINT from ICAO
# 2 - Check OSINT from tail number
# 3 - Tool to convert icao to tail number
parser = argparse.ArgumentParser()
parser.add_argument("--action",
help="Action to perform ('ICAO', 'tail', 'convert')",
type=str, required=True)
parser.add_argument('--tail-number',
help='Tail number to lookup')
parser = argparse.ArgumentParser()
parser.add_argument(
"--action",
help="Action to perform ('ICAO', 'tail', 'convert')",
type=str, required=True)
parser.add_argument(
'--tail-number',
help='Tail number to lookup')
# Optional arguments
parser.add_argument("--icao",
help="ICAO code to retrieve OSINT for", required=False)
parser.add_argument("--config",
help="Config file", type=str)
parser.add_argument("--proxy",
help="Use proxy address", type=str)
parser.add_argument("--interactive",
action="store_true")
parser.add_argument("--verbose",
action="store_true")
parser.add_argument(
"--icao",
help="ICAO code to retrieve OSINT for", required=False)
parser.add_argument(
"--config",
help="Config file", type=str)
parser.add_argument(
"--proxy",
help="Use proxy address", type=str)
parser.add_argument(
"--interactive",
action="store_true")
parser.add_argument(
"--verbose",
action="store_true")

require_group = parser.add_mutually_exclusive_group(required=False)
require_group.add_argument("--country", help="country code", type=str)
Expand All @@ -297,25 +316,30 @@ def main():
else:
printok("All checks passed")

action = args.action
action = args.action
tail_number = args.tail_number
icao = args.icao
verbose = args.verbose
icao = args.icao
verbose = args.verbose

while action != 'quit':
if action == "ICAO":
try:
intel_from_ICAO(icao)
except Exception as e:
status = 'ActionICAOException'
print(status, e)
elif action == "tail":
try:
while tail_number == None:
if tail_number is None:
tail_number = input("Enter tail number to lookup: ")
owner_infos, aircraft_infos, wiki_infos = intel_from_tail_n(tail_number)
incident_reports = search_incidents(tail_number, args.verbose)

owner_infos, aircraft_infos, wiki_infos \
= intel_from_tail_n(tail_number)
incident_reports \
= search_incidents(tail_number, args.verbose)
except Exception as e:
status = 'IncidentSearchException'
print(status, e)

status = 'Done'
elif action == "convert":
Expand Down
12 changes: 7 additions & 5 deletions investigation_authorities.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@
import time
from bs4 import BeautifulSoup


def search_incidents(tail_n, is_verbose):
r = requests.get('https://aviation-safety.net/database/registration/regsearch.php?regi={}'.format(tail_n))

r = requests.get('https://aviation-safety.net/database/'
'registration/regsearch.php?regi={}'.format(tail_n))
if r.status_code == 200:
soup= BeautifulSoup(r.content, 'html.parser')
td = soup.find('span', {'class': 'nobr'})
soup = BeautifulSoup(r.content, 'html.parser')
td = soup.find('span', {'class': 'nobr'})
if td:
r = requests.get('https://aviation-safety.net'+td.find('a')['href'])
r = requests.get('https://aviation-safety.net' +
td.find('a')['href'])
return r.url
if r.status_code == 403:
return 'HTTP 403 while retriving incidents'
Expand Down
5 changes: 3 additions & 2 deletions monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,16 @@
import math
import numpy as np
import os


def monitor(icao):
positions = []
api = OpenSkyApi()
accumulated_angle = 0.0
old_alpha = 0
url = 'https://globe.adsbexchange.com/?icao={}'.format(icao)
hovering = False
icao = icao.lower()

while True:
s = api.get_states(icao24=icao)
if s is not None and len(s.states) > 0:
Expand Down
4 changes: 4 additions & 0 deletions registers.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ def init_poolmanager(self, *args, **kwargs):
kwargs['ssl_context'] = context
return super(NODHAdapter, self).init_poolmanager(*args, **kwargs)


class NoIntelException(Exception):
""" Raised when no info has been found """
pass
Expand Down Expand Up @@ -490,6 +491,7 @@ def AT(tail_n):
raise e



def AU(tail_n):
"""
Australia Registry
Expand All @@ -513,6 +515,8 @@ def AU(tail_n):
return Owner(name, addr, city, '', 'Australia'), Aircraft(tail_n)
raise Exception(
"Could not get info from AU register")


def BA(tail_n):
register = register_from_config("BA")
infos = register.request_infos(tail_n)
Expand Down
Loading