Skip to content

Commit

Permalink
adapt new neutron and zombie
Browse files Browse the repository at this point in the history
  • Loading branch information
M09Ic committed Mar 1, 2024
1 parent 1aab0e2 commit e75e62e
Show file tree
Hide file tree
Showing 9 changed files with 47 additions and 15 deletions.
11 changes: 8 additions & 3 deletions v2/example/neutron/neutron.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package main

import (
templates "github.com/chainreactors/neutron/templates_gogo"
"github.com/chainreactors/logs"
templates "github.com/chainreactors/neutron/templates"
"sigs.k8s.io/yaml"
"strings"
)
Expand Down Expand Up @@ -41,8 +42,12 @@ requests:
panic(err)
}

res, ok := t.Execute("http://127.0.0.1:8080")
if ok {
res, err := t.Execute("http://127.0.0.1:8080", nil)
if err != nil {
logs.Log.Error(err.Error())
return
}
if res != nil {
println(res)
}
}
4 changes: 2 additions & 2 deletions v2/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ require (
github.com/M09ic/go-ntlmssp v0.0.0-20230312133735-dcccd454dfe0
github.com/chainreactors/files v0.0.0-20231123083421-cea5b4ad18a8
github.com/chainreactors/logs v0.0.0-20231220102821-19f082ce37c1
github.com/chainreactors/neutron v0.0.0-20240227102003-0e55e04af206
github.com/chainreactors/parsers v0.0.0-20240125061054-ac0c92abbe94
github.com/chainreactors/neutron v0.0.0-20240301094645-f1f6d5808464
github.com/chainreactors/parsers v0.0.0-20240301095314-82aa51c2fd31
github.com/chainreactors/utils v0.0.0-20231031063336-9477f1b23886
github.com/jessevdk/go-flags v1.5.0
github.com/panjf2000/ants/v2 v2.5.0
Expand Down
12 changes: 12 additions & 0 deletions v2/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,20 @@ github.com/chainreactors/logs v0.0.0-20231220102821-19f082ce37c1 h1:y4xbdWsmBu1a
github.com/chainreactors/logs v0.0.0-20231220102821-19f082ce37c1/go.mod h1:6Mv6W70JrtL6VClulZhmMRZnoYpcTahcDTKLMNEjK0o=
github.com/chainreactors/neutron v0.0.0-20240227102003-0e55e04af206 h1:GGDbi5oGmmT7eRFtHunFzcO4IP5QmwCMfY7Qx4s+/Bo=
github.com/chainreactors/neutron v0.0.0-20240227102003-0e55e04af206/go.mod h1:nhCtnrfRsXxIlsI3LBW1ZGA7diwU/VmgFngaBdtTLiw=
github.com/chainreactors/neutron v0.0.0-20240228084913-07420083f6a2 h1:fcguM2iQaUFCVeM/vpuGCkSFHfJV6obo70gf2/BKRlg=
github.com/chainreactors/neutron v0.0.0-20240228084913-07420083f6a2/go.mod h1:nhCtnrfRsXxIlsI3LBW1ZGA7diwU/VmgFngaBdtTLiw=
github.com/chainreactors/neutron v0.0.0-20240301091500-146befcf2708 h1:IhpnJaZ99B97E1xsLinQNl/lAvsTk83FqL8LlPCjKRs=
github.com/chainreactors/neutron v0.0.0-20240301091500-146befcf2708/go.mod h1:SIJhRs9LYuE+znKjyPlS6R2BrU3PynWaW2Nlu+ZVnR0=
github.com/chainreactors/neutron v0.0.0-20240301094645-f1f6d5808464 h1:gh1MLp687aGGjXB79ucPg+OVEkt306Be5i7TypU2Dus=
github.com/chainreactors/neutron v0.0.0-20240301094645-f1f6d5808464/go.mod h1:SIJhRs9LYuE+znKjyPlS6R2BrU3PynWaW2Nlu+ZVnR0=
github.com/chainreactors/parsers v0.0.0-20240125061054-ac0c92abbe94 h1:y4LK5npTHc7YMAonFHH3lonvFzWUNSZG8M74GVvlLdE=
github.com/chainreactors/parsers v0.0.0-20240125061054-ac0c92abbe94/go.mod h1:IS0hrYnccfJKU0NA12zdZk4mM7k/Qt4qnzMnFGBFLZI=
github.com/chainreactors/parsers v0.0.0-20240229064316-6146c4e7de47 h1:vLgiZ6Ppuor88gx5g587FnMjILpGnu6qKwmMErBbIzc=
github.com/chainreactors/parsers v0.0.0-20240229064316-6146c4e7de47/go.mod h1:IS0hrYnccfJKU0NA12zdZk4mM7k/Qt4qnzMnFGBFLZI=
github.com/chainreactors/parsers v0.0.0-20240229065700-b803c0d0bb3d h1:h2hwmr/eZvrmnH9eVR2PLpRnlNee4PKD9SvGKO73ax8=
github.com/chainreactors/parsers v0.0.0-20240229065700-b803c0d0bb3d/go.mod h1:IS0hrYnccfJKU0NA12zdZk4mM7k/Qt4qnzMnFGBFLZI=
github.com/chainreactors/parsers v0.0.0-20240301095314-82aa51c2fd31 h1:ZuMdyMqpTtuowbTceqI++k+kncQ1MnWzoDXSjLq4yPM=
github.com/chainreactors/parsers v0.0.0-20240301095314-82aa51c2fd31/go.mod h1:IS0hrYnccfJKU0NA12zdZk4mM7k/Qt4qnzMnFGBFLZI=
github.com/chainreactors/utils v0.0.0-20231031063336-9477f1b23886 h1:lS2T/uE9tg1MNDPrb44wawbNlD24zBlWoG0H+ZdwDAk=
github.com/chainreactors/utils v0.0.0-20231031063336-9477f1b23886/go.mod h1:JA4eiQZm+7AsfjXBcIzIdVKBEhDCb16eNtWFCGTxlvs=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
Expand Down
1 change: 1 addition & 0 deletions v2/internal/core/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ func (r *Runner) Prepare() bool {
}

if r.FormatterFilename != "" {
LoadNeutron("")
var formatOut string
if r.Outputf == Default {
formatOut = "color"
Expand Down
4 changes: 2 additions & 2 deletions v2/internal/plugin/hostScan.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func hostScan(result *Result) {
}

req, _ := http.NewRequest("GET", url, nil)
vuln := &parsers.Vuln{Name: "host", Detail: map[string]interface{}{}, SeverityLevel: parsers.SeverityINFO}
vuln := &parsers.Vuln{Name: "host", Detail: map[string][]string{}, SeverityLevel: parsers.SeverityINFO}
for _, host := range result.HttpHosts {
req.Host = host
resp, err := conn.Do(req)
Expand All @@ -38,7 +38,7 @@ func hostScan(result *Result) {
result.CurrentHost = host
}
result.Host = host
vuln.Detail[host] = title
vuln.Detail[host] = []string{title}
}
}
if len(vuln.Detail) > 0 {
Expand Down
8 changes: 5 additions & 3 deletions v2/internal/plugin/neutronScan.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (

. "github.com/chainreactors/gogo/v2/pkg"
"github.com/chainreactors/logs"
"github.com/chainreactors/neutron/templates_gogo"
"github.com/chainreactors/neutron/templates"
"github.com/chainreactors/parsers"
)

Expand All @@ -31,13 +31,15 @@ chainLoop: // 实现chain
var chainsTemplates []*templates.Template
for _, template := range ts { // 遍历所有poc
logs.Log.Debugf("nuclei scan %s with %s", target, template.Id)
res, ok := template.Execute(target, nil)
if ok {
res, err := template.Execute(target, nil)
if err == nil {
for name, extract := range res.Extracts {
result.AddExtract(&parsers.Extracted{Name: name, ExtractResult: extract})
}
vulns = append(vulns, &parsers.Vuln{Name: template.Id, Payload: res.PayloadValues, Detail: res.DynamicValues, SeverityLevel: parsers.GetSeverityLevel(template.Info.Severity)})
chainsTemplates = append(chainsTemplates, diffTemplates(ts, choiceTemplates(template.Chains))...)
} else {
logs.Log.Debugf("nuclei scan %s with %s error: %s", target, template.Id, err.Error())
}
}
if chainsTemplates != nil {
Expand Down
2 changes: 1 addition & 1 deletion v2/pkg/fingers/fingers.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func (finger *Finger) ToResult(hasFrame, hasVuln bool, res string, index int) (f
vuln = &parsers.Vuln{Name: finger.Name, SeverityLevel: INFO}
}
if finger.IsActive {
vuln.Detail = map[string]interface{}{"path": finger.Rules[index].SendDataStr}
vuln.Detail = map[string][]string{"path": []string{finger.Rules[index].SendDataStr}}
}
}

Expand Down
2 changes: 1 addition & 1 deletion v2/pkg/load_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ var (
NameMap = utils.NameMap
PortMap = utils.PortMap
TagMap = utils.TagMap
//WorkFlowMap map[string][]*Workflow

Extractor []*parsers.Extractor
Extractors = make(parsers.Extractors)
ExtractRegexps = map[string][]*parsers.Extractor{}
Expand Down
18 changes: 15 additions & 3 deletions v2/pkg/load_neutron.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ package pkg
import (
"encoding/json"
"fmt"
"github.com/chainreactors/parsers"
"github.com/chainreactors/utils/encode"
"io/ioutil"
"strings"

"github.com/chainreactors/files"
"github.com/chainreactors/neutron/protocols"
"github.com/chainreactors/neutron/templates_gogo"
"github.com/chainreactors/neutron/templates"
"github.com/chainreactors/utils/iutils"
)

Expand Down Expand Up @@ -50,7 +51,7 @@ var TemplateMap map[string][]*templates.Template
func LoadNeutron(filename string) map[string][]*templates.Template {
var content []byte
if filename == "" {
return LoadTemplates(LoadConfig("nuclei"))
return LoadTemplates(LoadConfig("neutron"))
} else {
if files.IsExist(filename) {
var err error
Expand Down Expand Up @@ -90,7 +91,18 @@ func LoadTemplates(content []byte) map[string][]*templates.Template {

// 以tag归类
for _, tag := range template.GetTags() {
templatemap[strings.ToLower(tag)] = append(templatemap[strings.ToLower(tag)], template)
tag := strings.ToLower(tag)
templatemap[tag] = append(templatemap[tag], template)
}

// add zombie-finger map
if template.Info.Zombie != "" {
for _, tag := range template.GetTags() {
parsers.ZombieMap[strings.ToLower(tag)] = template.Info.Zombie
}
for _, finger := range template.Fingers {
parsers.ZombieMap[finger] = template.Info.Zombie
}
}
}
return templatemap
Expand Down

0 comments on commit e75e62e

Please sign in to comment.