实验吧-----IHDR

解题链接: http://ctf5.shiyanbar.com/stega/IHDR.png

有点坑哈,点开链接发现图片因存在错误而无法显示,一开始我是以为题目炸了,直接跳过。后来才知道。。。坑

可以利用脚本下载

import requests
import io,sys
sys.stdout = io.TextIOWrapper(sys.stdout.buffer,encoding='utf-8')#控制输出的编码,可以不要
response = requests.get('http://ctf5.shiyanbar.com/stega/IHDR.png')

cat_img = str(response.text).encode('utf-8')
#出现bytes错误,TypeError: a bytes-like object is required, not 'str'
#str通过encode()方法可以编码为指定的bytes
print(cat_img)

with open('ihdr1.png','wb') as f:
 f.write(cat_img)
 f.close()

可是发现图片无法正常打开,拉到winhex发现发件头错误。修改过来,应该是可以了,但不知为啥还是不行,怀疑是requests的text获取的字节流有差错。

百度发现

resp.text返回的是Unicode型的数据。

resp.content返回的是bytes型也就是二进制的数据。

 

也就是说,如果你想取文本,可以通过r.text。

如果想取图片,文件,则可以通过r.content。

(resp.json()返回的是json格式数据)

那就改为content

import requests
# import io,sys
# sys.stdout = io.TextIOWrapper(sys.stdout.buffer,encoding='utf-8')
response = requests.get('http://ctf5.shiyanbar.com/stega/IHDR.png')

cat_img = response.content
print(cat_img)

with open('ihdr1.png','wb') as f:
 f.write(cat_img)
 f.close()

再补上一段,urllib库的

#!/usr/bin/python
# -*- coding: utf-8 -*-  
import urllib.request
response = urllib.request.urlopen('http://ctf5.shiyanbar.com/stega/IHDR.png')
cat_img = response.read()
print(cat_img)
with open('ihdr1.png','wb') as f:
f.write(cat_img)
f.close()

打开图片,where key?

图片三步法

记事本或者编辑器查看

下载Adobe Fireworks cs5

打开ihdr.png。无法打开???

最后在系统自带的画图工具打开后,另存为ihdr2.png .终于

 

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值