Skip to content

Commit

Permalink
在yaml模板规则,在type中增加https标头,区别http标头。
Browse files Browse the repository at this point in the history
  • Loading branch information
Rubby2001 authored and zan8in committed Aug 7, 2024
1 parent 0c4cbe1 commit 2cfd555
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 9 deletions.
13 changes: 7 additions & 6 deletions pkg/poc/poc.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,12 @@ type RuleRequest struct {
}

const (
HTTP_Type = "http"
TCP_Type = "tcp"
UDP_Type = "udp"
SSL_Type = "ssl"
GO_Type = "go"
HTTP_Type = "http"
HTTPS_Type = "https"
TCP_Type = "tcp"
UDP_Type = "udp"
SSL_Type = "ssl"
GO_Type = "go"
)

// 以下开始是 信息部分
Expand Down Expand Up @@ -319,7 +320,7 @@ func (poc *Poc) Reset() {
func (poc *Poc) IsHTTPType() bool {
for _, rule := range poc.Rules {
reqType := rule.Value.Request.Type
if len(reqType) == 0 || reqType == HTTP_Type {
if len(reqType) == 0 || reqType == HTTP_Type || reqType == HTTPS_Type {
return true
}
}
Expand Down
18 changes: 15 additions & 3 deletions pkg/runner/checker.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func (c *Checker) Check(target string, pocItem *poc.Poc) (err error) {
isMatch := false
reqType := strings.ToLower(rule.Request.Type)

if len(reqType) > 0 && reqType != string(poc.HTTP_Type) {
if len(reqType) > 0 && reqType != string(poc.HTTP_Type) && reqType != string(poc.HTTPS_Type) {
if reqType == poc.TCP_Type || reqType == poc.UDP_Type {
if nc, err := netxclient.NewNetClient(rule.Request.Host, netxclient.Config{
Network: rule.Request.Type,
Expand Down Expand Up @@ -119,8 +119,20 @@ func (c *Checker) Check(target string, pocItem *poc.Poc) (err error) {
err = rt.RawHttpRequest(rule.Request.Raw, target, c.Options.Header, c.VariableMap)

} else {

err = retryhttpclient.Request(target, c.Options.Header, rule, c.VariableMap)
targetTmp := target
if len(reqType) > 0 {
if reqType == poc.HTTPS_Type {
if strings.HasPrefix(targetTmp, "http://") {
targetTmp = strings.Replace(targetTmp, "http://", "https://", 1)
}
}
if reqType == poc.HTTP_Type {
if strings.HasPrefix(targetTmp, "https://") {
targetTmp = strings.Replace(targetTmp, "https://", "http://", 1)
}
}
}
err = retryhttpclient.Request(targetTmp, c.Options.Header, rule, c.VariableMap)
}
}

Expand Down

0 comments on commit 2cfd555

Please sign in to comment.