Skip to content
This repository has been archived by the owner on Oct 22, 2024. It is now read-only.

Commit

Permalink
[优化] 开启 debug 时仅详细打印来自 poc 的请求
Browse files Browse the repository at this point in the history
  • Loading branch information
4ra1n committed Sep 10, 2024
1 parent f73dce9 commit d87627d
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.MD
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

- [BUG] 修复某些情况 `path` 开头包含多个 `/` 问题
- [优化] 使用 `interactsh` 反连随机选择可用的服务器
- [优化] 开启 `debug` 时仅详细打印来自 `poc` 的请求
- [优化] 开启 `debug` 时请求响应限制打印长度

感谢以下用户的贡献:
Expand Down
1 change: 1 addition & 0 deletions base/poc.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ type POC struct {
}

func (p *POC) DoReq(req *client.TheRequest) (*client.TheResponse, error) {
req.IsFromPoC = true
return p.Context.Client.DoReq(req)
}

Expand Down
1 change: 1 addition & 0 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ func (c *HttpClient) DoReq(req *TheRequest) (*TheResponse, error) {
if err != nil {
return nil, xerr.Wrap(err)
}
rawReq.IsFromPoC = req.IsFromPoC
rawReq.SetBody(req.Body)
rawReq.SetFollowRedirect(req.FollowRedirect)
for k, v := range req.Headers {
Expand Down
2 changes: 2 additions & 0 deletions client/req.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ type TheRequest struct {
Body string
Headers map[string]string
All []byte
// 特殊信息
IsFromPoC bool
}

// Equals
Expand Down
6 changes: 4 additions & 2 deletions rawhttp/impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,12 @@ func (c *HTTPClient) DoReq(req *Request) (*Response, error) {

buildReq := c.buildReqRaw(req)

if c.Debug {
if c.Debug && req.IsFromPoC {
log.BluePrintln("------------------- REQUEST DEBUG -------------------")
log.YellowPrintln(formatMessage(buildReq))
log.BluePrintln("-----------------------------------------------------")
} else if c.Debug && !req.IsFromPoC {
log.BluePrintln(fmt.Sprintf("[*] %s://%s:%s%s", req.Protocol, req.IP, req.Port, req.Path))
}

n, err := conn.Write(buildReq)
Expand Down Expand Up @@ -187,7 +189,7 @@ func (c *HTTPClient) DoReq(req *Request) (*Response, error) {
}
}

if c.Debug {
if c.Debug && req.IsFromPoC {
log.BluePrintln("------------------- RESPONSE DEBUG -------------------")
log.YellowPrintln(formatMessage(resp.RawResponse))
log.BluePrintln("-----------------------------------------------------")
Expand Down
2 changes: 2 additions & 0 deletions rawhttp/req.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ type Request struct {
RawHeader []byte
RawRequest []byte
redirectCount int
// 特殊信息
IsFromPoC bool
}

func NewRequest(target string, method string) (*Request, error) {
Expand Down
1 change: 1 addition & 0 deletions reverse/dnslog.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ func (d *DnsLogCn) waitInternal() bool {
Headers: map[string]string{
"Cookie": d.session,
},
IsFromPoC: false,
})
if err != nil {
log.Error(err)
Expand Down
3 changes: 3 additions & 0 deletions reverse/interact.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ func NewInteract(c *client.HttpClient, server string) (*Interact, error) {
Headers: map[string]string{
"Content-Type": "application/json",
},
IsFromPoC: false,
}
reResp, err := c.DoReq(regReq)
if err != nil {
Expand Down Expand Up @@ -202,6 +203,7 @@ func (i *Interact) Close() {
Headers: map[string]string{
"Content-Type": "application/json",
},
IsFromPoC: false,
}
deResp, err := i.c.DoReq(deReq)
if err != nil {
Expand Down Expand Up @@ -236,6 +238,7 @@ func (i *Interact) Wait(w int) bool {
FollowRedirect: false,
Body: "",
Headers: make(map[string]string),
IsFromPoC: false,
}
var respAesKey string
t := time.Duration(w) * time.Second
Expand Down
1 change: 1 addition & 0 deletions reverse/reverse.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ func NewReverse(c *client.HttpClient) (Reverse, error) {
FollowRedirect: false,
Body: "",
Headers: make(map[string]string),
IsFromPoC: false,
})
if err != nil {
return nil, xerr.Wrap(err)
Expand Down

0 comments on commit d87627d

Please sign in to comment.