Notice
Recent Posts
Recent Comments
Link
«   2024/05   »
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
Tags
more
Archives
Today
Total
관리 메뉴

dohki

Internetwache CTF 2016: Code 80 - Brute with Force 본문

Hacking/CTF write up

Internetwache CTF 2016: Code 80 - Brute with Force

dohki 2016. 2. 26. 02:01

Description


People say, you're good at brute forcing... Have fun!








Write-up


어떤 시각을 주고 어떤 hash를 주는데 '그 시각과 30초 오차 범위 내에 있는 시각의 timestamp:1 byte character'의 sha1 값이 주어진 hash와 같을 때 이 string을 보내주면 된다. 이 문제가 짜증나는 게 처음에는 timestamp라고 써주지 않아서 format을 헷갈리게 하고, 시각도 UTC가 아닌 CET로 줘서 삽질을 하게 했다. 31번 문제도 답이 맞는데 틀렸다고 해서 문의 했더니 그 뒤로 답을 더 구할 필요가 없다는 대답을 하는 것이다. 알고 보니 이 때까지 구한 글자들을 연결하면 flag라고... 아무튼 다음 code를 실행하면 flag를 얻을 수 있다.


from pwn import *
from hashlib import *

p = remote('188.166.133.53', 11117)
p.recvuntil('\n')

base = 1451606400
flag = ''

for k in range(32):  
  print k

  data = p.recvuntil('\n')
  print data
  data = p.recvuntil('\n')
  print data

  tmp = base

  idx_th = data.find('th')
  day = data[idx_th - 2 : idx_th]
  tmp += (int(day) - 1) * 24 * 3600
  
  idx_is = data.find('is ')
  time = data[idx_is + 3 : idx_is + 11] 
  time = time.split(':')
  tmp += int(time[0]) * 3600 + int(time[1]) * 60 + int(time[2])  

  tmp -= 30
  tmp -= 3600

  hash1 = data[data.find('is:') + 4 : -1] 

  for i in range(61):
    for j in range(128):
      tester = str(tmp + i) + ':' + chr(j)
      hash2 = sha1(tester).hexdigest()

      if hash1 == hash2:
        flag += chr(j)
        p.send(tester)
        break

print flag


Flag


IW{M4N_Y0U_C4N_B3_BF_M4T3RiAL!}

Comments