hanayo/scripts/top_passwords.go

52 lines
1.1 KiB
Go
Raw Permalink Normal View History

2019-02-23 13:29:15 +00:00
// +build ignore
package main
import (
"bufio"
"fmt"
"net/http"
"os"
)
const topPasswords = `https://raw.githubusercontent.com/danielmiessler/SecLists/master/Passwords/10_million_password_list_top_10000.txt`
const fileHeader = `// THIS FILE WAS AUTOMATICALLY GENERATED BY A TOOL
// Use ` + "`go generate`" + ` to generate this.
package toppasswords
// TopPassword is a list of the top 10,000 passwords longer or exactly 8
// characters. This is used in Hanayo to detect common password, and to inform
// the user about it.
var TopPasswords = []string{
`
func main() {
resp, err := http.Get(topPasswords)
if err != nil {
panic(err)
}
f, err := os.Create("modules/top-passwords/top_passwords.go")
defer f.Close()
if err != nil {
panic(err)
}
f.Write([]byte(fileHeader))
s := bufio.NewScanner(resp.Body)
for s.Scan() {
// passwords shorter than 8 characters aren't allowed on ripple anyway.
if len(s.Text()) < 8 {
continue
}
fmt.Fprintf(f, "\t\"%s\",\n", s.Text())
}
f.Write([]byte{'}', '\n'})
fmt.Println("generate: top_passwords.go")
}