refactor:移除原有限制

This commit is contained in:
samwaf
2024-08-06 15:22:15 +08:00
parent 7566c8b619
commit 5cec4353e5
6 changed files with 17 additions and 80 deletions

View File

@@ -129,7 +129,7 @@ var (
GWAF_REG_KEY = []byte("5F!vion$k@a7QZ&)") //注册信息加密密钥
GWAF_REG_PUBLIC_KEY string = "" //注册信息加密公钥
GWAF_REG_TMP_REG []byte //用户传来的信息
GWAF_REG_FREE_COUNT int64 = 3 //免费版授权用户数
GWAF_REG_FREE_COUNT int64 = 99999 //免费版授权用户数
GWAF_REG_CUR_CLIENT_COUNT int64 = 3 //当前客户端用户数
)

View File

@@ -213,6 +213,7 @@ export default Vue.extend({
},
mounted() {
this.getList("")
this.loadCurrentLicense()
},
methods: {
@@ -230,7 +231,7 @@ export default Vue.extend({
console.log(resdata)
if (resdata.code === 0) {
that.regData = resdata.data.license;
if(that.regData.username!="" && that.regData.is_expiry == true){
if(that.regData.username!="" && that.regData.is_expiry == false){
that.isVip = true
}
}

View File

@@ -24,7 +24,7 @@
<t-row v-if="regData.username ==''">
<t-col :span="6">授权类型</t-col> <t-col :span="6">免费版</t-col>
<t-col :span="6">授权机器码</t-col> <t-col :span="6">{{ clientData.machine_id }}</t-col>
<t-col :span="6">授权数量</t-col> <t-col :span="6">3 <t-link theme="warning" underline> 需要升级请联系samwafgo@gmail.com我们进行商业授权 </t-link> </t-col>
<t-col :span="6">授权数量</t-col> <t-col :span="6">3 </t-col>
<t-col> <t-button variant="outline" @click="HandleImportLicense">
<cloud-upload-icon slot="icon" />
上传文件

View File

@@ -177,20 +177,14 @@ export default [
name: 'center',
component: Layout,
redirect: '/center',
meta: { title: '集中管理', icon: ServerIcon },
meta: { title: '设备管理', icon: ServerIcon },
children: [
{
path: 'CenterManager',
name: 'CenterManager',
component: () => import('@/pages/waf/center/index.vue'),
meta: { title: '设备列表' },
},
{
path: 'License',
name: 'License',
component: () => import('@/pages/waf/license/index.vue'),
meta: { title: '授权信息' },
},
}
],
},
];

4
vue/dist/index.html vendored
View File

@@ -6,8 +6,8 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>SamWaf网站防火墙系统Web Application Firewall</title>
<script type="module" crossorigin src="./assets/index.9cbec8d4.js"></script>
<link rel="stylesheet" href="./assets/style.5c316313.css">
<script type="module" crossorigin src="./assets/index.69a428cc.js"></script>
<link rel="stylesheet" href="./assets/style.7029ad6e.css">
</head>
<body>
<div id="app"></div>

View File

@@ -3,12 +3,9 @@ package wafreg
import (
"SamWaf/global"
"SamWaf/model"
"SamWaf/utils/zlog"
"SamWaf/wafsec"
"bytes"
"crypto/sha256"
"encoding/base64"
"encoding/binary"
"encoding/json"
"errors"
"fmt"
@@ -60,72 +57,17 @@ func GenClientMachineInfoWithEncrypt() (string, error) {
校验注册服务信息
*/
func VerifyServerReg(binData []byte) (success bool, info model.RegistrationInfo, err error) {
defer func() {
if err := recover(); err != nil {
zlog.Error("数据异常")
success = false
info = model.RegistrationInfo{}
err = errors.New("数据异常")
}
}()
//根据用户传来得数据信息
cryptoUtil := &wafsec.CryptoUtil{}
publicKey := []byte(global.GWAF_REG_PUBLIC_KEY)
// 假设读取当前机器的机器码
currentMachineInfo := GenClientMachineInfo()
buffer := bytes.NewBuffer(binData)
// 读取注册信息长度
var dataLen int32
err = binary.Read(buffer, binary.LittleEndian, &dataLen)
if err != nil {
return false, model.RegistrationInfo{}, errors.New("验签失败-读取注册信息长度失败")
}
// 读取注册信息
data := make([]byte, dataLen)
_, err = buffer.Read(data)
if err != nil {
return false, model.RegistrationInfo{}, errors.New("验签失败-读取注册信息失败")
}
// 读取签名长度
var sigLen int32
err = binary.Read(buffer, binary.LittleEndian, &sigLen)
if err != nil {
return false, model.RegistrationInfo{}, errors.New("验签失败-读取签名长度失败")
}
// 读取签名
signature := make([]byte, sigLen)
_, err = buffer.Read(signature)
if err != nil {
return false, model.RegistrationInfo{}, errors.New("验签失败-读取签名失败")
}
// 客户端验证签名
signWithSha256Result := cryptoUtil.RsaVerySignWithSha256(data, signature, publicKey)
if !signWithSha256Result {
return false, model.RegistrationInfo{}, errors.New("验签失败")
} else {
decrypt, err := wafsec.AesDecrypt(string(data), global.GWAF_REG_KEY)
data = decrypt
// 解析数据
var regInfo model.RegistrationInfo
err = json.Unmarshal(data, &regInfo)
if err != nil {
return false, model.RegistrationInfo{}, errors.New("验签成功-转换json失败")
}
// 验证机器码
if regInfo.MachineID != currentMachineInfo.MachineID {
return false, model.RegistrationInfo{}, errors.New("验签成功-机器码不正确")
} else {
return true, regInfo, nil
}
//社区信息处理
var regInfo = model.RegistrationInfo{
Version: "v1",
Username: "user",
MemberType: "社区版",
MachineID: "",
ExpiryDate: time.Now().AddDate(1, 0, 0),
IsExpiry: false,
}
return true, regInfo, nil
}
/*