Skip to content

Commit 056ac25

Browse files
committed
added keys-to-kingdom
1 parent f7426b8 commit 056ac25

File tree

5 files changed

+514
-0
lines changed

5 files changed

+514
-0
lines changed

keys-to-kingdom/index.html

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
<head>
2+
<link rel=stylesheet type=text/css href=http://nicolasgallagher.com/pure-css-speech-bubbles/demo/default.css >
3+
<style>
4+
p {text-align: center}
5+
</style>
6+
<script>
7+
window.onmessage = function(e) {
8+
if (!e) e = this.event;
9+
var k = e.data;
10+
document.getElementById('key').innerHTML = k;
11+
}
12+
13+
function crack(f) {
14+
document.getElementById('f').contentWindow.postMessage(f.elements['tryme'].value, '*');
15+
f.elements['tryme'].value = '';
16+
return false;
17+
}
18+
19+
</script>
20+
</head>
21+
<body>
22+
<div style="width: 700px; margin: 0 auto">
23+
<h1>Keys to a kingdom!</h1>
24+
<p>A quick fun sidechannel, posssibly crypto challenge by <a href="http://blog.kotowicz.net">Krzysztof Kotowicz</a></p>
25+
<h2>Rules</h2>
26+
<ol>
27+
<li>Remote kingdom posesses a secret. Every 2 seconds its king gives you a new key to crack
28+
<li>If you can crack the key, enter the solution in the input field below and press the magical ENTER key
29+
<li>Beware! Solutions expire, so you have only about 100 seconds to crack any key on average!
30+
<li>Once in a while, you'll be getting expired solutions as a hint.
31+
<li><strong>Make the kingdom display you the generated secret</strong>
32+
<li>Modern browsers only or respect the iframe sandbox rules (i.e. no direct access to remote.html DOM)
33+
<li>You can copy the challenge to automate tasks, but no tampering with kingdom.html
34+
<li>There's more than one way to skin a cat, so Think OUTB.
35+
</ol>
36+
<div style="text-align: center">
37+
<h1>Newest key to crack:</h1>
38+
<p id=key>&nbsp;</p>
39+
</div>
40+
<img src="knight.png" style="float: right;">
41+
42+
<form style="margin: 0 200px; text-align: right" class="triangle-border right" onsubmit="return crack(this)" action=#>
43+
44+
<input id=tryme placeholder="Your solution is..." size=32 maxlength=32>
45+
</form>
46+
<iframe id=f sandbox=allow-scripts seamless style="width:700px; border: none; height: 400px;"></iframe>
47+
<script>
48+
var f = document.getElementById('f');
49+
f.onload = function() {
50+
window.frames[0].postMessage(null, '*');
51+
}
52+
f.src = 'kingdom.html';
53+
54+
</script>
55+
<p>
56+
<small>
57+
Used <a href="http://www.iconspedia.com/pack/desktop-boss-2-icons-3659/">http://www.iconspedia.com/pack/desktop-boss-2-icons-3659/</a>,
58+
<a href=http://icones.pro/en/knight-png-image.html>http://icones.pro/en/knight-png-image.html</a>,
59+
<a href="http://nicolasgallagher.com/pure-css-speech-bubbles/demo/">http://nicolasgallagher.com/pure-css-speech-bubbles/demo/</a> and <a href="http://pajhome.org.uk/crypt/md5">http://pajhome.org.uk/crypt/md5</a>.
60+
61+
<h1>Hall of fame</h1>
62+
<p>awaits you!
63+
</div>
64+
</body>

keys-to-kingdom/king.png

32.7 KB
Loading

keys-to-kingdom/kingdom.html

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
<head>
2+
<title>Remote kingdom says...</title>
3+
<link rel=stylesheet type=text/css href=http://nicolasgallagher.com/pure-css-speech-bubbles/demo/default.css >
4+
<style>
5+
#container {width: 670px;}
6+
</style>
7+
<script src=md5.js></script>
8+
<script>
9+
var secret;
10+
(function() {
11+
var kingdom = {};
12+
var knight;
13+
var age = 40 + (Math.random() * 60);
14+
// a secret is A SECRET - no peeking here!
15+
secret = "age(princess) > " + Math.ceil(Math.ceil(365*age) * 24 * 60) + " min";
16+
17+
window.onmessage = function(e) {
18+
if (!e) e = this.event;
19+
var k = e.data;
20+
21+
if (!knight) {
22+
knight = e.source;
23+
return;
24+
}
25+
26+
if (kingdom[k]) {
27+
document.getElementById('msg').innerHTML =
28+
"Congratulations! You cracked <strong>" + kingdom[k]
29+
+ "</strong> with <strong>" + encodeURIComponent(k) + "</strong><br>Secret:<br>\n" + secret + '\"<br>'
30+
+ "Submit the solution to kkotowicz (on gmail) AND SPECIFY HOW YOU FOUND IT." ;
31+
} else {
32+
document.getElementById('msg').innerHTML = "\"" + encodeURIComponent(k) + "\" is not right :/";
33+
}
34+
}
35+
36+
var keyNo = 0;
37+
38+
setInterval(function() {
39+
var msg = "THIS_IS_KEY_NUMBER_" + (++keyNo);
40+
//var hash = (new jsSHA(secret + msg , 'TEXT')).getHash("SHA-512", "HEX").substring(0,32);
41+
var hash = hex_md5(secret + msg);
42+
kingdom[hash] = msg;
43+
// keep number of keys low
44+
if ((keyNo % 2 == 0) || keyNo > 50) {
45+
// expire keys
46+
for(var i in kingdom) {
47+
if ((Math.random() * 2) > 1) { // display hint
48+
var old = document.getElementById('old');
49+
old.style.opacity = 1;
50+
old.innerHTML = ('"' +i + "\" used to work...");
51+
}
52+
delete kingdom[i];
53+
break;
54+
}
55+
}
56+
knight.postMessage(msg, '*');
57+
}, 2000);
58+
})();
59+
</script>
60+
</head>
61+
<body>
62+
<div id=container>
63+
<img src="king.png" style="float: left; width: 256px;">
64+
<div class="triangle-border left" style="margin-left: 200px">
65+
<p id=msg ><strong>Greetings! Please type you solution to one of given keys above. Half of the kingdom and the princess awaits
66+
you!</strong></p>
67+
</div>
68+
<div class="triangle-isosceles left" style="margin-left: 250px; opacity: 0" id=old></div>
69+
</div>
70+
71+
</body>

keys-to-kingdom/knight.png

16.8 KB
Loading

0 commit comments

Comments
 (0)