티스토리 뷰

Wargame/Webhacking.kr

Challenge 42

do9dark 2015. 8. 28. 00:49

문제 페이지를 보면 테이블에 no와 subject, file에 대한 정보가 나와있고 <a href> 태그가 걸려있는 것을 볼 수 있다.



no 1에 해당하는 read me에 있는 test.zip 파일을 다운받기 위해서 눌러보면 아래와 같이 Access Denied 창이 발생하면서 다운을 받을 수가 없다.



no 2에 해당하는 test에 있는 test.txt 파일을 다운받기 위해서 눌러보면 아래와 같이 test.txt 파일의 내용을 확인할 수 있다.



소스 파일을 확인해보면 아래와 같이 주석으로 test.zip 파일의 패스워드는 오직 숫자로만 되어있다는 정보를 얻을 수 있고 다운 받는 부분을 보면 하드코딩으로 test.zip 파일은 받을 수 없도록 되어있는 부분을 볼 수 있다.

소스 내용 중에 test.txt 파일을 다운 받는 부분을 보면 파일명이 아니라 ?down=dGvzdC50eHQ= 로 인코딩되어 있는 것을 알 수 있다.

따라서 같은 방법으로 test.zip을 base64 encode 해준 다음 다운을 시도해본다.



test.zip을 base64 encode 하면 아래와 같이 dGVzdC58aXA= 가 나온다.



아래와 같이 인코딩한 값을 이용하여 ?down=dGVzdC56aXA= 를 입력하면 test.zip 파일을 다운 받을 수 있다.



test.zip 압축파일을 열어보면 패스워드가 걸려있는 것을 볼 수 있다.


파이썬을 이용해서 패스워드를 크랙하는 스크립트를 아래와 같이 작성할 수 있다.


#!/usr/bin/python
# -*- coding: utf-8 -*-
# do9dark
 
import sys
import zipfile
import optparse
from threading import Thread
 
def crack(ZipFile,Word):
   try:
      ZipFile.extractall(pwd=Word)
      print '[+] Found Password: ' + Word
   except:
      pass
 
def main():
   parser = optparse.OptionParser('\n\tpython zipCrack.py -f <zip file> -d <dictionary file>\n\tpython zipCrack.py -f <zip file> -i <number>')
   parser.add_option('-f', dest='zip_name', type='string', help='specify zip file.')
   parser.add_option('-d', dest='dict_name', type='string', help='specify dictionary file.')
   parser.add_option('-i', dest='num_range', type='int', help='specify range of numbers.')
   (options,args) = parser.parse_args()
 
   if(options.zip_name == None):
      print 'Help:\n\tPython zipCrack.py -h\n'
      sys.exit(0)
 
   elif(options.num_range == None) & (options.dict_name == None):
      print 'Help:\n\tPython zipCrack.py -h\n'
      sys.exit(0)
 
   elif(options.zip_name != None) & (options.dict_name != None) & (options.num_range == None):
      zip_name = options.zip_name
      dict_name = options.dict_name
 
      ZipFile = zipfile.ZipFile(zip_name)
      DictFile = open(dict_name)
 
      for line in DictFile.readlines():
         Word = line.strip('\n')
         t = Thread(target=crack, args=(ZipFile,Word))
         t.start()
         
   elif(options.zip_name != None) & (options.dict_name == None) & (options.num_range != None):
      zip_name = options.zip_name
      num_range = options.num_range
 
      ZipFile = zipfile.ZipFile(zip_name)
      Word = num_range+1
 
      for i in range(0,Word):
         t = Thread(target=crack, args=(ZipFile,str(i)))
         t.start()
 
   else:
      print 'Help:\n\tPython zipCrack.py -h\n'
      sys.exit(0)
 
if __name__ == '__main__':
   main()
cs


위 스크립트를 이용해서 test.zip 패스워드를 크랙해보면 852인 것을 알아낼 수  있다.



알아낸 패스워드를 입력하면 아래와 같이 readme.txt 파일을 볼 수 있고 내용에는 URL 주소가 적힌 것을 볼 수 있다.



해당 경로로 이동해보면 패스워드 값을 알 수 있고 문제를 풀 수 있다.



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

Challenge 47  (0) 2015.08.31
Challenge 46  (0) 2015.08.29
Challenge 45  (0) 2015.08.28
Challenge 44  (0) 2015.08.28
Challenge 43  (0) 2015.08.28
Challenge 41  (0) 2015.08.15
Challenge 40  (0) 2015.08.14
Challenge 39  (0) 2015.08.14
Challenge 38  (0) 2015.08.13
Challenge 37  (0) 2015.08.12
댓글
«   2024/04   »
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
링크
공지사항
Total
Today
Yesterday