LunaModeler是一款使用 Electron 开发的数据建模软件,这是一款收费软件,只有14天试用期。
发现了这篇文章,但是我使用没有生效。于是还是自己动手吧。
关于使用Electron开发的软件操作方法可以参考这里修改 NoSQLBooster for MongoDB 试用时间
源码已经摆出来了
思路
-
根据产品确认生成激活文件的位置。
-
随机生成一个合适的时间
-
写激活文件
-
调用执行
实现
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[2];
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);
|