-
Notifications
You must be signed in to change notification settings - Fork 247
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
26 changed files
with
46,797 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
package fingerprint | ||
|
||
import ( | ||
"encoding/json" | ||
"fmt" | ||
"github.com/hanc00l/nemo_go/pkg/conf" | ||
"github.com/hanc00l/nemo_go/pkg/logging" | ||
"github.com/hanc00l/nemo_go/pkg/task/domainscan" | ||
"github.com/hanc00l/nemo_go/pkg/task/portscan" | ||
"github.com/hanc00l/nemo_go/pkg/utils" | ||
"github.com/remeh/sizedwaitgroup" | ||
"os" | ||
"os/exec" | ||
"path/filepath" | ||
"runtime" | ||
) | ||
|
||
type FingerprintHub struct { | ||
Config Config | ||
ResultPortScan portscan.Result | ||
ResultDomainScan domainscan.Result | ||
} | ||
|
||
type FingerprintHubReult struct { | ||
Url string `json:"url"` | ||
WhatWebName []string `json:"what_web_name"` | ||
Priority int `json:"priority"` | ||
Length int `json:"length"` | ||
Title string `json:"title"` | ||
StatusCode int `json:"status_code"` | ||
Plugins []string `json:"plugins"` | ||
} | ||
|
||
// NNewFingerprintHub 创建FingerprintHub对象 | ||
func NewFingerprintHub(config Config) *FingerprintHub { | ||
return &FingerprintHub{Config: config} | ||
} | ||
|
||
// Do 调用ObserverWard,获取指纹 | ||
func (f *FingerprintHub) Do() { | ||
swg := sizedwaitgroup.New(fpObserverWardThreadNumber) | ||
|
||
if f.ResultPortScan.IPResult != nil { | ||
bport := make(map[int]struct{}) | ||
for _, p := range IgnorePort { | ||
bport[p] = struct{}{} | ||
} | ||
for ipName, ipResult := range f.ResultPortScan.IPResult { | ||
for portNumber, _ := range ipResult.Ports { | ||
if _, ok := bport[portNumber]; ok { | ||
continue | ||
} | ||
url := fmt.Sprintf("%v:%v", ipName, portNumber) | ||
swg.Add() | ||
go func(ip string, port int, u string) { | ||
fingerPrintResult := f.RunObserverWard(u) | ||
if len(fingerPrintResult) > 0 { | ||
for _, fpa := range fingerPrintResult { | ||
for _,name := range fpa.WhatWebName { | ||
par := portscan.PortAttrResult{ | ||
Source: "ObserverWard", | ||
Tag: "fingerprint", | ||
Content: name, | ||
} | ||
f.ResultPortScan.SetPortAttr(ip, port, par) | ||
} | ||
} | ||
} | ||
swg.Done() | ||
}(ipName, portNumber, url) | ||
} | ||
} | ||
} | ||
if f.ResultDomainScan.DomainResult != nil { | ||
for domain, _ := range f.ResultDomainScan.DomainResult { | ||
swg.Add() | ||
go func(d string) { | ||
fingerPrintResult := f.RunObserverWard(d) | ||
if len(fingerPrintResult) > 0 { | ||
for _, fpa := range fingerPrintResult { | ||
for _,name := range fpa.WhatWebName { | ||
dar := domainscan.DomainAttrResult{ | ||
Source: "ObserverWard", | ||
Tag: "fingerprint", | ||
Content: name, | ||
} | ||
f.ResultDomainScan.SetDomainAttr(d, dar) | ||
} | ||
} | ||
} | ||
swg.Done() | ||
}(domain) | ||
} | ||
} | ||
swg.Wait() | ||
} | ||
|
||
// RunObserverWard 调用ObserverWard,获取一个目标的指纹 | ||
func (f *FingerprintHub) RunObserverWard(url string) []FingerprintHubReult { | ||
resultTempFile := utils.GetTempPathFileName() | ||
defer os.Remove(resultTempFile) | ||
|
||
observerWardBinPath := filepath.Join(conf.GetRootPath(), "thirdparty/fingerprinthub", "observer_ward_darwin") | ||
if runtime.GOOS == "linux" { | ||
observerWardBinPath = filepath.Join(conf.GetRootPath(), "thirdparty/fingerprinthub", "observer_ward_amd64") | ||
} | ||
var cmdArgs []string | ||
cmdArgs = append(cmdArgs, "-t", url, "-j", resultTempFile) | ||
cmd := exec.Command(observerWardBinPath, cmdArgs...) | ||
_, err := cmd.CombinedOutput() | ||
if err != nil { | ||
logging.RuntimeLog.Error(err.Error()) | ||
return nil | ||
} | ||
return parseObserverWardResult(resultTempFile) | ||
} | ||
|
||
// parseObserverWardResult 解析结果 | ||
func parseObserverWardResult(outputTempFile string) (result []FingerprintHubReult) { | ||
content, err := os.ReadFile(outputTempFile) | ||
if err != nil || len(content) == 0 { | ||
return | ||
} | ||
json.Unmarshal(content, &result) | ||
return | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package fingerprint | ||
|
||
import ( | ||
"github.com/hanc00l/nemo_go/pkg/task/portscan" | ||
"testing" | ||
) | ||
|
||
func TestFingerprintHub_RunObserverWard(t *testing.T) { | ||
f := NewFingerprintHub(Config{Target: "183.141.20.136:8082"}) | ||
rs := f.RunObserverWard("183.141.20.136:8082") | ||
for _,fp := range rs{ | ||
t.Log(fp) | ||
for _,n := range fp.WhatWebName { | ||
t.Log(n) | ||
} | ||
} | ||
} | ||
|
||
func TestFingerprintHub_Do(t *testing.T) { | ||
nmapConfig := portscan.Config{ | ||
Target: "183.60.156.84", | ||
Port: "8088", | ||
Rate: 1000, | ||
IsPing: false, | ||
Tech: "-sS", | ||
CmdBin: "nmap", | ||
} | ||
nmap := portscan.NewNmap(nmapConfig) | ||
nmap.Do() | ||
t.Log(nmap.Result) | ||
|
||
fp := NewFingerprintHub(Config{}) | ||
fp.ResultPortScan = nmap.Result | ||
fp.Do() | ||
for _,r := range fp.ResultPortScan.IPResult{ | ||
for port,p := range r.Ports{ | ||
t.Log(port,p) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,5 +32,4 @@ func TestScreenShot_Do(t *testing.T) { | |
t.Log(s) | ||
} | ||
} | ||
ss.UploadResult() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.