Skip to content

Commit

Permalink
fix error output.
Browse files Browse the repository at this point in the history
add origin-request field in csv output
  • Loading branch information
wjlin0 committed Apr 1, 2024
1 parent 15c3f86 commit a6a11dd
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 36 deletions.
16 changes: 9 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ go install -v github.com/wjlin0/pathScan/v2/cmd/pathScan@latest
```
下载准备运行的[二进制文件](https://github.com/wjlin0/pathScan/releases/latest)

- [macOS-arm64](https://github.com/wjlin0/pathScan/releases/download/v2.0.5/pathScan_2.0.5_macOS_arm64.zip)
- [macOS-arm64](https://github.com/wjlin0/pathScan/releases/download/v2.0.6/pathScan_2.0.6_macOS_arm64.zip)

- [macOS-amd64](https://github.com/wjlin0/pathScan/releases/download/v2.0.5/pathScan_2.0.5_macOS_amd64.zip)
- [macOS-amd64](https://github.com/wjlin0/pathScan/releases/download/v2.0.6/pathScan_2.0.6_macOS_amd64.zip)

- [linux-amd64](https://github.com/wjlin0/pathScan/releases/download/v2.0.5/pathScan_2.0.5_linux_amd64.zip)
- [linux-amd64](https://github.com/wjlin0/pathScan/releases/download/v2.0.6/pathScan_2.0.6_linux_amd64.zip)

- [windows-amd64](https://github.com/wjlin0/pathScan/releases/download/v2.0.5/pathScan_2.0.5_windows_amd64.zip)
- [windows-amd64](https://github.com/wjlin0/pathScan/releases/download/v2.0.6/pathScan_2.0.6_windows_amd64.zip)

- [windows-386](https://github.com/wjlin0/pathScan/releases/download/v2.0.5/pathScan_2.0.5_windows_386.zip)
- [windows-386](https://github.com/wjlin0/pathScan/releases/download/v2.0.6/pathScan_2.0.6_windows_386.zip)


# 用法
Expand All @@ -44,7 +44,7 @@ go install -v github.com/wjlin0/pathScan/v2/cmd/pathScan@latest
pathScan -h
```
```yaml
pathScan 2.0.5 Go 扫描、信息收集工具
pathScan 2.0.6 Go 扫描、信息收集工具

Usage:
pathScan [flags]
Expand Down Expand Up @@ -146,6 +146,7 @@ EXAMPLES:

其他文档可在以下网址获得: https://github.com/wjlin0/pathScan/


```
## 提供API KEY 配置
Expand Down Expand Up @@ -312,7 +313,8 @@ func main() {
pathScan 支持默认配置文件位于下面两个路径,它允许您在配置文件中定义任何标志并设置默认值以包括所有扫描。
- $HOME/.config/pathScan/config.yaml
- $HOME/.config/pathScan/provider-config.yaml

# 更多用法
- https://www.wjlin0.com/archives/1711956620976
# 感谢

- [projectdiscovery.io](https://projectdiscovery.io/#/)
2 changes: 2 additions & 0 deletions pkg/input/input.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ func NewTarget(target string, methods []string, headers map[string]interface{},
scheme = HTTP
case HTTPS:
scheme = HTTPS
case HTTPandHTTPS:
scheme = HTTPandHTTPS
default:
scheme = HTTPorHTTPS
}
Expand Down
19 changes: 18 additions & 1 deletion pkg/output/js/template.html
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,9 @@
<a-descriptions-item label="响应包" :span="3">
<pre style="white-space: pre-line;">{{ text.response }}</pre>
</a-descriptions-item>
<a-descriptions-item label="是否为原始请求" :span="3">
<pre style="white-space: pre-line;">{{ text.originRequest }}</pre>
</a-descriptions-item>
</a-descriptions>
</a-table>
</a-row>
Expand Down Expand Up @@ -226,6 +229,19 @@
});
}
}},
{ title: '是否为原始请求', dataIndex: 'originRequest', key: 'originRequest',scopedSlots: {filterDropdown: 'filterDropdown', filterIcon: 'filterIcon', customRender: 'customRender',} ,
onFilter: (value, record) =>
record.originRequest
.toString()
.toLowerCase()
.includes(value.toLowerCase()),
onFilterDropdownVisibleChange: visible => {
if (visible) {
setTimeout(() => {
this.searchInput.focus();
});
}
}},
{ title: '指纹', dataIndex: 'technology', key: 'technology',scopedSlots: { customRender: 'technology' } },
];

