Skip to content

Commit

Permalink
v1.0.7 新增更新功能
Browse files Browse the repository at this point in the history
  • Loading branch information
wjlin0 committed Mar 12, 2023
1 parent 7cc27e6 commit e8c3204
Show file tree
Hide file tree
Showing 16 changed files with 378 additions and 233 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ Flags:
速率:
-rh, -rate-http int 允许每秒钟最大http请求数 (default 100)

更新:
-update 更新版本

```
## 安装
Expand Down
9 changes: 9 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,27 @@ require (
github.com/projectdiscovery/utils v0.0.10-0.20230217185600-008d111dd1c1
github.com/remeh/sizedwaitgroup v1.0.0
github.com/stretchr/testify v1.8.1
github.com/tj/go-update v2.2.5-0.20200519121640-62b4b798fd68+incompatible
golang.org/x/net v0.6.0
)

require (
github.com/Mzack9999/go-http-digest-auth-client v0.6.1-0.20220414142836-eb8883508809 // indirect
github.com/apex/log v1.9.0 // indirect
github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d // indirect
github.com/aymerick/douceur v0.2.0 // indirect
github.com/c4milo/unpackit v0.1.0 // indirect
github.com/cnf/structhash v0.0.0-20201127153200-e1b16c1ebc08 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/dsnet/compress v0.0.1 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/google/go-github v17.0.0+incompatible // indirect
github.com/google/go-querystring v1.1.0 // indirect
github.com/gorilla/css v1.0.0 // indirect
github.com/gosuri/uilive v0.0.4 // indirect
github.com/gosuri/uiprogress v0.0.1 // indirect
github.com/klauspost/compress v1.16.0 // indirect
github.com/klauspost/pgzip v1.2.5 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.17 // indirect
github.com/mholt/archiver v3.1.1+incompatible // indirect
Expand Down
73 changes: 73 additions & 0 deletions go.sum

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"github.com/projectdiscovery/gologger"
"github.com/wjlin0/pathScan/pkg/runner"
"github.com/wjlin0/pathScan/pkg/util"
"os"
"os/signal"
"path/filepath"
Expand All @@ -15,13 +16,16 @@ func main() {
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 := runner.RandStr(30) + ".cfg"
filename := util.RandStr(30) + ".cfg"
fmt.Println(filepath.Join(runner.DefaultResumeFolderPath(), filename))
err := run.Cfg.MarshalResume(filename)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions pkg/projectdiscovery/uncover/uncover/util.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package uncover

import (
"io"
"github.com/projectdiscovery/retryablehttp-go"
"io"
)

func NewHTTPRequest(method, url string, body io.Reader) (*retryablehttp.Request, error) {
request, err := retryablehttp.NewRequest(method, url, body)
if err != nil {
return nil, err
}
request.Header.Set("User-Agent", "Uncover - FOSS Project (github.com/projectdiscovery/uncover)")
request.Header.Set("User-Agent", "PathScan - FOSS Project (github.com/wjlin0/pathScan)")
return request, nil
}
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.0.6
/ .__/\_,_/ \__//_//_//___/ \__/ \_,_//_//_/ v1.0.7
/_/
`

const Version = `1.0.6`
const Version = `1.0.7`

