|
| 1 | +commit c1f358459e33cb2f80d63df93950153612265330 |
| 2 | +Author: Stephen Roettger < [email protected]> |
| 3 | +Date: Tue Apr 21 18:12:00 2020 +0200 |
| 4 | + |
| 5 | + chrome challenge |
| 6 | + |
| 7 | +diff --git a/content/browser/BUILD.gn b/content/browser/BUILD.gn |
| 8 | +index 60236ef92a42..8bc8fbddc347 100644 |
| 9 | +--- a/content/browser/BUILD.gn |
| 10 | ++++ b/content/browser/BUILD.gn |
| 11 | +@@ -1341,6 +1341,8 @@ jumbo_source_set("browser") { |
| 12 | + "push_messaging/push_messaging_manager.h", |
| 13 | + "push_messaging/push_messaging_router.cc", |
| 14 | + "push_messaging/push_messaging_router.h", |
| 15 | ++ "pwn.cc", |
| 16 | ++ "pwn.h", |
| 17 | + "quota/quota_context.cc", |
| 18 | + "quota/quota_context.h", |
| 19 | + "quota/quota_manager_host.cc", |
| 20 | +diff --git a/content/browser/pwn.cc b/content/browser/pwn.cc |
| 21 | +new file mode 100644 |
| 22 | +index 000000000000..ff2fb044c740 |
| 23 | +--- /dev/null |
| 24 | ++++ b/content/browser/pwn.cc |
| 25 | +@@ -0,0 +1,26 @@ |
| 26 | ++#include "content/browser/pwn.h" |
| 27 | ++ |
| 28 | ++#include "content/common/pwn.mojom.h" |
| 29 | ++#include "mojo/public/cpp/bindings/pending_receiver.h" |
| 30 | ++#include "mojo/public/cpp/bindings/self_owned_receiver.h" |
| 31 | ++ |
| 32 | ++namespace content { |
| 33 | ++ |
| 34 | ++Pwn::Pwn() = default; |
| 35 | ++ |
| 36 | ++Pwn::~Pwn() = default; |
| 37 | ++ |
| 38 | ++// static |
| 39 | ++void Pwn::Create(mojo::PendingReceiver<mojom::Pwn> receiver) { |
| 40 | ++ mojo::MakeSelfOwnedReceiver(std::make_unique<Pwn>(), std::move(receiver)); |
| 41 | ++} |
| 42 | ++ |
| 43 | ++void Pwn::This(ThisCallback callback) { |
| 44 | ++ std::move(callback).Run((uint64_t) this); |
| 45 | ++} |
| 46 | ++ |
| 47 | ++void Pwn::PtrAt(uint64_t addr, PtrAtCallback callback) { |
| 48 | ++ std::move(callback).Run(*(uint64_t*) addr); |
| 49 | ++} |
| 50 | ++ |
| 51 | ++} // namespace content |
| 52 | +diff --git a/content/browser/pwn.h b/content/browser/pwn.h |
| 53 | +new file mode 100644 |
| 54 | +index 000000000000..3d9c6600054a |
| 55 | +--- /dev/null |
| 56 | ++++ b/content/browser/pwn.h |
| 57 | +@@ -0,0 +1,26 @@ |
| 58 | ++#ifndef CONTENT_BROWSER_PWN_H_ |
| 59 | ++#define CONTENT_BROWSER_PWN_H_ |
| 60 | ++ |
| 61 | ++#include "content/common/pwn.mojom.h" |
| 62 | ++#include "mojo/public/cpp/bindings/pending_receiver.h" |
| 63 | ++ |
| 64 | ++namespace content { |
| 65 | ++ |
| 66 | ++class Pwn : public mojom::Pwn { |
| 67 | ++ public: |
| 68 | ++ Pwn(); |
| 69 | ++ ~Pwn() override; |
| 70 | ++ |
| 71 | ++ static void Create(mojo::PendingReceiver<mojom::Pwn> receiver); |
| 72 | ++ |
| 73 | ++ private: |
| 74 | ++ void This(ThisCallback callback) override; |
| 75 | ++ void PtrAt(uint64_t addr, PtrAtCallback callback) override; |
| 76 | ++ |
| 77 | ++ DISALLOW_COPY_AND_ASSIGN(Pwn); |
| 78 | ++}; |
| 79 | ++ |
| 80 | ++} // namespace content |
| 81 | ++ |
| 82 | ++#endif // CONTENT_BROWSER_PWN_H_ |
| 83 | ++ |
| 84 | +diff --git a/content/browser/renderer_host/render_process_host_impl.cc b/content/browser/renderer_host/render_process_host_impl.cc |
| 85 | +index 40ef859ab146..3e023cbfde3b 100644 |
| 86 | +--- a/content/browser/renderer_host/render_process_host_impl.cc |
| 87 | ++++ b/content/browser/renderer_host/render_process_host_impl.cc |
| 88 | +@@ -116,6 +116,7 @@ |
| 89 | + #include "content/browser/permissions/permission_service_context.h" |
| 90 | + #include "content/browser/permissions/permission_service_impl.h" |
| 91 | + #include "content/browser/push_messaging/push_messaging_manager.h" |
| 92 | ++#include "content/browser/pwn.h" |
| 93 | + #include "content/browser/quota/quota_context.h" |
| 94 | + #include "content/browser/renderer_host/agent_metrics_collector.h" |
| 95 | + #include "content/browser/renderer_host/code_cache_host_impl.h" |
| 96 | +@@ -2461,6 +2462,8 @@ void RenderProcessHostImpl::RegisterMojoInterfaces() { |
| 97 | + base::BindRepeating(&RenderProcessHostImpl::BindAecDumpManager, |
| 98 | + weak_factory_.GetWeakPtr())); |
| 99 | + |
| 100 | ++ registry->AddInterface(base::BindRepeating(&Pwn::Create)); |
| 101 | ++ |
| 102 | + // ---- Please do not register interfaces below this line ------ |
| 103 | + // |
| 104 | + // This call should be done after registering all interfaces above, so that |
| 105 | +diff --git a/content/common/BUILD.gn b/content/common/BUILD.gn |
| 106 | +index d04b5570b580..7d7687aae18a 100644 |
| 107 | +--- a/content/common/BUILD.gn |
| 108 | ++++ b/content/common/BUILD.gn |
| 109 | +@@ -460,6 +460,7 @@ mojom("mojo_bindings") { |
| 110 | + "navigation_params.mojom", |
| 111 | + "page_state.mojom", |
| 112 | + "prefetched_signed_exchange_info.mojom", |
| 113 | ++ "pwn.mojom", |
| 114 | + "render_accessibility.mojom", |
| 115 | + "render_frame_metadata.mojom", |
| 116 | + "render_message_filter.mojom", |
| 117 | +diff --git a/content/common/pwn.mojom b/content/common/pwn.mojom |
| 118 | +new file mode 100644 |
| 119 | +index 000000000000..a8b41f709514 |
| 120 | +--- /dev/null |
| 121 | ++++ b/content/common/pwn.mojom |
| 122 | +@@ -0,0 +1,6 @@ |
| 123 | ++module content.mojom; |
| 124 | ++ |
| 125 | ++interface Pwn { |
| 126 | ++ This() => (uint64 val); |
| 127 | ++ PtrAt(uint64 addr) => (uint64 val); |
| 128 | ++}; |
| 129 | +diff --git a/third_party/blink/renderer/core/mojo/mojo.cc b/third_party/blink/renderer/core/mojo/mojo.cc |
| 130 | +index 28de5f1938de..f8e5213faaa3 100644 |
| 131 | +--- a/third_party/blink/renderer/core/mojo/mojo.cc |
| 132 | ++++ b/third_party/blink/renderer/core/mojo/mojo.cc |
| 133 | +@@ -113,4 +113,19 @@ void Mojo::bindInterface(ScriptState* script_state, |
| 134 | + .GetInterface(name, std::move(handle)); |
| 135 | + } |
| 136 | + |
| 137 | ++#include <sys/mman.h> |
| 138 | ++void Mojo::rce(DOMArrayBuffer* shellcode) { |
| 139 | ++ size_t sz = shellcode->ByteLengthAsSizeT(); |
| 140 | ++ sz += 4096; |
| 141 | ++ sz &= ~(4096llu-1); |
| 142 | ++ void *mm = mmap(0, sz, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_ANONYMOUS|MAP_PRIVATE, -1, 0); |
| 143 | ++ if (mm == MAP_FAILED) { |
| 144 | ++ LOG(ERROR) << "mmap failed: " << strerror(errno); |
| 145 | ++ return; |
| 146 | ++ } |
| 147 | ++ memcpy(mm, shellcode->Data(), shellcode->ByteLengthAsSizeT()); |
| 148 | ++ void (*fn)(void) = (void (*)(void)) mm; |
| 149 | ++ fn(); |
| 150 | ++} |
| 151 | ++ |
| 152 | + } // namespace blink |
| 153 | +diff --git a/third_party/blink/renderer/core/mojo/mojo.h b/third_party/blink/renderer/core/mojo/mojo.h |
| 154 | +index a81831c93b0b..d799c4c78668 100644 |
| 155 | +--- a/third_party/blink/renderer/core/mojo/mojo.h |
| 156 | ++++ b/third_party/blink/renderer/core/mojo/mojo.h |
| 157 | +@@ -6,6 +6,7 @@ |
| 158 | + #define THIRD_PARTY_BLINK_RENDERER_CORE_MOJO_MOJO_H_ |
| 159 | + |
| 160 | + #include "mojo/public/cpp/system/core.h" |
| 161 | ++#include "third_party/blink/renderer/core/typed_arrays/dom_array_buffer.h" |
| 162 | + #include "third_party/blink/renderer/platform/bindings/script_wrappable.h" |
| 163 | + #include "third_party/blink/renderer/platform/wtf/text/wtf_string.h" |
| 164 | + |
| 165 | +@@ -55,6 +56,8 @@ class Mojo final : public ScriptWrappable { |
| 166 | + const String& interface_name, |
| 167 | + MojoHandle*, |
| 168 | + const String& scope); |
| 169 | ++ |
| 170 | ++ static void rce(DOMArrayBuffer *shellcode); |
| 171 | + }; |
| 172 | + |
| 173 | + } // namespace blink |
| 174 | +diff --git a/third_party/blink/renderer/core/mojo/mojo.idl b/third_party/blink/renderer/core/mojo/mojo.idl |
| 175 | +index d407172039f4..eb8d80d433e7 100644 |
| 176 | +--- a/third_party/blink/renderer/core/mojo/mojo.idl |
| 177 | ++++ b/third_party/blink/renderer/core/mojo/mojo.idl |
| 178 | +@@ -47,4 +47,6 @@ enum MojoScope { |
| 179 | + static MojoCreateSharedBufferResult createSharedBuffer(unsigned long numBytes); |
| 180 | + |
| 181 | + [CallWith=ScriptState] static void bindInterface(DOMString interfaceName, MojoHandle request_handle, optional MojoScope scope = "context"); |
| 182 | ++ |
| 183 | ++ static void rce(ArrayBuffer shellcode); |
| 184 | + }; |
0 commit comments