Expand All @@ -241,7 +257,8 @@
{ title: '状态码', dataIndex: 'status', key: 'status' },
{ title: '指纹', dataIndex: 'technology', key: 'technology',},
{ title: '请求包',dataIndex: 'request',key: 'request',},
{ title: '响应包',dataIndex: 'response',key: 'response',}
{ title: '响应包',dataIndex: 'response',key: 'response',},
{title: "是否为原始请求",dataIndex: 'originRequest',key: 'originRequest'},
];

const innerData = data;
Expand Down
1 change: 1 addition & 0 deletions pkg/output/result.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ type ResultEvent struct {
Technology []string `json:"technology" csv:"technology"`
ResponseBody string `json:"response" csv:"-"`
RequestBody string `json:"request" csv:"-"`
OriginRequest bool `json:"originRequest" csv:"originRequest"`
Links []string `json:"-" csv:"-"`
Header map[string][]string `json:"-" csv:"-"`
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/runner/banner.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const (
/ .__/\_,_/ \__//_//_//___/ \__/ \_,_//_//_/
/_/
`
Version = `2.0.5`
Version = `2.0.6`
userName = "wjlin0"
pathScanMatchRepoName = "pathScan-match"
pathScanRepoName = "pathScan"
Expand Down
2 changes: 1 addition & 1 deletion pkg/runner/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ func ParserOptions() *types.Options {
gologger.Fatal().Msgf("init pathScan error: %s", err.Error())
}

set.SetConfigFilePath(filepath.Join(DefaultPathScanConfig, "config.yaml"))
set.SetConfigFilePath(filepath.Join(DefaultPathScanConfig))

_ = set.Parse()

Expand Down
27 changes: 7 additions & 20 deletions pkg/runner/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,12 @@ func (r *Runner) setEventWriter() (err error) {
return err
}
outputWriter.AddWriters(htmlWriter)
default:
if file, err := fileutil.OpenOrCreateFile(r.options.Output); err != nil {
return err
} else {
outputWriter.AddWriters(file)
}
}
}

Expand Down Expand Up @@ -378,19 +384,6 @@ func (r *Runner) aliveHosts(targets []*input.Target) {
r.targets = targets
return
}
disableCheck := true

for _, target := range targets {
if target.Scheme == input.HTTPorHTTPS {
disableCheck = false
break
}
}

if disableCheck {
r.targets = targets
return
}

gologger.Info().Msgf("Running check alive on input host")

Expand All @@ -401,18 +394,12 @@ func (r *Runner) aliveHosts(targets []*input.Target) {
wg := sizedwaitgroup.New(-1)

for _, target := range targets {
if target.Scheme != input.HTTPorHTTPS {
r.scanner.Lock()
alives = append(alives, target)
r.scanner.Unlock()
return
}
wg.Add()
go func(target *input.Target) {
defer wg.Done()
if alive := r.scanner.Alive(target); alive != nil {
r.scanner.Lock()
alives = append(alives, alive)
alives = append(alives, alive...)
r.scanner.Unlock()
}
}(target)
Expand Down
14 changes: 8 additions & 6 deletions pkg/scanner/scanner.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@ retry:

if path == "/" && !scanner.options.DisableScanMatch {
tech = append(tech, scanner.scanByOperators(request, resp, callback)...)
event.OriginRequest = true
}

event.Technology = sliceutil.Dedupe(tech)
Expand Down Expand Up @@ -499,18 +500,18 @@ func (scanner *Scanner) CountOperatorsRequest() int {
return count
}

func (scanner *Scanner) Alive(target *input.Target) *input.Target {
func (scanner *Scanner) Alive(target *input.Target) []*input.Target {
var (
Schemes []string
aliveTarget = target.Clone()
Schemes []string
aliveTargets []*input.Target
)
if target.Scheme == input.HTTPandHTTPS {
Schemes = []string{"https", "http"}
} else {
Schemes = []string{target.Scheme}
}
for _, scheme := range Schemes {

aliveTarget := target.Clone()
originProtocol := scheme
if scheme == input.HTTPorHTTPS {
scheme = input.HTTPS
Expand Down Expand Up @@ -546,9 +547,10 @@ func (scanner *Scanner) Alive(target *input.Target) *input.Target {
continue
}
aliveTarget.Scheme = scheme
return aliveTarget
aliveTargets = append(aliveTargets, aliveTarget)
}
return nil

return aliveTargets
}

func (scanner *Scanner) checkEventSkip(event output.ResultEvent) bool {
Expand Down

0 comments on commit a6a11dd

Please sign in to comment.