diff --git a/.dockerfile b/.dockerfile index e1b8b04..9317337 100644 --- a/.dockerfile +++ b/.dockerfile @@ -1,11 +1,8 @@ -# 使用Debian镜像作为基础镜像 FROM debian:11 -# 将APT源更换为国内源(这里使用阿里云的源) RUN sed -i 's/deb.debian.org/mirrors.aliyun.com/g' /etc/apt/sources.list && \ sed -i 's/security.debian.org/mirrors.aliyun.com\/debian-security/g' /etc/apt/sources.list -# 更新软件包索引并安装必要的工具 RUN apt-get update && apt-get install -y \ python3 \ python3-pip \ @@ -58,7 +55,9 @@ ENV PATH="/usr/local/sillyGirl/language/node:${PATH}" ENV SILLYGIRL_DATA_PATH=/usr/local/sillyGirl/ # 指定容器启动时要运行的命令 -CMD ["/usr/local/sillyGirl/sillyGirl", "-t"] +# CMD ["/usr/local/sillyGirl/sillyGirl", "-t"] -# docker build -t my-sillygirl . -# docker run -d --restart always --name my-sillygirl my-sillygirl +CMD ["/usr/local/sillyGirl/sillyGirl -t"] + +# docker build -t sillygirl . +# docker run -d --restart always --name sillygirl sillygirl diff --git a/.gitignore b/.gitignore index ed9f146..e8d77b4 100644 --- a/.gitignore +++ b/.gitignore @@ -17,6 +17,7 @@ _* fanli_vip cable sillyplus.cache +sillyplus.* main sillyplus.pid sillyGirl.pid @@ -36,4 +37,4 @@ test* node_modules plugins bin -language \ No newline at end of file +language diff --git a/autMan/main.go b/autMan/main.go deleted file mode 100644 index b838257..0000000 --- a/autMan/main.go +++ /dev/null @@ -1,96 +0,0 @@ -package main - -import ( - "crypto/aes" - "crypto/cipher" - "encoding/base64" - "fmt" - "io/ioutil" - "net/http" - "net/url" -) - -func getJS(user, pass, title string) string { - baseURL := "http://aut.zhelee.cn/plugin/download" - queryParams := url.Values{} - queryParams.Set("title", title) - queryParams.Set("username", user) - queryParams.Set("password", pass) - queryParams.Set("version", "1") - - u, err := url.Parse(baseURL) - if err != nil { - panic(err) - } - - u.RawQuery = queryParams.Encode() - - urlStr := u.String() - method := "POST" - - client := &http.Client{} - req, err := http.NewRequest(method, urlStr, nil) - - if err != nil { - fmt.Println(err) - return "" - } - res, err := client.Do(req) - if err != nil { - fmt.Println(err) - return "" - } - defer res.Body.Close() - - body, err := ioutil.ReadAll(res.Body) - if err != nil { - fmt.Println(err) - return "" - } - // fmt.Println(string(body)) - return string(body) -} - -func main() { - user := "test1234" - pass := "test1234" - title := "hook" - plaintext := getJS(user, pass, title) - key := getKey("test1234") - panic(key) - decrypted, err := decrypt(string(plaintext), []byte(key)) - // 打印解密后的数据 - fmt.Println(err) - fmt.Printf("解密后的数据:%s\n", decrypted) -} - -func getKey(user string) string { - t := user + "killsillygirltodeath109times" - if len(t) > 32 { - return t[:32] - } - // if len(t) > 24 { - // return t[:24] - // } - // return t[:16] - return t[:24] -} - -// 使用AES-CBC模式进行解密 -func decrypt(encrypted string, key []byte) (string, error) { - block, err := aes.NewCipher(key) - if err != nil { - return "", err - } - ciphertext, err := base64.StdEncoding.DecodeString(encrypted) - if err != nil { - return "", err - } - - iv := ciphertext[:aes.BlockSize] - ciphertext = ciphertext[aes.BlockSize:] - decrypter := cipher.NewCBCDecrypter(block, iv) - decrypted := make([]byte, len(ciphertext)) - decrypter.CryptBlocks(decrypted, ciphertext) - return string(decrypted), nil -} diff --git a/autMan/下载.js b/autMan/下载.js deleted file mode 100644 index bada463..0000000 --- a/autMan/下载.js +++ /dev/null @@ -1,86 +0,0 @@ -/** - * @title 怪兽插件下载 - * @create_at 2022-07-04 16:05:44 - * @description 🐒仅供学习,访问傻妞地址下载:http://${ app.ip }:${ app.port ?? "8080"}/api/fuckatm?title=hook&username=username&password=password - * @author 佚名 - * @version v1.0.0 - * @http GET /api/fuckatm - * @encrypt true - * @form {key: "autMan.title", "title": "默认标题", required: true, tooltip: "请求参数title为空时"} - * @form {key: "autMan.username", "title": "默认用户", required: true, tooltip: "请求参数username为空时"} - * @form {key: "autMan.password", "title": "默认密码", required: true, tooltip: "请求参数password为空时"} - */ - -const plt = s.getPlatform() -const autMan = Bucket("autMan") -const base_url = "http://aut.zhelee.cn/plugin/" - -class AESCipher { - constructor(key) { - this.key = key; - } - decrypt(encrypt) { - const encryptBuffer = Buffer.from(encrypt, 'base64'); - const decipher = crypto.createDecipheriv('aes-256-cbc', this.key, encryptBuffer.slice(0, 16)); - let decrypted = decipher.update(encryptBuffer.slice(16).toString('hex'), 'hex', 'utf8'); - decrypted += decipher.final('utf8'); - return decrypted; - } -} - -function main() { - if (req) { - let title = req.query("title") - if (!title) { - title = autMan.title ?? "" - } - if (!title) { - res.send("title不为空") - return - } - let username = req.query("username") - if (!username) { - username = autMan.username ?? "" - } - if (!username) { - res.send("username不为空") - return - } - let password = req.query("password") - if (!password) { - password = autMan.password ?? "" - } - if (!password) { - res.send("password不为空") - return - } - let { body } = request({ - url: base_url + "download?" + strings.encodeQueryString({ - title, - username, - password, - version: "1", - dataType: "text" - }), - method: "POST", - }) - console.log("==",body) - let key = username + "killsillygirltodeath109times" - key = Buffer.from(key) - key = key.length() > 32 ? key.slice(0, 32) : key.slice(0, 24) - let cipher = new AESCipher(key.toString()) - res.send(cipher.decrypt(body)) - let resp = request({ - url: base_url + "remove?" + strings.encodeQueryString({ - title: title, - username: username, - password: password, - version: "1", - }), - method: "POST", - }) - console.log("remove", resp.body) - } -} - -main() \ No newline at end of file diff --git a/core/grpc_plugins.go b/core/grpc_plugins.go index a086367..7208276 100644 --- a/core/grpc_plugins.go +++ b/core/grpc_plugins.go @@ -124,19 +124,19 @@ func initNodePlugins() { } else { // fmt.Println("非插件目录", event.Name) } - // tf := event.Name + "/node_modules/sillygirl.d.ts" - // ti := event.Name + "/demo.main.js" - // if _, err := os.Stat(tf); err != nil { - // os.Mkdir(event.Name+"/node_modules", 0700) - // os.WriteFile(tf, []byte(typeat), 0700) - // } - // go func() { - // time.Sleep(time.Second) - // if _, err := os.Stat(ti); err != nil { - // os.Mkdir(event.Name+"/node_modules", 0700) - // os.WriteFile(ti, []byte(defaultScript(plugin_name)), 0700) - // } - // }() + tf := event.Name + "/node_modules/sillygirl.d.ts" + ti := event.Name + "/demo.main.js" + if _, err := os.Stat(tf); err != nil { + os.Mkdir(event.Name+"/node_modules", 0700) + os.WriteFile(tf, []byte(typeat), 0700) + } + go func() { + time.Sleep(time.Second) + if _, err := os.Stat(ti); err != nil { + os.Mkdir(event.Name+"/node_modules", 0700) + os.WriteFile(ti, []byte(defaultScript(plugin_name)), 0700) + } + }() } else if plugin_index { // fmt.Println("增加插件", event.Name) // RemNodePlugin(plugin_name) diff --git a/core/grpc_sender.go b/core/grpc_sender.go index 1e67221..0f63992 100644 --- a/core/grpc_sender.go +++ b/core/grpc_sender.go @@ -116,7 +116,6 @@ func (sg *SillyGirlService) SenderListen(stream srpc.SillyGirlService_SenderList var persistent bool ctx := stream.Context() - defer fmt.Println("已关闭,", "===") for { req, err := stream.Recv() // fmt.Println("req", string(utils.JsonMarshal(req))) diff --git a/core/plugin_ptr.go b/core/plugin_ptr.go index ef34784..c85541c 100644 --- a/core/plugin_ptr.go +++ b/core/plugin_ptr.go @@ -14,7 +14,6 @@ func getPaterner(uuid, path string) (string, string, bool) { break } } - for _, f := range ls { //同源 if f.Address == address && (f.Title == path || f.UUID == path) { data = plugins.GetBytes(f.UUID) diff --git a/core/web.go b/core/web.go index 007f4d1..2c01a37 100644 --- a/core/web.go +++ b/core/web.go @@ -7,7 +7,6 @@ import ( "embed" "fmt" "io" - "io/ioutil" "net" "net/http" "os" @@ -132,7 +131,7 @@ func initWeb() { } if is_index { var data []byte - data, err = ioutil.ReadAll(file) + data, err = io.ReadAll(file) if err != nil { return err } diff --git a/main.go b/main.go index 8eb601a..711a6cd 100644 --- a/main.go +++ b/main.go @@ -6,6 +6,7 @@ import ( "os" "os/exec" "runtime" + "strings" "time" // _ "github.com/cdle/sillyplus/adapters/qq" @@ -65,10 +66,10 @@ func main() { } if t { // core.Logs.Info("Terminal机器人已连接") - scanner := bufio.NewScanner(os.Stdin) + a := &core.Factory{} a.Init("terminal", "default", nil) - i := 0 + i := 1 a.SetIsAdmin(func(s string) bool { return true }) @@ -81,24 +82,27 @@ func main() { // fmt.Println(`do action: ` + string(utils.JsonMarshal(m))) // return "" // }) + reader := bufio.NewReader(os.Stdin) + for { + input, err := reader.ReadString('\n') + if err != nil { + core.Logs.Error(err) + a.Destroy() + break + } + input = strings.TrimSpace(input) - for scanner.Scan() { - data := scanner.Text() s := &core.CustomSender{ - // Type: "terminal", - // Message: string(data), - // Admin: true, F: a, } i++ s.SetFsps(&common.FakerSenderParams{ - Content: data, + Content: input, MessageID: fmt.Sprint(i), }) - s.SetContent(data) core.Messages <- s + // 在这里可以根据输入执行相应的逻辑 } - core.Logs.Info("Terminal机器人异常,请检查运行环境设置,如果是docker环境,请附加-it参数") } else { // core.Logs.Info("Terminal机器人不可用,运行带-t参数即可启用") }