Skip to content

Instantly share code, notes, and snippets.

@yohanes yohanes/jail1.js
Created Oct 26, 2014

Embed
What would you like to do?
Secuinside 2014
function (rand) {
function stage1() {
var a = Array.apply(null,
new Array(Math.floor(Math.random() * 20) + 10)).map(function () {return Math.random() * 0x10000;});
var b = rand(a.length);
if (!Array.isArray(b)) {
print("You're a cheater!");
return false;
}
if (b.length < a.length) {
print("hmm.. too short..");
for (var i = 0, n = a.length - b.length; i < n; i++) {
delete b[b.length];
b[b.length] = [Math.random() * 0x10000];
}
} else if (b.length > a.length) {
print("hmm.. too long..");
for (var i = 0, n = b.length - a.length; i < n; i++)
Array.prototype.pop.apply(b);
}
for (var i = 0, n = b.length; i < n; i++) {
if (a[i] != b[i]) {
print("ddang~~");
return false;
}
}
return true;
}
function stage2() {
var a = Array.apply(null, new Array((myRand() % 20) + 10)).map(function () {return myRand() % 0x10000;});
var b = rand(a.length);
if (!Array.isArray(b)) {
print("You're a cheater!");
return false;
}
if (b.length < a.length) {
print("hmm.. too short..");
for (var i = 0, n = a.length - b.length; i < n; i++) {
delete b[b.length];
b[b.length] = [Math.random() * 0x10000];
}
} else if (b.length > a.length) {
print("hmm.. too long..");
for (var i = 0, n = b.length - a.length; i < n; i++)
Array.prototype.pop.apply(b);
}
for (var i = 0, n = b.length; i < n; i++) {
if (a[i] != b[i]) {
print("ddang~~");
return false;
}
}
return true;
}
print("stage1");
if (!stage1())
return;
print("stage2");
if (!stage2())
return;
print("awesome!");
return flag;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.