-
-
Save ChiefORZ/4b08266cf78c333f8403dceb5b52f0e3 to your computer and use it in GitHub Desktop.
QLocker File Revery
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PASSWORD=<<YOUR 7 ZIP PASSWORD>> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const path = require('path'); | |
require('dotenv').config({ path: path.join(__dirname, '.env') }) | |
const { exec, spawn } = require('child_process'); | |
const fs = require('fs'); | |
const fsPromises = require('fs').promises; | |
const util = require('util'); | |
const chalk = require('chalk'); | |
const { extractFull } = require('node-7z'); | |
const glob = require('glob'); | |
const cliProgress = require('cli-progress'); | |
const dayjs = require('dayjs') | |
const logger = require('./logger'); | |
const mv = util.promisify(fs.rename); | |
const password = process.env.PASSWORD; | |
const progressBar = new cliProgress.SingleBar({}, cliProgress.Presets.shades_classic); | |
const convertArgsToMessage = (...args) => { | |
if (args.length > 1) { | |
return util.format(args[0], ...args); | |
} else { | |
return args[0]; | |
} | |
} | |
const consoleLog = (...args) => { | |
logger.info(convertArgsToMessage(args)); | |
// console.log(...args) | |
}; | |
const consoleError = (...args) => { | |
logger.error(convertArgsToMessage(args)); | |
// console.error(chalk.red(...args)) | |
}; | |
const consoleTitle = (...args) => { | |
logger.info(convertArgsToMessage(args)); | |
console.log(chalk.bgGreen.white(...args)); | |
} | |
const consoleStep = (...args) => { | |
logger.info(convertArgsToMessage(args)); | |
// console.log(chalk.bgBlue.white(...args)); | |
} | |
const consoleSub = (...args) => { | |
logger.info(convertArgsToMessage(args)); | |
// console.log(chalk.gray(...args)); | |
} | |
function execPromise(command, args, opts = {}, internalOpts = { ignoreError: false }) { | |
return new Promise(function(resolve, reject) { | |
consoleStep(command, args.join(' ')); | |
const child = spawn(command, args, opts); | |
const output = []; | |
child.stdout.on('data', (data) => { | |
data.toString().split('\n').forEach(line => output.push(line)) | |
consoleLog(data.toString()); | |
}); | |
child.stderr.on('data', (data) => { | |
consoleError('stderr: ' + data.toString()); | |
}); | |
child.on('close', (code) => { | |
if (!internalOpts.ignoreError && code !== 0) { | |
return reject() | |
} | |
return resolve(output); | |
}); | |
}); | |
} | |
function extractAsync(archivePath, outputPath, options = {}) { | |
return new Promise(function(resolve, reject) { | |
const myStream = extractFull(archivePath, outputPath, { | |
...options, | |
}) | |
const filesExtracted = []; | |
myStream.on('data', function (data) { | |
filesExtracted.push(data.file); | |
}) | |
myStream.on('end', function () { | |
resolve(filesExtracted); | |
}) | |
myStream.on('error', (err) => { | |
reject(err) | |
}) | |
}) | |
} | |
(async function exe() { | |
const zipFilesFound = await glob.sync('./**/*.7z'); | |
consoleTitle(`${zipFilesFound.length} zips to extract...`); | |
progressBar.start(zipFilesFound.length, 0); | |
for (let zipPath of zipFilesFound) { | |
const outputDir = path.join(path.dirname(zipPath), 'tmp'); | |
try { | |
const files = await extractAsync(zipPath, outputDir, { password }); | |
for (let file of files) { | |
await mv(path.join(outputDir, file), zipPath.replace('.7z', '')); | |
} | |
await fsPromises.rmdir(outputDir, { recursive: true }) | |
await fsPromises.unlink(zipPath) | |
progressBar.increment(); | |
consoleSub(`Extracting ${zipPath} done!`, { path: zipPath }); | |
} catch(err) { | |
consoleError(err, {path: zipPath}); | |
} | |
} | |
})() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const path = require('path'); | |
const winston = require('winston'); | |
require('winston-daily-rotate-file'); | |
const logger = winston.createLogger({ | |
format: winston.format.combine( | |
winston.format.timestamp({ | |
format: 'YYYY-MM-DD HH:mm:ss' | |
}), | |
winston.format.json(), | |
), | |
transports: [ | |
new winston.transports.DailyRotateFile({ | |
name: 'access-file', | |
level: 'info', | |
filename: path.resolve(`${__dirname}/logs/access-%DATE%.log`), | |
json: true, | |
datePattern: 'yyyy-MM-DD', | |
prepend: true, | |
}), | |
new winston.transports.DailyRotateFile({ | |
name: 'error-file', | |
level: 'error', | |
filename: path.resolve(`${__dirname}/logs/error-%DATE%.log`), | |
json: true, | |
datePattern: 'yyyy-MM-DD', | |
prepend: true, | |
}), | |
], | |
}); | |
module.exports = logger; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "recover-qlocker", | |
"version": "1.0.0", | |
"main": "index.js", | |
"license": "MIT", | |
"dependencies": { | |
"chalk": "^4.1.1", | |
"cli-progress": "^3.9.0", | |
"dayjs": "^1.10.4", | |
"dotenv": "^9.0.2", | |
"glob": "^7.1.7", | |
"node-7z": "^2.1.2", | |
"winston": "^3.3.3", | |
"winston-daily-rotate-file": "^4.5.5" | |
} | |
} |
Many Many thanks for your very fast answer.
But it is still not working.
I have the same issue as vladkatz above.
There is a progress bar, but nothing happens.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@vladkatz
it seems that 7-zip is not recognizing your password as a valid password...
have you entered your password into to .env file??