Skip to content

Commit

Permalink
v1.1.3 新增 递归扫描 结果回调处理
Browse files Browse the repository at this point in the history
  • Loading branch information
wjlin0 committed Jun 16, 2023
1 parent 3e6402e commit 1ce5ccf
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 5 deletions.
71 changes: 69 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@

- 快速发现路径
- 丰富的内置字典,自动下载字典,可远程加载目标或远程加载字典
- 可恢复上次扫描进度
- 可持续递归扫描,恢复上次扫描进度
- 从网络空间测绘中发现目标
- 支持使用HTTP/SOCKS5代理
- 可自定义请求头,可自定义指纹识别规则
- 通过hash,len指定跳过
- 结果可回调处理

# 用法

Expand All @@ -36,11 +37,16 @@ Flags:
-resume string 使用resume.cfg恢复扫描
-mf, -match-file string 指纹文件

递归:
-r, -recursive 递归扫描
-rt, -recursive-time int 递归扫描深度 (default 3)
-rf, -recursive-file string 递归扫描目录 (default "/root/.config/pathScan/dict/dir.txt")

跳过:
-su, -skip-url string[] 跳过的目标(以逗号分割)
-sc, -skip-code string[] 跳过状态码
-sh, -skip-hash string 跳过指定hash
-sbl, -skip-body-len int 跳过body固定长度
-sbl, -skip-body-len int 跳过body固定长度 (default -1)

扫描字典:
-ps, -path string[] 路径(以逗号分割)
Expand Down Expand Up @@ -137,6 +143,67 @@ rules:
group: 1 # 指定后匹配的名字为正则匹配后的第1个元素
```
# 集成到自己的工具中
```go
package main

import (
"fmt"
"github.com/projectdiscovery/gologger"
"github.com/wjlin0/pathScan/pkg/result"
"github.com/wjlin0/pathScan/pkg/runner"
"github.com/wjlin0/pathScan/pkg/util"
"os"
"os/signal"
"path/filepath"
"time"
)

func main() {
options := &runner.Options{Url: []string{
"https://localhost:8000",
},
RateHttp: 2,
TimeoutTCP: 2 * time.Second,
TimeoutHttp: 2 * time.Second,
ResultBack: func(result *result.TargetResult) {
fmt.Println(result)
},
Method: "GET",
Path: []string{
"/",
},
}
run, err := runner.NewRunner(options)
if err != nil {
gologger.Print().Msg(fmt.Sprintf("无法创建Runner: %s", err.Error()))
os.Exit(0)
}
if run == nil {
os.Exit(0)
}

c := make(chan os.Signal, 1)
signal.Notify(c, os.Interrupt)
go func() {
for range c {
gologger.Info().Msg("CTRL+C 按下: Exiting")
filename := util.RandStr(30) + ".cfg"
fmt.Println(filepath.Join(runner.DefaultResumeFolderPath(), filename))
err := run.Cfg.MarshalResume(filename)
if err != nil {
gologger.Error().Msgf("无法创建 resume 文件: %s", err.Error())
}
os.Exit(1)
}
}()
err = run.Run()
if err != nil {
gologger.Fatal().Msgf("无法 运行: %s", err.Error())
}
run.Cfg.CleanupResumeConfig()
}
```


pathScan 支持默认配置文件位于下面两个路径,它允许您在配置文件中定义任何标志并设置默认值以包括所有扫描。
Expand Down
Binary file modified config/dict.zip
Binary file not shown.
4 changes: 2 additions & 2 deletions pkg/runner/banner.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ const banner = `
__ __ ____
___ ___ _ / /_ / / / __/____ ___ _ ___
/ _ \/ _ // __// _ \ _\ \ / __// _ // _ \
/ .__/\_,_/ \__//_//_//___/ \__/ \_,_//_//_/ v1.1.2
/ .__/\_,_/ \__//_//_//___/ \__/ \_,_//_//_/ v1.1.3
/_/
`

const Version = `1.1.2`
const Version = `1.1.3`

// showBanner is used to show the banner to the user
func showBanner() {
Expand Down
4 changes: 3 additions & 1 deletion pkg/runner/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/wjlin0/pathScan/pkg/common/identification"
"github.com/wjlin0/pathScan/pkg/common/uncover"
ucRunner "github.com/wjlin0/pathScan/pkg/projectdiscovery/uncover/runner"
"github.com/wjlin0/pathScan/pkg/result"
"os"
"path/filepath"
"time"
Expand Down Expand Up @@ -67,6 +68,7 @@ type Options struct {
RecursiveRunTimes int `json:"recursive_run_times"`
RecursiveRunFile string `json:"recursive_run_file"`
GetHash bool `json:"get_hash"`
ResultBack func(result *result.TargetResult)
}

var defaultProviderConfigLocation = filepath.Join(folderutil.HomeDirOrDefault("."), ".config", "pathScan", "provider-config.yaml")
Expand All @@ -93,7 +95,7 @@ func ParserOptions() *Options {
set.StringSliceVarP(&options.SkipUrl, "skip-url", "su", nil, "跳过的目标(以逗号分割)", goflags.NormalizedStringSliceOptions),
set.StringSliceVarP(&options.SkipCode, "skip-code", "sc", nil, "跳过状态码", goflags.NormalizedStringSliceOptions),
set.StringVarP(&options.SkipHash, "skip-hash", "sh", "", "跳过指定hash"),
set.IntVarP(&options.SkipBodyLen, "skip-body-len", "sbl", 0, "跳过body固定长度"),
set.IntVarP(&options.SkipBodyLen, "skip-body-len", "sbl", -1, "跳过body固定长度"),
)
set.CreateGroup("Dict", "扫描字典",
set.StringSliceVarP(&options.Path, "path", "ps", nil, "路径(以逗号分割)", goflags.CommaSeparatedStringSliceOptions),
Expand Down
8 changes: 8 additions & 0 deletions pkg/runner/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,10 @@ func (r *Runner) Run() error {
}
r.limiter.Take()
targetResult, check, err := r.GoTargetPathByRetryable(target, path)
if r.Cfg.Options.ResultBack != nil {
r.Cfg.Options.ResultBack(targetResult)
return
}
if targetResult != nil && err == nil {
r.Cfg.Results.AddSkipped(targetResult.Path, targetResult.Target)
// 跳过条件满足
Expand Down Expand Up @@ -340,6 +344,10 @@ func (r *Runner) Run() error {

r.limiter.Take()
targetResult, check, err := r.GoTargetPathByRetryable(target, path)
if r.Cfg.Options.ResultBack != nil {
r.Cfg.Options.ResultBack(targetResult)
return
}
if targetResult != nil && err == nil {
r.Cfg.Results.AddSkipped(targetResult.Path, targetResult.Target)
// 跳过条件满足
Expand Down

0 comments on commit 1ce5ccf

Please sign in to comment.