-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjs-parse.js
1 lines (1 loc) · 3.59 KB
/
js-parse.js
1
javascript:(function(){let scope_input=prompt("list scopes in spaces. Ex: example.com github.com OR use a null/blank value for all domains",parse_fqdn()),scopes=scope_input.split(" "),scriptTags=document.getElementsByTagName("script"),urlBuffer="";const relRegex=/["'](\/[\w./\-_?=&]*)["%27]/g,abRegex=/(["%27])(https?:\/\/(?:www\.)?[^\s%27"]+?)\1/g,fileRegex=/\.(pdf|docx?|xlsx?|pptx?|js|css|jpg|jpeg|png|gif|bmp|svg|mp3|mp4|avi|mov|txt|csv|json|xml|zip|rar|7z|exe|woff2?|otf)$/i;function parse_external_files(){for(let e=0;e<scriptTags.length;e++){let t=scriptTags[e].src;for(let l of scopes){let n=`https?://${l}`;-1!=t.search(n)&&fetch_file(t).then(e=>{let l=Array.from(e.matchAll(relRegex),e=>e[1]),n=Array.from(e.matchAll(abRegex),e=>e[2]),a=new Set([...l,...n]),r=encodeURIComponent(t);document.write(""),setTimeout(()=>{let e=document.documentElement.outerHTML,t=new Blob([e],{type:"text/html"});document.write(`<a href="${URL.createObjectURL(t)}" download="${parse_fqdn()}.html">Download</a> <br>`);let l=document.createElement("a");e=document.documentElement.outerHTML,t=new Blob([e],{type:"text/html"}),l.href=URL.createObjectURL(t),l.target="_blank",l.click()},1e3),document.write(`<br><h3>${a.size} URLS FOUND IN: <span style="font-weight:100;">[ <a href="${t}">${t}</a> ]</span></h3>`),document.write(`<body><table id=${r} style="border: 1px solid black;width:70%;"></table></body>`);let i=document.getElementById(r),o=document.createElement("th");o.textContent="Endpoint",o.id=r+"/endpoint-th",o.style.border="1px solid black";let p=document.createElement("th");p.textContent="Extension",p.id=r+"/media-type-th",p.style.border="1px solid black";let d=document.createElement("th");d.textContent="Location",d.id=r+"/location-th";let c=document.createElement("tr");c.id=r+"/row1",c.appendChild(o),c.appendChild(p),i.appendChild(c),a.forEach(e=>{urlBuffer+=e;let t=document.createElement("tr"),l=document.createElement("td");l.textContent=e,l.style.border="1px solid black";let n=document.createElement("td");n.textContent=e.match(fileRegex),n.style.border="1px solid black",t.appendChild(l),t.appendChild(n),i.appendChild(t)}),document.write("<br>")}).catch(e=>{console.error("Error fetching script:",e)})}}}function parse_curr_page(){let e=document.documentElement.outerHTML,t=Array.from(e.matchAll(abRegex),e=>e[2]),l=Array.from(e.matchAll(relRegex),e=>e[1]),n=new Set([...t,...l]);parse_external_files(),document.write(`<br><h3>${n.size} URLS FOUND IN: <span style="font-weight:100;">[ <a href="${document.location}">${document.location}</a> ] [Inline/Main Page]</span></h3>`),document.write(%27<table id="mainpage" style="border: 1px solid black;width:70%;"></table>%27);let a=document.getElementById("mainpage"),r=document.createElement("th");r.textContent="Endpoint",r.id="mainpage/endpoint-th",r.style.border="1px solid black";let i=document.createElement("th");i.textContent="Extension",i.id="mainpage/media-type-th",i.style.border="1px solid black";let o=document.createElement("th");o.textContent="Location",o.id="mainpage/location-th";let p=document.createElement("tr");p.id="mainpage/row1",p.appendChild(r),p.appendChild(i),a.appendChild(p),n.forEach(e=>{console.log(e),urlBuffer+=e;let t=document.createElement("tr"),l=document.createElement("td");l.textContent=e,l.style.border="1px solid black";let n=document.createElement("td");n.textContent=e.match(fileRegex),n.style.border="1px solid black",t.appendChild(l),t.appendChild(n),a.appendChild(t)}),document.write("<br>")}async function fetch_file(e){let t=await fetch(e);return await t.text()}function parse_fqdn(){return(url_pieces=document.location.href.split("/"))[2]}parse_curr_page();})();