📃
Anggi's Notes
  • Tentang Penulis
  • Preambule
  • Tutorial Red Team Area (General)
    • Tutorial Setup VirtualBox
    • Tutorial Setup Kali Linux pada VirtualBox
    • Network Adapter Type pada Virtual Box
    • Tutorial Port Forwarding Pada Virtual Box
    • Mempercepat update/upgrade/install Kali Linux
    • Networking in a Nutshell
    • Linux in A Nutshell
    • Linux Command Intro
    • VA-PT Cheatsheet
    • Penetration Testing Guide & Checklist
    • Pentesting Web checklist
    • NMAP Cheatsheet
    • Bind vs Reverse Shell Concept
    • Reverse Shell Cheatsheet
    • Linux TTY Shell Cheat Sheet
    • Menaikkan Common Shell ke Meterpreter
    • Metasploit Cheatsheet
      • msfvenom
      • searchploit
    • Metasploitable-2
    • Metasploitable-3
    • Linux Privilege Escalation
      • Linux Privilege Escalation with Misconfigured /etc/passwd
      • Linux Privilege Escalation with SUID
      • Linux Privilege Escalation with Misconfigured Sudo
      • Linux Privilege Escalation with MSF
    • DVWA
      • Brute Force
        • Low
        • Medium
        • High
      • Command Injection
        • Low
        • Medium
        • High
      • Local File Inclusion
        • Low
        • Medium
        • High
      • File Upload Vulnerability
        • Low
        • Medium
        • High
      • Cross Site Scripting (XSS)
        • Reflected
          • Low
          • Medium
          • High
        • Stored
          • Low
          • Medium
          • High
        • DOM
          • Low
          • Medium
          • High
      • SQL Injection
        • Non Blind
          • Low
          • Medium
          • High
        • Blind
          • Low
          • Medium
          • High
      • CSRF
        • Low
        • Medium
        • High
    • Pentesting Report Sample
    • Tutorial Penggunaan ZAP
    • Windows VA/Audit
      • DetExploit
      • HardeningKitty
      • Tutorial Installasi OWASP ZAP pada Windows OS
    • Linux VA/Audit dengan Lynis
    • Mobile Security Framework (MobSF) Windows Docker
  • Tutorial Red Team Area (Teknik Windows Attack )
    • Reconnaissance Techniques
    • Windows Red Team Exploitation Techniques
    • Windows Red Team Defense Evasion Techniques
  • Tutorial Blue Team Area
    • Merancang SOC
    • IR Playbook
    • Blue Team Opensource Online Tools
    • Wireshark Query Cheatsheet
  • Temuan Celah Keamanan
    • LFI (Directory Traversal) di redacted.co.id
    • Kredensial Database dan Azure Leaks pada redacted.com
    • HTML Injection di Tokopedia
    • 🤪4300$ Bounty from Opensource automate recon tools, why not?
    • I hacked Mastercard 4 times? But How?
    • LFI dan RCE di aset redacted.com
    • FTPd DOS di aset redacted.co.id
    • Gitlab SSRF di redacted.com
    • Firebase Android database Takeover
    • RCE di 11 Subdomain Dell
    • SSRF di redacted.com
    • Reflected XSS di CelticPipes
    • Git Disclosure di redacted.co.id
    • Open Redirection+XSS pada Private Program Bugcrowd
    • Rails Debug Mode Enabled pada redacted.com
Powered by GitBook
On this page
  • Mencari Informasi
  • Melakukan Serangan

Was this helpful?

  1. Tutorial Red Team Area (General)
  2. DVWA
  3. CSRF

Medium

CSRF level Medium on DVWA

PreviousLowNextHigh

Last updated 3 years ago

Was this helpful?

Di bawah ini adalah source-code dari CSRF level medium di DVWA.

vulnerabilities/csrf/source/medium.php<?php​if( isset( $_GET[ 'Change' ] ) ) {    // Checks to see where the request came from    if( stripos( $_SERVER[ 'HTTP_REFERER' ] ,$_SERVER[ 'SERVER_NAME' ]) !== false ) {        // Get input        $pass_new  = $_GET[ 'password_new' ];        $pass_conf = $_GET[ 'password_conf' ];​        // Do the passwords match?        if( $pass_new == $pass_conf ) {            // They do!            $pass_new = ((isset($GLOBALS["___mysqli_ston"]) && is_object($GLOBALS["___mysqli_ston"])) ? mysqli_real_escape_string($GLOBALS["___mysqli_ston"],  $pass_new ) : ((trigger_error("[MySQLConverterToo] Fix the mysql_escape_string() call! This code does not work.", E_USER_ERROR)) ? "" : ""));            $pass_new = md5( $pass_new );​            // Update the database            $insert = "UPDATE `users` SET password = '$pass_new' WHERE user = '" . dvwaCurrentUser() . "';";            $result = mysqli_query($GLOBALS["___mysqli_ston"],  $insert ) or die( '<pre>' . ((is_object($GLOBALS["___mysqli_ston"])) ? mysqli_error($GLOBALS["___mysqli_ston"]) : (($___mysqli_res = mysqli_connect_error()) ? $___mysqli_res : false)) . '</pre>' );​            // Feedback for the user            echo "<pre>Password Changed.</pre>";        }        else {            // Issue with passwords matching            echo "<pre>Passwords did not match.</pre>";        }    }    else {        // Didn't come from a trusted source        echo "<pre>That request didn't look correct.</pre>";    }​    ((is_null($___mysqli_res = mysqli_close($GLOBALS["___mysqli_ston"]))) ? false : $___mysqli_res);}​?> 

Mencari Informasi

​ berfungsi untuk mencari adanya substring dalam sebuah string (case-insensitive). Dalam kasus ini mungkin developer bermaksud ingin membuat semua request berasal dari website-nya. Terlihat bahwa di baris ke-5 terdapat validasi bahwa jika HTTP_REFERER mengandung kata dari SERVER_NAME maka akan bernilai true dan proses akan dilanjutkan.

Jika kita menggunakan cara sebelumnya, maka proses perubahan password akan gagal karena referer tidak mengandung kata dari server name/host.

Untuk mengatasi hal ini kita bisa saja merubah file index.html yang sebelumnya kita buat, dirubah menjadi nama host target (dalam kasus saya ini menjadi 172.17.0.2.html).

Melakukan Serangan

Seperti dari hasil recon, kita akan merubah nama file-nya menjadi host dari website target. Setelah itu, kita akan membuat victim mengakses mengakses website yang telah kita buat.

Setelah victim yang telah terautentikasi mengakses website tersebut, maka password akan berhasil diubah. Dan sekarang kita bisa menggunakan password baru yang telah ditentukan yaitu "pwned".

Happy Hacking! 🍻

stripos()