Jump to content

Text File Decode


Philips
 Share

Recommended Posts

hello to everyone JavaScript Code convert Autoit code ?

 

 

JavaScript Code

const 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

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 :)

Click here to see my signature:

Spoiler

ALWAYS GOOD TO READ:

 

Link to comment
Share on other sites

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

@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.

Link to comment
Share on other sites

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 by Earthshine

My resources are limited. You must ask the right questions

 

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...