steghide是一個隱寫術軟件,可以在圖片、音頻等文件里隱藏數據。
鑒於原始的steghide在解密數據時不能選擇字典文件破解,於是本人就用python簡單地為其實現字典破解功能。
----------
1、安裝steghide
*由於steghide太老了,不建議源碼安裝,我嘗試在Kali、Ubuntu上安裝各種失敗,github上那個實現-pf字典文件破解的項目安裝源碼也是失敗。(當然如果你有好法子,煩請不吝賜教。)
linux安裝法子:
apt-get install steghide
windows安裝法子:
打開https://sourceforge.net/projects/steghide/ 下載steghide-0.5.1-win32.zip,解壓后就可以用。
2、steghide的使用方法
steghide --help
steghide info FILENAME
steghide embed -cf COVERFILE -ef EMBEDFILE
steghide extract -sf STEGOFILE
3、實現字典破解功能
這里以一個實驗吧的隱寫題為例,里面的rose.jpg是用steghide加上一個密碼來隱藏數據的,而這個密碼我們不知道,所以只能爆破。
這里我用AAPR(Advanced Archive Password Recovery)軟件里的english.dic作為這次破解需要的字典文件(你們也可以准備別的字典,這題密碼很簡單的)
指定輸出的文件為hide.txt(要求該文件不存在於本文件夾內,因為若是存在,會提示覆蓋,但是我嘗試Popen的交互模式總無法把y傳遞到steghide里,如果有朋友能弄出,請多多指教。)
# -*- coding: utf8 -*- #author:pcat #http://pcat.cnblogs.com from subprocess import * def foo(): stegoFile='rose.jpg' extractFile='hide.txt' passFile='english.dic' errors=['could not extract','steghide --help','Syntax error'] cmdFormat='steghide extract -sf "%s" -xf "%s" -p "%s"' f=open(passFile,'r') for line in f.readlines(): cmd=cmdFormat %(stegoFile,extractFile,line.strip()) p=Popen(cmd,shell=True,stdout=PIPE,stderr=STDOUT) content=unicode(p.stdout.read(),'gbk') for err in errors: if err in content: break else: print content, print 'the passphrase is %s' %(line.strip()) f.close() return if __name__ == '__main__': foo() print 'ok' pass
*在windows里除非把steghide所在文件夾加入系統變量Path里,否則上面py代碼文件、rose.jpg、english.dic得放在steghide所在文件夾里。
*本程序在windows和linux都可以使用。
