[watevrCTF 2019]Repyc

[watevrCTF 2019]Repyc复现

拿到题是个pyc python反编译后得到

= 0= ~* ~佤
俴 =+def():= 佤
    굿 = 佤
    괠 = [] *** (*)= [] * 100= []
    while[][] != '듃':=[][].lower()=[][:]
        if== '뉃':[[]] =[[]] +[[]]
        else:
            if== '렀':[[]] =[[]] ^[[]]
            else:
                if== '렳':[[]] =[[]] -[[]]
                else:
                    if== '냃':[[]] =[[]] *[[]]
                    else:
                        if== '뢯':[[]] =[[]] /[[]]
                        else:
                            if== '륇':[[]] =[[]] &[[]]
                            else:
                                if== '맳':[[]] =[[]] |[[]]
                                else:
                                    if== '괡':[[]] =[[]]
                                    else:
                                        if== '뫇':[[]] =[[]]
                                        else:
                                            if== '꼖':[[]] =[]
                                            else:
                                                if== '뫻':[[]] =[[]]
                                                else:
                                                    if== '딓':[[]] =[[]]
                                                    else:
                                                        if== '댒':[[]] =else:
                                                            if== '묇':[[]] =else:
                                                                if== '묟':[[]] = input([[]])
                                                                else:
                                                                    if== '꽺':[[]] = input([[]])
                                                                    else:
                                                                        if== '돯':
                                                                            print([[]])
                                                                        else:
                                                                            if== '뭗':
                                                                                print([[]])
                                                                            else:
                                                                                if== '뭿':=[[]]
                                                                                else:
                                                                                    if== '뮓':=[[]]
                                                                                    else:
                                                                                        if== '뮳':=.pop()
                                                                                        else:
                                                                                            if== '믃':
                                                                                                if[[]] >[[]]:=[].append()
                                                                                                    continue
                                                                                            else:
                                                                                                if== '꽲':[7] =for i in range(len([[]])):
                                                                                                        if[[]] !=[[]]:[7] = 侰
                                                                                                            굴 =[[]].append()

                                                                                                else:
                                                                                                    if== '꾮':= ''
                                                                                                        for i in range(len([[]])):+= chr(ord([[]][i]) ^[[]])[[]] =else:
                                                                                                        if== '꿚':= ''
                                                                                                            for i in range(len([[]])):+= chr(ord([[]][i]) -[[]])[[]] =else:
                                                                                                            if== '떇':
                                                                                                                if[[]] >[[]]:=[[]].append()
                                                                                                                    continue
                                                                                                            else:
                                                                                                                if== '뗋':
                                                                                                                    if[[]] >[[]]:=[[]].append()
                                                                                                                        continue
                                                                                                                else:
                                                                                                                    if== '똷':
                                                                                                                        if[[]] ==[[]]:=[].append()
                                                                                                                            continue
                                                                                                                    else:
                                                                                                                        if== '뚫':
                                                                                                                            if[[]] ==[[]]:=[[]].append()
                                                                                                                                continue
                                                                                                                        else:
                                                                                                                            if== '띇':
                                                                                                                                if[[]] ==[[]]:=[[]].append()
                                                                                                                                    continue+= 侰


䯂([
 [
  '꼖',, 'Authentication token: '],
 [
  '꽺',,],
 [
  '꼖', 6, 'á×äÓâæíäàßåÉÛãåäÉÖÓÉäàÓÉÖÓåäÉÓÚÕæïèäßÙÚÉÛÓäàÙÔÉÓâæÉàÓÚÕÓÒÙæäàÉäàßåÉßåÉäàÓÉÚÓáÉ·Ôâ×ÚÕÓÔɳÚÕæïèäßÙÚÉÅä×ÚÔ×æÔÉ×Úïá×ïåÉßÉÔÙÚäÉæÓ×ÜÜïÉà×âÓÉ×ÉÑÙÙÔÉâßÔÉÖãäÉßÉæÓ×ÜÜïÉÓÚÞÙïÉäàßåÉåÙÚÑÉßÉàÙèÓÉïÙãÉáßÜÜÉÓÚÞÙïÉßäÉ×åáÓÜÜ\x97ÉïÙãäãÖÓ\x9aÕÙÛ\x99á×äÕà©â«³£ï²ÕÔÈ·±â¨ë'],
 [
  '꼖',,** (3 *+) -** (+)],
 [
  '꼖', 4, 15],
 [
  '꼖', 3,],
 [
  '냃',,, 3],
 [
  '뉃',,, 4],
 [
  '괡',,],
 [
  '댒', 3],
 [
  '꾮', 6, 3],
 [
  '꼖',, 'Thanks.'],
 [
  '꼖',, 'Authorizing access...'],
 [
  '돯',],
 [
  '딓',,],
 [
  '꾮',,],
 [
  '꿚',, 4],
 [
  '꼖', 5, 19],
 [
  '꽲',, 6, 5],
 [
  '돯',],
 [
  '듃'],
 [
  '꼖',, 'Access denied!'],
 [
  '돯',],
 [
  '듃']])

