图片隐写

图片隐写

PNG和JPG文件结构

PNG:https://www.cnblogs.com/ECJTUACM-873284962/p/8986391.html (有题目需要修改PNG宽高),结尾是IEND

https://en.wikipedia.org/wiki/Portable_Network_Graphics#File_format

JPG:https://www.cnblogs.com/bandy/p/4956086.html

jpg的一些隐写:https://zhuanlan.zhihu.com/p/24054040

无论是png还是jpg,只会识别到文件尾,所以可以在文件尾加入信息

F5隐写

Stegpy隐写

之前有过题了,就不说了,讲讲下载

看这篇就够了

https://blog.csdn.net/Amherstieae/article/details/109010064

Steghide

https://www.jianshu.com/p/c3679f805a0c

题目

https://buuoj.cn/challenges#九连环

解题过程

binwalk分解文件

伪加密

得到图片和加密压缩包

对图片使用steghide

steghide info 文件查看隐藏信息,输入y后提取,也可以直接:steghide extract 文件

找到ko.txt,得到压缩包密码

flag{1RTo8w@&4nK@z*XL}

Binwalk、Winrar——图片隐藏文件

binwalk使用:https://blog.csdn.net/wxh0000mm/article/details/85683661

可以直接binwalk提取文件,命令:binwalk -e 文件,这个比较常见,就不说了

winrar也可以直接打开被隐藏的文件

修改图片宽高

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import binascii
import struct
import sys

file = input("图片地址:")
fr = open(file,'rb').read()
data = bytearray(fr[0x0c:0x1d])
crc32key = eval('0x'+str(binascii.b2a_hex(fr[0x1d:0x21]))[2:-1])
#原来的代码: crc32key = eval(str(fr[29:33]).replace('\\x','').replace("b'",'0x').replace("'",''))
n = 4095
for w in range(n):
width = bytearray(struct.pack('>i', w))
for h in range(n):
height = bytearray(struct.pack('>i', h))
for x in range(4):
data[x+4] = width[x]
data[x+8] = height[x]
crc32result = binascii.crc32(data) & 0xffffffff
if crc32result == crc32key:
print(width,height)
newpic = bytearray(fr)
for x in range(4):
newpic[x+16] = width[x]
newpic[x+20] = height[x]
fw = open(file+'.png','wb')
fw.write(newpic)
fw.close
sys.exit()

二进制转二维码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
from PIL import Image
from zlib import *

MAX = 25
pic = Image.new("RGB",(MAX,MAX))
str ='''0000000001110010000000000000000000001111010000000000000000011100010000000000000000010111100000000000000000001010101000000000000000000011000101000000000000000010101010100000000000000000100000110000000011000111011101101000110000001000010110010010010100010011110100001110111001100111101001010110010010011000001001100001001101000111100011111101110010100010110111110011011111101111000110110010010101101100100011110011111111111011100000000101100011000101000000000010010100101010001000000001010101010001100100000000001001111111100100000000000011001011110111000000000100110010010000100000000110000110110110010000000011010000101110101'''
i=0
for y in range(0,MAX):
for x in range(0,MAX):
if(str[i] == '1'):
pic.putpixel([x,y],(0,0,0))
else:pic.putpixel([x,y],(255,255,255))
i = i+1
pic.show()
pic.save("flag.png")


坐标画图

gnuplot

linux,直接sudo apt install gnuplot,使用 直接gnuplot进入后,plot 文件名,就可以了

题目

https://buuoj.cn/challenges#梅花香之苦寒来

解题过程

在文件尾之后发现大量十六进制数据,这里我使用010editor复制,这样比较快,复制后转为字符

这样的格式不能被识别,所以需要替换,我使用的是VS

替换这里不用填写,直接替换全部,然后保存到txt中,再使用工具

GIF

在stegsolve可以实现,逐帧查看,注意不要漏了

LSB隐写

文件头尾倒置

题目

https://www.yunyansec.com/#/experiment/expdetail/3

