-1

I'm trying to use jint to decode jsfuck, and am basing myself off this project: https://github.com/enkhee-Osiris/Decoder-JSFuck (it's the only one I've found that can decode the jsfuck correctly). The following c# isn't working correctly:

Jint.Engine engine = new Jint.Engine();
engine.SetValue("code", jsfuck_string);
string result = engine.Execute(@"function decode() {
return (/\n(.+)/.exec(eval(code.value.replace(/\s+/, "").slice(0, -2)))[1]);
}").GetValue("decode").ToString();

I'm getting the following exception: Line 2: Unexpected token ILLEGAL

j08691
  • 204,283
  • 31
  • 260
  • 272
user2950509
  • 1,018
  • 2
  • 14
  • 37

1 Answers1

0

It looks like you want to run the following JavaScript code in Jint:

function decode() {
    return (/\n(.+)/.exec(eval(code.value.replace(/\s+/, "").slice(0, -2)))[1]);
}

However, "" in a C# verbatim string (i.e. @"...") represents only a single " character. You're actually trying to run this JS code, which isn't valid as there is an unmatched " character:

function decode() {
    return (/\n(.+)/.exec(eval(code.value.replace(/\s+/, ").slice(0, -2)))[1]);
}

Try replacing the "" in replace(/\s+/, "") in your C# verbatim string with """", or ''.

Luke Woodward
  • 63,336
  • 16
  • 89
  • 104
  • I've taken your advice, and my C# now resembles this: `var result = engine.SetValue("code", data).Execute(@"(/\n(.+)/.exec(eval(code.value.replace(/\s+/, '').slice(0, -2)))[1])").GetCompletionValue();`, but now I'm just getting "Jint.Runtime.JavaScriptException" on the entire line :/ – user2950509 Apr 02 '17 at 16:07
  • @user2950509: I don't really know what's causing this. To make matters worse the exception message is rather helpfully empty. To get any further I think it would be necessary to debug into Jint... – Luke Woodward Apr 03 '17 at 19:13