都是乱码 ,看一看发现是python虚拟机,把乱码替换

# uncompyle6 version 3.7.4
# Python bytecode 3.6 (3379)
# Decompiled from: Python 3.8.3 (default, Jul  2 2020, 17:30:36) [MSC v.1916 64 bit (AMD64)]
# Embedded file name: circ.py
# Compiled at: 2019-12-14 02:29:55
# Size of source mod 2**32: 5146 bytes
a = 0
b = ~a * ~a
c = b + b

def main(argv):
    d = 0
    e = 0
    t = [0] * 2 ** (2 * 2)
    h1 = [a] * 100
    array1 = []
    while argv[d][a] != 'not null':
        opcode = argv[d][a].lower()
        l = argv[d][b:]
        if opcode == 'add':
            t[l[a]] = t[l[b]] + t[l[c]]
        else:
            if opcode == 'xor':
                t[l[a]] = t[l[b]] ^ t[l[c]]
            else:
                if opcode == 'sub':
                    t[l[a]] = t[l[b]] - t[l[c]]
                else:
                    if opcode == 'mul':
                        t[l[a]] = t[l[b]] * t[l[c]]
                    else:
                        if opcode == 'div':
                            t[l[a]] = t[l[b]] / t[l[c]]
                        else:
                            if opcode == 'and':
                                t[l[a]] = t[l[b]] & t[l[c]]
                            else:
                                if opcode == 'or':
                                    t[l[a]] = t[l[b]] | t[l[c]]
                                else:
                                    if opcode == 'equal':
                                        t[l[a]] = t[l[a]]
                                    else:
                                        if opcode == 'mov1':
                                            t[l[a]] = t[l[b]]
                                        else:
                                            if opcode == 'mov2':
                                                t[l[a]] = l[b]
                                            else:
                                                if opcode == 'mov3':
                                                    h1[l[a]] = t[l[b]]
                                                else:
                                                    if opcode == 'mov4':
                                                        t[l[a]] = h1[l[b]]
                                                    else:
                                                        if opcode == 'mov5':
                                                            t[l[a]] = a
                                                        else:
                                                            if opcode == 'mov6':
                                                                h1[l[a]] = a
                                                            else:
                                                                if opcode == 'input1':
                                                                    t[l[a]] = input(t[l[b]])
                                                                else:
                                                                    if opcode == 'input2':
                                                                        h1[l[a]] = input(t[l[b]])
                                                                    else:
                                                                        if opcode == 'printf':
                                                                            print(t[l[a]])
                                                                        else:
                                                                            if opcode == 'printf1':
                                                                                print(t[l[a]])
                                                                            else:
                                                                                if opcode == 'mov7':
                                                                                    d = t[l[a]]
                                                                                else:
                                                                                    if opcode == 'mov8':
                                                                                        d = h1[l[a]]
                                                                                    else:
                                                                                        if opcode == 'pop':
                                                                                            d = array1.pop()
                                                                                        else:
                                                                                            if opcode == 'cmp+push':
                                                                                                if t[l[b]] > t[l[c]]:
                                                                                                    d = l[a]
                                                                                                    array1.append(d)
                                                                                                    continue
                                                                                            else:
                                                                                                if opcode == 'cmp+push1':
                                                                                                    t[7] = a
                                                                                                    for i in range(len(t[l[a]])):
                                                                                                        if t[l[a]] != t[l[b]]:
                                                                                                            t[7] = b
                                                                                                            d = t[l[c]]
                                                                                                            array1.append(d)

                                                                                                else:
                                                                                                    if opcode == 'array_xor':
                                                                                                        string = ''
                                                                                                        for i in range(len(t[l[a]])):
                                                                                                            string += chr(ord(t[l[a]][i]) ^ t[l[b]])

                                                                                                        t[l[a]] = string
                                                                                                    else:
                                                                                                        if opcode == 'array_sub':
                                                                                                            string = ''
                                                                                                            for i in range(len(t[l[a]])):
                                                                                                                string += chr(ord(t[l[a]][i]) - t[l[b]])

                                                                                                            t[l[a]] = string
                                                                                                        else:
                                                                                                            if opcode == 'cmp+push2':
                                                                                                                if t[l[b]] > t[l[c]]:
                                                                                                                    d = t[l[a]]
                                                                                                                    array1.apparray1(d)
                                                                                                                    continue
                                                                                                            else:
                                                                                                                if opcode == 'cmp+push3':
                                                                                                                    if t[l[b]] > t[l[c]]:
                                                                                                                        d = h1[l[a]]
                                                                                                                        array1.apparray1(d)
                                                                                                                        continue
                                                                                                                else:
                                                                                                                    if opcode == 'cmp+push4':
                                                                                                                        if t[l[b]] == t[l[c]]:
                                                                                                                            d = l[a]
                                                                                                                            array1.apparray1(d)
                                                                                                                            continue
                                                                                                                    else:
                                                                                                                        if opcode == 'cmp+push5':
                                                                                                                            if t[l[b]] == t[l[c]]:
                                                                                                                                d = t[l[a]]
                                                                                                                                array1.apparray1(d)
                                                                                                                                continue
                                                                                                                        else:
                                                                                                                            if opcode == 'cmp+push6':
                                                                                                                                if t[l[b]] == t[l[c]]:
                                                                                                                                    d = h1[l[a]]
                                                                                                                                    array1.apparray1(d)
                                                                                                                                    continue
        d += b



