去年我写了一篇哈希长度扩展攻击的简介以及HashPump安装使用方法,本来已经足够了,但HashPump还不是很完善的哈希长度扩展攻击,HashPump在使用的时候必须提供original_data,近来的哈希长度扩展攻击的题目已经不提供original_data,从原理上来说也不一定需要这个original_data,所以今年pcat又来写一篇hexpand的安装使用方法,鉴于时间关系,本人只在kali、Ubuntu14.04下测试。

--------------------------------------------------------------------

1. 安装pkg-config

https://pkg-config.freedesktop.org/releases/

目前最新版pkg-config-0.29.2.tar.gz

v=0.29.
wget https://pkg-config.freedesktop.org/releases/pkg-config-${v}.tar.gz
tar -xzvf pkg-config-${v}.tar.gz
cd pkg-config-${v}/
./configure --with-internal-glib && make && make install

2. 安装OpenSSL开发包

apt-get update
apt-get install -y libssl-dev

# 新版kali里这样安装openssl是不行的,参考下面第7点。

3. hexpand的安装

git clone https://github.com/amlweems/hexpand
cd hexpand
make

4. 报错Package openssl was not found in the pkg-config search path.

搜索本机pkgconfig文件夹的openssl.pc、libssl.pc、libcrypto.pc,并将这3个文件复制到/usr/lib/pkgconfig/(如果不存在就新建个)下,然后

export PKG_CONFIG_PATH=/usr/lib/pkgconfig:$PKG_CONFIG_PATH

再进去hexpand所在目录下进行hexpand的编译

5. 报错make: clang: Command not found

apt-get install clang

6. hexpand的使用方法

在hexpand所在目录(当然你也可以把文件复制到/usr/bin/里)

./hexpand -t md5 -s 21232f297a57a5a743894a0e4a801fc3 -l  -m "pcat"

其中-l的5是哈希原文的长度,运行后就会得到附加数据,以及新得到的哈希值。

7. Kali 2018.1等安装错误

-= 2018.08补充 =-

按以上的方法如果在Kali 2018.1或者别的版本上运行报错如下:

hexpand.c::: error: incomplete definition of type 'struct evp_md_ctx_st'
int length_modulo = mdctx->digest->block_size;
~~~~~^
/usr/include/openssl/ossl_typ.h::: note: forward declaration of 'struct evp_md_ctx_st'
typedef struct evp_md_ctx_st EVP_MD_CTX;
^
hexpand.c::: error: incomplete definition of type 'struct evp_md_ctx_st'
unsigned char* h_data = (unsigned char *)((SHA512_CTX *)mdctx->md_data)->h; ……

这个跟系统有关系,Kali每一次变化都很大。这个得更新到最新的OpenSSL

git clone https://github.com/PeterMosmans/openssl
cd openssl
./config && make && make test && make install

在最后的make install会看到

cp libcrypto.pc /usr/local/ssl/lib/pkgconfig
chmod /usr/local/ssl/lib/pkgconfig/libcrypto.pc
cp libssl.pc /usr/local/ssl/lib/pkgconfig
chmod /usr/local/ssl/lib/pkgconfig/libssl.pc
cp openssl.pc /usr/local/ssl/lib/pkgconfig
chmod /usr/local/ssl/lib/pkgconfig/openssl.pc

把这3个新的pc文件替换到/usr/lib/pkgconfig/下

cd /usr/local/ssl/lib/pkgconfig/ && cp openssl.pc libssl.pc libcrypto.pc /usr/lib/pkgconfig/

(注意,PKG_CONFIG_PATH环境变量要存在,可往上翻看第4点)

再进去hexpand文件夹下编译会报错:

hexpand.c::: error: format specifies type 'unsigned int' but the argument has type '__uint64_t' (aka 'unsigned long') [-Werror,-Wformat]
if (length_modulo == ) sprintf(output+*padding, "%032" PRIx32 , htole64(*length));
~~~~~~ ^~~~~~~~~~~~~~~~~
/usr/include/endian.h::: note: expanded from macro 'htole64'
# define htole64(x) __uint64_identity (x)
^~~~~~~~~~~~~~~~~~~~~
hexpand.c::: error: format specifies type 'unsigned int' but the argument has type '__uint64_t' (aka 'unsigned long') [-Werror,-Wformat]
else sprintf(output+*padding, "%016" PRIx32 ,htole64(*length));
~~~~~~ ^~~~~~~~~~~~~~~~~
/usr/include/endian.h::: note: expanded from macro 'htole64'
# define htole64(x) __uint64_identity (x)
^~~~~~~~~~~~~~~~~~~~~
errors generated.
Makefile:: recipe for target 'hexpand.o' failed

