Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NodeJS cli: accept eval source #45

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions fuck.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
#!/usr/bin/env node

/// Usage: jsfuck inputfile.js [true|false] > outputfile.js
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks interesting! But can you please add some more information to the possible options?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this commit the possible options are just true or false to enable/disable eval source.

The > outputfile.js part is just stream redirection to ouput to file what the program is writing to standard output.

It's not all that different from your old version: I just check if the argv length is 4, and convert the argument to boolean (argv[2] === "true"), and pass that value to the JSFuck.encode function.

I needed this to create JSFucked files with the eval source option enabled.


var stream = require('stream');
var util = require('util');
var lib = require("./jsfuck.js");
var repl = require('repl');

if(process.argv.length !== 3) {
if(process.argv.length < 3 || process.argv.length > 4) {

function Stream() {
stream.Transform.call(this);
Expand All @@ -31,8 +33,13 @@ if(process.argv.length !== 3) {
});

process.stdin.pipe(fuckScript);
} else {
} else if (process.argv.length === 3) {
var data = require("fs").readFileSync(process.argv[2], "utf8");
var output = lib.JSFuck.encode(data, false);
console.log(output);
} else if (process.argv.length === 4) {
var bool = process.argv[3] === "true";
var data = require("fs").readFileSync(process.argv[2], "utf8");
var output = lib.JSFuck.encode(data, bool);
console.log(output);
}