Skip to content

Commit

Permalink
Add more detail after parsing the config file - fixes #1
Browse files Browse the repository at this point in the history
    found 269 remote definitions
    found 54 passwords generated by rclone config which need checking
    ignored 11 passwords not generated by rclone config
    ignored 14 passwords less than 64 bits
  • Loading branch information
ncw committed Nov 22, 2020
1 parent c447e44 commit 4dce5de
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ For example:

```
$ ./passwordcheck ~/.rclone.conf
2020/11/19 14:01:49 found 269 remote definitions
2020/11/19 14:01:49 found 54 passwords generated by rclone config which need checking
2020/11/19 14:01:49 ignored 11 passwords not generated by rclone config
2020/11/19 14:01:49 ignored 14 passwords less than 64 bits
2020/11/19 14:01:49 Looking through 39103309 seeds from seed 1566691200 generated at 2019-08-25 01:00:00 to seed 1605794509 generated at 2020-11-19 14:01:49 for 3 passwords of length 64 bits
2020/11/19 14:03:38 FOUND match for remote test-remote-1: obscured password "fJKeinHaUgkd_4pO0J70tUMUkvoxoPES5p7-" at seed 1605788442 generated at 2020-11-19 12:20:42
2020/11/19 14:03:38 That took 1m48.992723504s for 358769.904475 seeds/s
Expand Down Expand Up @@ -73,3 +77,4 @@ remote test-remote-3: "px0py_poF8Jzis0rxNGf2OvtVZPnmwUruqI1o3trhE1I8fcR3To"
prints - these can easily be reversed into the actual password. The
ones show here are for demonstration purposes.

To see more detail what is happening run with the `-verbose` flag.
18 changes: 17 additions & 1 deletion passwordcheck.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,12 @@ func seedString(seed int64) string {

// read the config file and return candidate passwords grouped by length
func readConfigFile(in io.Reader) (pws map[int][]passEntry) {
var (
remotes = 0
nonGeneratedPasswords = 0
tooShortPasswords = 0
generatedPasswords = 0
)
pws = make(map[int][]passEntry)

scanner := bufio.NewScanner(in)
Expand All @@ -99,6 +105,7 @@ func readConfigFile(in io.Reader) (pws map[int][]passEntry) {
}
if line[0] == '[' && line[len(line)-1] == ']' {
remote = line[1 : len(line)-1]
remotes++
continue
}
if strings.Contains(line, "RCLONE_ENCRYPT") {
Expand All @@ -120,17 +127,21 @@ func readConfigFile(in io.Reader) (pws map[int][]passEntry) {
pwString, err := obscure.Reveal(value)
if err != nil {
debugf("%s: %s = %q is not an obscured password: %v", remote, key, value, err)
nonGeneratedPasswords++
continue
}
pw, err := base64.RawURLEncoding.DecodeString(pwString)
if err != nil {
debugf("%s: obscured password %s = %q was not generated by rclone: %v", remote, key, value, err)
nonGeneratedPasswords++
continue
}
if len(pw) < *minBits/8 {
debugf("%s: IGNORING obscured password %s = %q is only %d bits (set with -min-bits)", remote, key, value, len(pw)*8)
tooShortPasswords++
continue
}
generatedPasswords++
pws[len(pw)] = append(pws[len(pw)],
passEntry{
remote: remote,
Expand All @@ -145,6 +156,11 @@ func readConfigFile(in io.Reader) (pws map[int][]passEntry) {
if err := scanner.Err(); err != nil {
log.Fatal(err)
}

log.Printf("found %d remote definitions", remotes)
log.Printf("found %d passwords generated by rclone config which need checking", generatedPasswords)
log.Printf("ignored %d passwords not generated by rclone config", nonGeneratedPasswords)
log.Printf("ignored %d passwords less than %d bits", tooShortPasswords, *minBits)
return pws
}

Expand Down Expand Up @@ -265,7 +281,7 @@ func main() {
pwsMap := readConfigFile(in)
_ = in.Close()
if len(pwsMap) == 0 {
log.Fatalf("No passwords found in config file - did you use the right file?")
log.Fatalf("No passwords to check found in config file - did you use the right file?")
}

pws := findAllPasswords(startSeed, endSeed, pwsMap)
Expand Down

0 comments on commit 4dce5de

Please sign in to comment.