吾爱破解 - LCG - LSG |安卓破解|病毒分析|www.52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 511|回复: 12
收起左侧

[讨论] 手握go源码,硬是找不到无法启动的原因,真的很灵异

[复制链接]
wucuoym 发表于 2024-1-11 00:24
在别的语言还没有碰到过这种情况。

一份Go的源码,会在启动的时候找一个 key.bin 文件,如果找不到,就无法启动。

打了断点在main里边,根本没有进到main。 那应该是在  init() 方法里边。于是我在所有的init()方法里边打断点,还是没有进。

最后调试是在以下的代码会异常退出。而且退出是毫无征兆的退出。

[C] 纯文本查看 复制代码
		firstFunc := add(unsafe.Pointer(t), 8)
		for i := uint32(0); i < t.nfns; i++ {
			p := add(firstFunc, uintptr(i)*goarch.PtrSize)
			f := *(*func())(unsafe.Pointer(&p))
			f()
		}


但是从源码中,找死了也没找到是在哪里做这个事情的。

甚至加断点加到了go源码里边也没找出来。

源码下载: https://vvpp.cc/s/aNcg

大佬们看看这个程序是如何做到这种限制的。

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

 楼主| wucuoym 发表于 2024-1-11 23:31
下面是我处理下的代码,但是还是启动不起来。

[C] 纯文本查看 复制代码
package bootstrap

import (
        "bytes"
        "crypto/aes"
        "crypto/cipher"
        "fmt"
        "github.com/cloudreve/Cloudreve/v3/bootstrap/constant"
        "github.com/cloudreve/Cloudreve/v3/pkg/conf"
        "github.com/cloudreve/Cloudreve/v3/pkg/vol"
        "github.com/gin-gonic/gin"
        "io/ioutil"
        "log"
        "strconv"
)

var matrix []byte
var APPID string

// InitApplication 初始化应用常量
func InitApplication() {
        fmt.Print(`
   Cloudreve Application Information
   Version: ` + conf.BackendVersion + `  Commit: #` + conf.LastCommit + `  Pro: ` + conf.IsPro + `
================================================
`)
        pic, err := ioutil.ReadFile("bg.png")
        if err != nil {
                log.Fatalf("Failed to read bg.png: %v", err)
        }

        // Your data
        table := map[string]interface{}{
                "id":      "2018110303550773058",
                "pic":     pic,
                "secret":  "C3E8E7FDB44F866A29309FAF91242343",
                "version": "3.3.1",
                "date":    "1111111111111111111",
                "domains": "dd.cc",
                "table":   make([]int, 15),
        }
        // 使用解密和解码后的数据初始化全局变量
        constant.HashIDTable = table["table"].([]int)
        APPID = table["id"].(string)
        matrix = table["pic"].([]byte)
        vol.ClientSecret = table["secret"].(string)
}

// InitCustomRoute 初始化自定义路由
func InitCustomRoute(group *gin.RouterGroup) {
        // 定义一个返回 PNG 图片的路由
        group.GET("bg", func(c *gin.Context) {
                c.Header("content-type", "image/png")
                c.Writer.Write(matrix)
        })

        // 定义一个返回 APPID 的路由
        group.GET("id", func(c *gin.Context) {
                c.String(200, APPID)
        })
}

func seed() []byte {
        res := []int{8}
        s := "20210323"
        m := 1 << 20
        a := 9
        b := 7
        for i := 1; i < 23; i++ {
                res = append(res, (a*res[i-1]+b)%m)
                s += strconv.Itoa(res[i])
        }
        return []byte(s)
}

func decode(cryted []byte, key []byte) []byte {
        block, _ := aes.NewCipher(key[:32])
        blockSize := block.BlockSize()
        blockMode := cipher.NewCBCDecrypter(block, key[:blockSize])
        orig := make([]byte, len(cryted))
        blockMode.CryptBlocks(orig, cryted)
        orig = pKCS7UnPadding(orig)
        return orig
}

func pKCS7UnPadding(origData []byte) []byte {
        length := len(origData)
        unpadding := int(origData[length-1])
        return origData[:(length - unpadding)]
}

func encode(orig []byte, key []byte) []byte {
        block, _ := aes.NewCipher(key[:32])
        blockSize := block.BlockSize()
        orig = pKCS7Padding(orig, blockSize)
        blockMode := cipher.NewCBCEncrypter(block, key[:blockSize])
        crypted := make([]byte, len(orig))
        blockMode.CryptBlocks(crypted, orig)
        return crypted
}

func pKCS7Padding(origData []byte, blockSize int) []byte {
        padding := blockSize - len(origData)%blockSize
        padtext := bytes.Repeat([]byte{byte(padding)}, padding)
        return append(origData, padtext...)
}
go4399 发表于 2024-1-11 21:39
bootstrap\app.go

[Asm] 纯文本查看 复制代码
	data, err := ioutil.ReadFile(util.RelativePath(string([]byte{107, 101, 121, 46, 98, 105, 110})))


107, 101, 121, 46, 98, 105, 110 正好就是key.bin
 楼主| wucuoym 发表于 2024-1-11 00:27
go4399 发表于 2024-1-11 13:25
go编译器版本,1.21.5及以上无法在Win7及以下系统启动
 楼主| wucuoym 发表于 2024-1-11 17:50
go4399 发表于 2024-1-11 13:25
go编译器版本,1.21.5及以上无法在Win7及以下系统启动

不是版本问题,我把key.bin文件放进去就可以运行了。
我是win10。
主要是我没有找到读取文件的地方。而且这种直接exit一般是什么情况下会出现呢。
 楼主| wucuoym 发表于 2024-1-11 17:52
另外go编译器有没有办法打出所有的运行堆栈。这样我才能找到是哪里退出的,现在完全没头绪。
go4399 发表于 2024-1-11 20:37
查一下go.mod里面的包的源代码,有没有读key.bin的地方
C:\Users\xxxx\go\pkg\mod下面的源代码
 楼主| wucuoym 发表于 2024-1-11 23:28
go4399 发表于 2024-1-11 21:39
bootstrap\app.go

[mw_shl_code=asm,true]        data, err := ioutil.ReadFile(util.RelativePath(string([]b ...

谢谢帮忙查看源码。

这个地方我也找到了,然后我根据key.bin给几个变量都赋值了。

也就是这段代码已经屏蔽了。可以后面还是启动不起来。
 楼主| wucuoym 发表于 2024-1-11 23:32
而且问题是我在这个方法里边打断点使用Goland调试根本走不到这里来。。。
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则 警告:本版块禁止回复与主题无关非技术内容,违者重罚!

快速回复 收藏帖子 返回列表 搜索

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2024-5-4 11:14

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表