Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added some surrogates #12

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

KOLANICH
Copy link

No description provided.

"surrogate.oracle_downloads.sources": "!^https?://(?:www\\.)oracle\\.com/.+?/downloads/[^\\/]+?-downloads-.+$",
"surrogate.oracle_downloads.replacement" : "document.cookie = 'oraclelicense=accept-securebackup-cookie; domain=.oracle.com; path=/; expires=' +(new Date(Date.now() + 1800000)).toGMTString();",
"surrogate.microsoft_kb.sources" : "!https?://support\\.microsoft\\.com/(\\w{2}-\\w{2,3}/help|kb)/\\d+(/.+)?",
"surrogate.microsoft_kb.replacement" : "'use strict';let ce=document.createElement.bind(document);let r=/microsoft\\.support\\.prefetchedArticle\\s*=\\s*\\(\\s*function\\s*\\(\\s*\\)\\s*\\{\\s*return\\s+([^]+?)\\}\\)\\(\\);/m;let x=/'([a-z]{2}(?:-[a-z]{2})?\\/\\d+)'/g;let t;for(let w of document.getElementsByTagName('SCRIPT')){if(!w.src){let m=w.textContent.match(r);if(m){t=m[1].replace(x,'\"$1\"');break;}}}let j=JSON.parse(t),M=document.getElementById('mainContent');function A(a,b){a=new Date(a);var g=ce('time'),n=ce('p');n.textContent=b;g.a=a;g.textContent=a;n.appendChild(g);M.appendChild(n);}M.innerHTML='';for(let B in j){var d=j[B].details,h=ce('h1');document.head.title=h.textContent='KB'+d.id+' - '+d.heading;M.appendChild(h);A(d.createdOn,'created: ');A(d.publishedOn,'published: ');var s=ce('section');s.textContent=d.description;M.appendChild(s);for(var body of d.body){let S=ce('section'),J=ce('h3');J.textContent=body.title;S.appendChild(J);var P=ce('p');P.innerHTML=body.content;S.appendChild(P);M.appendChild(S)}var a=ce('a');a.textContent='Download JSON';a.download='KB'+d.id+'.json';a.href=URL.createObjectURL(new Blob([JSON.stringify(j,null,'\\t')],{type:'application/json'}));a.style.color='blue';M.appendChild(a);break;}",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this actually do? There's a lot of it for a simple surrogate.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

parses data encoded into a JS object (by carving them with regexp, fixing quotes to make a valid JSON and then using JSON.parse, no actual code execution involved) and renderes them. Also adds a link to download them as JSON.

"surrogate.goszakupki.sources" : "!https?://zakupki\\.gov\\.ru/.+",
"surrogate.goszakupki.replacement" : "'use strict';for(let el of document.querySelectorAll('[url]')){let a=document.createElement('A');a.href=el.getAttribute('url');let spn=el.getElementsByTagName('SPAN')[0];a.innerHTML=spn.innerHTML;a.className=spn.className;spn.replaceWith(a);}",
"surrogate.cloud_mail_ru.sources":"!^https://cloud\\.mail\\.ru/(stock|public)/.+$",
"surrogate.cloud_mail_ru.replacement":"'use strict';const rx=/require.config\((\{[^]+?\})\)/;const entRx=/\\x([\da-fA-F]+)/g;function getConfig(){let scripts=[...document.querySelectorAll('script:not([class]):not([src])')];let text=scripts.map((s)=>s.textContent.match(rx)).filter(j=>!!j)[0][1];text=text.replace(entRx,(...e)=>String.fromCodePoint(parseInt(e[1],16)));let config=JSON.parse(text);return config;}function getToken(){fetch('https://cloud.mail.ru/api/v2/tokens/download').then((res)=>{return res.json().then((res)=>{return new Promise(function(resolve,reject){let b=res['body'];if(b){let t=b['token'];if(t){console.log('token:',t);resolve(t);console.log('never called');}}console.error('No token present');reject('No token present: error code '+res['status']);});});}).then(token=>console.log(token));};const config=getConfig();const cls=config['config']['Cloud/settings'];const notifEl=document.querySelector('.b-page-content-loader__message-text_nojs');const stockBase=cls['dispatcher']['stock'][0]['url'];const weblinkBase=cls['dispatcher']['weblink_get'][0]['url'];var processMapping={'file':function(file,parentName){console.info(file);let fileName=file['name'];let id=file['id'];let url;if(file['dwl_token']){url=stockBase+'get/'+file['dwl_token']+'/'+encodeURIComponent(fileName);}else{url=cls['dispatcher']['weblink_get'][0]['url']+'/'+id+'/'+encodeURIComponent(fileName);}a=document.createElement('A');a.href=url;a.download=fileName;a.textContent=`${parentName}${fileName}(${file['size']}bytes,virus scan:${file['virus_scan']})`;return a;},'folder':function(folderObj,parentName){let cont=document.createElement('UL');for(var file of folderObj['list']){let child=processMapping[file['kind']](file,parentName+folderObj['id']);let it=document.createElement('LI');it.appendChild(child);cont.appendChild(it);}return cont;}};noti fEl.appendChild(processMapping['folder'](cls['folders']['folder'],''));",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this surrogate do?

Copy link
Author

@KOLANICH KOLANICH Nov 23, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renders files list from JS object.

@KOLANICH
Copy link
Author

@hackademix

Base automatically changed from master to main February 16, 2021 23:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants