/
dict.go
46 lines (40 loc) · 921 Bytes
/
dict.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
package brute
import (
"github.com/Athena1337/blackJack/config"
"github.com/Athena1337/blackJack/utils"
"github.com/t43Wiu6/tlog"
"os"
"path/filepath"
)
func PrepareDict() (dicts []string, err error){
dict, err := loadDict(config.Dict_mini)
if err != nil {
return
}
dicts = append(dicts, dict...)
dict, err = loadDict(config.Api)
if err != nil {
return
}
dicts = append(dicts, dict...)
dict, err = loadDict(config.File)
if err != nil {
return
}
dicts = append(dicts, dict...)
log.Debugf("Generate dict %d 's", len(dicts))
return
}
func loadDict(name string)(dict []string, err error) {
filePath, err := utils.GetCurrentAbPathByCaller()
if err == nil{
home, _ := os.UserHomeDir()
filePath = filepath.Join(home, ".blackJack", name)
dict, err = utils.ReadFile(filePath)
if err != nil {
log.Warnf("dict not found, unable to read dict file: %s", filePath)
return
}
}
return
}