2020湖湘杯部分writeup
第一次发帖,如有问题,请联系我修改,谢谢。周末打了湖湘杯,把做题过程记录一下,大家交流学习。
下面的链接里有题目,可以下来看看。
https://download.csdn.net/download/jameswhite2417/13081994
1. miscpasswd下载文件发现是raw,是道内存取证的题目拷到kail中,先识别配置文件
获取密码hash
进行解密
再根据题目用sha1加密得到flag
2. CPYPTO 古典美++Virginia(维吉尼亚)无密钥解密1. 破解秘钥长度。Python代码: #coding=utf-8#-*- coding:utf-8 –*-def c_alpha(cipher): # 去掉非字母后的密文 cipher_alpha = ''
for i in range(len(cipher)):
if (cipher.isalpha()):
cipher_alpha += cipher
return cipher_alpha
# 计算cipher的重合指数def count_CI(cipher):
N =
cipher = c_alpha(cipher)
L = len(cipher)
if cipher == '':
return 0
else:
for i in range(L): #计算所有字母的频数,存在数组N当中
if (cipher.islower()):
N) - ord('a')] += 1
else:
N) - ord('A')] += 1
CI_1 = 0
for i in range(26):
CI_1 += ((N / L) * ((N-1) / (L-1)))
return CI_1
# 计算秘钥长度为 key_len 的重合指数def count_key_len_CI(cipher,key_len):
un_cip = ['' for i in range(key_len)] # un_cip 是分组
aver_CI = 0.0
count = 0
for i in range(len(cipher_alpha)):
z = i % key_len
un_cip += cipher_alpha
for i in range(key_len):
un_cip= count_CI(un_cip)
aver_CI += un_cip
aver_CI = aver_CI/len(un_cip)
return aver_CI
## 找出最可能的前十个秘钥长度def pre_10(cipher):
M = [(1,count_CI(cipher))]+[(0,0.0) for i in range(49)]
for i in range(2,50):
M = (i,abs(0.065 - count_key_len_CI(cipher,i)))
M = sorted(M,key = lambda x:x) #按照数组第二个元素排序
for i in range(1,10):
print (M)
F = # 英文字符频率。
cipher = 'SZWLVSRVVZICMUOJYIIZBSVSSITFSWHPCWCFPVPFXJMWRVJICVRGTCFLHPRJKJKSRVWYFUSEWHFXLHFOSFLYPFXXYFPOEGXFXMBUHVNIYHNDWXPGBXWSYBNDVQRVYRTZUWKTFSKUMVERCCRSBEMKEDRUNYYVRYKXFOK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OSEHGHLGIVJRVVUFLURVFXKYURVVBAVSCBZFIXSYBUZSIEQHFVEPQPSJHRKMWGYHFVHYBRJEZOGKFQHVSGTZVLRMJTROPIJEVKWLIPSUYWLVFYFKKLFXDIEQCZUJZJHIDUMQFPIFVRODRRXUFSGHSGMCHYDXNBJYNLXYUFSZULVBBGURAEXYFUWLVBLHZSEKIGSJLXYJLYJKINBQFRWLVSEZRGXYFPSNDWEPMBVOMJUCBZQKKIGGKLQVBQWKGMUORGFXRUBROCOXYFPWXKXNPPRSXXZTFOCOLRWCHFDWBUFSDZLRURVVQEDFMTKKITPSBKUCZTWCLNRFXNZVDWVNYODLWKIGGEHAQFYZRQHFSYIJWVRMGORQHJICHILIUUMQLUXJFWOJVLVTNCBHJROAMTXVKTCMZQKRTWCLUIWBJZZQKKIPCLJLKICOZUHFZMIKKMELWCLFSLMBARQEXFGHRQHNIYHRQMXOMFRQXCJRHCHKZSJGYHPCUFWENQVGMFRVOZOEBFLXCMLSMHVUPRCRVOGFPVRSWZTFOCOWVFGHNUMKUCBLSWFNCKYHVV'
cipher_alpha = c_alpha(cipher)print u"秘钥长度为:"
pre_10(cipher)
得出的结果排名靠前的都是7的倍数,我们可以猜测秘钥长度为7 2.将密文分成N组,逐个破解秘钥。Python代码:# 猜测单个秘钥得到的重合指数def count_CI2(cipher,n): # n 代表我们猜测的秘钥,也即偏移量
N =
cipher = c_alpha(cipher)
L = len(cipher)
for i in range(L): #计算所有字母的频数,存在数组N当中
if (cipher.islower()):
N[(ord(cipher) - ord('a') - n)%26] += 1
else:
N[(ord(cipher) - ord('A') - n)%26] += 1
CI_2 = 0
for i in range(26):
CI_2 += ((N / L) * F)
return CI_2
def one_key(cipher,key_len):
un_cip = ['' for i in range(key_len)]
cipher_alpha = c_alpha(cipher)
for i in range(len(cipher_alpha)): # 完成分组工作
z = i % key_len
un_cip += cipher_alpha
for i in range(key_len):
print (i)
pre_5_key(un_cip) ####这里应该将7个分组的秘钥猜测全部打印出来
## 找出前5个最可能的单个秘钥def pre_5_key(cipher):
M = [(0,0.0) for i in range(26)]
for i in range(26):
M = (chr(ord('a')+i),abs(0.065 - count_CI2(cipher,i)))
M = sorted(M,key = lambda x:x) #按照数组第二个元素排序
for i in range(10):
print (M)
key_len = 7 #输入猜测的秘钥长度
one_key(cipher,key_len)
结果
得出的秘钥会按照可能性进行排序,排在第一位的字符取出得到orderby 验证一下
解密的结果最后几个单词明显有意义 按题目要求将秘钥大写,用md5加密得到flag
参考:python实现维吉尼亚秘钥破解 - 简书 https://www.jianshu.com/p/23e3dcb3f0e9
3. 未解出Misc颜文字之谜过滤http中含有flag的内容
追踪http流
Base64解码
AAEncode解码无果 ……
4. 未解出Misc 虚实之间Binwalk一下发现有两个zip包Foremost分离出来用360压缩打开,有个没加密的副本,把内容拷出来,保存到本地。 用好压打开有3个加密的文件。文件名也是mingwen-副本,还有个正本,crc32一样。应该是明文攻击。把刚才保存到本地的txt压缩一下,对比一下crc32一样,这样我们就有了明文文件。
用archpr进行明文攻击,可是报错了……
5.未解出 web 文件包含 有过滤 做不动……
skrskr 发表于 2020-11-4 09:57
https://www.mygeocachingprofile.com/codebreaker.vigenerecipher.aspx
维吉尼亚密码那题这个网址可以在线破解,挺方便的 skrskr 发表于 2020-11-4 09:58
维吉尼亚密码那题这个网址可以在线破解,挺方便的
github那个更直观,搜索维吉尼亚就找得到了 敢不敢把附件传到这里来! 学习学习 来学习得 多看看 新人赞一个 谢谢,看看 看看怎么样 纯新人,先学习学习. 学习了,很有用 感谢,学习了!