From 267b6ebf8670a492807437e9f3e4d199df93f6c0 Mon Sep 17 00:00:00 2001 From: angelina-tsuboi Date: Sun, 7 May 2023 08:15:11 -0700 Subject: [PATCH] feat: init reformat code --- cli/cli.go | 10 +++++- main.go | 1 + osint/osint.go | 82 ++++++++++++++++++++++++++++++++++++------------- osint/tle.go | 23 ++++++++++++++ txt/options.txt | 2 +- 5 files changed, 94 insertions(+), 24 deletions(-) create mode 100644 osint/tle.go diff --git a/cli/cli.go b/cli/cli.go index 4b21cc0..74fe168 100644 --- a/cli/cli.go +++ b/cli/cli.go @@ -36,7 +36,15 @@ func DisplayFunctions(x int) { osint.OrbitalElement() Banner() Option() - } else if (x == 4) { + } else if (x == 2) { + osint.SatellitePositionVisualization() + Banner() + Option() + } else if (x == 3) { + osint.SatellitePositionVisualization() + Banner() + Option() + }else if (x == 4) { osint.TLEParser() Banner() Option() diff --git a/main.go b/main.go index 27c951d..d4de56e 100644 --- a/main.go +++ b/main.go @@ -12,5 +12,6 @@ import ( func main() { os.Setenv("SPACE_TRACK_USERNAME", "username") os.Setenv("SPACE_TRACK_PASSWORD", "password") + os.Setenv("N2YO_API_KEY", "api-key") cli.SatIntel() } diff --git a/osint/osint.go b/osint/osint.go index 5897571..12f0584 100644 --- a/osint/osint.go +++ b/osint/osint.go @@ -15,28 +15,6 @@ import ( "net/url" ) -type TLE struct { - CommonName string - SatelliteCatalogNumber int - ElsetClassificiation string - InternationalDesignator string - ElementSetEpoch float64 - FirstDerivativeMeanMotion float64 - SecondDerivativeMeanMotion string - BDragTerm string - ElementSetType int - ElementNumber int - ChecksumOne int - OrbitInclination float64 - RightAscension float64 - Eccentrcity float64 - Perigee float64 - MeanAnamoly float64 - MeanMotion float64 - RevolutionNumber int - ChecksumTwo int -} - type field string type orderBy string const authURL = "https://www.space-track.org/ajaxauth/login" @@ -142,6 +120,66 @@ func PrintNORADInfo(norad string) { PrintTLE(tle) } +// Satellite Position Visualization Code +func SatellitePositionVisualization() { + options, _ := ioutil.ReadFile("txt/orbital_element.txt") + opt,_:=gradient.NewGradient("#1179ef", "cyan") + opt.Print("\n" + string(options)) + var selection int = Option(0, 3) + + if (selection == 1) { + vals := url.Values{} + vals.Add("identity", os.Getenv("SPACE_TRACK_USERNAME")) + vals.Add("password", os.Getenv("SPACE_TRACK_PASSWORD")) + vals.Add("query", "https://www.space-track.org/basicspacedata/query/class/satcat/orderby/SATNAME asc/limit/10/emptyresult/show") + + client := &http.Client{} + + resp, err := client.PostForm(authURL, vals) + if err != nil { + fmt.Println(color.Ize(color.Red, " [!] ERROR: API REQUEST TO SPACE TRACK")) + } + + defer resp.Body.Close() + if resp.StatusCode < 200 || resp.StatusCode >= 300 { + fmt.Println(color.Ize(color.Red, " [!] ERROR: API REQUEST TO SPACE TRACK")) + } + respData, err := ioutil.ReadAll(resp.Body) + + if err != nil { + fmt.Println(color.Ize(color.Red, " [!] ERROR: API REQUEST TO SPACE TRACK")) + } + + var sats []Satellite + if err := json.Unmarshal(respData, &sats); err != nil { + fmt.Println(color.Ize(color.Red, " [!] ERROR: API REQUEST TO SPACE TRACK")) + } + + var satStrings []string + for _, sat := range sats { + satStrings = append(satStrings, sat.SATNAME + " (" + sat.NORAD_CAT_ID + ")") + } + prompt := promptui.Select{ + Label: "Select a Satellite 🛰", + Items: satStrings, + } + _, result, err := prompt.Run() + if err != nil { + fmt.Println(color.Ize(color.Red, " [!] PROMPT FAILED")) + return + } + PrintNORADInfo(extractNorad(result)) + + } else if (selection == 2) { + fmt.Print("\n ENTER NORAD ID > ") + var norad string + fmt.Scanln(&norad) + PrintNORADInfo(norad) + } + + return +} + // TLE Parser Code func TLEParser() { diff --git a/osint/tle.go b/osint/tle.go new file mode 100644 index 0000000..d4145fe --- /dev/null +++ b/osint/tle.go @@ -0,0 +1,23 @@ +package osint + +type TLE struct { + CommonName string + SatelliteCatalogNumber int + ElsetClassificiation string + InternationalDesignator string + ElementSetEpoch float64 + FirstDerivativeMeanMotion float64 + SecondDerivativeMeanMotion string + BDragTerm string + ElementSetType int + ElementNumber int + ChecksumOne int + OrbitInclination float64 + RightAscension float64 + Eccentrcity float64 + Perigee float64 + MeanAnamoly float64 + MeanMotion float64 + RevolutionNumber int + ChecksumTwo int +} \ No newline at end of file diff --git a/txt/options.txt b/txt/options.txt index 90fabc5..74a506a 100644 --- a/txt/options.txt +++ b/txt/options.txt @@ -4,7 +4,7 @@ [ 2 ] Satellite Position Visualization - [ 3 ] Visual and Radio Passes Predictions + [ 3 ] Orbital Predictions (Visual, Radio, and SGP4) [ 4 ] TLE Parser