分析完后

main=[
 [
  'mov2', a, 'Authentication toopcodeen: '],        #t[l[0]] = l[1]
 [
  'input2', 0, 0], #input[t[l[1]]]
 [
  'mov2', 6, 'á×äÓâæíäàßåÉÛãåäÉÖÓÉäàÓÉÖÓåäÉÓÚÕæïèäßÙÚÉÛÓäàÙÔÉÓâæÉàÓÚÕÓÒÙæäàÉäàßåÉßåÉäàÓÉÚÓáÉ·Ôâ×ÚÕÓÔɳÚÕæïèäßÙÚÉÅä×ÚÔ×æÔÉ×Úïá×ïåÉßÉÔÙÚäÉæÓ×ÜÜïÉà×âÓÉ×ÉÑÙÙÔÉâßÔÉÖãäÉßÉæÓ×ÜÜïÉÓÚÞÙïÉäàßåÉåÙÚÑÉßÉàÙèÓÉïÙãÉáßÜÜÉÓÚÞÙïÉßäÉ×åáÓÜÜ\x97ÉïÙãäãÖÓ\x9aÕÙÛ\x99á×äÕà©â«³£ï²ÕÔÈ·±â¨ë'],# h1[l[0]] = 0
 [
  'mov2', c, c ** (3 * c + b) - c ** (c + b)], #t[2] = 120  128-8=120
 [
  'mov2', 4, 15],#t[l[0]] = l[1] t[4] = 15
 [
  'mov2', 3, b], #t[3] = 1
 [
  'mul', c, c, 3], #t[2] = t[2]*t[3]=120
 [
  'add', c, c, 4],# t[2] = t[2] + t[4]  t[2] =120+15=135
 [
  'equal', a, c],#t[0] = t[0]
 [
  'mov5', 3], #t[3] = 0
 [
  'array_xor', 6, 3], # string += chr(ord()^t[3])
 [
  'mov2', a, 'Thanopcodes.'],#t[0] = l[1]
 [
  'mov2', b, 'Authorizing access...'],#t[1] = l[1]
 [
  'printf', a], #print(t[a])
 [
  'mov4', a, a],#t[0] = h1[0]
 [
  'array_xor', a, c],#string += t[l[0]][i]) ^ t[2] t[2] = 135
 [
  'array_sub', a, 4],#string += t[0][i]) - t[4])
 [
  'mov2', 5, 19],#t[5] = l[1]
 [
  'cmp+push1', a, 6, 5],
 [
  'printf', b],#print(t[1])
 [
  '듃'],
 [
  'mov2', b, 'Access denied!'],
 [
  'printf', b],
 [
  'not null']
]

发现就是先与135异或,再减15
所以

str = ' á×äÓâæíäàßåÉÛãåäÉÖÓÉäàÓÉÖÓåäÉÓÚÕæïèäßÙÚÉÛÓäàÙÔÉÓâæÉàÓÚÕÓÒÙæäàÉäàßåÉßåÉäàÓÉÚÓáÉ·Ôâ×ÚÕÓÔɳÚÕæïèäßÙÚÉÅä×ÚÔ×æÔÉ×Úïá×ïåÉßÉÔÙÚäÉæÓ×ÜÜïÉà×âÓÉ×ÉÑÙÙÔÉâßÔÉÖãäÉßÉæÓ×ÜÜïÉÓÚÞÙïÉäàßåÉåÙÚÑÉßÉàÙèÓÉïÙãÉáßÜÜÉÓÚÞÙïÉßäÉ×åáÓÜÜ\x97ÉïÙãäãÖÓ\x9aÕÙÛ\x99á×äÕà©â«³£ï²ÕÔÈ·±â¨ë'
flag = ''
for i in range(len(str)):
    flag+= chr((ord(str[i])+15)^135 )
print(flag)

得到flag为
watevr{this_must_be_the_best_encryption_method_evr_henceforth_this_is_the_new_Advanced_Encryption_Standard_anyways_i_dont_really_have_a_good_vid_but_i_really_enjoy_this_song_i_hope_you_will_enjoy_it_aswell!_youtube.com/watch?v=E5yFcdPAGv0}

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值