niwajiang 发表于 2023-10-30 16:36

LunaModeler

> LunaModeler是一款使用 Electron 开发的数据建模软件,这是一款收费软件,只有14天试用期。
> 发现了[这篇文章](https://www.52pojie.cn/thread-1468258-1-1.html),但是我使用没有生效。于是还是自己动手吧。

> 关于使用Electron开发的软件操作方法可以参考这里[**修改 NoSQLBooster for MongoDB 试用时间**](https://www.52pojie.cn/thread-1758253-1-1.html)
>
> 源码已经摆出来了



## 思路

- 根据产品确认生成激活文件的位置。

- 随机生成一个合适的时间

- 写激活文件

- 调用执行

- ```bash
    node index.js luna
    ```



## 实现

```js
const crypto = require('crypto');
const moment = require('moment');
const fs = require('fs');

const encryption_key = 'BUA9VFNtbRQM85BODcCbXlrUtXXH3D3x';
const initialization_vector = '665UHDQ5qdBnI777';

function encrypt(text) {
const cipher = crypto.createCipheriv('aes-256-cbc', Buffer.from(encryption_key), Buffer.from(initialization_vector));
let crypted = cipher.update(text, 'utf8', 'hex');
crypted += cipher.final('hex');
return crypted;
}

function saveLicense(content, path) {
const fileName = `${path}dts.asar.sys`;
const encryptedContent = encrypt(JSON.stringify(content));
fs.writeFileSync(fileName, encryptedContent);
}

// Get product name from argument
const productName = process.argv;
let pathName;

switch (productName) {
case 'luna':
    pathName = 'LunaModeler';
    break;
case 'meteor':
    pathName = 'MeteorModeler';
    break;
case 'perseid':
    pathName = 'PerseidModeler';
    break;
case 'galaxy':
    pathName = 'GalaxyModeler';
    break;
case 'moon':
    pathName = 'MoonModeler';
    break;
default:
    console.log('Invalid product name:');
    console.log('Usage: node index.js <product_name>');
    console.log('Where <product_name> is one of: luna, meteor, perseid, galaxy, moon');
    process.exit(1);
    break;
}

let licPath = '';
let username;
if (process.platform === 'win32') {
// Path of app userData
username = process.env.USERNAME;
licPath = `C:\\Users\\${username}\\AppData\\Roaming\\`;
} else if (process.platform === 'darwin') {
// Path of app userData
username = process.env.USER;
licPath = `/Users/${username}/Library/Application Support/`;
} else if (process.platform === 'linux') {
// Path of app userData
username = process.env.USER;
licPath = `/home/${username}/.config/`;
} else {
console.log('Unsupported platform');
process.exit(1);
}

licPath += `${pathName}/`;

const fileName = `${licPath}dt.asar.sys`;
const expires = moment().add(60, 'years').unix();
fs.writeFileSync(fileName, `${expires.toString()}963`);

const stamp = new Date();

const randomKey = `${crypto.randomBytes(4).toString('hex')}-${crypto.randomBytes(4).toString('hex')}-${crypto.randomBytes(4).toString('hex')}-${crypto
.randomBytes(4)
.toString('hex')}`;
const randomMail = `${crypto.randomBytes(10).toString('hex')}@${crypto.randomBytes(10).toString('hex')}.com`;

/**
* Returns a random number between min (inclusive) and max (exclusive)
*/
function getRandomArbitrary(min, max) {
return Math.random() * (max - min) + min;
}

const licData = {
licType: 'commercial',
key: randomKey,
purchase: {
    seller_id: 'Datensen',
    short_product_id: 'abc',
    product_name: productName,
    email: randomMail,
},
created: moment(stamp).subtract(1, 'days').unix(),
uses: getRandomArbitrary(99999, 999999),
};

saveLicense(licData, licPath);
console.log('ok');
process.exit(0);

```

小龙虾辣菊花 发表于 2023-10-30 16:55

可以可以

今朝有酒须纵歌 发表于 2023-10-30 17:10

学习了!!!!!

hyc12 发表于 2023-10-30 17:16

可以。。

luoyueqing 发表于 2023-10-30 19:52

学习了!

co2qy 发表于 2023-11-1 10:43

学习了!

ouzhenwei 发表于 2023-11-1 22:05

学习学习!
页: [1]
查看完整版本: LunaModeler