mirror of
https://github.com/anotherhadi/iknowyou.git
synced 2026-04-12 00:47:26 +02:00
add proxy settings
Signed-off-by: Hadi <112569860+anotherhadi@users.noreply.github.com>
This commit is contained in:
@@ -8,6 +8,7 @@ import (
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/anotherhadi/iknowyou/internal/proxy"
|
||||
"github.com/anotherhadi/iknowyou/internal/tools"
|
||||
)
|
||||
|
||||
@@ -80,7 +81,7 @@ func (r *Runner) Run(ctx context.Context, target string, _ tools.InputType, out
|
||||
req.Header.Set("X-RapidAPI-Host", "breachdirectory.p.rapidapi.com")
|
||||
req.Header.Set("Accept", "application/json")
|
||||
|
||||
resp, err := http.DefaultClient.Do(req)
|
||||
resp, err := proxy.ClientFromContext(ctx).Do(req)
|
||||
if err != nil {
|
||||
if ctx.Err() != nil {
|
||||
out <- tools.Event{Tool: name, Type: tools.EventTypeError, Payload: "scan cancelled"}
|
||||
|
||||
@@ -10,6 +10,7 @@ import (
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
"github.com/anotherhadi/iknowyou/internal/proxy"
|
||||
"github.com/anotherhadi/iknowyou/internal/tools"
|
||||
)
|
||||
|
||||
@@ -61,7 +62,7 @@ func (r *Runner) Run(ctx context.Context, target string, _ tools.InputType, out
|
||||
req.Header.Set("Accept", "application/json")
|
||||
req.Header.Set("User-Agent", "Mozilla/5.0 (compatible; crtsh-scanner/1.0)")
|
||||
|
||||
resp, err := http.DefaultClient.Do(req)
|
||||
resp, err := proxy.ClientFromContext(ctx).Do(req)
|
||||
if err != nil {
|
||||
if ctx.Err() != nil {
|
||||
out <- tools.Event{Tool: name, Type: tools.EventTypeError, Payload: "scan cancelled"}
|
||||
|
||||
@@ -94,7 +94,7 @@ func (r *Runner) Run(ctx context.Context, target string, _ tools.InputType, out
|
||||
parsed[i] = ansiRe.ReplaceAllString(l, "")
|
||||
}
|
||||
|
||||
start := 0
|
||||
start := -1
|
||||
for i, l := range parsed {
|
||||
if strings.Contains(l, "[+] Authenticated !") {
|
||||
start = i + 1
|
||||
@@ -102,6 +102,14 @@ func (r *Runner) Run(ctx context.Context, target string, _ tools.InputType, out
|
||||
}
|
||||
}
|
||||
|
||||
if start == -1 {
|
||||
// Banner printed but auth line never appeared — bad/expired credentials.
|
||||
out <- tools.Event{Tool: name, Type: tools.EventTypeError, Payload: "GHunt authentication failed — credentials may be missing or expired (run 'ghunt login' and update your creds in Settings)"}
|
||||
out <- tools.Event{Tool: name, Type: tools.EventTypeCount, Payload: 0}
|
||||
out <- tools.Event{Tool: name, Type: tools.EventTypeDone}
|
||||
return nil
|
||||
}
|
||||
|
||||
end := len(lines)
|
||||
for i := start; i < len(parsed); i++ {
|
||||
if strings.Contains(parsed[i], "Traceback (most recent call last)") {
|
||||
@@ -117,6 +125,8 @@ func (r *Runner) Run(ctx context.Context, target string, _ tools.InputType, out
|
||||
} else if output != "" {
|
||||
out <- tools.Event{Tool: name, Type: tools.EventTypeOutput, Payload: output}
|
||||
out <- tools.Event{Tool: name, Type: tools.EventTypeCount, Payload: 1}
|
||||
} else {
|
||||
out <- tools.Event{Tool: name, Type: tools.EventTypeCount, Payload: 0}
|
||||
}
|
||||
out <- tools.Event{Tool: name, Type: tools.EventTypeDone}
|
||||
return nil
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/anotherhadi/iknowyou/internal/proxy"
|
||||
"github.com/anotherhadi/iknowyou/internal/tools"
|
||||
)
|
||||
|
||||
@@ -76,7 +77,7 @@ func (r *Runner) Run(ctx context.Context, target string, _ tools.InputType, out
|
||||
}
|
||||
req.Header.Set("Accept", "application/json")
|
||||
|
||||
resp, err := http.DefaultClient.Do(req)
|
||||
resp, err := proxy.ClientFromContext(ctx).Do(req)
|
||||
if err != nil {
|
||||
if ctx.Err() != nil {
|
||||
out <- tools.Event{Tool: name, Type: tools.EventTypeError, Payload: "scan cancelled"}
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/anotherhadi/iknowyou/internal/proxy"
|
||||
"github.com/anotherhadi/iknowyou/internal/tools"
|
||||
)
|
||||
|
||||
@@ -90,7 +91,7 @@ func (r *Runner) Run(ctx context.Context, target string, inputType tools.InputTy
|
||||
req.Header.Set("X-API-Key", r.cfg.APIKey)
|
||||
req.Header.Set("Accept", "application/json")
|
||||
|
||||
resp, err := http.DefaultClient.Do(req)
|
||||
resp, err := proxy.ClientFromContext(ctx).Do(req)
|
||||
if err != nil {
|
||||
if ctx.Err() != nil {
|
||||
out <- tools.Event{Tool: name, Type: tools.EventTypeError, Payload: "scan cancelled"}
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"os/exec"
|
||||
"regexp"
|
||||
|
||||
"github.com/anotherhadi/iknowyou/internal/proxy"
|
||||
"github.com/creack/pty"
|
||||
)
|
||||
|
||||
@@ -14,7 +15,14 @@ var oscRe = regexp.MustCompile(`\x1b\][^\x07\x1b]*(?:\x07|\x1b\\)`)
|
||||
|
||||
// RunWithPTY runs cmd under a pseudo-terminal (preserving ANSI colours) and
|
||||
// returns the full output once the process exits.
|
||||
// If a proxychains config path is stored in ctx, the command is transparently
|
||||
// wrapped with proxychains4.
|
||||
func RunWithPTY(ctx context.Context, cmd *exec.Cmd) (string, error) {
|
||||
if confPath := proxy.ProxychainsConfFromContext(ctx); confPath != "" {
|
||||
args := append([]string{"-q", "-f", confPath, cmd.Path}, cmd.Args[1:]...)
|
||||
cmd = exec.CommandContext(ctx, "proxychains4", args...)
|
||||
}
|
||||
|
||||
ptmx, err := pty.StartWithSize(cmd, &pty.Winsize{Rows: 50, Cols: 220})
|
||||
if err != nil {
|
||||
return "", err
|
||||
|
||||
@@ -10,6 +10,7 @@ import (
|
||||
|
||||
wappalyzergo "github.com/projectdiscovery/wappalyzergo"
|
||||
|
||||
"github.com/anotherhadi/iknowyou/internal/proxy"
|
||||
"github.com/anotherhadi/iknowyou/internal/tools"
|
||||
)
|
||||
|
||||
@@ -55,7 +56,7 @@ func (r *Runner) Run(ctx context.Context, target string, _ tools.InputType, out
|
||||
}
|
||||
req.Header.Set("User-Agent", "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)")
|
||||
|
||||
resp, err = http.DefaultClient.Do(req)
|
||||
resp, err = proxy.ClientFromContext(ctx).Do(req)
|
||||
if err == nil {
|
||||
defer resp.Body.Close()
|
||||
body, err = io.ReadAll(resp.Body)
|
||||
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/anotherhadi/iknowyou/internal/proxy"
|
||||
"github.com/anotherhadi/iknowyou/internal/tools"
|
||||
"github.com/tidwall/gjson"
|
||||
)
|
||||
@@ -101,9 +102,9 @@ func prettyResult(r gjson.Result, depth int) string {
|
||||
return sb.String()
|
||||
}
|
||||
|
||||
func doRequest(ctx context.Context, req *http.Request) ([]byte, *http.Response, error) {
|
||||
func doRequest(ctx context.Context, client *http.Client, req *http.Request) ([]byte, *http.Response, error) {
|
||||
for {
|
||||
resp, err := http.DefaultClient.Do(req)
|
||||
resp, err := client.Do(req)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
@@ -161,7 +162,7 @@ func (r *Runner) Run(ctx context.Context, target string, inputType tools.InputTy
|
||||
}
|
||||
req.Header.Set("Accept", "application/json")
|
||||
|
||||
body, resp, err := doRequest(ctx, req)
|
||||
body, resp, err := doRequest(ctx, proxy.ClientFromContext(ctx), req)
|
||||
if err != nil {
|
||||
if ctx.Err() != nil {
|
||||
out <- tools.Event{Tool: name, Type: tools.EventTypeError, Payload: "scan cancelled"}
|
||||
|
||||
Reference in New Issue
Block a user