Skip to content

Commit

Permalink
fix mongod 指纹名称和代码定义不一致的bug 2022-07-21
Browse files Browse the repository at this point in the history
  • Loading branch information
x51pwn committed Jul 21, 2022
1 parent d7c2666 commit 67d15fc
Show file tree
Hide file tree
Showing 16 changed files with 84 additions and 93 deletions.
3 changes: 3 additions & 0 deletions .github/up.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
cd $HOME/MyWork/nuclei-templates
git pull
cd $HOME/MyWork/scan4all
cat ./go.mod|grep projectdiscovery|grep -E "subfinder|nuclei|wappalyzergo"|awk '{print $1}'|xargs -I % go get -u %

ls ../nuclei-templates|xargs -I % cp -rf ../nuclei-templates/% config/nuclei-templates/
Expand Down
40 changes: 24 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
<img width="928" alt="image" src="https://user-images.githubusercontent.com/18223385/175768227-098c779b-6c5f-48ee-91b1-c56e3daa9c87.png">
</h1>

- 什么是scan4all:集成vscan、nuclei、ksubdomain、subfinder等,充分自动化、智能化
并对这些集成对项目进行代码级别优化、参数优化,个别模块重写
原则上不重复造轮子,除非轮子bug、问题太多
- 什么是scan4all:集成 vscan、nuclei、ksubdomain、subfinder等,充分自动化、智能化
并对这些集成的项目进行代码级别优化、参数优化,个别模块,如 vscan filefuzz部分进行了重写
原则上不重复造轮子,除非存在bug、问题
- 跨平台:基于golang实现,轻量级、高度可定制、开源,支持Linux、windows、mac os等
- 支持【20】种密码爆破,支持自定义字典, 通过 "priorityNmap": true 开启
* RDP
Expand All @@ -37,15 +37,17 @@
* Wap-wsp(Elasticsearch)
* RouterOs
* HTTP BasicAuth
* Weblogic,同时通过enableNuclei=true开启nuclei,支持T3、IIOP等检测
* Weblogic,同时通过 enableNuclei=true 开启nuclei,支持T3、IIOP等检测
* Tomcat
* Jboss
* Winrm(wsman)
- 默认开启http密码智能爆破,需要http密码时才会自动启动,无需人工干预
- 检测系统是否存在nmap,存在通过 priorityNmap=true 启用nmap进行快速扫描,鉴于大多数人使用windows,默认关闭
使用nmap的弊端:因为设置网络包过大会导致结果不全
使用nmap另外需要将root密码设置到环境变量PPSSWWDD,更多参考config/doNmapScan.sh
默认使用naabu完成端口扫描 -stats=true 可以查看扫描进度
- 默认开启http密码智能爆破,需要 HTTP 密码时才会自动启动,无需人工干预
- 检测系统是否存在 nmap ,存在通过 priorityNmap=true 启用 nmap 进行快速扫描,默认开启,优化过的 nmap 参数比 masscan 快
使用 nmap 的弊端:网络不好的是否,因为流量网络包过大可能会导致结果不全
使用 nmap 另外需要将 root 密码设置到环境变量
export PPSSWWDD=yourRootPswd
更多参考:config/doNmapScan.sh
默认使用 naabu 完成端口扫描 -stats=true 可以查看扫描进度
- 快速 15000+ POC 检测功能,PoCs包含:
* nuclei POC
#### Nuclei Templates Top 10 statistics
Expand All @@ -66,11 +68,11 @@
* vscan POC包含了:xray 2.0 300+ POC、 go POC等
* scan4all POC

- 支持7000+web指纹扫描、识别:
* httpx指纹
* vscan指纹
* vscan指纹:包含 eHoleFinger、 localFinger等
* scan4all指纹
- 支持 7000+ web 指纹扫描、识别:
* httpx 指纹
* vscan 指纹
* vscan 指纹:包含 eHoleFinger、 localFinger等
* scan4all 指纹

