Vâng, bạn cũng có biến số module
trong node
. Vì vậy, bạn có thể yêu cầu vm
gói và chạy mã sử dụng phương pháp require
của nó:
var vm = module.require('vm');
vm.runInThisContext(' console.log("hello") ');
UPD Vâng, bạn cập nhật các câu hỏi, nhưng chúng ta có thể hack nó một lần nữa:
var vm = module.constructor.prototype.require('vm');
vm.runInThisContext(' console.log("hello") ');
UPD2 Một biến thể khác:
var vm = module.constructor._load('vm');
vm.runInThisContext(' console.log("hello") ');
.210
điều kiện UPD3 Một lần nữa được thay đổi để biến thể tiếp theo:
module.constructor.prototype._compile(' console.log("again hacked") ');
// or
module.__proto__._compile(' console.log("again hacked") ');
// or
Object.getPrototypeOf(module)._compile(' console.log("again hacked") ');
Tôi nghĩ tốt hơn để thiết lập module = undefined
để làm cho câu hỏi phức tạp hơn :)
UPD4 Có biến thể khác mà không module
:)
process.stdin.push(' console.log("here we are") \n ');
Nhưng nó hoạt động chỉ trong CLI ("repl")
UPD5 Cũng trong iojs
và trong node
với phiên bản> = 0.11.x bạn có thể sử dụng contextify
ràng buộc:
var contextify = process.binding('contextify');
var script = new contextify.ContextifyScript(' console.log("im here, buddy") ');
script.runInThisContext();
Trong node
với phiên bản < 0.11.x bạn có thể sử dụng evals
ràng buộc:
var evals = process.binding('evals');
var script = new evals.NodeScript(' console.log("here I am") ')
script.runInThisContext();
Bạn có thể gửi bài thành công hơn này trên một trang web mã hóa thử thách. – Barmar
Tôi cho rằng đây là biện pháp an ninh? trong trường hợp này, nó là một danh sách đen, như câu hỏi của bạn ngụ ý. – Timmerz
@Barmar Tôi nghĩ đây là một trang web thách thức mã hóa? – Timmerz