Espcms 통 살 SQL 주입 구멍 분석 (EXP 첨부)
홈 페이지 소개:
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("'
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
Redash를 사용할 때 몰랐던 SQL을 쓰는 법을 배웠습니다.최근 redash에서 sql을 쓸 기회가 많고, 이런 쓰는 방법이 있었는지와 sql에 대해 공부를 다시하고 있기 때문에 배운 것을 여기에 씁니다. Redash란? 월별로 데이터를 표시하고 싶습니다 주별로 데이터를 표...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.