Add recon network batch 1: stack banners and smart port profiles.
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
Parse technology stack from crawl headers, grab SSH/HTTP/WinRM banners, merge smart port bundles with FleetPorts, and suggest deploy-kit lane plus SSM for EC2 metadata targets.
This commit is contained in:
@@ -18,7 +18,7 @@ func TestScanPortsWithInject(t *testing.T) {
|
||||
return port == 22 || port == 443
|
||||
})
|
||||
t.Cleanup(func() { SetPortDialHook(nil) })
|
||||
results := ScanPorts("10.0.0.5")
|
||||
results := ScanPorts("10.0.0.5", nil)
|
||||
open := map[int]bool{}
|
||||
for _, r := range results {
|
||||
if r.Open {
|
||||
@@ -119,7 +119,7 @@ func TestScanReportRecommendations(t *testing.T) {
|
||||
MultipartForms: []FormFinding{{PageURL: "http://x/", Multipart: true}},
|
||||
SSRFScore: 40,
|
||||
}
|
||||
recs := BuildRecommendations(ports, crawl)
|
||||
recs := BuildRecommendations(ports, crawl, nil, "10.0.0.1", false)
|
||||
if len(recs) < 5 {
|
||||
t.Fatalf("recs=%+v", recs)
|
||||
}
|
||||
@@ -184,3 +184,24 @@ func atoi(s string) int {
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
|
||||
func TestResolveScanPortsMergesProfiles(t *testing.T) {
|
||||
ports, used := ResolveScanPorts([]string{"web", "linux", "cloud_metadata"})
|
||||
if !containsInt(ports, 6262) || len(used) != 3 { t.Fatalf("%v %v", ports, used) }
|
||||
}
|
||||
func TestBuildStackFromHeaders(t *testing.T) {
|
||||
stack := BuildStack([]HTTPHeaderSnap{{Headers: map[string]string{"X-Powered-By":"PHP/8.1"}}}, nil)
|
||||
if SuggestDeployKitLane(stack) != "php" { t.Fatal(stack) }
|
||||
}
|
||||
func TestGrabBannersWithHooks(t *testing.T) {
|
||||
SetBannerHooks(func(_ string,p int) string { if p==22 {return "SSH"}; return "" }, func(_ string,p int)(string,string){ if p==80 {return "t","s"}; return "","" }, func(_ string,p int) string { if p==5985 {return "w"}; return "" }, nil)
|
||||
t.Cleanup(func(){SetBannerHooks(nil,nil,nil,nil)})
|
||||
if len(GrabBanners("h", []PortResult{{22,true},{80,true},{5985,true}})) != 3 { t.Fatal() }
|
||||
}
|
||||
func TestCloudMetadataProfileSuggestsSSM(t *testing.T) {
|
||||
SetBannerHooks(nil,nil,nil,func()bool{return true}); t.Cleanup(func(){SetBannerHooks(nil,nil,nil,nil)})
|
||||
for _,r := range BuildRecommendations(nil,nil,nil,"ec2.compute.amazonaws.com",true) { if r.Lane=="ssm_document" { return } }
|
||||
t.Fatal()
|
||||
}
|
||||
func containsInt(a []int,w int) bool { for _,n:=range a { if n==w {return true} }; return false }
|
||||
|
||||
Reference in New Issue
Block a user