phpinfo跨站脚本漏洞
漏洞说明: php是一款被广泛使用的编程语言,可以被嵌套在html里用做web程序开发。phpinfo()是用来显示当前php环境的一个函数,许多站点和程序都会将phpinfo放在自己的站点上或者在程序里显示,但是phpinfo里存在一些安全问题,导致精心构造数据就可以产生一个跨站脚本漏洞,可以被用来进行攻击。
漏洞成因: phpinfo页面对输入的参数都做了详细的过滤,但是没有对输出的进行charset的指定,而在一些浏览器里如IE7里,你可以让它自动选择编码或者通过一个iframe页面给它指定编码,这样就可以饶过phpinfo的过滤而产生一个跨站脚本漏洞。
漏洞来源: http://www.80sec.com/release/phpinfo-xss.txt
漏洞利用: 利用代码如下:
<head>
<META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=UTF-7">
</head>
<body >
<iframe src="http://www.80sec.com/phpinfo.php?+ADw-SCRIPT+AD4-alert(document.domain);+ADw-/SCRIPT+AD4-=1">
以上代码在IE7+php 5.2.6测试成功。phpinfo页面的xss甚至比其他页面更加危险,因为如果有phpinfo的存在,恶意攻击者可以利用phpinfo的输出bypass如httponly和一些基础认证。
漏洞影响: 影响所有版本的php和浏览器IE7
漏洞修补: 建议暂时删除站点的phpinfo页面避免被人利用。
本站内容均为原创,转载请务必保留署名与链接!
phpinfo跨站脚本漏洞:http://www.80sec.com/phpinfo-xss.html
中国万网2008免费空间
在2008年北京奥运即将来临之际,作为中国最大的互联网基础服务提供商,为助力广大中小企业网上奥运,中国万网继十年前推出“万网计划”后,再次倾情推出“新”万网计划,暨“中国万网2008免费计划”,此次活动主题为“迎奥运,赢万网”。 本次活动通过提供免费的虚拟主机空间、免费域名和相关的系列优惠产品,旨在更加深入的普及互联网应用,帮助更多的中国中小企业抓住奥运契机和科技奥运的大趋势,体验和实践互联网的梦想,融入电子商务潮流,最终通过信息化提升企业的形象和竞争力。
☆ 活动细则
1、每个工作日限量最多送出200套“2008免费套餐”,包括:0元注册.cn英文域名1个一年; 0元获得迎奥主机(100M网页空间)1个一年;同时可获得一次8.8折购买其它特定产品的机会。活动总计10000套,先到先得;
2、活动限时开放时间:工作日上午10:00—下午15:00,每日先到先得,申请了2008免费套餐才能获得8.8折扣优惠券;
3、限新注册直接用户,一个会员ID限只能申请一套2008免费套餐一年服务和享受一次一年8.8折优惠;
4、免费注册域名的用户需要在一个月内将域名指向具体的网站内容,有何问题,联系万网4006008500;
5、活动当期已经有折扣优惠的产品不再享受8.8折优惠;
6、用户如果一个月内不使用免费申请的迎奥主机,则万网会予以注销;
7、万网有权在发布到免费迎奥主机上的网站页面嵌入万网LOGO;
8、为了保证产品能送给有效的用户,真正发挥作用,要求用户注册时提交真实有效的电话,以便我们验证,如果用户提交的电话无法进行联系,我们会将产品予以注销;
☆ 申请流程
1、在本页面点击“参加2008免费计划”2、根据提示先注册会员,再填写产品申请信息;
3、产品申请成功后,可获得一个万网指定产品8.8折优惠券,优惠券自发出时起30天内有效;
4、用户凭8.8折优惠券券按万网产品申请流程可申购指定产品一次;
活动地址: http://www.net.cn/static/discount/08free.asp
php中include与require
include则不同,找不到该文件,将直接跳过。下面的继续执行。
至于require_once, include_once,只是为了你同一程序中多次包含了同一文件的时候,只调用一次罢了
require 的使用方法如 require("MyRequireFile.php"); 。这个函数通常放在 PHP 程序的最前面,PHP 程序在执行前,就会先读入 require 所指定引入的文件,使它变成 PHP 程序网页的一部份。常用的函数,亦可以这个方法将它引入网页中。
include 使用方法如 include("MyIncludeFile.php"); 。这个函数一般是放在流程控制的处理部分中。PHP 程序网页在读到 include 的文件时,才将它读进来。这种方式,可以把程序执行时的流程简单化
========================================================
在PHP中include和require到底有什么区别呢?看这里的例子就知道了:
include.php3的运行结果是:
这是inc1.inc文件中的一个变量的值!
这是inc2.inc文件中的一个变量的值!
inc1.inc文件中的$int变量值为1!
require.php3的运行结果是:
这是inc1.inc文件中的一个变量的值!
inc1.inc文件中的$int变量值为2!
你可以看到在require.php3中$int变为了2,也就是说inc1.inc中的语句被执行了2次,这样看来在循环中require语句只被解释一次,而且会把require语句所在的位置用require的文件内容替代并运行,而在循环中include语句每次都会被解释运行。
[sonymusic]补充道:
require是只执行一次的,不,这么说不恰当。应当说,require是先替代,将指定文件的内容代进来,再运行,所以它不知道你设置了一FOR循环。而include语句,是什么时候执行到了,什么把指定文件的内容代进来,继续执行。
include.php3:
for($i=1;$i<=2;$i++){
include("inc$i.inc");
}
echo $var1;
echo $var2;
echo 'inc1.inc文件中的$int变量值为' . $int . "!
";
?>
require.php3:
for($i=1;$i<=2;$i++){
require("inc$i.inc");
}
echo $var1;
echo $var2;
echo 'inc1.inc文件中的$int变量值为' . $int . "!
";
?>
inc1.inc:
$var1 = "这是inc1.inc文件中的一个变量的值!
";
if(isset($int)){
$int++;
}
else{
$int = 1;
}
?>
inc2.inc:
$var2 = "这是inc2.inc文件中的一个变量的值!
";
?>
PHP做301网页转向的方法,含代码
$url="http://www.winliuxq.cn".$_SERVER["REQUEST_URI"];
header("HTTP/1.1 301 Moved Permanently");
header ("Location:$url");
?>
Base64之asp应用
<%const sbase_64_characters = "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz0123456789+/"
function base64encode(byval ascontents)
dim lnposition
dim lsresult
dim char1
dim char2
dim char3
dim char4
dim byte1
dim byte2
dim byte3
dim savebits1
dim savebits2
dim lsgroupbinary
dim lsgroup64
if len(ascontents) mod 3 > 0 then ascontents = ascontents & string(3 - (len(ascontents) mod 3), " ")
lsresult = ""
for lnposition = 1 to len(ascontents) step 3
lsgroup64 = ""
lsgroupbinary = mid(ascontents, lnposition, 3)
byte1 = asc(mid(lsgroupbinary, 1, 1)): savebits1 = byte1 and 3
byte2 = asc(mid(lsgroupbinary, 2, 1)): savebits2 = byte2 and 15
byte3 = asc(mid(lsgroupbinary, 3, 1))
char1 = mid(sbase_64_characters, ((byte1 and 252) \ 4) + 1, 1)
char2 = mid(sbase_64_characters, (((byte2 and 240) \ 16) or (savebits1 * 16) and &hff) + 1, 1)
char3 = mid(sbase_64_characters, (((byte3 and 192) \ 64) or (savebits2 * 4) and &hff) + 1, 1)
char4 = mid(sbase_64_characters, (byte3 and 63) + 1, 1)
lsgroup64 = char1 & char2 & char3 & char4
lsresult = lsresult + lsgroup64
next
base64encode = lsresult
end function
response.write base64encode("abck")
%>
<%''''加密解密
' Functions to provide encoding/decoding of strings with Base64.
'
' Encoding: myEncodedString = base64_encode( inputString )
' Decoding: myDecodedString = base64_decode( encodedInputString )
'
' Programmed by Markus Hartsmar for ShameDesigns in 2002.
' Email me at: mark@shamedesigns.com
' Visit our website at: http://www.shamedesigns.com/
'
Dim Base64Chars
Base64Chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" & _
"abcdefghijklmnopqrstuvwxyz" & _
"0123456789" & _
"+/"
' Functions for encoding string to Base64
Public Function base64_encode( byVal strIn )
Dim c1, c2, c3, w1, w2, w3, w4, n, strOut
For n = 1 To Len( strIn ) Step 3
c1 = Asc( Mid( strIn, n, 1 ) )
c2 = Asc( Mid( strIn, n + 1, 1 ) + Chr(0) )
c3 = Asc( Mid( strIn, n + 2, 1 ) + Chr(0) )
w1 = Int( c1 / 4 ) : w2 = ( c1 And 3 ) * 16 + Int( c2 / 16 )
If Len( strIn ) >= n + 1 Then
w3 = ( c2 And 15 ) * 4 + Int( c3 / 64 )
Else
w3 = -1
End If
If Len( strIn ) >= n + 2 Then
w4 = c3 And 63
Else
w4 = -1
End If
strOut = strOut + mimeencode( w1 ) + mimeencode( w2 ) + _
mimeencode( w3 ) + mimeencode( w4 )
Next
base64_encode = strOut
End Function
Private Function mimeencode( byVal intIn )
If intIn >= 0 Then
mimeencode = Mid( Base64Chars, intIn + 1, 1 )
Else
mimeencode = ""
End If
End Function
' Function to decode string from Base64
Public Function base64_decode( byVal strIn )
Dim w1, w2, w3, w4, n, strOut
For n = 1 To Len( strIn ) Step 4
w1 = mimedecode( Mid( strIn, n, 1 ) )
w2 = mimedecode( Mid( strIn, n + 1, 1 ) )
w3 = mimedecode( Mid( strIn, n + 2, 1 ) )
w4 = mimedecode( Mid( strIn, n + 3, 1 ) )
If w2 >= 0 Then _
strOut = strOut + _
Chr( ( ( w1 * 4 + Int( w2 / 16 ) ) And 255 ) )
If w3 >= 0 Then _
strOut = strOut + _
Chr( ( ( w2 * 16 + Int( w3 / 4 ) ) And 255 ) )
If w4 >= 0 Then _
strOut = strOut + _
Chr( ( ( w3 * 64 + w4 ) And 255 ) )
Next
base64_decode = strOut
End Function
Private Function mimedecode( byVal strIn )
If Len( strIn ) = 0 Then
mimedecode = -1 : Exit Function
Else
mimedecode = InStr( Base64Chars, strIn ) - 1
End If
End Function
%>
不能加密中文,对此做了一点修改,可以加密任何字符了,效率非常高
<%
OPTION EXPLICIT
const BASE_64_MAP_INIT = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
dim newline
dim Base64EncMap(63)
dim Base64DecMap(127)
'初始化函数
PUBLIC SUB initCodecs()
' 初始化变量
newline = "
" & chr(13) & chr(10)
dim max, idx
max = len(BASE_64_MAP_INIT)
for idx = 0 to max - 1
Base64EncMap(idx) = mid(BASE_64_MAP_INIT, idx + 1, 1)
next
for idx = 0 to max - 1
Base64DecMap(ASC(Base64EncMap(idx))) = idx
next
END SUB
'Base64加密函数
PUBLIC FUNCTION base64Encode(plain)
if len(plain) = 0 then
base64Encode = ""
exit function
end if
plain=enasc(plain)
dim ret, ndx, by3, first, second, third
by3 = (len(plain) \ 3) * 3
ndx = 1
do while ndx <= by3
first = asc(mid(plain, ndx+0, 1))
second = asc(mid(plain, ndx+1, 1))
third = asc(mid(plain, ndx+2, 1))
ret = ret & Base64EncMap( (first \ 4) AND 63 )
ret = ret & Base64EncMap( ((first * 16) AND 48) + ((second \ 16) AND 15 ) )
ret = ret & Base64EncMap( ((second * 4) AND 60) + ((third \ 64) AND 3 ) )
ret = ret & Base64EncMap( third AND 63)
ndx = ndx + 3
loop
if by3 < len(plain) then
first = asc(mid(plain, ndx+0, 1))
ret = ret & Base64EncMap( (first \ 4) AND 63 )
if (len(plain) MOD 3 ) = 2 then
second = asc(mid(plain, ndx+1, 1))
ret = ret & Base64EncMap( ((first * 16) AND 48) + ((second \ 16) AND 15 ) )
ret = ret & Base64EncMap( ((second * 4) AND 60) )
else
ret = ret & Base64EncMap( (first * 16) AND 48)
ret = ret '& "="
end if
ret = ret '& "="
end if
base64Encode = ret
END FUNCTION
'Base64解密函数
PUBLIC FUNCTION base64Decode(scrambled)
if len(scrambled) = 0 then
base64Decode = ""
exit function
end if
dim realLen
realLen = len(scrambled)
do while mid(scrambled, realLen, 1) = "="
realLen = realLen - 1
loop
dim ret, ndx, by4, first, second, third, fourth
ret = ""
by4 = (realLen \ 4) * 4
ndx = 1
do while ndx <= by4
first = Base64DecMap(asc(mid(scrambled, ndx+0, 1)))
second = Base64DecMap(asc(mid(scrambled, ndx+1, 1)))
third = Base64DecMap(asc(mid(scrambled, ndx+2, 1)))
fourth = Base64DecMap(asc(mid(scrambled, ndx+3, 1)))
ret = ret & chr( ((first * 4) AND 255) + ((second \ 16) AND 3))
ret = ret & chr( ((second * 16) AND 255) + ((third \ 4) AND 15))
ret = ret & chr( ((third * 64) AND 255) + (fourth AND 63))
ndx = ndx + 4
loop
if ndx < realLen then
first = Base64DecMap(asc(mid(scrambled, ndx+0, 1)))
second = Base64DecMap(asc(mid(scrambled, ndx+1, 1)))
ret = ret & chr( ((first * 4) AND 255) + ((second \ 16) AND 3))
if realLen MOD 4 = 3 then
third = Base64DecMap(asc(mid(scrambled,ndx+2,1)))
ret = ret & chr( ((second * 16) AND 255) + ((third \ 4) AND 15))
end if
end if
base64Decode = deasc(ret)
END FUNCTION
function enasc(str)
dim str_len,i,str_a,str_b,str_res
str_len=len(str)
if str_len<>0 then
for i=1 to str_len
str_a=mid(str,i,1)
str_b=ASC(str_a)
str_res=str_res & "," & str_b
next
end if
enasc=str_res
end function
function deasc(str)
dim str_len,i,str_a,str_b,str_res,str_v
str_len=len(str)
if str_len<>0 then
str_v=split(str,",")
for i=1 to ubound(str_v)
str_a=chr(str_v(i))
str_res=str_res & str_a
next
end if
deasc=str_res
end function
' 初始化
call initCodecs
' 测试代码
' dim inp, encode
' inp = "中国"
' response.write "加密前为:" & inp & newline
' encode = base64Encode(inp)
' response.write "加密后为:" & encode & newline
' response.write "解密后为:" & base64Decode(encode) & newline
%>