题目地址:https://ctf.show
0x01
打开下载下来的文档,base64解码发现关键字 Rar!,然后保存下来解压得到steg.txt
打开steg.txt,发现为一堆base64,解码出来暂时没发现新的可利用信息,尝试base64隐写解密,脚本如下:
def get_base64_diff_value(s1, s2):
base64chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
res = 0
for i in xrange(len(s2)):
if s1[i] != s2[i]:
return abs(base64chars.index(s1[i]) - base64chars.index(s2[i]))
return res
def solve_stego():
with open('1.txt', 'rb') as f:
file_lines = f.readlines()
bin_str = ''
for line in file_lines:
steg_line = line.replace('\n', '')
norm_line = line.replace('\n', '').decode('base64').encode('base64').replace('\n', '')
diff = get_base64_diff_value(steg_line, norm_line)
print diff
pads_num = steg_line.count('=')
if diff:
bin_str += bin(diff)[2:].zfill(pads_num * 2)
else:
bin_str += '0' * pads_num * 2
print goflag(bin_str)
def goflag(bin_str):
res_str = ''
for i in xrange(0, len(bin_str), 8):
res_str += chr(int(bin_str[i:i + 8], 2))
return res_str
if __name__ == '__main__':
solve_stego()
运行后结果为网站加提示
访问网站下载下来文件,看来这是要我们一直用base的各种类型解码了,尝试了一番以后(大概七八次)发现文件还是很大,算了,写个脚本。(说多了都是泪)
#author:羽
import base64
import base91
import base58
import py3base92
def hex_to_str(s):
k=''
for i in range(0,len(s),2):
j = s[i]+s[i+1]
k+=chr(int(j,16))
print('16')
return k
def ba32(s):
s = base64.b32decode(s)
s = bytes.decode(s)
print('32')
return s
def ba58(s):
s = base58.b58decode(s)
s = bytes.decode(s)
print('58')
return s
def ba64(s):
s = base64.b64decode(s)
s = bytes.decode(s)
print('64')
return s
def baa85(s):
s = base64.a85decode(s)
s = bytes.decode(s)
print('a85')
return s
def bab85(s):
s = base64.b85decode(s)
s = bytes.decode(s)
print('b85')
return s
def ba91(s):
s = base91.decode(s)
s = s.decode()
print('91')
return s
def ba92(s):
s = py3base92.decode(s)
print('91')
return s
def start(s):
for i in range(50):
if len(s)
关注
打赏
最近更新
- 深拷贝和浅拷贝的区别(重点)
- 【Vue】走进Vue框架世界
- 【云服务器】项目部署—搭建网站—vue电商后台管理系统
- 【React介绍】 一文带你深入React
- 【React】React组件实例的三大属性之state,props,refs(你学废了吗)
- 【脚手架VueCLI】从零开始,创建一个VUE项目
- 【React】深入理解React组件生命周期----图文详解(含代码)
- 【React】DOM的Diffing算法是什么?以及DOM中key的作用----经典面试题
- 【React】1_使用React脚手架创建项目步骤--------详解(含项目结构说明)
- 【React】2_如何使用react脚手架写一个简单的页面?