这个就是系统文件的问题了,我查阅了当前的/usr/include/endian.h

# define htole64(x) __uint64_identity (x)

而查阅老系统版本的/usr/include/endian.h

# define htole64(x) (x)

所以这个问题的暂时解决方法,修改下hexpand.c文件

sed -i 's/htole64(8\*length)/(8\*length)/g' hexpand.c

再进行编译,报错:

clang hexpand.o main.o -o hexpand  -L/usr/local/ssl/lib -lssl -lcrypto
/usr/local/ssl/lib/libcrypto.a(dso_dlfcn.o): In function `dlfcn_globallookup':
dso_dlfcn.c:(.text+0x11): undefined reference to `dlopen'
dso_dlfcn.c:(.text+0x24): undefined reference to `dlsym'
dso_dlfcn.c:(.text+0x2f): undefined reference to `dlclose'
/usr/local/ssl/lib/libcrypto.a(dso_dlfcn.o): In function `dlfcn_bind_func':
dso_dlfcn.c:(.text+0x374): undefined reference to `dlsym'
dso_dlfcn.c:(.text+0x432): undefined reference to `dlerror'
/usr/local/ssl/lib/libcrypto.a(dso_dlfcn.o): In function `dlfcn_bind_var':
dso_dlfcn.c:(.text+0x4a7): undefined reference to `dlsym'
dso_dlfcn.c:(.text+0x562): undefined reference to `dlerror'
/usr/local/ssl/lib/libcrypto.a(dso_dlfcn.o): In function `dlfcn_load':
dso_dlfcn.c:(.text+0x5c8): undefined reference to `dlopen'
dso_dlfcn.c:(.text+0x62d): undefined reference to `dlclose'
dso_dlfcn.c:(.text+0x665): undefined reference to `dlerror'
/usr/local/ssl/lib/libcrypto.a(dso_dlfcn.o): In function `dlfcn_pathbyaddr':
dso_dlfcn.c:(.text+0x701): undefined reference to `dladdr'
dso_dlfcn.c:(.text+0x75f): undefined reference to `dlerror'
/usr/local/ssl/lib/libcrypto.a(dso_dlfcn.o): In function `dlfcn_unload':
dso_dlfcn.c:(.text+0x7b2): undefined reference to `dlclose'
clang: error: linker command failed with exit code (use -v to see invocation)
Makefile:: recipe for target 'hexpand' failed

这也是新版OpenSSL的问题,只要加上-ldl -lpthread进行编译即可,编辑Makefile文件

sed -i 's/--libs openssl)/& -ldl -lpthread /g' Makefile

最后就可以顺利编译成功。

哈希长度扩展攻击(Hash Length Extension Attack)利用工具hexpand安装使用方法的更多相关文章

  1. 哈希长度扩展攻击的简介以及HashPump安装使用方法

    哈希长度扩展攻击(hash length extension attacks)是指针对某些允许包含额外信息的加密散列函数的攻击手段.该攻击适用于在消息与密钥的长度已知的情形下,所有采取了 H(密钥 ∥ ...

  2. hash长度扩展攻击

    这里面就放一张百度百科的解释吧,emmm 反正我是看不懂还是做一下题来巩固一下吧 CTF中的hash长度攻击 进入网页你会发现页面显示  我这里没有看到什么可以利用的,抓了一下包也没有什么有可以利 ...

  3. 实验吧_天下武功唯快不破&让我进去(哈希长度拓展攻击)

    天下武功唯快不破 第一反应就去抓包,看到返回包的header中有FLAG的值,base64解码后得到下图所示 这就要求我们在请求头中post相应key的值,我直接在burp中尝试了多次都没有用,想起来 ...

  4. MD5的Hash长度扩展攻击

    Hash长度扩展攻击 引子 无意中碰到一道题,大概代码是这样的 $flag = "XXXXXXXXXXXXXXXXXXXXXXX"; $secret = "XXXXXXX ...

  5. 实验吧——让我进去(hash长度扩展攻击)

    题目地址:http://ctf5.shiyanbar.com/web/kzhan.php 在页面源码没发现什么,于是用burp进行抓包重放 看到有setcookie,于是重新刷新页面拦截数据包(这次才 ...

  6. Hash Length Extension Attacks

    catalogue . Hash函数的内部原理 . 漏洞原理 1. Hash函数的内部原理 0x1: 分组.Padding 哈希函数以区块为单位操作数据.比如说,MD5, SHA1, SHA256的区 ...

  7. 实验吧Web-中-让我进去(Hash长度扩展攻击、加盐密码及Linux下hashpump的安装使用)

    打开网页,测试开始,注入费老大劲,看了大佬的blog才知道怎么干. bp抓包,观察发现cookie中有个source=0,在repeater中修改为source=1,然go一下,出来了一段源代码. $ ...

  8. 哈希长度拓展攻击之De1CTF - SSRF Me

    题目考查:python代码审计.hash长度拓展攻击 0x01 题目源码: #! /usr/bin/env python #encoding=utf-8 from flask import Flask ...

  9. [De1CTF 2019]SSRF Me-MD5长度扩展攻击&CVE-2019-9948

    0x00 打开题目查看源代码,开始审计 这里贴上网上师傅的博客笔记: https://xz.aliyun.com/t/6050 #! /usr/bin/env python #encoding=utf ...

随机推荐

  1. javascript入门篇(二)

    对   象 对象:一组元素的集合 声明方式:字面量方式 var O = { } 构造函数方式:var obj  =  new object(); 为对象添加新属性,如:o.name = 'jerry' ...

  2. 图解ARP协议(二)ARP攻击原理与实践

    一.ARP攻击概述 在上篇文章里,我给大家普及了ARP协议的基本原理,包括ARP请求应答.数据包结构以及协议分层标准,今天我们继续讨论大家最感兴趣的话题:ARP攻击原理是什么?通过ARP攻击可以做什么 ...

  3. 痞子衡嵌入式:飞思卡尔i.MX RT系列MCU启动那些事(6)- Bootable image格式与加载(elftosb/.bd)

    大家好,我是痞子衡,是正经搞技术的痞子.今天痞子衡给大家介绍的是飞思卡尔i.MX RT系列MCU的Bootable image格式与加载过程. 在i.MXRT启动系列第三篇文章 Serial Down ...

  4. Leetcode 第133场周赛解题报告

    今天参加了leetcode的周赛,算法比赛,要求速度比较快.有思路就立马启动,不会纠结是否有更好的方法或代码可读性.只要在算法复杂度数量级内,基本上是怎么实现快速就怎么来了. 比赛时先看的第二题,一看 ...

  5. 逐步搭建vs2015的API自带认证调用+跨域调用

    demo百度网盘链接:https://pan.baidu.com/s/1HJ19RJwS6qCixui8KF8QBg 提取码:yt1c 首先我们建立一个webapi项目,这个就不需要小编解释了.如下图 ...

  6. 大前端的自动化工厂(2)—— SB Family

    原文链接:https://bbs.huaweicloud.com/blogs/53c0c3509b7a11e89fc57ca23e93a89f 我坦白我是标题党,SB只是SCSS-Bourbon的简写 ...

  7. Selenium自动化-调用Mysql数据库

    上几篇博客发布了几篇Selenium入门知识和进阶, 现在附上如何 从数据库中取值 能够逐行取值,并且返回二维数组 import java.io.FileInputStream; import jav ...

  8. gulp前端自动化构建并上传oss

    前言 前端自动化构建工具从最开始的grunt, gulp, fis等到现在比较流行的webpack可谓层出不穷,个人还是比较倾向于gulp,虽然有的时候会因为某个插件的配置问题头疼很久,但不可否认gu ...

  9. Python进阶之面向对象编程

    面向对象编程——Object Oriented Programming,简称OOP,是一种程序设计思想.OOP把对象作为程序的基本单元,一个对象包含了数据和操作数据的函数. 面向过程的程序设计把计算机 ...

  10. 使用Python下载工具you-get下载媒体文件

    You-Get是一个基于 Python 3 的下载工具.使用 You-Get 可以很轻松的下载到网络上的视频.图片及音乐. 使用you-get下载媒体文件 1.安装Python(步骤详情见另一篇文章) ...