steghide的安装使用方法以及实现字典破解功能

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都可以使用。

 

posted @ 2016-05-17 21:24  pcat  阅读(11653)  评论(0编辑  收藏  举报