Created
May 24, 2020 23:56
-
-
Save pdelteil/98ec6684b47694fcf1964aa69836ebd7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from skyfield.api import Topos, load | |
import socket | |
from time import sleep | |
import re | |
import array as arr | |
#connecting to server | |
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
s.connect(('where.satellitesabove.me', 5021)) | |
print("connecting to where.satellitesabove.me:5021") | |
sleep(0.1) | |
print(s.recv(1024).decode()) | |
ticket="ticket{yankee2425golf:GG2riBRYfMfQM3W4fDz9ZUhdJ9C7YHwx4jSvhXgMrRh47AWIwve0R0SKLAmMkKG7Fg}\n" | |
s.send(ticket.encode()) | |
print(s.recv(3048).decode()) | |
#loading stations | |
stations_url = 'stations.txt' | |
satellites = load.tle_file(stations_url) | |
ts = load.timescale() | |
#always the same satellite | |
satellite = satellites[5] | |
buff = 10000 | |
#doing the work | |
while True: | |
while True: | |
sleep(0.1) | |
input = s.recv(buff).decode() | |
#if we receive the flag as response | |
if 'flag' in input: | |
print(input) | |
exit() | |
if 'What is the X coordinate at the time of:' in input: | |
time = re.search(r'\((.*?)\)',input).group(1) | |
array = [float(x) for x in time.split(",")] | |
t = ts.utc(array[0], array[1], array[2], array[3], array[4], array[5]) | |
geocentric = satellite.at(t) | |
x = geocentric.position.km[0] | |
print(f'Sending {x}') | |
s.send((str(x)+"\n").encode()) | |
#print(s.recv(1024).decode()) | |
break | |
if 'What is the Y coordinate at the time of:' in input: | |
time = re.search(r'\((.*?)\)',input).group(1) | |
array = [float(x) for x in time.split(",")] | |
t = ts.utc(array[0], array[1], array[2], array[3], array[4], array[5]) | |
geocentric = satellite.at(t) | |
x = geocentric.position.km[1] | |
print(f'Sending {x}') | |
s.send((str(x)+"\n").encode()) | |
#print(s.recv(1024).decode()) | |
break | |
if 'What is the Z coordinate at the time of:' in input: | |
time = re.search(r'\((.*?)\)',input).group(1) | |
array = [float(x) for x in time.split(",")] | |
t = ts.utc(array[0], array[1], array[2], array[3], array[4], array[5]) | |
geocentric = satellite.at(t) | |
x = geocentric.position.km[2] | |
print(f'Sending {x}') | |
s.send((str(x)+"\n").encode()) | |
#print(s.recv(1024).decode()) | |
break |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment