Skip to content

Commit

Permalink
feat: 增加单独指定用户名/密码参数
Browse files Browse the repository at this point in the history
增加单独指定用户名/密码参数
  • Loading branch information
X1r0z committed Aug 8, 2023
1 parent 464d8a6 commit c9f1089
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 12 deletions.
1 change: 1 addition & 0 deletions lib/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ func BruteRunner(targetUrl string, mode string, domain string, userDict []string
authPath := ExchangeUrls[mode]
u, _ := url.JoinPath(targetUrl, authPath)
Log.Info("[*] 使用 %v 接口爆破: %v", mode, targetUrl)
Log.Info("[*] 用户名:%v 密码:%v 共计:%v", len(userDict), len(passDict), len(userDict)*len(passDict))

task := make(chan []string, len(userDict)*len(passDict))

Expand Down
41 changes: 29 additions & 12 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ func main() {
domain string
user string
pass string
userf string
passf string
n int
v bool
delay int
Expand All @@ -26,8 +28,10 @@ func main() {
flag.StringVar(&mode, "mode", "", "指定 Exchange Web 接口")
flag.BoolVar(&check, "check", false, "检测目标 Exchange 可用接口")
flag.StringVar(&domain, "domain", "", "AD 域名")
flag.StringVar(&user, "user", "", "用户名字典")
flag.StringVar(&pass, "pass", "", "密码字典")
flag.StringVar(&user, "user", "", "指定用户名")
flag.StringVar(&pass, "pass", "", "指定密码")
flag.StringVar(&userf, "userf", "", "用户名字典")
flag.StringVar(&passf, "passf", "", "密码字典")
flag.IntVar(&n, "thread", 2, "协程数量")
flag.IntVar(&delay, "delay", 0, "请求延时")
flag.BoolVar(&v, "verbose", false, "显示详细信息")
Expand All @@ -50,19 +54,32 @@ func main() {
lib.Check(targetUrl)
} else {

userFp, _ := os.Open(user)
passFp, _ := os.Open(pass)
var userDict []string
var passDict []string

defer userFp.Close()
defer passFp.Close()
if user != "" {
userDict = []string{user}
}

userBytes, _ := io.ReadAll(userFp)
passBytes, _ := io.ReadAll(passFp)
if pass != "" {
passDict = []string{pass}
}

userDict := strings.Split(string(userBytes), "\n")
passDict := strings.Split(string(passBytes), "\n")
userDict = userDict[:len(userDict)-1]
passDict = passDict[:len(passDict)-1]
if userf != "" {
fp, _ := os.Open(userf)
defer fp.Close()
b, _ := io.ReadAll(fp)
userDict = strings.Split(string(b), "\n")
userDict = userDict[:len(userDict)-1]
}

if passf != "" {
fp, _ := os.Open(passf)
defer fp.Close()
b, _ := io.ReadAll(fp)
passDict = strings.Split(string(b), "\n")
passDict = passDict[:len(passDict)-1]
}

var worker lib.BruteWorker

Expand Down

0 comments on commit c9f1089

Please sign in to comment.