- 支持146种协议90000+规则port扫描
* 依赖nmap支持的协议、指纹
Expand All @@ -91,6 +93,10 @@
* 该版本屏蔽你目标信息传递到 DNS Log Server 的bug,避免暴露漏洞
* 增加了将结果发送到 Elasticsearch 的功能,便于批量、盲打
* 未来有时间了再实现golang版本
如何使用?
```bash
mkdir ~/MyWork/;cd ~/MyWork/;git clone https://github.com/hktalent/log4j-scan
```
- 智能识别蜜罐,并跳过目标,默认该功能是关闭的,可设置EnableHoneyportDetection=true开启
- 高度可定制:允许通过config/config.json配置定义自己的字典,或者控制更多细节,包含不限于:nuclei、httpx、naabu等

Expand Down Expand Up @@ -122,17 +128,19 @@ http://127.0.0.1:9200/nmap_index/_doc/_search?q=_id:192.168.0.111
go build
# 精准扫描 url列表 UrlPrecise=true
UrlPrecise=true ./scan4all -l xx.txt
# 关闭适应nmap,使用naabu端口扫描其内部定义的http相关端口
priorityNmap=false ./scan4all -tp http -list allOut.txt -v
```

# Work Plan
- 整合 web-cache-vulnerability-scanner 实现HTTP smuggling走私、缓存中毒检测
- 联动 metasploit-framework,在系统已经安装好对前提条件下,配合tmux,并以 macos 环境为最佳实践完成联动
- 整合 更多 fuzzer <!-- gryffin -->,如 联动 sqlmap
- 整合 chromedp 实现对登陆页面截图,以及对纯js、js架构前端登陆页面进行检测、以及相应爬虫(敏感信息检测、页面爬取)
- 整合 nmap-go 提高执行效率
- 整合 nmap-go 提高执行效率,动态解析结果流,并融合到当前任务瀑布流中
- 整合 ksubdomain 实现更快子域名爆破
- 整合 spider 以便发现更多漏洞
- 指纹半自动化学习,提高精准度
- 半自动化指纹学习,提高精准度;指定指纹名称,通过配置

# 变更日志
- 2022-07-20 fix and PR nuclei <a href=https://github.com/projectdiscovery/nuclei/issues/2301>#2301</a> 并发多实例的bug
Expand Down
3 changes: 1 addition & 2 deletions pkg/doPy3log4j.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package pkg

import (
"fmt"
"github.com/hktalent/scan4all/lib"
"net/url"
"os"
Expand All @@ -16,7 +15,7 @@ var log4jsv sync.Map
// 3、只支持:https://github.com/hktalent/log4j-scan 版本
func DoLog4j(szUrl string) {
if 5 > len(szUrl) || !FileExists(UserHomeDir+"/MyWork/log4j-scan") {
fmt.Println("DoLog4j: ", 5 > len(szUrl), !FileExists(UserHomeDir+"/MyWork/log4j-scan"))
//fmt.Println("DoLog4j: ", 5 > len(szUrl), !FileExists(UserHomeDir+"/MyWork/log4j-scan"))
return
}
lib.DoSyncFunc(func() {
Expand Down
4 changes: 2 additions & 2 deletions pkg/httpx/runner/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,7 @@ func (r *Runner) process(t string, wg *sizedwaitgroup.SizedWaitGroup, hp *httpx.
go func(target, method, protocol string) {
defer wg.Done()
result := r.analyze(hp, protocol, target, method, t, scanopts)
pkg.SendAnyData(result, pkg.Httpx)
pkg.SendAnyData(&result, pkg.Httpx)
output <- result
if scanopts.TLSProbe && result.TLSData != nil {
scanopts.TLSProbe = false
Expand Down Expand Up @@ -749,7 +749,7 @@ func (r *Runner) process(t string, wg *sizedwaitgroup.SizedWaitGroup, hp *httpx.
defer wg.Done()
h, _ := urlutil.ChangePort(target, fmt.Sprint(port))
result := r.analyze(hp, protocol, h, method, t, scanopts)
pkg.SendAnyData(result, pkg.Httpx)
pkg.SendAnyData(&result, pkg.Httpx)
output <- result
if scanopts.TLSProbe && result.TLSData != nil {
scanopts.TLSProbe = false
Expand Down
10 changes: 3 additions & 7 deletions pkg/hydra/hydra.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ var (
CustomAuthMap *AuthList
// rtsp://admin:admin@192.168.0.111:554/0x8b6c42
// rtsp: 554, 5554,8554
ProtocolList = strings.Split("rdp,ssh,rsh-spx,mysql,mssql,oracle,postgresql,redis,ftp,mongodb,smb,telnet,snmp,wap-wsp,router,winrm", ",")
ProtocolList = strings.Split("rdp,ssh,rsh-spx,mysql,mssql,oracle,postgresql,redis,ftp,mongodb,mongod,smb,telnet,snmp,wap-wsp,router,winrm", ",")
)

func NewCracker(info *AuthInfo, isAuthUpdate bool, threads int) *Cracker {
Expand Down Expand Up @@ -78,11 +78,7 @@ func (c *Cracker) Run() {
//若SID未知,则不进行后续暴力破解
case "postgresql":
c.Pool.Function = postgresqlCracker
case "ldap":

case "rsh-spx":
c.Pool.Function = sshCracker
case "ssh":
case "ldap", "rsh-spx", "ssh":
c.Pool.Function = sshCracker
case "telnet":
serverType := getTelnetServerType(ip, port)
Expand All @@ -108,7 +104,7 @@ func (c *Cracker) Run() {
c.Pool.Function = RouterOsCracker
case "winrm":
c.Pool.Function = WinrmCracker
case "mongodb":
case "mongod", "mongodb":
c.Pool.Function = mongodbCracker
case "redis":
c.Pool.Function = redisCracker
Expand Down
31 changes: 16 additions & 15 deletions pkg/hydra/loadDicts.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,74 +129,75 @@ type PPDict struct {
DefaultUp string
}

var md = map[string]PPDict{}
var md = map[string]*PPDict{}

func init() {
md["ftp"] = PPDict{
md["ftp"] = &PPDict{
Username: pkg.GetVal4File("ftp_user", ftpusername),
Paswd: pkg.GetVal4File("ftp_pswd", ftp_pswd),
DefaultUp: pkg.GetVal4Filedefault("ftp_default", ftp_default),
}
md["ssh"] = PPDict{
md["ssh"] = &PPDict{
Username: pkg.GetVal4File("ssh_username", username),
Paswd: pkg.GetVal4File("ssh_pswd", pswd),
DefaultUp: pkg.GetVal4Filedefault("ssh_default", ssh_default),
}
md["rsh-spx"] = md["ssh"]
md["snmp"] = PPDict{
md["snmp"] = &PPDict{
Username: pkg.GetVal4File("snmp_user", snmp_user),
Paswd: pkg.GetVal4File("snmp_pswd", snmp_pswd),
DefaultUp: pkg.GetVal4Filedefault("snmp_default", snmp_default),
}
// 再增加字典
md["wap-wsp"] = PPDict{
md["wap-wsp"] = &PPDict{
Username: pkg.GetVal4File("es_user", es_user),
Paswd: pkg.GetVal4File("es_pswd", es_pswd),
DefaultUp: pkg.GetVal4Filedefault("es_default", es_default),
}
md["router"] = md["wap-wsp"]
md["mongodb"] = PPDict{
md["mongodb"] = &PPDict{
Username: pkg.GetVal4File("mongodb_username", mongodbusername),
Paswd: pkg.GetVal4File("mongodb_pswd", mongodb_pswd),
DefaultUp: pkg.GetVal4Filedefault("mongodb_default", mongodb_default),
}
md["mssql"] = PPDict{
md["mongod"] = md["mongodb"]
md["mssql"] = &PPDict{
Username: pkg.GetVal4File("mssql_username", mssqlusername),
Paswd: pkg.GetVal4File("mssql_pswd", mssql_pswd),
DefaultUp: pkg.GetVal4Filedefault("mssql_default", mssql_default),
}
md["mysql"] = PPDict{
md["mysql"] = &PPDict{
Username: pkg.GetVal4File("mysql_username", mysqlusername),
Paswd: pkg.GetVal4File("mysql_pswd", mysql_pswd),
DefaultUp: pkg.GetVal4File("mysql_default", mysql_default),
}
md["oracle"] = PPDict{
md["oracle"] = &PPDict{
Username: pkg.GetVal4File("oracle_username", oracleusername),
Paswd: pkg.GetVal4File("oracle_pswd", oracle_pswd),
DefaultUp: pkg.GetVal4Filedefault("oracleh_default", oracle_default),
}
md["postgresql"] = PPDict{
md["postgresql"] = &PPDict{
Username: pkg.GetVal4File("postgresql_username", postgresqlusername),
Paswd: pkg.GetVal4File("postgresql_pswd", postgresql_pswd),
DefaultUp: pkg.GetVal4Filedefault("postgresql_default", postgresql_default),
}
md["rdp"] = PPDict{
md["rdp"] = &PPDict{
Username: pkg.GetVal4File("rdp_username", rdpusername),
Paswd: pkg.GetVal4File("rdp_pswd", rdp_pswd),
DefaultUp: pkg.GetVal4Filedefault("rdp_default", rdp_default),
}
md["redis"] = PPDict{
md["redis"] = &PPDict{
Username: pkg.GetVal4File("redis_username", redisusername),
Paswd: pkg.GetVal4File("redis_pswd", redis_pswd),
DefaultUp: pkg.GetVal4Filedefault("redis_default", redis_default),
}
md["smb"] = PPDict{
md["smb"] = &PPDict{
Username: pkg.GetVal4File("smb_username", smbusername),
Paswd: pkg.GetVal4File("smb_pswd", smb_pswd),
DefaultUp: pkg.GetVal4Filedefault("smb_default", smb_default),
}
md["winrm"] = md["smb"]
md["telnet"] = PPDict{
md["telnet"] = &PPDict{
Username: pkg.GetVal4File("telnet_username", telnetusername),
Paswd: pkg.GetVal4File("telnet_pswd", telnet_pswd),
DefaultUp: pkg.GetVal4Filedefault("telnet_default", telnet_default),
Expand All @@ -205,7 +206,7 @@ func init() {

func GetDefaultFtpList(t string) *AuthList {
if x1, ok := md[t]; ok {
return func(o PPDict) *AuthList {
return func(o *PPDict) *AuthList {
a := NewAuthList()
a.Username = strings.Split(strings.TrimSpace(o.Username), "\n")
a.Password = strings.Split(strings.TrimSpace(o.Paswd), "\n")
Expand Down
2 changes: 1 addition & 1 deletion pkg/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func BurteLog(log string) {
}

func writeoutput(log string) {
SendAnyData(log, Scan4all)
SendAnyData(&log, Scan4all)
if "" == Output {
return
}
Expand Down
17 changes: 8 additions & 9 deletions pkg/sv2es.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,15 @@ func Log(v ...any) {

// 一定得有全局得线程等待
func SendAnyData(data interface{}, szType ESaveType) {
data1, _ := json.Marshal(data)
if 0 < len(data1) && enableEsSv {
hasher := sha1.New()
hasher.Write(data1)
k := hex.EncodeToString(hasher.Sum(nil))
if nil != myConst.Wg {
myConst.Wg.Add(1)
myConst.DoSyncFunc(func() {
data1, _ := json.Marshal(data)
if 0 < len(data1) && enableEsSv {
hasher := sha1.New()
hasher.Write(data1)
k := hex.EncodeToString(hasher.Sum(nil))
SendReq(data, k, szType)
}
SendReq(data, k, szType)
}
})
}

// k is id
Expand Down
4 changes: 2 additions & 2 deletions pocs_go/go_poc_check.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ func POCcheck(wappalyzertechnologies []string, URL string, finalURL string, chec
}
// 发送结果
if 0 < len(technologies) {
pkg.SendAnyData(map[string]interface{}{"Urls": []string{URL, finalURL}, "technologies": technologies}, pkg.Scan4all)
pkg.SendAnyData(&map[string]interface{}{"Urls": []string{URL, finalURL}, "technologies": technologies}, pkg.Scan4all)
}
return technologies
}
Expand All @@ -277,7 +277,7 @@ func init() {
nCnt = 0
log.Printf("<-lib.PocCheck_pipe: %+v %s", *x1.Wappalyzertechnologies, x1.URL)
lib.Wg.Add(1)
POCcheck(*x1.Wappalyzertechnologies, x1.URL, x1.FinalURL, x1.Checklog4j)
go POCcheck(*x1.Wappalyzertechnologies, x1.URL, x1.FinalURL, x1.Checklog4j)
default:
if nMax < nCnt {
close(lib.PocCheck_pipe)
Expand Down
5 changes: 3 additions & 2 deletions pocs_go/ms/ms17010.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ func MS17010(ip string, timeout time.Duration) {
//if runtime.GOOS=="windows" {fmt.Printf("%s\tMS17-010\t(%s)\n", ip, os)
//} else{fmt.Printf("\033[33m%s\tMS17-010\t(%s)\033[0m\n", ip, os)}
//color.Magenta("%s\tMS17-010\t(%s)\n", ip, os)
pkg.SendAnyData([]string{ip, "MS17-010", os}, pkg.Scan4all)
pkg.SendAnyData(&[]string{ip, "MS17-010", os}, pkg.Scan4all)
log.Print(ip + "\tMS17-010\t" + os + "\n")
// detect present of DOUBLEPULSAR SMB implant
trans2SessionSetupRequest[28] = treeID[0]
Expand All @@ -125,7 +125,8 @@ func MS17010(ip string, timeout time.Duration) {

if reply[34] == 0x51 {
// CVE-2017-0143 CVE-2017-0144 CVE-2017-0145 CVE-2017-0146 CVE-2017-0147 CVE-2017-0148
pkg.SendAnyData(fmt.Sprintf("ms17-010:DOUBLEPULSAR SMB IMPLANT in %s\n", ip), pkg.Scan4all)
s001 := fmt.Sprintf("ms17-010:DOUBLEPULSAR SMB IMPLANT in %s\n", ip)
pkg.SendAnyData(&s001, pkg.Scan4all)
fmt.Printf("DOUBLEPULSAR SMB IMPLANT in %s\n", ip)
}

Expand Down
3 changes: 2 additions & 1 deletion projectdiscovery/nuclei_Yaml/internal/runner/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,8 @@ func New(options *types.Options) (*Runner, error) {
}

if (len(options.Templates) == 0 || !options.NewTemplates || (options.TargetsFilePath == "" && !options.Stdin && len(options.Targets) == 0)) && options.UpdateTemplates {
os.Exit(0)
//os.Exit(0)
return nil, errors.Wrap(err, "no templates files")
}

// Initialize the input source
Expand Down
8 changes: 6 additions & 2 deletions projectdiscovery/nuclei_Yaml/masscan/masscan.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/pkg/errors"
"io"
"os/exec"
"time"
"regexp"
)

type Address struct {
Expand Down Expand Up @@ -78,6 +78,10 @@ func (m *Masscan) SetRate(rate string) {
m.Rate = rate
}

// 获取ip的正则表达式
var GetIpPort = regexp.MustCompile("Discovered open port (\\d+)\\/tcp on ((\\d+\\.){3}\\d+)")

// masscan -p- --rate=2000 192.168.10.31
func (m *Masscan) Run() error {
var cmd *exec.Cmd
var outb, errs bytes.Buffer
Expand Down Expand Up @@ -123,7 +127,7 @@ func (m *Masscan) Parse() ([]Host, error) {
}
switch a := t1.(type) {
case xml.StartElement:
time.Sleep(3)
//time.Sleep(3)
if a.Name.Local == "nmaprun" {
for _, v := range a.Attr {
if v.Name.Local == "start" {
Expand Down
1 change: 0 additions & 1 deletion projectdiscovery/nuclei_Yaml/nmap/nmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@ func (n *Nmap) Parse() ([]NmapResult, error) {
Os.Name = n1.Hosts[i].Os.OsMatches[y].Name
Os.Accuracy = tmp
}

}
if len(PortList) != 0 {
for _, v := range PortList {
Expand Down
1 change: 1 addition & 0 deletions projectdiscovery/nuclei_Yaml/nuclei_yaml.go
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,7 @@ func readConfig(options *types.Options) {
cleanupOldResumeFiles()
}

// 删除10天前文件
func cleanupOldResumeFiles() {
root, err := config.GetConfigDir()
if err != nil {
Expand Down
1 change: 0 additions & 1 deletion spider/catch_http.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@ func fullScreenshot(url string, quality int64, res *[]byte) chromedp.Tasks {
return nil
}),
}

}

func (a TLS) IsEmpty() bool {
Expand Down
Loading

0 comments on commit 67d15fc

Please sign in to comment.