Nome Utente: 
Password : 
Restringi sessione all'IP 
Online in 1gg
Domande  |  score: 2  |  4,84 5,97 6,02 |  Risolta da 3106 persone  |  906719 views  |  da 27 Nov 2010 - 23:51:34

Training: MySQL II (MySQL, Exploit, Training)

Bypass Autenticazione MySQL - Caso II
Questa sfida è uguale a MySQLI ma, questa volta, devi utilizzare un metodo di SQL Injection più elaborato per superare questa autenticazione.
La tua missione è semplice: effettua il login come admin.
Come sempre, ti viene dato il codice sorgente, anche come versione evidenziata.

Buon divertimento!
<?php
/* TABLE STRUCTURE
CREATE TABLE IF NOT EXISTS users (
userid    INT(11) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
username  VARCHAR(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
password  CHAR(32) CHARACTER SET ascii COLLATE ascii_bin NOT NULL
) ENGINE=myISAM;
*/

# Username and Password sent?
if ( ('' !== ($username = Common::getPostString('username'))) && (false !== ($password = Common::getPostString('password', false))) ) {
	auth2_onLogin($chall, $username, $password);
}

/**
 * Get the database for this challenge.
 * @return GDO_Database
 */
function auth2_db()
{
	if (false === ($db = gdo_db_instance(WCC_AUTH_BYPASS2_DBHOST, WCC_AUTH_BYPASS2_USER, WCC_AUTH_BYPASS2_PASS, WCC_AUTH_BYPASS2_DB))) {
		die('Database error 0815_2!');
	}
	$db->setLogging(false);
	$db->setEMailOnError(false);
	return $db;
}

/**
 * Exploit this! It is the same as MySQL-I, but with an additional check, marked with ###
 * @param WC_Challenge $chall
 * @param unknown_type $username
 * @param unknown_type $password
 * @return boolean
 */
function auth2_onLogin(WC_Challenge $chall, $username, $password)
{
	$db = auth2_db();
	
	$password = md5($password);
	
	$query = "SELECT * FROM users WHERE username='$username'";
	
	if (false === ($result = $db->queryFirst($query))) {
		echo GWF_HTML::error('Auth2', $chall->lang('err_unknown'), false);
		return false;
	}
	
	
	#############################
	### This is the new check ###
	if ($result['password'] !== $password) {
		echo GWF_HTML::error('Auth2', $chall->lang('err_password'), false);
		return false;
	} #  End of the new code  ###
	#############################
	
	
	echo GWF_HTML::message('Auth2', $chall->lang('msg_welcome_back', array(htmlspecialchars($result['username']))), false);
	
	if (strtolower($result['username']) === 'admin') {
		$chall->onChallengeSolved(GWF_Session::getUserID());
	}
	
	return true;
}
?>
<form action="index.php" method="post">
<table>
<tr>
	<td><?php echo $chall->lang('username'); ?>:</td>
	<td><input type="text" name="username" value="" /></td>
</tr>
<tr>
	<td><?php echo $chall->lang('password'); ?>:</td>
	<td><input type="password" name="password" value="" /></td>
</tr>
<tr>
	<td></td>
	<td><input type="submit" name="login" value="<?php echo $chall->lang('btn_login'); ?>" /></td>
</tr>
</table>
</form>
Nome utente:
Password :
© 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023, 2024, 2025 e 2026 by Gizmore

PHP Fatal Error(1): Constant E_STRICT is deprecated since 8.4, the error level was removed in www/protected/config.php line 6


Backtrace starts in [unknown file] line ?. GWF_Debug::shutdown_function() core/inc/util/GWF_Debug.php line 109. GWF_Debug::error_handler().... core/inc/util/GWF_Debug.php line 180.