-
Notifications
You must be signed in to change notification settings - Fork 4
/
evernote_legacy_darwin.go
51 lines (38 loc) · 1.23 KB
/
evernote_legacy_darwin.go
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
package main
import (
"encoding/hex"
"regexp"
"strconv"
"strings"
"howett.net/plist"
)
func legacyGetUsers() (Users []User) {
for _, accountID := range legacyMacGetAccounts() {
Users = append(Users, legacyMacGetUser(accountID))
}
return
}
func legacyMacGetAccounts() (accounts []string) {
evernoteAccounts := getSecureStorageData("Evernote", "")
r, _ := regexp.Compile("\"acct\"<blob>=\"([0-9]+/Evernote/smd)\"")
for _, userMatch := range r.FindAllStringSubmatch(string(evernoteAccounts), -1) {
accountID := userMatch[1]
accounts = append(accounts, accountID)
}
return
}
func legacyMacGetUser(accountID string) User {
accountDataHex := getSecureStorageData("Evernote", accountID)
accountDataBin, err := hex.DecodeString(strings.TrimSpace(string(accountDataHex)))
panicFail(err)
accountData := make(map[string]interface{})
_, err = plist.Unmarshal(accountDataBin, &accountData)
panicFail(err)
return User{
path: accountID,
id: strconv.FormatUint(accountData["$objects"].([]interface{})[6].(uint64), 10),
username: accountData["$objects"].([]interface{})[7].(string),
email: accountData["$objects"].([]interface{})[8].(string),
token: accountData["$objects"].([]interface{})[3].(string),
}
}