반응형

pyc decompile

 

bughela.pyc

:D

 

 

 

 

 

servertime 이 표시되며, pyc 파일이 주어진다.

 

pyc는 python에서 import 한 py파일을 컴파일해서 만들어진다.

 

 

 

 

 

 

 

pyc 디컴파일은 간단하다.

 

sudo pip install uncompyle6
uncompyle6 bughela.pyc 
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
35
36
37
# uncompyle6 version 3.6.1
# Python bytecode 2.7 (62211)
# Decompiled from: Python 3.6.9 (default, Nov  7 2019, 10:44:02) 
# [GCC 8.3.0]
# Embedded file name: bughela.py
# Compiled at: 2015-02-09 16:13:20
import time
from sys import exit
from hashlib import sha512
 
def main():
    print 'import me :D'
 
 
def GIVE_ME_FLAG(flag):
    if flag[:43!= 'http://wargame.kr:8080/pyc_decompile/?flag=':
        die()
    flag = flag[43:]
    now = time.localtime(time.time())
    seed = time.strftime('%m/%d/HJEJSH', time.localtime())
    hs = sha512(seed).hexdigest()
    start = now.tm_hour % 3 + 1
    end = start * (now.tm_min % 30 + 10)
    ok = hs[start:end]
    if ok != flag:
        die()
    print 'GOOD!!!'
 
 
def die():
    print 'NOPE...'
    exit()
 
 
if __name__ == '__main__':
    main()
 
cs

 

19행부터 24행의 과정을 거쳐서 flag값을 만들어낸다.

 

해당 코드만 뽑아서 flag를 가져오는 코드를 작성하였다.

 

 

 

주의 할 점은 서버의 시간과 로컬의 시간이 맞지 않다.

따라서 로컬의 시간을 서버의 시간으로 맞춰주어야 한다. (10행에서 보정)

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
import time
from hashlib import sha512
 
url= 'http://wargame.kr:8080/pyc_decompile/?flag='
 
now = time.localtime(time.time())
seed = time.strftime('%m/%d/HJEJSH', time.localtime())
hs = sha512(seed).hexdigest()
start = now.tm_hour % 3 + 1
end = start * ((now.tm_min+8) % 30 + 10)
ok = hs[start:end]
print ok
 
 
import urllib
import urllib2
 
 
url += ok
 
opener = urllib2.build_opener(urllib2.HTTPHandler)
request = urllib2.Request(url)
request.add_header('User-Agent''Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.125 Safari/537.36')
request.add_header('Cookie''PHPSESSID=cookie')
request.get_method = lambda:'GET'
 
data = opener.open(request)
data = data.read()
 
print data
 
cs

 

 

 

 

 

 

반응형

'WAR GAME > wargame.kr' 카테고리의 다른 글

Wargame.kr [ip log table] 풀이  (0) 2020.01.04
Wargame.kr [SimpleBoard] 풀이  (0) 2020.01.04
Wargame.kr [web chatting] 풀이  (0) 2020.01.01
Wargame.kr [EASY_CrackMe] 풀이  (0) 2020.01.01
Wargame.kr [php? c?] 풀이  (0) 2019.12.31

+ Recent posts