summary refs log tree commit diff stats
path: root/cmd
diff options
context:
space:
mode:
Diffstat (limited to 'cmd')
-rw-r--r--cmd/orion/orion.go55
1 files changed, 55 insertions, 0 deletions
diff --git a/cmd/orion/orion.go b/cmd/orion/orion.go
new file mode 100644
index 0000000..e3ce011
--- /dev/null
+++ b/cmd/orion/orion.go
@@ -0,0 +1,55 @@
+package main
+
+import (
+	"os"
+	"time"
+
+	"framagit.org/andinus/orion/hibp"
+
+	"github.com/AlecAivazis/survey/v2"
+	"github.com/AlecAivazis/survey/v2/terminal"
+	"github.com/briandowns/spinner"
+	"github.com/fatih/color"
+)
+
+func main() {
+	var pass string
+
+	prompt := &survey.Password{
+		Message: "Password:",
+		Help:    "Enter password to be checked against HIBP's Database",
+	}
+	err := survey.AskOne(prompt, &pass, survey.WithValidator(survey.Required))
+	if err == terminal.InterruptErr {
+		color.Yellow("Interrupt Received")
+		os.Exit(0)
+	} else if err != nil {
+		panic(err)
+	}
+
+	s := spinner.New(spinner.CharSets[12], 32*time.Millisecond)
+	s.Start()
+	s.Color("cyan")
+
+	// get password hash
+	hsh := hibp.GetHsh(pass)
+
+	// get list of pwned passwords
+	list, err := hibp.GetPwned(hsh)
+	if err != nil {
+		color.Yellow(err.Error())
+		os.Exit(1)
+	}
+
+	// check if pass is pwned
+	pwn, fq := hibp.ChkPwn(list, hsh)
+	s.Stop()
+
+	if pwn {
+		color.New(color.FgRed).Add(color.Bold).Println("\nPwned!")
+		color.Yellow("This password has been seen %s times before.", fq)
+		return
+	}
+
+	color.Green("\nPassword wasn't found in Have I Been Pwned's Database")
+}
1d596f56a6f2198ea8ea1b0a90c613e919d891b'>^
248e789e ^

bfadbd4b ^





f898ee7a ^
6e1eeeeb ^
248e789e ^

72f278ae ^
9e5e87ca ^
248e789e ^
9e5e87ca ^
248e789e ^

9e5e87ca ^


248e789e ^
9e5e87ca ^

5170e27c ^
75f2c123 ^

248e789e ^
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104