-
Notifications
You must be signed in to change notification settings - Fork 81
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
0 parents
commit 7a46e7a
Showing
511 changed files
with
92,733 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
ksubdomain.yaml | ||
.idea | ||
dist/ |
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,20 @@ | ||
# This is an example .goreleaser.yml file with some sensible defaults. | ||
# Make sure to check the documentation at https://goreleaser.com | ||
|
||
# The lines below are called `modelines`. See `:help modeline` | ||
# Feel free to remove those if you don't want/need to use them. | ||
# yaml-language-server: $schema=https://goreleaser.com/static/schema.json | ||
# vim: set ts=2 sw=2 tw=0 fo=cnqoj | ||
|
||
version: 1 | ||
builds: | ||
- goos: | ||
- windows | ||
- linux | ||
- darwin | ||
goarch: | ||
- amd64 | ||
main: ./cmd/ScopeSentry/main.go | ||
binary: "ScopeSentry" | ||
|
||
dist: ./dist |
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,6 @@ | ||
# ScopeSentry-Scan | ||
ScopeSentry工具的扫描端 | ||
|
||
# 教程&安装 | ||
- 官网: https://www.scope-sentry.top/ | ||
- Github: https://github.com/Autumn-27/ScopeSentry |
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,14 @@ | ||
version: "3" | ||
|
||
services: | ||
mongodb: | ||
image: mongo:latest | ||
container_name: scopesentry-mongodb | ||
restart: always | ||
ports: | ||
- "27017:27017" | ||
environment: | ||
MONGO_INITDB_ROOT_USERNAME: admin | ||
MONGO_INITDB_ROOT_PASSWORD: yourpassword | ||
volumes: | ||
- ./data/mongodb:/data/db |
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,12 @@ | ||
version: "3" | ||
|
||
services: | ||
redis: | ||
image: redis:7.0.11 | ||
container_name: scopesentry-redis | ||
restart: always | ||
ports: | ||
- "6379:6379" | ||
command: redis-server --requirepass yourpassword | ||
volumes: | ||
- ./data/redis/data:/data |
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,16 @@ | ||
version: '3' | ||
services: | ||
scan: | ||
image: autumn27/scopesentry-scan:latest | ||
container_name: scopesentry-scan | ||
restart: always | ||
environment: | ||
NodeName: node-test | ||
TimeZoneName: Asia/Shanghai | ||
Mongodb_IP: 127.0.0.1 | ||
MONGODB_PORT: 27017 | ||
Mongodb_Username: root | ||
Mongodb_Password: yourpassword | ||
Redis_IP: 127.0.0.1 | ||
Redis_PORT: 6379 | ||
Redis_Password: yourpassword |
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,171 @@ | ||
// Package ScopeSentry ----------------------------- | ||
// @file : main.go | ||
// @author : Autumn | ||
// @contact : [email protected] | ||
// @time : 2023/12/6 17:24 | ||
// ------------------------------------------- | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"github.com/Autumn-27/ScopeSentry-Scan/pkg/crawlerMode" | ||
"github.com/Autumn-27/ScopeSentry-Scan/pkg/node" | ||
"github.com/Autumn-27/ScopeSentry-Scan/pkg/system" | ||
"github.com/Autumn-27/ScopeSentry-Scan/pkg/task" | ||
"github.com/Autumn-27/ScopeSentry-Scan/pkg/util" | ||
"github.com/shirou/gopsutil/v3/mem" | ||
"math/rand" | ||
"net/http" | ||
_ "net/http/pprof" | ||
"os" | ||
"os/signal" | ||
"runtime" | ||
"sync" | ||
"syscall" | ||
"time" | ||
) | ||
|
||
func printStackTrace() { | ||
// 获取堆栈信息 | ||
buf := make([]byte, 1<<16) | ||
stackSize := runtime.Stack(buf, true) | ||
fmt.Printf("堆栈信息:\n%s\n", buf[:stackSize]) | ||
} | ||
|
||
func main() { | ||
defer system.RecoverPanic("main") | ||
Banner() | ||
rand.Seed(time.Now().UnixNano()) | ||
flag := system.SetUp() | ||
if !flag { | ||
myLog := system.CustomLog{ | ||
Status: "Error", | ||
Msg: fmt.Sprintf("SetUp Config Error"), | ||
} | ||
system.PrintLog(myLog) | ||
os.Exit(1) | ||
} | ||
if system.AppConfig.System.Debug { | ||
go func() { | ||
_ = http.ListenAndServe("0.0.0.0:6060", nil) | ||
}() | ||
//go DebugMem() | ||
sigs := make(chan os.Signal, 1) | ||
signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM) | ||
|
||
go func() { | ||
sig := <-sigs | ||
fmt.Println("收到终止信号:", sig) | ||
printStackTrace() | ||
}() | ||
} | ||
util.InitHttpClient() | ||
var wg sync.WaitGroup | ||
|
||
// 初始化爬虫 | ||
go crawlerMode.CrawlerThread(system.CrawlerThreadUpdateFlag) | ||
system.CrawlerThreadUpdateFlag <- true | ||
|
||
// node 注册、存活更新 | ||
go func() { | ||
defer wg.Done() // 减少计数器,表示任务完成 | ||
node.Register() | ||
}() | ||
|
||
// 配置更新、暂停扫描 | ||
wg.Add(1) // 增加计数器,表示有一个任务需要等待 | ||
// node 注册、存活更新 | ||
go func() { | ||
defer wg.Done() // 减少计数器,表示任务完成 | ||
system.RefreshConfig() | ||
}() | ||
|
||
wg.Add(1) // 增加计数器,表示有一个任务需要等待 | ||
// node 注册、存活更新 | ||
go func() { | ||
defer wg.Done() // 减少计数器,表示任务完成 | ||
task.GetTask() | ||
}() | ||
go workerUpdateSystem(system.UpdateSystemFlag) | ||
time.Sleep(time.Second * 5) | ||
wg.Wait() | ||
} | ||
|
||
func DebugMem() { | ||
var m runtime.MemStats | ||
ticker := time.Tick(2 * time.Second) | ||
for { | ||
<-ticker | ||
memInfo, err := mem.VirtualMemory() | ||
system.SlogDebugLocal(fmt.Sprintf("Total Memory: %.2f MiB Used Memory: %.2f MiB", float64(memInfo.Total)/1024/1024, float64(memInfo.Used)/1024/1024)) | ||
if err != nil { | ||
fmt.Println("Error:", err) | ||
return | ||
} | ||
runtime.ReadMemStats(&m) | ||
system.SlogDebugLocal(fmt.Sprintf("Alloc = %v MiB\tTotalAlloc = %v MiB\tSys = %v MiB\tNumGC = %v", bToMb(m.Alloc), bToMb(m.TotalAlloc), bToMb(m.Sys), m.NumGC)) | ||
} | ||
} | ||
|
||
func bToMb(b uint64) any { | ||
return b / 1024 / 1024 | ||
} | ||
|
||
func Banner() { | ||
banner := " _____ _____ _ \n / ____| / ____| | | \n | (___ ___ ___ _ __ ___ | (___ ___ _ __ | |_ _ __ _ _ \n \\___ \\ / __/ _ \\| '_ \\ / _ \\ \\___ \\ / _ \\ '_ \\| __| '__| | | |\n ____) | (_| (_) | |_) | __/ ____) | __/ | | | |_| | | |_| |\n |_____/ \\___\\___/| .__/ \\___| |_____/ \\___|_| |_|\\__|_| \\__, |\n | | __/ |\n |_| |___/ " | ||
fmt.Println(banner) | ||
} | ||
|
||
func workerUpdateSystem(done chan bool) { | ||
//time.Sleep(2 * time.Second) | ||
//<-done | ||
//overseer.Run(overseer.Config{ | ||
// TerminateTimeout: 60 * time.Second, | ||
// Fetcher: &fetcher.HTTP{ | ||
// URL: fmt.Sprintf("%v/get/scopesentry/client?system=%s&arch=%s", system.UpdateUrl, runtime.GOOS, runtime.GOARCH), | ||
// Interval: 1 * time.Second, | ||
// }, | ||
//}) | ||
} | ||
|
||
//func preUpgrade(tempBinaryPath string) error { | ||
// fmt.Printf("download binary path: %s\n", tempBinaryPath) | ||
// return nil | ||
//} | ||
|
||
//func UpdateSysmeMain(state overseer.State) { | ||
// flag := system.SetUp() | ||
// if !flag { | ||
// myLog := system.CustomLog{ | ||
// Status: "Error", | ||
// Msg: fmt.Sprintf("SetUp Config Error"), | ||
// } | ||
// system.PrintLog(myLog) | ||
// os.Exit(1) | ||
// } | ||
// util.InitHttpClient() | ||
// var wg sync.WaitGroup | ||
// wg.Add(1) // 增加计数器,表示有一个任务需要等待 | ||
// // node 注册、存活更新 | ||
// go func() { | ||
// defer wg.Done() // 减少计数器,表示任务完成 | ||
// node.Register() | ||
// }() | ||
// | ||
// // 配置更新、暂停扫描 | ||
// wg.Add(1) // 增加计数器,表示有一个任务需要等待 | ||
// // node 注册、存活更新 | ||
// go func() { | ||
// defer wg.Done() // 减少计数器,表示任务完成 | ||
// system.RefreshConfig() | ||
// }() | ||
// | ||
// wg.Add(1) // 增加计数器,表示有一个任务需要等待 | ||
// // node 注册、存活更新 | ||
// go func() { | ||
// defer wg.Done() // 减少计数器,表示任务完成 | ||
// task.GetTask() | ||
// }() | ||
// time.Sleep(time.Second * 5) | ||
// wg.Wait() | ||
//} |
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,24 @@ | ||
FROM debian:10-slim | ||
|
||
WORKDIR /apps | ||
|
||
# 更新软件包列表并安装必要的软件包 | ||
RUN apt-get update && apt-get install -y \ | ||
libexif-dev \ | ||
udev \ | ||
chromium \ | ||
vim \ | ||
tzdata \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
# 拷贝当前目录下的可执行文件到容器中 | ||
COPY dist/linux_amd_x64/ScopeSentry /apps/ScopeSentry | ||
|
||
# 设置时区为上海 | ||
RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime | ||
RUN echo 'Asia/Shanghai' >/etc/timezone | ||
|
||
# 设置编码 | ||
ENV LANG C.UTF-8 | ||
|
||
# 运行golang程序的命令 | ||
ENTRYPOINT ["/apps/ScopeSentry"] |
Oops, something went wrong.