Philips Posted October 23, 2018 Share Posted October 23, 2018 hello to everyone JavaScript Code convert Autoit code ? JavaScript Code expandcollapse popupconst fse = require('fs-extra'); module.exports = async function (file, out) { const fd = await fse.open(file, 'r'); while (true) { let num = Buffer.allocUnsafe(4); if ((await fse.read(fd, num, 0, 4)).bytesRead != 4) break; num = num.readInt32LE(0); if (num > 0x8000) { throw new Exception('String is too long to decompile: ' + num); } let data = Buffer.allocUnsafe(num); if ((await fse.read(fd, data, 0, num)).bytesRead != num) break; let v = 0x816; for (let i = 0; i < num; i++) { let a = data[i]; let z = (v & 0xff00) >>> 8; let b = (z ^ a) & 0xFF; v = (((((a + v) & 0xffff) * 0x6081) & 0xffff) + 0x1608) & 0xffff; data[i] = b; } if (out) { out(data); } else { process.stdout.write(data); } } await fse.close(fd); } Link to comment Share on other sites More sharing options...
FrancescoDiMuro Posted October 23, 2018 Share Posted October 23, 2018 Hi @Philips, and welcome to the AutoIt forum Maybe you missed the part Quote Usually asking for a script is not taken too well, within reason. Keep in mind that this is a support forum, so please acknowledge that. We are here to help you with your scripts, not to spoon-feed code to you. in the Forum Etiquette. By the way, start to take a look at File* and _File* functions in the Help file Philips 1 Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette Link to comment Share on other sites More sharing options...
Philips Posted October 23, 2018 Author Share Posted October 23, 2018 3 hours ago, FrancescoDiMuro said: Hi @Philips, and welcome to the AutoIt forum Maybe you missed the part in the Forum Etiquette. By the way, start to take a look at File* and _File* functions in the Help file not understand code : let z = (v & 0xff00) >>> 8; let b = (z ^ a) & 0xFF; v = (((((a + v) & 0xffff) * 0x6081) & 0xffff) + 0x1608) & 0xffff; Link to comment Share on other sites More sharing options...
Davidowicza Posted October 23, 2018 Share Posted October 23, 2018 @Philips, Saying "I don't understand this:" isn't much help. Do you just not understand how to read javascript, do you not know why that script does those 3 lines or you do not know how to convert those 3 lines? Because we wouldn't know either until you tell us what the purpose of the script is and what you expect from the outcome. Philips 1 Link to comment Share on other sites More sharing options...
Earthshine Posted October 23, 2018 Share Posted October 23, 2018 (edited) looks like some bit shifting to begin with... https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Bitwise_Operators you got a lot to learn to understand that one kid... lol One of my bosses loves bitmasking... lol, like we are in the old school days and don't have enough ram, you can load a boatload of flags into an integer... ahhh the old C days.... they use an integer (in binary) to store a bunch of flags for later use and use bit-masking to reveal what they want. this does save big on ram usage instead of one variable per flag... that's why we used to use it so much in the olden days... LOL Edited October 23, 2018 by Earthshine Philips 1 My resources are limited. You must ask the right questions Link to comment Share on other sites More sharing options...
Earthshine Posted October 23, 2018 Share Posted October 23, 2018 (edited) so anyway, they are filling a buffer with some data from a file they read, and then scanning it--looks like output goes to file or console, for what I don't know Edited October 23, 2018 by Earthshine Philips 1 My resources are limited. You must ask the right questions Link to comment Share on other sites More sharing options...
Earthshine Posted October 23, 2018 Share Posted October 23, 2018 (edited) https://www.autoitscript.com/autoit3/docs/functions/BitShift.htm AutoIt has Bitshift and all the Bit functions you need, you might be able to code this Edited October 23, 2018 by Earthshine Philips 1 My resources are limited. You must ask the right questions Link to comment Share on other sites More sharing options...
Danp2 Posted October 23, 2018 Share Posted October 23, 2018 Maybe it would help if you told us more about this javascript routine, such as -- Where did it come from? What type of encryption is involved? Etc Philips 1 Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now