首页 > 其他分享 >ISC2016训练赛-phrackCTF-FindKey

ISC2016训练赛-phrackCTF-FindKey

时间:2024-03-26 18:48:09浏览次数:26  
标签:17 FindKey flag phrackCTF 训练赛 pwdb pwda lookup 255

ISC2016训练赛——phrackCTF

Reverse-FindKey:

题目描述:FLAG就是你输入的key

解题方法:将题目附件下载下来是一个无后缀名的文件,把他放进exeinfope.exe里查看一下它的信息

这里我们看到它不是一个EXE文件,但是下面有提示说是用python,然后我们将他的后缀名改成.py文件,用python打开是乱码,所以根据经验猜测可能是.pyc文件,我们将后缀名改成.pyc然后去在线反编译pyc文件就可以得到它的源码:

# uncompyle6 version 3.9.0
# Python bytecode version base 2.7 (62211)
# Decompiled from: Python 3.6.12 (default, Feb  9 2021, 09:19:15) 
# [GCC 8.3.0]
# Embedded file name: findkey
# Compiled at: 2016-04-30 09:54:18
import sys
lookup = [
 196, 153, 149, 206, 17, 221, 10, 217, 167, 18, 36, 135, 103, 61, 
 111, 31, 92, 152, 21, 228, 105, 191, 173, 41, 2, 245, 23, 144, 1, 
 246, 89, 178, 182, 119, 38, 85, 48, 226, 165, 241, 166, 214, 71, 
 90, 151, 3, 109, 169, 150, 224, 69, 156, 158, 57, 181, 29, 200, 
 37, 51, 252, 227, 93, 65, 82, 66, 80, 170, 77, 49, 177, 81, 94, 
 202, 107, 25, 73, 148, 98, 129, 231, 212, 14, 84, 121, 174, 171, 
 64, 180, 233, 74, 140, 242, 75, 104, 253, 44, 39, 87, 86, 27, 68, 
 22, 55, 76, 35, 248, 96, 5, 56, 20, 161, 213, 238, 220, 72, 100, 
 247, 8, 63, 249, 145, 243, 155, 222, 122, 32, 43, 186, 0, 102, 216, 
 126, 15, 42, 115, 138, 240, 147, 229, 204, 117, 223, 141, 159, 131, 
 232, 124, 254, 60, 116, 46, 113, 79, 16, 128, 6, 251, 40, 205, 137, 
 199, 83, 54, 188, 19, 184, 201, 110, 255, 26, 91, 211, 132, 160, 
 168, 154, 185, 183, 244, 78, 33, 123, 28, 59, 12, 210, 218, 47, 
 163, 215, 209, 108, 235, 237, 118, 101, 24, 234, 106, 143, 88, 9, 
 136, 95, 30, 193, 176, 225, 198, 197, 194, 239, 134, 162, 192, 11, 
 70, 58, 187, 50, 67, 236, 230, 13, 99, 190, 208, 207, 7, 53, 219, 
 203, 62, 114, 127, 125, 164, 179, 175, 112, 172, 250, 133, 130, 52, 
 189, 97, 146, 34, 157, 120, 195, 45, 4, 142, 139]
pwda = [
 188, 155, 11, 58, 251, 208, 204, 202, 150, 120, 206, 237, 114, 92, 
 126, 6, 42]
pwdb = [53, 222, 230, 35, 67, 248, 226, 216, 17, 209, 32, 2, 181, 200, 171, 
 60, 108]
flag = raw_input('Input your Key:').strip()
if len(flag) != 17:
    print 'Wrong Key!!'
    sys.exit(1)
flag = flag[::-1]
for i in range(0, len(flag)):
    if ord(flag[i]) + pwda[i] & 255 != lookup[i + pwdb[i]]:
        print 'Wrong Key!!'
        sys.exit(1)

print 'Congratulations!!'

这里我们得到源码之后就可以来分析它的源码,第一步将我们的输入进行长度判断是否为17,所以我们可以知道我们的flag的长度为17,然后将flag进行reverse逆序,最后进行关键的一步转换操作:

ord(flag[i]) + pwda[i] & 255 != lookup[i + pwdb[i]]

分析下来发现是一个很简单清晰的加密过程,只需要将它逆向回去就可以得到flag:

下面是解密的python代码:

lookup = [
 196, 153, 149, 206, 17, 221, 10, 217, 167, 18, 36, 135, 103, 61,
 111, 31, 92, 152, 21, 228, 105, 191, 173, 41, 2, 245, 23, 144, 1,
 246, 89, 178, 182, 119, 38, 85, 48, 226, 165, 241, 166, 214, 71,
 90, 151, 3, 109, 169, 150, 224, 69, 156, 158, 57, 181, 29, 200,
 37, 51, 252, 227, 93, 65, 82, 66, 80, 170, 77, 49, 177, 81, 94,
 202, 107, 25, 73, 148, 98, 129, 231, 212, 14, 84, 121, 174, 171,
 64, 180, 233, 74, 140, 242, 75, 104, 253, 44, 39, 87, 86, 27, 68,
 22, 55, 76, 35, 248, 96, 5, 56, 20, 161, 213, 238, 220, 72, 100,
 247, 8, 63, 249, 145, 243, 155, 222, 122, 32, 43, 186, 0, 102, 216,
 126, 15, 42, 115, 138, 240, 147, 229, 204, 117, 223, 141, 159, 131,
 232, 124, 254, 60, 116, 46, 113, 79, 16, 128, 6, 251, 40, 205, 137,
 199, 83, 54, 188, 19, 184, 201, 110, 255, 26, 91, 211, 132, 160,
 168, 154, 185, 183, 244, 78, 33, 123, 28, 59, 12, 210, 218, 47,
 163, 215, 209, 108, 235, 237, 118, 101, 24, 234, 106, 143, 88, 9,
 136, 95, 30, 193, 176, 225, 198, 197, 194, 239, 134, 162, 192, 11,
 70, 58, 187, 50, 67, 236, 230, 13, 99, 190, 208, 207, 7, 53, 219,
 203, 62, 114, 127, 125, 164, 179, 175, 112, 172, 250, 133, 130, 52,
 189, 97, 146, 34, 157, 120, 195, 45, 4, 142, 139]
