Espcms 통 살 SQL 주입 구멍 분석 (EXP 첨부)

54796 단어 SQLINJECT
구멍: Espcms 통 살 SQL 주입 구멍 분석 첨부 EXP 구멍 작성 자: Seay 블 로그: www. cnseay. com
홈 페이지 소개:
  ESPCMS          LAMP             ,       、    、    、        、           ,      、                 。

85W 수록
인터페이스 / search. php 파일 과 인터페이스 / 3gwap 에 구멍 이 있 습 니 다.search. php 파일 intaglist () 함수 에 똑 같은 문제 가 존재 합 니 다.
interface / search. php 를 예 로 들 어 설명 합 니 다.
function in_taglist() {
		parent::start_pagetemplate();
		include_once admin_ROOT . 'public/class_pagebotton.php';

		$page = $this->fun->accept('page', 'G');
		$page = isset($page) ? intval($page) : 1;
		$lng = (admin_LNG == 'big5') ? $this->CON['is_lancode'] : admin_LNG;
		$tagkey = urldecode($this->fun->accept('tagkey', 'R'));
		$tagkey = $this->fun->inputcodetrim($tagkey);

		$db_where = ' WHERE lng=\'' . $lng . '\' AND isclass=1';
		if (empty($tagkey)) {
			$linkURL = $_SERVER['HTTP_REFERER'];
			$this->callmessage($this->lng['search_err'], $linkURL, $this->lng['gobackbotton']);
		}
		if (!empty($tagkey)) {
			$db_where.=" AND FIND_IN_SET('$tagkey',tags)";
		}
		$pagemax = 20;

		$pagesylte = 1;

		$templatesDIR = $this->get_templatesdir('article');

		$templatefilename = $lng . '/' . $templatesDIR . '/search';

		$db_table = db_prefix . 'document';
		$countnum = $this->db_numrows($db_table, $db_where);
		if ($countnum > 0) {

			$numpage = ceil($countnum / $pagemax);
		} else {
			$numpage = 1;
		}
		$sql = "SELECT did,lng,pid,mid,aid,tid,sid,fgid,linkdid,isclass,islink,ishtml,ismess,isorder,purview,recommend,tsn,title,longtitle,
			color,author,source,pic,link,oprice,bprice,click,description,keywords,addtime,template,filename,filepath FROM $db_table $db_where LIMIT 0,$pagemax";
		$this->htmlpage = new PageBotton($sql, $pagemax, $page, $countnum, $numpage, $pagesylte, $this->CON['file_fileex'], 5, $this->lng['pagebotton'], $this->lng['gopageurl'], $this->CON['is_rewrite']);
		$sql = $this->htmlpage->PageSQL('pid,did', 'down');
		$rs = $this->db->query($sql);
		while ($rsList = $this->db->fetch_assoc($rs)) {
  

$tagkey 변 수 는 urldecode 를 사 용 했 기 때문에 GPC 를 돌아 갈 수 있 습 니 다.
$db_where.=” AND FIND_IN_SET(‘$tagkey’,tags)”;

$tagkey 가 SQL 구문 에 가 져 왔 습 니 다.
밑 에 보 여요.
$sql = "SELECT did,lng,pid,mid,aid,tid,sid,fgid,linkdid,isclass,islink,ishtml,ismess,isorder,purview,recommend,tsn,title,longtitle,color,author,source,pic,link,oprice,bprice,click,description,keywords,addtime,template,filename,filepath FROM $db_table $db_where LIMIT 0,$pagemax";

데이터베이스 조회 에 도 가 져 왔 습 니 다. 두 문 구 는 주입 할 수 있 고 두 번 째 SQL 문 구 는 데 이 터 를 조회 할 수 있 습 니 다.그러나 espcms 기본 설정 은 SQL 문 구 를 표시 하지 않 기 때문에 첫 번 째 SQL 문 구 는 count (*), 즉 int 를 조회 합 니 다.
더 아 픈 것 은 첫 번 째 조회 가 틀 리 면 두 번 째 조 는 실행 되 지 않 는 다 는 것 이다.그래서 첫 번 째 블라인드 로 만 할 수 있 었 습 니 다.
빈틈 테스트 EXP:http://localhost/espcms/index.php?ac=search&at=taglist&tagkey=a%2527
espcms 자체 에 주입 방지 함수 가 있 기 때문에 파일 에 있 습 니 다.
public\class_function. phpinput codetrim () 함수.
function inputcodetrim($str) {
		if (empty($str)) return $str;
		$str = str_replace("&", "&", $str);
		$str = str_replace(">", ">", $str);
		$str = str_replace("<", ", $str);
		$str = str_replace("<", ", $str);
		$str = str_ireplace("select", "", $str);
		$str = str_ireplace("join", "", $str);
		$str = str_ireplace("union", "", $str);
		$str = str_ireplace("where", "", $str);
		$str = str_ireplace("insert", "", $str);
		$str = str_ireplace("delete", "", $str);
		$str = str_ireplace("update", "", $str);
		$str = str_ireplace("like", "", $str);
		$str = str_ireplace("drop", "", $str);
		$str = str_ireplace("create", "", $str);
		$str = str_ireplace("modify", "", $str);
		$str = str_ireplace("rename", "", $str);
		$str = str_ireplace("count", "", $str);
		$str = str_ireplace("from", "", $str);
		$str = str_ireplace("group by", "", $str);
		$str = str_ireplace("concat", "", $str);
		$str = str_ireplace("alter", "", $str);
		$str = str_ireplace("cas", "cast", $str);
		$str = preg_replace("/]+>/i", "", $str);
		$str = preg_replace("/

]+>/i"

, "

"

, $str); $str = preg_replace("/]+>/i", "", $str); $str = preg_replace("/width=(\'|\")?[\d%]+(\'|\")?/i", "", $str); $str = preg_replace("/height=(\'|\")?[\d%]+(\'|\")?/i", "", $str); $str = preg_replace("'

좋은 웹페이지 즐겨찾기