-
Notifications
You must be signed in to change notification settings - Fork 0
/
rop.js
184 lines (154 loc) · 4.11 KB
/
rop.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
var rythm = null;
var roptext = null;
var started = false;
var gindex = 0;
var jiffies = 0;
var firstplay = true;
var BPM = 109;
var BPM_RATE = 60.0/BPM;
//var startTime = Math.round(BPM_RATE*40);
var startTime = 0;
var fontBump = { min: 2, max: 2.75 };
var errors = [
'pwn[1337]: segfault at 7f2a90cd0000 ip 00007f2a90cd0000',
'Segmentation fault (core dumped)',
'[ 5293.2444] Kernel panic - not syncing',
'Connection refused'
];
var landed = [
'[+] connectback from 107.161.28.10',
'[+] g0t r00t!',
'[+] replaced syscall handler',
'[+] KASLR slide: 0x4b000000',
];
var win = [
['$ cat flag', 'HCTF{sm00th_r0p3rat0r}'],
['# id', 'uid=0(root) gid=0(root) groups=0(root)'],
['# whoami', 'root'],
['# cat /etc/shadow', 'root:$1$u2kaj$RiBYa4UwjKViEjb1zjYUp/:16131:0:99999:7:::']
];
var gadgets_x86 = [
['mov rsp, [rbp+0x10]', 'ret'],
['pop rdi', 'pop rsi', 'pop rdx', 'ret'],
['xchg eax, esp', 'ret'],
['jmp rsp'],
['pop rbp', 'pop r12', 'ret'],
['add rcx, 8', 'jmp [rcx]']
];
var gadgets_arm = [
['stp x2, x3, [x0]', 'ret'],
['str x0, [x1, #0x1b8]','br x11'],
['ldp x29, x30, [sp], #0x10','ret'],
['strb w0, [x1, #0xa]','ret'],
['br x30'],
['ldr x21, [sp, #0x20]','ldp x29, x30, [sp], #0x30','ret']
];
var gadgets = Math.random() < 0.5 ? gadgets_arm : gadgets_x86;
var textsource = gadgets;
var scroller = null;
var audio = new Audio('roproprop_loop.mp3');
function setrop(t, frozen) {
if (frozen) {
fontBump.min = 1.5;
fontBump.max = 1.5;
if (Array.isArray(t)) {
roptext.style.textAlign = 'left';
}
} else {
fontBump.min = 2.0;
fontBump.max = 2.75;
roptext.style.textAlign = 'center';
}
if (Array.isArray(t)) {
roptext.innerHTML = t.join('<br\>');
} else {
roptext.innerHTML = t;
}
}
function gadgetcycle() {
jiffies = parseInt(Math.round(audio.currentTime / BPM_RATE));
console.log(jiffies);
// play dead
if (jiffies >= 46 && jiffies < 50) {
textsource = errors;
// pose
} else if (jiffies >= 54 && jiffies < 58) {
textsource = landed;
// she fine
} else if (jiffies >= 62 && jiffies < 66) {
textsource = win;
} else {
textsource = gadgets;
gindex = gindex + 1;
}
setrop(textsource[gindex % textsource.length], textsource !== gadgets);
var adjust = 0;
// sync hack
if (jiffies == 61) {
adjust = BPM_RATE*0.2;
}
// schedule the next update frame
scroller = setTimeout(function() {
gadgetcycle()
}, ((jiffies+1)*BPM_RATE - audio.currentTime - adjust)*1000);
//console.log(((jiffies+1)*BPM_RATE - audio.currentTime - adjust)*1000);
}
audio.addEventListener('ended', function() {
jiffies = 0;
gadgets = Math.random() < 0.5 ? gadgets_arm : gadgets_x86;
gindex = parseInt(Math.random()*gadgets.length);
console.log('Loop');
clearInterval(scroller);
this.currentTime = startTime;
// required to loop on safari
setTimeout(function() {
audio.pause()
audio.play()
gadgetcycle();
}, 10);
//this.pause();
//this.play();
}, false);
function toggle() {
// pause
if (started) {
audio.pause();
rythm.stop(true);
clearInterval(scroller);
started = false;
// play
} else {
audio.play();
if (firstplay)
audio.currentTime = startTime;
firstplay = false;
rythm.start();
gadgetcycle();
started = true;
}
}
function install() {
window.addEventListener("click", function(event) {
if (firstplay) {
rythm = new Rythm();
rythm.connectExternalAudioElement(audio);
audio.volume = 0.5;
//rythm.setMusic("roproprop_loop.mp3");
rythm.maxValueHistory = 20;
rythm.addRythm('color2', 'color', 100,10, {
from: [00,0,0],
to:[00,30,00]
});
rythm.addRythm('fontSize', 'fontSize', 10, 10, fontBump);
roptext = document.getElementById("rop-text");
gindex = parseInt(Math.random()*gadgets.length);
}
toggle();
});
window.addEventListener("keypress", function(event) {
if (event.keyCode == 13 || event.keyCode == 32) {
toggle();
}
});
}
window.onload = install;