随着B/S模式应用开发的发展,使用这种模式编写应用程序的程序员也越来越多。但是由于这个行业的入门门槛不高,程序员的水平及经验也参差不齐,相当大一部分程序员在编写代码的时候,没有对用户输入数据的合法性进行判断,使应用程序存在安全隐患。用户可以提交一段数据库查询代码,根据程序返回的结果,获得某些他想得知的数据,这就是所谓的SQL
Injection,即SQL注入。
SQL注入是从正常的WWW端口访问,而且表面看起来跟一般的Web页面访问没什么区别,所以目前市面的防火墙都不会对SQL注入发出警报,如果管理员没查看IIS日志的习惯,可能被入侵很长时间都不会发觉。
但是,SQL注入的手法相当灵活,在注入的时候会碰到很多意外的情况。能不能根据具体情况进行分析,构造巧妙的SQL语句,从而成功获取想要的数据,是高手与“菜鸟”的根本区别。
根据国情,国内的网站用ASP+Access或SQLServer的占70%以上,PHP+MySQ占L20%,其他的不足10%。在本文,我们从分入门、进阶至高级讲解一下ASP注入的方法及技巧,PHP注入的文章由NB联盟的另一位朋友zwell撰写,希望对安全工作者和程序员都有用处。了解ASP注入的 ......
exec sp_spaceused [[@objname=]'objname'][,[@updateusage=]'updateusage']
检查数据库空间大小
dbcc showfilestats
统计数据文件的使用情况
dbcc showcontig
检查数据库控件分配情况
dbcc sqlperf(logspace)
查看日志文件的使用情况 ......
<?php
/********************************************************************
* FileName: class.msn.php
* by changwei, 2010-4-13
* Contact MSN: changwei0112@hotmail.com
* 获取MSN好友Email列表
*
============================================================
*
* PHP配置环境要求
* 支持socket、ssl、curl,开启php.ini文件中的以下地方
* ;extension=php_sockets.dll
* ;extension=php_curl.dll
* ;extension=php_openssl.dll
*
============================================================
*
* 使用方法 DEMO
* require('class.msn.php'); //引用MSN好友列表类
* $msn = new MsnFriend();
* $list = $msn->GetList('changwei0112@hotmail.com','123123');
* print_r($list);   ......
CentOS的php版本默认为5.1.6,然后在5.2.9版本之前的的php都存在一个漏洞,但是目前网上很多地方都无法使用yum update php*升级到5.2.9,比较常见的是升级到5.2.6版本的,经过搜索国外资料,现在终于找到一种升级CentOS的php到5.2.9的方法。
运行下面命令:
# wget http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-3.noarch.rpm
# wget http://rpms.famillecollet.com/el5.i386/remi-release-5-7.el5.remi.noarch.rpm
# rpm -Uvh remi-release-5*.rpm epel-release-5*.rpm
然后编辑/etc/yum.repos.d/remi.repo
#vi /etc/yum.repos.d/remi.repo
在这个文件的最后增加一行:
priority=1
保存退出。
使用下面的命令进行升级,但是经过测试,如果单独升级php将提示失败,只有连同mysql一起升级才可以,所以我们必须执行以下命令才能升级php到5.2.9版本:
yum --enablerepo=remi update php* mysql* ......
<?php
set_time_limit(0);
$url='http://item.taobao.com/auction/item_detail.htm?xid=0db2&item_num_id=4512430274&cm_cat=50000671&pm2=1';
$ch = curl_init();
$timeout = 10;
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$html = curl_exec($ch);
curl_close($ch);
$reg="|好评率:[\s\S]*<strong>(\d{0,5}[.]\d{0,5})%</strong>|";
preg_match_all ($reg,
$html,
$out, PREG_PATTERN_ORDER);
/*
foreach ($out as $value){
foreach ($value as $value2){
if(strlen($value2)<20)
echo ($value2."<br>");
}
}
*/
echo $out[1][0];
//ikmb
?>
......
<?php
$s = <<<html
<html>
<head>
<title>nested tag test</title>
<mce:script type="text/javascript"><!--
alert('fdsafdasfasd');
// --></mce:script>
</head>
<body>
<div id=0>
<div id=1><img name="img1" id="img1" src=""/>
<div id=2><img name="img2" id="img2" src=""/>
<div id=3><img name="img3" id="img3" src=""/>
</div>
</div>
</div>
</div>
</body>
</html>
html;
$pattern = "/(".
"<\!\w+(?:\s+[^>]*?)+\s*>|".
"<\w+(?:\s+\w+(?:\s*=\s*(?:\"[^\"]*\"|'[^']*'|[^\"'>\s]+))?)*\s*\/?>|".
"<\/\w+\s*>|".
"<\!--[^-]*-->".
")/";
preg_match_all($pattern, $s, $aMatches, PREG_OFFSET_CAPTURE);
function getMatchTags($s, $arr) {
$sMatchClose = '';
$arrClose = array();
$arrReturn = array();
for($i=0; $ ......
<?php
$s = <<<html
<html>
<head>
<title>nested tag test</title>
<mce:script type="text/javascript"><!--
alert('fdsafdasfasd');
// --></mce:script>
</head>
<body>
<div id=0>
<div id=1><img name="img1" id="img1" src=""/>
<div id=2><img name="img2" id="img2" src=""/>
<div id=3><img name="img3" id="img3" src=""/>
</div>
</div>
</div>
</div>
</body>
</html>
html;
$pattern = "/(".
"<\!\w+(?:\s+[^>]*?)+\s*>|".
"<\w+(?:\s+\w+(?:\s*=\s*(?:\"[^\"]*\"|'[^']*'|[^\"'>\s]+))?)*\s*\/?>|".
"<\/\w+\s*>|".
"<\!--[^-]*-->".
")/";
preg_match_all($pattern, $s, $aMatches, PREG_OFFSET_CAPTURE);
function getMatchTags($s, $arr) {
$sMatchClose = '';
$arrClose = array();
$arrReturn = array();
for($i=0; $ ......