-
Notifications
You must be signed in to change notification settings - Fork 1
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
Block access via automation like puppeteer #266
Comments
t2ym
added a commit
that referenced
this issue
May 19, 2018
t2ym
added a commit
that referenced
this issue
May 19, 2018
t2ym
added a commit
that referenced
this issue
May 20, 2018
t2ym
added a commit
that referenced
this issue
May 20, 2018
…d no-hook scripts before the first DomContentLoaded
t2ym
added a commit
that referenced
this issue
May 20, 2018
… -->" to load no-hook scripts before the first DomContentLoaded
t2ym
added a commit
that referenced
this issue
May 21, 2018
t2ym
added a commit
that referenced
this issue
May 21, 2018
t2ym
added a commit
that referenced
this issue
May 21, 2018
t2ym
added a commit
that referenced
this issue
May 21, 2018
t2ym
added a commit
that referenced
this issue
May 21, 2018
t2ym
added a commit
that referenced
this issue
May 21, 2018
t2ym
added a commit
that referenced
this issue
May 21, 2018
…l) to use globalObjectAccess.constructor property as a normal one
t2ym
added a commit
that referenced
this issue
May 22, 2018
t2ym
added a commit
that referenced
this issue
May 22, 2018
t2ym
added a commit
that referenced
this issue
May 22, 2018
Using Symbols for contexts to avoid disguised string contexts via puppeteer
Notes:
New helper function for Symbols$hook$.$ = function contextSymbolGenerator(symbolToContext, contexts) {
let result = [];
let contextToSymbol = {};
let hookGlobal = hook.global;
for (let i = 0; i < contexts.length; i++) {
symbolToContext[result[i] = _Symbol()] = contexts[i];
contextToSymbol[contexts[i]] = result[i];
hookGlobal[result[i]] = contextToSymbol;
}
return result;
} Example (
|
t2ym
added a commit
that referenced
this issue
May 25, 2018
t2ym
added a commit
that referenced
this issue
May 25, 2018
t2ym
added a commit
that referenced
this issue
May 25, 2018
t2ym
added a commit
that referenced
this issue
May 25, 2018
|
t2ym
added a commit
that referenced
this issue
May 28, 2018
…ook.eval('__hook__',...)('Object'), etc.
t2ym
added a commit
that referenced
this issue
Jun 17, 2018
…ects in hook.min.js and hook-callback.js for perfomrance optimization
t2ym
added a commit
that referenced
this issue
Aug 22, 2018
…position of onXX attribute for compact=false
t2ym
added a commit
that referenced
this issue
Aug 23, 2018
t2ym
added a commit
that referenced
this issue
Aug 23, 2018
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Block access via automation like puppeteer
Current Status
[email protected]
in stack branch merged to develop and master branchesnpm i [email protected]
ornpm i thin-hook
Update README.md for the next release
0.2.0
stack
branch<!-- end of mandatory no-hook scripts -->
const enableDebugging = false
inhook-callback.js
:true
to enable debuggingconst devToolsDisabled = true
indisable-devtools.js
:false
to enable debuggerconst wildcardWhitelist = []
inhook-callback.js
: for Chromenew Error().stack
formatnew RegExp('^at (.* [(])?' + origin + '/components/'), // trust the site contents including other components
new RegExp('^at ([^(]* [(])?' + 'https://cdnjs.cloudflare.com/ajax/libs/vis/4[.]18[.]1/vis[.]min[.]js'),
new RegExp('^at ([^(]* [(])?' + 'https://www.gstatic.com/charts/loader[.]js'),
const excludes = new Set() : { 'window.Math' }
undefined
for global objects unless they are in whitelistshook-native-api.js
deprecated and moved tohook-callback.js
Stack
class forcontextStack
instead ofArray
about:blank
for non-whitelisted global object accessconst URL = window.URL, RegExp = window.RegExp, ...
__hook__
arguments for global objects$hook$.$
context symbol generatorconst __context_mapper__
object__context_mapper__ = __ + hex(sha256(context + code)) + __
__hook__('op', ThisObject, ['prop'], __context_mapper__[1])
$hook$.global(__hook__, __context_mapper__[24], 'o', 'let')[__context_mapper__[25]]
__hook__[Symbol()]
-> contextcache-bundle.json
get-version
cache-bundle-automation-json
cacheBundleGeneration.js
cache-automation.js
https://thin-hook.localhost.localdomain/automation.json
cache-bundle.json
forcache-automation.js
serverSecret
- one-time build-time-only secret for validatingcache-automation.js
Proof of Concept Implementation
DomContentLoaded
event<!-- end of mandatory no-hook scripts -->
tooriginal-index.html
caches
is inaccessible at the firstdomcontentloaded
eventPage.frameStartedLoading
event, there should be HOPEFULLY no chances of inspecting the main document untildomcontentloaded
. It is not verified whether any events betweenPage.frameStartedLoading
anddomcontentloaded
are fired or not.window
object propertiesObject.prototype.constructor
(=== Object
)EventTarget.prototype
object properties such asaddEventListener
Object.prototype
object properties such as__lookupGetter__
__proto__
window
object propertiesundefined
for any global object accessundefined
for own native properties ofwindow
undefined
for own non-native properties ofwindow
undefined
for globals from no-hook APIshook
,$hook$
, etc.) properly__hook__
by using Symbols for contextshook.eval('__hook__',...)('script')
by usingSymbol.for('__hook__')
hook.utils.createHash
andhook.utils.HTMLParser
via automationabout:blank
transitioncaches
gulp cache-bundle
to fetch the bundle exclusively and securelycache-automation.js
to automate navigation for cache collectioncache-automation.js
and move cache operations tocache-bundle.js
cache-automation.js
performs only UI navigations for cache target UIsUpdate tests
$hook$.global(...)
in the expected hooked resultsAdd puppeteer tests to
cacheBundleGeneration.js
caches
this.__proto__.__proto__.__proto__.__proto__.constructor
(=== Object
)Polymer
__lookupGetter__
originally fromObject.prototype
addEventListener
originally fromEventTarget.prototype
this.__proto__.__proto__.__proto__.__proto__.__lookupGetter__
Math.__lookupGetter__
Math.abs.__lookupGetter__
__hook__('.', this, ['navigator'], 'context')
__hook__('.', this, ['navigator'], Symbol.for('context'))
hook.eval('__hook__')('Object')
hook.utils.createHash.sha256
Reduce Overheads
hook.min.js
thin-hook/lib/*.js
scriptst2ym/espree
t2ym/escodegen
acorn
hook-callback.js
$hook$.global()
Issues
event
is mistreated as a global object insetAttribute('onXX', 'event.target')
{ event: true }
is missing in the initial scope of hookingenableDebugging
flag inhook-callback.js
Object.$__proto__$
is unexpectedly defined by__hook__()
globalObjectAccess.constructor
unexpectedly points toObject
while it is expected as a normal property of theglobalObjectAccess
objectObject['/components/polymer/lib/mixins/property-accessors.html,script@741,props']
is unexpectedly defined by__hook__()
hook-native-api.js
hook-prefix=_uNpREdiC4aB1e_
compact=false
is not supported by context symbols]);
must be looked up instead of']);
hook.encodeHtml()
,</head></html>
is inserted at a wrong position before<!-- end of mandatory no-hook scripts -->
Notes
(automated withnpm run cache-bundle
fails as expected for nowcache-automation.js
)demo/cache-bundle.json
can be generated via?cache-bundle=save
option, but can be automated withcache-automation.js
The text was updated successfully, but these errors were encountered: