0

On NodeJS (12.10.0) I get an error if I try to eval some JSFuck:

const test = '(![]+[])[(((+!+([])))+[])]+([]+[][(![]+[])[((((!+([])+!(![])+(!![]))))+[])]+(+{}+[]+[]+{})[(((((((!+([])+!(![])+!(![])+!+([])))))))+[])]+(+{}+[]+!![]+[])[(((((((((!+[])+!(+[])+!!!(![])+!!!![])))))))+[])]+(!![]+[])[((((((+(![]))))))+[])]][([]+{})[(((((+!!!(![])))))+[])+(!(+[])+(!+[])+[])]+([]+{})[(((((((+!!([])))))))+[])]+([][[]]+[])[(((!+[]+!!!!([])+!+[]+!!([])+(!![])+!+([])))+[])]+(![]+[])[((((!+([])+!(![])+(!![]))))+[])]+([]+{})[(((((((+!!!(![])))))))+[])+(((((!+[])+!!!!([])+!!([]))))+[])]+(+{}+[]+!![]+[])[(((((((((!+[])+!(+[])+!!!(![])+!!!![])))))))+[])]+([][[]]+[])[(((((((+![]))))))+[])]+([]+{})[(((((+!!!(![])))))+[])+(!(+[])+(!+[])+[])]+(+{}+[]+!![]+[])[(((((!(+[])+!+[]+!+[]))))+[])]+(+{}+[]+[]+{})[(((((((!+([])+!(![])+!(![])+!+([])))))))+[])]+(+{}+[]+!![]+[])[(((((((((!+[])+!(+[])+!!!(![])+!!!![])))))))+[])]]((+{}+[]+!![]+[])[(((((((((!+[])+!(+[])+!!!(![])+!!!![])))))))+[])]+([]+{})[(+!(![])+[])+((((+!!!![])))+[])]+([]+{})[((((!(+[])+!+([])+!+([])+(!!!![])+!!!!([])+!+([]))))+[])]+([][[]]+[])[(((((((+![]))))))+[])]+(!![]+[])[(((+!(+[])))+[])]+(+((+!!(!![])+[])+(![]+[])[(!+([])+!(![])+(!+[])+!!!!([])+[])]+(((+(!+[])))+[])+(((((((+!!![])+(+!!![]))))))+[])+((((((+([]))))))+[])+(((+!!!([])))+[]))+[])[((((+(!+[]))))+[])]+([]+{})[((((((((!(+[])+!+([])+!(!!![])+!+[]+!!!!([])+!(+[])+(!+[]))))))))+[])]+(![]+[])[(((((((((!+[])+!(!!![]))))))))+[])]+([]+{})[(((((((+!!([])))))))+[])]+([]+{})[(((((+!!!(![])))))+[])+(!(+[])+(!+[])+[])]+(+{}+[])[((((((+!(!!![]))))))+[])]+(+{}+[]+!![]+[])[(((((!(+[])+!+[]+!+[]))))+[])]+(+((+!!(!![])+[])+(![]+[])[(!+([])+!(![])+(!+[])+!!!!([])+[])]+(((+(!+[])))+[])+(((((((+!!![])+(+!!![]))))))+[])+((((((+([]))))))+[])+(((+!!!([])))+[]))+[])[(!+[]+(!![])+!(![])+[])]+(+{}+[]+[]+{})[(((((((!+([])+!(![])+!(![])+!+([])))))))+[])]+([][[]]+[])[(((!+[]+!!!!([])+!+[]+!!([])+(!![])+!+([])))+[])])())[((((!(+[])+!!!!([])+!!(!![]))))+[])]+(+{}+[])[((((+(![]))))+[])]+(((((!+[])+!(!!![])+!+([]))))+[])';
eval(test); //ReferenceError: location is not defined

but on chrome 72 if I do the same thing in the console, I get apN3.

j08691
  • 204,283
  • 31
  • 260
  • 272
iflp
  • 1,742
  • 17
  • 25
  • 1
    If you do this `global.location = "somestring";` before your code, then it will not create an error in node.js. It is apparently relying on a global `location` property which is available in the browser and is not available in node.js by default. – jfriend00 Apr 12 '20 at 10:02
  • @Bergi - I don't have access to the human-readable source. – iflp Apr 13 '20 at 21:58

2 Answers2

1

No (at least not in a way significant for your problem).

Browsers provide a global location object object.

Node.js does not (because it isn't oriented around HTML documents).

Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335
1

The code simplifies to

"a"+(""+[]["sort"]["constructor"]("return location")())["3"]+"N3"

which does not work if there is no global location defined.

Bergi
  • 630,263
  • 148
  • 957
  • 1,375