pwda = [
 188, 155, 11, 58, 251, 208, 204, 202, 150, 120, 206, 237, 114, 92,
 126, 6, 42]
pwdb = [53, 222, 230, 35, 67, 248, 226, 216, 17, 209, 32, 2, 181, 200, 171,
 60, 108]
flag = ''
for i in range(0,17):
    flag += chr((lookup[i + pwdb[i]]-pwda[i])&255)
flag = flag[::-1]
print(flag)

运行就可以得到flag:

PCTF{PyC_Cr4ck3r}

标签:17,FindKey,flag,phrackCTF,训练赛,pwdb,pwda,lookup,255
From: https://www.cnblogs.com/xyweiwen/p/18097321

相关文章

  • SUM-ACM——VJ天梯训练赛
    这次比赛我暴露了很多问题,一些模拟还有贪心思路错误。补题如下:E-E题解:一道模拟题,我的问题在于不知道怎么替换下一个,就从0开始遍历数组然后数组的值--,如果为零就continue下一个,这个问题在于无法遍历完所有的数,会少算。其实只需要把接完水的按顺序到下一个就可以了,这样还有一个......
  • 牛客寒假训练赛第二场
    基本情况前面过的很顺,F吃满罚时,T4次WA4次最后乱搞过的,K有一点思路,但是码力跟不上,其他没做的题题目基本没思路。EFhttps://ac.nowcoder.com/acm/contest/67742/Ehttps://ac.nowcoder.com/acm/contest/67742/F两题虽然都是过了,但一个是提交前改了很久,一个是提交改了很久。E......
  • 20240204训练赛随记
    圆的覆盖通过STL删除被覆盖的点红警【时间】【攻击力】--->【伤害】时间是单调的--->二分时间middp[i]表示攻击力为i的最大伤害dp[i]dp[i+s[j].v]+s[j].v*(x-s[j].t)毕加猪Bellman-Ford求最短路llcalc(lls,llt){memset(dis,0x3f3f3f3f,sizeof(dis)......
  • 牛客寒假训练赛第一场
    基本状况赛时开了五题,B题大分讨卡住了,其他题目就看了题面。有几个基本状况:贪心题没有深入思考,就无脑二分入手,倒是大量罚时。分讨思路不清楚。E题很搞,名字叫贪心题但是纯爆搜,爽切。Ahttps://ac.nowcoder.com/acm/contest/67741/A虽然签到题,但是学习一下jly写法。我......
  • 20240202-训练赛随记
    机场检录//二分#include<bits/stdc++.h>usingnamespacestd;longlongn,m,a[100005];boolcheck(longlongx){longlongt=0;for(inti=1;i<=n;i++)t+=(x/a[i]);returnt>=m;}intmain(){cin>>n>>m;for(inti=1;i<......
  • 2024寒假集训 进阶训练赛 (六)部分题解
    A统计单词数题解注意是否是单词。CODECPP#include<iostream>#include<string>#include<algorithm>usingnamespacestd;intmain(){stringword,article;getline(cin,word);getline(cin,article);//转换为小写字母transform(word.beg......
  • 20231027NOIP训练赛
    20231027NOIP训练赛时间安排7:40-9:20写T19:20-10:20写T210:20-11:10写T3T411:10-11:50写T5总结T1写挂了,T3的set超时了题解T1简单DP题T2把加转化为差分,差分数组进行区间加操作,用线段树维护T3用一个栈维护一下没有被匹配的字符即可T4结论题,答案要么删掉一个点,要......
  • 20231019NOIP训练赛
    20231019NOIP训练赛时间安排7:50-8:50写T18:50-9:30写T29:30-10:30写T3T410:30-11:50写T1总结T2没花时间想,没想到建图题解T1枚举最大公约数,然后统计最大公约数的倍数T2并查集,设u=\(X_{b_i}\),v=\(X_{a_i}\),在u和v间建一条长度为\(c_i\)的边,可以用并查集维护,如果u和v已......
  • 20231018NOIP训练赛
    20231018NOIP训练赛时间安排7:50-8:10写T19:10-10:30写T210:30-11:50写T4总结没看T3去做了T4,考完试发现T3比T4更可做。题解T1贪心题,排序之后贪心即可T2对a做前缀和,把题目的式子化成\[\sum_{l=1}^{n}\sum_{r=l}^n\sum_{i=l}^{r}b[i]*(sum[r]-sum[l])\]对于每一个......
  • 20231015NOIP训练赛
    20231015NOIP训练赛时间安排7:50-8:10写T18:10-11:50写T2总结T2写了分段但是因为太过自信然后全删了题解T1板子题,建一个超级源点即可T2数学题,用组合数计算,然后再用前缀和优化T3先建出S到T的最短路图,然后在在这个DAG上进行DP,注意还要再建出T到S的最短路图再跑一遍。T......