pipicc

解题过程

得到一张图片

有噪点,应该是修改了像素点,是需要修复的

缺少png文件头,修补文件头

接下来找到IEND块,将多余部分删去,改为png

得到

拖进stegsolve

在蓝色低位发现了d9ff,这正好是jpg的文件尾反过来,save bin 下来,搜索d8ff,对应倒置的文件头

010editor有工具

需要安装

逆序后保存改为jpg后缀,得到图片

也可以使用脚本

1
2
3
4
5
6
7
8
input = open('D:\\new\\5', 'rb')
input_all = input.read()
ss = input_all[::-1]
output = open('m0re.jpg', 'wb')
output.write(ss)
input.close()
output.close()

Base64隐写

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25

import base64
path = input("请输入加密文件路径\n")
file = open(path)
a = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
aaa = ''
while True:
text = file.readline() # 只读取一行内容
# 判断是否读取到内容
text = text.replace("\n", "")
if not text:
break
if text.count('=') == 1:
aaa = aaa + \
str('{:02b}'.format((a.find(text[len(text)-2])) % 4))
if text.count('=') == 2:
aaa = aaa + \
str('{:04b}'.format((a.find(text[len(text)-3])) % 16))
file.close()
t = ""
ttt = len(aaa)
ttt = ttt//8*8
for i in range(0,ttt,8):
t = t + chr(int( aaa[i:i+8],2))
print(t)

StegSolve

两张图片拼接

提取http对象

把scanlines拖进stegsolve,在多个通道发现了一条横线

而logo正好缺了一段

使用stegsolve的图像结合

得到flag

添加文件头

文件属性藏信息

图片属性可以隐藏信息

outguess隐写

题目

https://buuoj.cn/challenges#[WUSTCTF2020]alison_likes_jojo

解题过程

binwalk分解boki.png得到压缩包,是真加密

尝试爆破

得到一段字符串

base64三次得到killerqueen

另一张图片是outguess隐写

打开flag1.txt文件

wctf2020{pretty_girl_alison_likes_jojo}

盲水印

BlindWaterMark

点阵提取

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# from PIL import Image
#
# img = Image.open('D:\\new\\cat.png')
# width, height = img.size
# pixs_list = []
# for w in range(5, width, 11):
# for h in range(5, height, 11):
# pix = img.getpixel((w, h))
# pixs_list.append(pix)
# #分解下pixs_list的长度,就可以得到生成图片的宽高
# new_width, new_height = 215, 215
# new_img = Image.new('RGB', (new_width, new_height))
# idx = 0
# for n_w in range(new_width):
# for n_h in range(new_height):
# new_img.putpixel((n_w, n_h), pixs_list[idx])
# idx += 1
# new_img.save('ok.png')
# new_img.show()
# from PIL import Image
#
# img = Image.open('ok.png')
# width, height = img.size
# pixs_list = []
# for w in range(2, width, 5):
# for h in range(2, height, 5):
# pix = img.getpixel((w, h))
# pixs_list.append(pix)
# #分解pixs_list的长度,
# new_width, new_height = 43, 43
# new_img = Image.new('RGB', (new_width, new_height))
# idx = 0
# for n_w in range(new_width):
# for n_h in range(new_height):
# new_img.putpixel((n_w, n_h), pixs_list[idx])
# idx += 1
# new_img.save('ok1.png')
# new_img.show()

from PIL import Image

img = Image.open('ok1.png')
if img.mode == "P":
img = img.convert("RGB")
assert img.size[0] == img.size[1]
dim = width, height = img.size

st = 1
a = 9
b = 39
for _ in range(st):
with Image.new(img.mode, dim) as canvas:
for nx in range(img.size[0]):
for ny in range(img.size[0]):
y = (ny - nx * a) % width
x = (nx - y * b) % height
canvas.putpixel((y, x), img.getpixel((ny, nx)))
canvas.show()
canvas.save('ok2.png')