Skip to content

Commit

Permalink
基础版本发布
Browse files Browse the repository at this point in the history
  • Loading branch information
DDZH-DEV committed Aug 1, 2023
1 parent 4cf2187 commit ac9c9b0
Show file tree
Hide file tree
Showing 13 changed files with 94 additions and 68,870 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ tmp/
front/
go.sum
last_scan.json
*.txt
33 changes: 33 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Find-Your-Shell
- Find-Your-Shell是一款由go语言开发得网站webshell查杀工具,支持linux,windows,默认包含了一部分php规则,
- 用户可以自定义添加规则对指定类型得文件进行查杀。
***
## 安装与使用
- 下载对应操作系统的release版本上次到需要扫描的服务器或者git clone 源代码
- 启动服务,会根据你的电脑提示服务器API,点击访问即可打开页面,如果是go源代码运行,可以输入命令 `go run main.go
![更改服务器API](/demos/run.jpg)
***
## 文件说明
### 启动必要文件
- `find-your-shell.exe 或 findyourshell `启动文件
- `conf.db` 规则与配置文件,复制可以跨电脑使用
### 启动辅助文件
- `public`文件夹用于展现UI,其实就是前后端分离的前端文件,无论你有多少服务器运行,只需一个能打开的前端文件点击服务器切换API即可
- `config.ini`用于配置启动端口,默认端口`9999`该文件可以不需要
### 其他文件
- `main.go` 开发的主要文件,目前是一个文件一把撸 `go.mod` 这个应该不需要解释
- `air.exe` 开发模式下修改代码自动重启工具 `.air.toml`是它的配置文件
***
## 项目演示
![主页](/demos/home.jpg)
![规则](/demos/rules.jpg)
![扫描结果](/demos/scan-result.jpg)
![编辑文件和创建规则](/demos/edit-code-file-and-rule.jpg)
![编辑规则](/demos/edit-rule.jpg)
![更改服务器API](/demos/change-server.jpg)
***
## 捐赠与支持
![支持作者](/demos/qrcode.jpg)
- 无论你打赏多少,有问题都可以来群里联系我
[规则讨论交流QQ群](https://jq.qq.com/?_wv=1027&k=5r3f8q0)

4 changes: 1 addition & 3 deletions config.ini
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
[http]
port=9999
token=
html=true
ports=9999
Binary file added demos/change-server.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added demos/edit-code-file-and-rule.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added demos/edit-rule.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added demos/home.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added demos/qrcode.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added demos/rules.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added demos/run.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added demos/scan-result.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
76 changes: 58 additions & 18 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package main
// 导入内置 fmt
import (
"crypto/md5"
"embed"
"encoding/hex"
"encoding/json"
"fmt"
Expand All @@ -12,7 +11,7 @@ import (
"github.com/jmoiron/sqlx"
_ "github.com/logoove/sqlite"
"io"
"io/fs"
"net"
"net/http"
"os"
"path/filepath"
Expand All @@ -22,6 +21,8 @@ import (
"time"
)

var VERSION = string("1.0.0")

// GetFileHash 获取文件的Hash
func GetFileHash(filename string) (string, error) {
// 打开文件
Expand Down Expand Up @@ -289,25 +290,24 @@ var lastSearchPath string
var configs []Conf
var scanResult []FileScanRes

//go:embed public/*
var staticFiles embed.FS

func startHttpServer() {

gin.SetMode(gin.ReleaseMode)
// 1.创建路由
r := gin.Default()
// 2.绑定路由规则,执行的函数
// gin.Context,封装了request和response
r.LoadHTMLFiles("./public/index.html")
//r.Static("/static", "./public/static")
if isDir("./public") {
r.LoadHTMLFiles("./public/index.html")
r.Static("/static", "./public/static")
}
//r.StaticFS("/static", http.FS(staticFiles))

fcss, _ := fs.Sub(staticFiles, "public/static/css")
fjs, _ := fs.Sub(staticFiles, "public/static/js")
ficonfont, _ := fs.Sub(staticFiles, "public/static/iconfont")
r.StaticFS("static/css", http.FS(fcss))
r.StaticFS("static/js", http.FS(fjs))
r.StaticFS("static/iconfont", http.FS(ficonfont))
//fcss, _ := fs.Sub(staticFiles, "public/static/css")
//fjs, _ := fs.Sub(staticFiles, "public/static/js")
//ficonfont, _ := fs.Sub(staticFiles, "public/static/iconfont")
//r.StaticFS("static/css", http.FS(fcss))
//r.StaticFS("static/js", http.FS(fjs))
//r.StaticFS("static/iconfont", http.FS(ficonfont))

r.Use(func(c *gin.Context) {
c.Writer.Header().Set("Access-Control-Allow-Origin", "*")
Expand All @@ -331,8 +331,16 @@ func startHttpServer() {

//默认请求
r.GET("/", func(c *gin.Context) {
fmt.Println("staticFiles", staticFiles)
c.HTML(http.StatusOK, "index.html", c)
if isDir("./public") {
c.HTML(http.StatusOK, "index.html", c)
} else {
c.Header("Content-Type", "text/html; charset=utf-8")
c.String(200, "<h1>Find-Your-Shell V"+VERSION+"</h1>"+
"<p>开源地址 : <a href='https://gitee.com/DDZH-DEV/Find-Your-Shell' target='_blank'>Gitee</a></p>"+
"<p>一般情况下,只需将执行文件和conf.db拷贝到对应得系统启动即可,文件夹 public 下得文件可以放置任意服务器网址下访问,只要填写对应得API地址即可</p>")

}

})

r.POST("/rule", func(c *gin.Context) {
Expand Down Expand Up @@ -643,22 +651,54 @@ func startHttpServer() {

})

r.Run(":9999")
r.Run(":" + port)

}

var cfg *ini.File
var port string

func ips() {
ifaces, err := net.Interfaces()
if err != nil {
fmt.Println(err)
return
}

for _, iface := range ifaces {
addrs, err := iface.Addrs()
if err != nil {
fmt.Println(err)
continue
}

for _, addr := range addrs {
ipnet, ok := addr.(*net.IPNet)
if ok && !ipnet.IP.IsLoopback() && ipnet.IP.To4() != nil {
fmt.Println("API:http://" + ipnet.IP.String() + ":" + port)
}
}
}
}

func main() { // main函数,是程序执行的入口
db, _ = sqlx.Open("sqlite3", "./conf.db")
cfg, err := ini.Load("config.ini")

if err != nil {
fmt.Println(cfg, err.Error())
return
port = "9999"
} else {
port = cfg.Section("http").Key("port").String()
if len(port) == 0 {
port = "9999"
}
}

//开启全性能
numCPU := runtime.NumCPU()
runtime.GOMAXPROCS(numCPU - 1)
ips()
loadRules()
startHttpServer()
}
Loading

0 comments on commit ac9c9b0

Please sign in to comment.