Add recon form fingerprint library and SSRF canary mode.
Some checks failed
CI Docker Mining Proof / Linux agent hashrate proof (push) Has been cancelled
Some checks failed
CI Docker Mining Proof / Linux agent hashrate proof (push) Has been cancelled
Score crawl inputs by SSRF-prone field names and register ping-back canaries for operator paste confirmation.
This commit is contained in:
75
scripts/_recon_handler_test_canary.go.bak
Normal file
75
scripts/_recon_handler_test_canary.go.bak
Normal file
@@ -0,0 +1,75 @@
|
||||
package api
|
||||
|
||||
|
||||
|
||||
import (
|
||||
|
||||
"bytes"
|
||||
|
||||
"context"
|
||||
|
||||
"encoding/json"
|
||||
|
||||
"net/http"
|
||||
|
||||
"net/http/httptest"
|
||||
|
||||
"strings"
|
||||
|
||||
"testing"
|
||||
|
||||
"time"
|
||||
|
||||
|
||||
|
||||
"github.com/go-chi/chi/v5"
|
||||
|
||||
|
||||
|
||||
"crypto-miner-server/internal/db"
|
||||
|
||||
"crypto-miner-server/internal/recon"
|
||||
|
||||
)
|
||||
|
||||
|
||||
|
||||
func TestReconScanEndpoint(t *testing.T) {
|
||||
|
||||
recon.SetPortDialHook(func(host string, port int, _ time.Duration) bool { return port == 80 })
|
||||
|
||||
t.Cleanup(func() { recon.SetPortDialHook(nil) })
|
||||
|
||||
recon.SetFetchPageHook(func(rawURL string) (int, string, error) {
|
||||
|
||||
return 200, `<html><input name="preview_url">`, nil
|
||||
|
||||
})
|
||||
|
||||
t.Cleanup(func() { recon.SetFetchPageHook(nil) })
|
||||
|
||||
database, _ := db.New(t.TempDir())
|
||||
|
||||
t.Cleanup(func() { _ = database.Close() })
|
||||
|
||||
h := NewReconHandler(database, nil)
|
||||
|
||||
body, _ := json.Marshal(map[string]interface{}{"host": "recon.lab", "port": 80, "scheme": "http"})
|
||||
|
||||
w := httptest.NewRecorder()
|
||||
|
||||
h.Scan(w, httptest.NewRequest(http.MethodPost, "/api/v1/recon/scan", bytes.NewReader(body)))
|
||||
|
||||
if w.Code != http.StatusOK {
|
||||
|
||||
t.Fatalf("%d %s", w.Code, w.Body.String())
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
func TestReconSSRfCanaryFlow(t *testing.T) {
|
||||
|
||||
recon.SetPortDialHook(func(host string, port int, _ time.Duration) bool { return port == 80 })
|
||||
Reference in New Issue
Block a user