URL***:顾名思义,就是利用URL来进行***,***方式就是更改地址栏中的$_GET的参数,另外进行一些必要的猜想,好比如下面的URL为例:php
http://www.myfreax.com/category.php?category=mysql3
***者能够了更改后面的参数mysql3的数值,进行猜想,或者结合一些其它的手段,我所知道有两个个Linux发行版专作***工具的,和测试的,很是强大,都是基于ubuntu制做的,html
BackTrack #这个曾经在我学习Linux是安装过,专门用来***和*** blackbox Linux #这个就没有使用过了
下面就是实例了,:
mysql
<?php /** * * @author Freax * @2014-3-24 * @contact huangyanxiong2013@gmail.com * */ define('FREAX', true); require_once 'include/init.php'; 'http://www.myfreax.com/category.php?category=PHP5';//正常url是这样的 class category{ /** * 数据库 对象 * @var Object */ public $db; /** * smarty 对象 * @var Object */ public $smarty; /** * 地址 指向须要显示的页面 * @var String */ public $action; /** * 分页类 * @var Object */ public $Page; /** * 缓存id * @var string */ public $cacheid; /** * 初始化 * @var String */ public function __construct($db,$smarty,$page){ //作完这个函数就是将页面显示出来 $this->db=$db; $this->smarty=$smarty; $this->Page=$page; $this->getAtion(); $this->getData(); $this->display(); } /** * 获取地址 这个是很是关键的这里作的不得好也是***的机会 * 在在这个函数中,因为我只想获取到的是一个数字其它都是不要的,因此要将其它过滤 */ public function getAtion(){ $bool=preg_match_all('/\d+/', $_SERVER['QUERY_STRING'],$match); /* 若是按照我正常些的url来执行的话,根本就不要这个判断,也能够正常执行, * 可是有意的人就会尝试更改这些参数 ,这里我须要获取到数据库分类的id, * 而且使用这个id查询数据,不免不会受到sql***的,因此有这个判断*/ if (!$bool) { header("HTTP/1.1 301 Moved Permanently"); //***者更改参数后你将重定向404,或者其它相对安全的页面,不过建议仍是重定向404静态页面, //我这里是首页,由于我首页是不接受任何参数的 header("location:http://".WEB); exit(); //记得要退出否则重定向后仍是会执行的,由于php解释器没有看到结束标签\?\> }else { $this->action=$match[0][0]; } } /** * 获取缓存id * @return string */ public function getcacheid(){ $this->cacheid=(isset($_GET['category'])?$_GET['category']:'').@(isset($_GET['page'])?$_GET['page']:''); return $this->cacheid; } /** * 根据地址 获取对应的数据 * 根据地址判断smarty是否有缓存 * 没有缓存区数据库获取 * 赋值给模板 */ public function getData(){ /* 这里根据cacheid判断是否存在缓存,若是没有缓存则从数据库中获取数据 ,因为cacheid在客户端也是能够更改的, * http://www.myfreax.com/category.php?category=PHP2&page=23 这个url就是很形的了,一个是分类,一个是页数, * 客户端能够随意更改页数,cacheid永远不一样,生成的缓存,也会增多,只要来个循环,就生成N的文件缓存 * 为何我这里能够随意更改$_GET参数都不会参数,均可以执行,由于$article=$this->db->selectArrs。。。。。。。。。。。。这个语句来讲,即便没有从数据库中获取到数据也会返回空数组*/ if (!$this->smarty->isCached('index.html',$this->getcacheid())){ $nav=$this->db->selectArrs('select * from '.PREFIX.'class'); $this->Page->getTotalPageClass($this->db,PREFIX.'article','typeid',$this->action); $this->Page->getcurrPage(); $this->Page->getStartPage(); $article=$this->db->selectArrs('select '.PREFIX.'article.*,'.PREFIX.'class.name from '.PREFIX.'article left join blog_class on ('.PREFIX.'article.typeid='.PREFIX.'class.id) where typeid= '.$this->action.' order by id desc limit '.$this->Page->startPage .','. $this->Page->paging); /* 因此这里就加上一个断 * */ if (!$article) { header("HTTP/1.1 301 Moved Permanently"); header("location:http://".WEB); exit(); } $this->Page->getLinkPage('category.php'); $this->Page->getClassPage($article[0]['name'].$article[0]['typeid']); $pagelink=$this->Page->createPageLinks(); $navAtcion=@$article[0]['name']; $this->smarty->assign('articles',$article); $this->smarty->assign('navs',$nav); $this->smarty->assign('navAction',$navAtcion); $this->smarty->assign('pagelink',$pagelink); } } /** * 返回给前能够对模板进行一些操做 * 将数据返回给用户 */ public function display(){ $this->smarty->display('index.html',$this->getcacheid()); } } /** * 实例化category类 */ new category($db,$smarty,$page); ?>