// showBanner is used to show the banner to the user
func showBanner() {
Expand Down
3 changes: 2 additions & 1 deletion pkg/runner/handlerPath.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package runner
import (
"github.com/projectdiscovery/fileutil"
"github.com/projectdiscovery/gologger"
"github.com/wjlin0/pathScan/pkg/util"
"io"
"net/http"
"strings"
Expand Down Expand Up @@ -71,7 +72,7 @@ func (r *Runner) getAllPaths() map[string]struct{} {

func (r *Runner) getFilePath(filename string) []string {

path := DataRoot("dict", "v"+Version, filename)
path := util.DataRoot("dict", "v"+Version, filename)
out, err := fileutil.ReadFile(path)
if err != nil {
return nil
Expand Down
47 changes: 0 additions & 47 deletions pkg/runner/http.go

This file was deleted.

61 changes: 30 additions & 31 deletions pkg/runner/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,39 +23,40 @@ type Options struct {
Path goflags.StringSlice `json:"path"`
PathFile goflags.StringSlice `json:"path_file"`

PathRemote string `json:"path_remote"`
ResumeCfg string `json:"resume_cfg"`
Output string `json:"output"`
RateHttp int `json:"rate_http"`
Retries int `json:"retries"`
Proxy string `json:"proxy"`
ProxyAuth string `json:"proxy_auth"`
NoColor bool `json:"no_color"`
Verbose bool `json:"verbose"`
Silent bool `json:"silent"`
OnlyTargets bool `json:"only_targets"`
EnableProgressBar bool `json:"enable_progress_bar"`
SkipCode bool `json:"skip_code"`
SkipHost bool `json:"skip_host"`
ErrUseLastResponse bool `json:"err_use_last_response"`
Csv bool `json:"csv,omitempty"`
ClearResume bool `json:"clear_resume"`
Version bool `json:"version"`
Uncover bool `json:"uncover"`
UncoverQuery goflags.StringSlice `json:"uncover_query"`
UncoverEngine goflags.StringSlice `json:"uncover_engine"`
UncoverDelay int `json:"uncover_delay"`
UncoverLimit int `json:"uncover_limit"`
UncoverField string `json:"uncover_field"`
UncoverOutput string `json:"uncover_output"`
PathRemote string `json:"path_remote"`
ResumeCfg string `json:"resume_cfg"`
Output string `json:"output"`
RateHttp int `json:"rate_http"`
Retries int `json:"retries"`
Proxy string `json:"proxy"`
ProxyAuth string `json:"proxy_auth"`
NoColor bool `json:"no_color"`
Verbose bool `json:"verbose"`
Silent bool `json:"silent"`
OnlyTargets bool `json:"only_targets"`
EnableProgressBar bool `json:"enable_progress_bar"`
SkipCode bool `json:"skip_code"`
SkipHost bool `json:"skip_host"`
ErrUseLastResponse bool `json:"err_use_last_response"`
Csv bool `json:"csv,omitempty"`
ClearResume bool `json:"clear_resume"`
Version bool `json:"version"`
Uncover bool `json:"uncover"`
UncoverQuery goflags.StringSlice `json:"uncover_query"`
UncoverEngine goflags.StringSlice `json:"uncover_engine"`
UncoverDelay int `json:"uncover_delay"`
UncoverLimit int `json:"uncover_limit"`
UncoverField string `json:"uncover_field"`
UncoverOutput string `json:"uncover_output"`
UpdatePathScanVersion bool `json:"update"`
}

var defaultProviderConfigLocation = filepath.Join(folderutil.HomeDirOrDefault("."), ".config/pathScan/provider-config.yaml")

func ParserOptions() *Options {
options := &Options{}
set := goflags.NewFlagSet()
set.SetDescription("PathScan Go 扫描工具")
set.SetDescription("PathScan Go 扫描、信息收集工具")
set.CreateGroup("Input", "输入",
set.StringSliceVarP(&options.Url, "target", "t", nil, "目标(以逗号分割)", goflags.NormalizedStringSliceOptions),
set.StringSliceVarP(&options.UrlFile, "target-file", "tf", nil, "从文件中,读取目标", goflags.FileStringSliceOptions),
Expand Down Expand Up @@ -102,6 +103,9 @@ func ParserOptions() *Options {
set.CreateGroup("rate", "速率",
set.IntVarP(&options.RateHttp, "rate-http", "rh", 100, "允许每秒钟最大http请求数"),
)
set.CreateGroup("update", "更新",
set.BoolVar(&options.UpdatePathScanVersion, "update", false, "更新版本"),
)
//set.CreateGroup("")
_ = set.Parse()
if !options.Silent {
Expand All @@ -118,11 +122,6 @@ func ParserOptions() *Options {
}
}

if options.ClearResume {
_ = os.RemoveAll(DefaultResumeFolderPath())
gologger.Print().Msgf("clear success: %s", DefaultResumeFolderPath())
os.Exit(0)
}
return options
}

Expand Down
3 changes: 0 additions & 3 deletions pkg/runner/output.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ func CSVHeaders(data *result.TargetResult) ([]string, error) {
return headers, nil
}

func writeCSVRow(data *result.TargetResult, writer *csv.Writer) {

}
func CSVFields(d *result.TargetResult) ([]string, error) {
var fields []string
vl := reflect.ValueOf(*d)
Expand Down
15 changes: 2 additions & 13 deletions pkg/runner/resume.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,11 @@ import (
"github.com/projectdiscovery/fileutil"
"github.com/projectdiscovery/gologger"
"github.com/wjlin0/pathScan/pkg/result"
"math/rand"
"github.com/wjlin0/pathScan/pkg/util"
"os"
"path/filepath"
"strings"
"sync"
"time"
)

const defaultResumeFileName = `resume.cfg`
Expand Down Expand Up @@ -58,16 +57,6 @@ func (cfg *ResumeCfg) MarshalResume(filename string) error {
}
return os.WriteFile(DefaultResumeFilePath(filename), data, 0644)
}
func RandStr(length int) string {
str := "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
bytes := []byte(str)
result := []byte{}
rand.Seed(time.Now().UnixNano() + int64(rand.Intn(100)))
for i := 0; i < length; i++ {
result = append(result, bytes[rand.Intn(len(bytes))])
}
return string(result)
}

func DefaultResumeFolderPath() string {
home, err := os.UserHomeDir()
Expand All @@ -87,7 +76,7 @@ func (cfg *ResumeCfg) CleanupResumeConfig() {
}

func (cfg *ResumeCfg) ClearResume() {
resumePath := DataRoot("resume")
resumePath := util.DataRoot("resume")
dir, err := os.ReadDir(resumePath)
if err != nil {
return
Expand Down
Loading

0 comments on commit e8c3204

Please sign in to comment.