Skip to content

Commit

Permalink
更新配置文件路径以及il8n
Browse files Browse the repository at this point in the history
  • Loading branch information
qiwentaidi committed Feb 4, 2024
1 parent a783fac commit 84d34a4
Show file tree
Hide file tree
Showing 24 changed files with 111 additions and 80 deletions.
Binary file added .DS_Store
Binary file not shown.
40 changes: 26 additions & 14 deletions app.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,23 @@ import (

// App struct
type App struct {
ctx context.Context
ctx context.Context
workflowFile string
webfingerFile string
afrogPathPoc string
cdnFile string
qqwryFile string
}

// NewApp creates a new App application struct
func NewApp() *App {
return &App{}
return &App{
workflowFile: "/slack/config/workflow.yaml",
webfingerFile: "/slack/config/webfinger.yaml",
afrogPathPoc: "/slack/config/afrog-pocs",
cdnFile: "/slack/config/cdn.yaml",
qqwryFile: "/slack/config/qqwry.dat",
}
}

// startup is called when the app starts. The context is saved
Expand Down Expand Up @@ -196,7 +207,7 @@ outerLoop:
for _, domain := range util.RemoveDuplicates[string](util.RegDomain.FindAllString(input, -1)) {
ips, cnames, err := core.Resolution(domain, []string{dns1 + ":53", dns2 + ":53"}, 5)
if err == nil {
for name, cdns := range core.ReadCDNFile() {
for name, cdns := range core.ReadCDNFile(a.cdnFile) {
for _, cdn := range cdns {
for _, cname := range cnames {
if strings.Contains(cname, cdn) { // 识别到cdn
Expand All @@ -222,14 +233,19 @@ func (a *App) InitIPResolved() {
core.IPResolved = make(map[string]int)
}

// subodomain
func (a *App) LoadSubDict(configPath string) []string {
return util.LoadSubdomainDict(util.HomeDir()+configPath, "/dicc.txt")
}

var onec sync.Once

func (a *App) Subdomain(subdomain, dns1, dns2 string, timeout int) []string {
var data map[string][]string
onec.Do(func() {
data = core.ReadCDNFile()
data = core.ReadCDNFile(a.cdnFile)
})
sr := core.BurstSubdomain(subdomain, []string{dns1 + ":53", dns2 + "53"}, data, timeout)
sr := core.BurstSubdomain(subdomain, []string{dns1 + ":53", dns2 + "53"}, data, timeout, a.qqwryFile)
return []string{sr.Subdomain, strings.Join(sr.Cname, " | "), strings.Join(sr.Ips, " | "), sr.Notes}
}

Expand Down Expand Up @@ -295,12 +311,8 @@ func (a *App) AssetHunter(mode int, target, api string) HunterSearch {

// dirsearch

func (a *App) InitDict(newExts []string) []string {
return util.LoadDirsearchDict(util.HomeDir()+"/slack/dirsearch", "/dicc.txt", "%EXT%", newExts)
}

func (a *App) LoadSubDict() []string {
return util.LoadSubdomainDict(util.HomeDir()+"/slack/subdomain", "/dicc.txt")
func (a *App) InitDict(configPath string, newExts []string) []string {
return util.LoadDirsearchDict(util.HomeDir()+configPath, "/dicc.txt", "%EXT%", newExts)
}

type PathData struct {
Expand Down Expand Up @@ -536,7 +548,7 @@ var RuleData map[string]map[string]string

// 仅在执行时调用一次
func (a *App) InitRule() {
yamlData, err := os.ReadFile(util.HomeDir() + "/slack/webfinger.yaml")
yamlData, err := os.ReadFile(util.HomeDir() + a.webfingerFile)
if err != nil {
logger.NewDefaultLogger().Debug(err.Error())
}
Expand Down Expand Up @@ -598,11 +610,11 @@ type WebResult struct {

func (a *App) PocNums(severity, keyword string) int {
o := runner.NewOptions("", keyword, severity, "")
return len(o.CreatePocList(a.LocalWalkFiles(util.HomeDir() + "/slack/afrog-pocs")))
return len(o.CreatePocList(a.LocalWalkFiles(util.HomeDir() + a.afrogPathPoc)))
}

func (a *App) GetFingerPoc(fingerprints []string) []string {
s, err := poc.FingerPocFilepath(fingerprints)
s, err := poc.FingerPocFilepath(fingerprints, a.workflowFile)
if err != nil {
logger.NewDefaultLogger().Debug(err.Error())
}
Expand Down
Binary file added build/.DS_Store
Binary file not shown.
4 changes: 2 additions & 2 deletions core/resolution.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ func LookupCNAMEWithServer(domain, domainServer string, timeout int) ([]string,
return CNAMES, nil
}

func ReadCDNFile() map[string][]string {
yamlData, err := os.ReadFile(util.HomeDir() + "/slack/cdn.yaml")
func ReadCDNFile(cdnFile string) map[string][]string {
yamlData, err := os.ReadFile(util.HomeDir() + cdnFile)
if err != nil {
logger.NewDefaultLogger().Debug(err.Error())
}
Expand Down
10 changes: 6 additions & 4 deletions core/subdomain.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ var (
)

// 初始化IP纯真库
func InitQqwry() {
fs, err := os.OpenFile(util.HomeDir()+"/slack/qqwry.dat", os.O_RDONLY, 0400)
func InitQqwry(qqwryFile string) {
fs, err := os.OpenFile(util.HomeDir()+qqwryFile, os.O_RDONLY, 0777)
if err != nil {
logger.NewDefaultLogger().Debug("qqwry open err:" + err.Error())
return
Expand All @@ -41,8 +41,10 @@ func InitQqwry() {
}

// 采用递归判断暴破层级
func BurstSubdomain(subdomains string, servers []string, cdndata map[string][]string, timeout int) *SubdomainResult {
onec.Do(InitQqwry)
func BurstSubdomain(subdomains string, servers []string, cdndata map[string][]string, timeout int, qqwryFile string) *SubdomainResult {
onec.Do(func() {
InitQqwry(qqwryFile)
})
var sr SubdomainResult
addrs, cnames, err := Resolution(subdomains, servers, timeout)
if err == nil {
Expand Down
6 changes: 2 additions & 4 deletions core/webscan/poc/poc.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,11 @@ type VulnerabilityDetails struct {
Solutions string
}

var pocsWorkflower = util.HomeDir() + "/slack/workflow.yaml"

// 输入目标指纹,返回对应指纹的POC路径
func FingerPocFilepath(fingerpirnts []string) ([]string, error) {
func FingerPocFilepath(fingerpirnts []string, workflowFile string) ([]string, error) {
files := []string{}
data := make(map[string][]string)
yamlData, err := os.ReadFile(pocsWorkflower)
yamlData, err := os.ReadFile(util.HomeDir() + workflowFile)
if err != nil {
return files, err
}
Expand Down
12 changes: 8 additions & 4 deletions file.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,14 @@ import (
)

// File struct 文件操作
type File struct{}
type File struct {
configPath string
}

func NewFile() *File {
return &File{}
return &File{
configPath: util.HomeDir() + "/slack/",
}
}

// 开始就要检测
Expand Down Expand Up @@ -63,7 +67,7 @@ func (f *File) GetFileContent(filename string) string {
}

func (f *File) UpdatePocFile() string {
if err := update.UpdatePoc(); err != nil {
if err := update.UpdatePoc(f.configPath); err != nil {
return err.Error()
}
return ""
Expand All @@ -87,5 +91,5 @@ func (f *File) Restart() {
}

func (f *File) InitConfig() bool {
return update.InitConfig()
return update.InitConfig(f.configPath)
}
18 changes: 9 additions & 9 deletions frontend/src/components/Sidebar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,13 @@ const changeZH = () => {
onMounted(async () => {
// 初始赋值
window.ActivePathPoc = "/slack/active-detect"
window.AFGPathPoc = "/slack/afrog-pocs"
window.PocVersion = "/slack/afrog-pocs/version"
let home = await UserHomeDir()
let cfg = await CheckFileStat(home + "/slack")
window.HomePath = await UserHomeDir()
window.ConfigPath = "/slack/config"
window.ActivePathPoc = window.ConfigPath + "/active-detect"
window.AFGPathPoc = window.ConfigPath + "/afrog-pocs"
window.PocVersion = window.ConfigPath + "/afrog-pocs/version"
window.LocalPocVersionFile = window.HomePath + window.PocVersion
let cfg = await CheckFileStat(window.HomePath + "/slack")
if (!cfg) {
ElNotification({
duration: 0,
Expand All @@ -39,7 +41,6 @@ onMounted(async () => {
message: "配置文件初始化成功!",
type: "success",
});
window.LocalPocVersion = await UserHomeDir() + window.PocVersion
check.client()
check.poc()
} else {
Expand All @@ -51,7 +52,6 @@ onMounted(async () => {
});
}
} else {
window.LocalPocVersion = await UserHomeDir() + window.PocVersion
check.client()
check.poc()
}
Expand All @@ -60,13 +60,13 @@ onMounted(async () => {
const check = ({
// poc
poc: async function () {
let pcfg = await CheckFileStat(window.LocalPocVersion)
let pcfg = await CheckFileStat(window.LocalPocVersionFile)
if (!pcfg) {
version.LocalPoc = "版本文件不存在"
version.PocStatus = false
return
} else {
version.LocalPoc = await GetFileContent(window.LocalPocVersion)
version.LocalPoc = await GetFileContent(window.LocalPocVersionFile)
}
let resp = await GoFetch("GET", download.RemotePocVersion, "", [{}], 10, null)
if (resp.Error == true) {
Expand Down
11 changes: 10 additions & 1 deletion frontend/src/i18n/en_US.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default {
'asset_from_company': 'Asset From CompanyName',
'subdomain_brute_force': 'Subdomain Brute Force',
'search_domain_info': 'Search Domain Info',
'space_engine': 'Space Engine',
'space_engine': 'Space Search Engine',
'hunter': 'Hunter',
'360quake': '360 Quake',
'agent_pool': 'Agent Pool',
Expand All @@ -31,5 +31,14 @@ export default {
'about': 'About',
'suggestions': 'If you have any improvement suggestions or other questions, you can contact us through wechat or issue. The contact information can be obtained by clicking on the logo on the homepage to go to the project address',
'technology': 'technology',
},
setting: {
'username': 'Username',
'password': 'Password',
'enable': 'Enabled',
'mode': 'Mode',
'address': 'Address',
'port': 'Port',
'proxy': 'Proxy (only applicable for webscan)',
}
}
9 changes: 9 additions & 0 deletions frontend/src/i18n/zh_CN.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,14 @@ export default {
'about': '关于',
'suggestions': '工具目前存在内存GC问题,如有改善意见或其他问题可以通过vx或者issue联系,联系方式可点击首页LOGO处前往项目地址获取',
'technology': '技术栈',
},
setting: {
'username': '用户名',
'password': '密码',
'enable': '启用',
'mode': '模式',
'address': '地址',
'port': '端口',
'proxy': '代理配置(仅适用网站扫描)'
}
}
4 changes: 3 additions & 1 deletion frontend/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ declare global {
var ActivePathPoc: string
var AFGPathPoc: string
var PocVersion: string
var LocalPocVersion: string
var LocalPocVersionFile: string
var ConfigPath: string
var HomePath: string
}


Expand Down
2 changes: 1 addition & 1 deletion frontend/src/views/Asset/Subdomain.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ async function BurstSubdomain() {
from.id = 0;
InitIPResolved();
if (from.subs.length === 0) {
from.subs = await LoadSubDict()
from.subs = await LoadSubDict(window.ConfigPath + "/subdomain")
from.tips = `loaded ${from.subs.length} dicts`
}
async.eachLimit(from.subs, from.thread, (sub: string, callback: () => void) => {
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/views/Permeation/Dirsearch.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script lang="ts" setup>
import { reactive, ref } from 'vue';
import { GoFetch, InitDict, PathRequest, SelectFile } from "../../../wailsjs/go/main/App";
import { GetFileContent, OpenFolder, UserHomeDir } from "../../../wailsjs/go/main/File";
import { GetFileContent, OpenFolder } from "../../../wailsjs/go/main/File";
import { ElMessage } from 'element-plus'
import async from 'async';
import { QuestionFilled, FolderOpened, Loading } from '@element-plus/icons-vue';
Expand Down Expand Up @@ -57,7 +57,7 @@ async function handleFileChange() {
}
async function Open() {
OpenFolder(await UserHomeDir() + "/slack/dirsearch")
OpenFolder(window.HomePath + window.ConfigPath + "/dirsearch")
}
async function dirscan() {
Expand Down Expand Up @@ -96,7 +96,7 @@ class Dirsearch {
from.url += "/"
}
if (from.paths.length === 0) {
await InitDict(from.exts.split(',')).then(result => {
await InitDict(window.ConfigPath + "/dirsearch", from.exts.split(',')).then(result => {
from.paths = result;
from.tips = `loaded default (${from.paths.length} dicts)`;
});
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/views/Permeation/Pocdetail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
LocalWalkFiles,
ReadPocDetail
} from '../../../wailsjs/go/main/App'
import { UserHomeDir, PathBase } from '../../../wailsjs/go/main/File'
import { PathBase } from '../../../wailsjs/go/main/File'
import { onMounted } from 'vue';
// 初始化时调用
onMounted(async () => {
Expand Down Expand Up @@ -41,7 +41,7 @@ const pd = reactive({
})
async function LoadPocList(filepath: string) {
let poclist = LocalWalkFiles(await UserHomeDir() + filepath)
let poclist = LocalWalkFiles(window.HomePath + filepath)
let index = 0
table.result = []
for (const fullpath of await poclist) {
Expand Down
8 changes: 2 additions & 6 deletions frontend/src/views/Permeation/Webscan.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import {
HunterSearch,
GoFetch
} from '../../../wailsjs/go/main/App'
import { UserHomeDir } from '../../../wailsjs/go/main/File'
import { ElMessage } from 'element-plus';
import { formatURL, ApiSyntaxCheck, splitInt } from '../../util'
import async from 'async';
Expand Down Expand Up @@ -77,9 +76,6 @@ const dashboard = reactive({
extInfo: '',
})
// const pathActive = "/slack/active-detect"
// const pathAFG = "/slack/afrog-pocs"
const ctrl = reactive({
exit: false,
buttonDisabled: false,
Expand Down Expand Up @@ -179,7 +175,7 @@ class Scanner {
count++
if (count == this.urls.length) { // 等任务全部执行完毕调用主动指纹探测
dashboard.logger += `[END] 指纹探测已结束\n`
form.currentLoadPath = await LocalWalkFiles(await UserHomeDir() + window.ActivePathPoc) // 初始化主动指纹目录
form.currentLoadPath = await LocalWalkFiles(window.HomePath + window.ActivePathPoc) // 初始化主动指纹目录
count = 0
dashboard.logger += `[INFO] 正在初始化主动指纹探测任务,已加载主动指纹: ${form.currentLoadPath.length}个\n`
callback();
Expand Down Expand Up @@ -298,7 +294,7 @@ class Scanner {
}
})
} else if (form.currentModule == "全部漏洞扫描") {
form.currentLoadPath = await LocalWalkFiles(await UserHomeDir() + window.AFGPathPoc)
form.currentLoadPath = await LocalWalkFiles(window.HomePath + window.AFGPathPoc)
dashboard.logger += `[INFO] 正在初始化全漏洞扫描任务,已加载POC: ${form.currentLoadPath.length}个\n`
let count = 0
async.eachLimit(this.urls, form.thread, (target: string, callback: () => void) => {
Expand Down

0 comments on commit 84d34a4

Please sign in to comment.