BST:一款功能强大的二进制字符串代码格式转换工具

admin 2024年4月12日23:52:55评论12 views字数 2747阅读9分9秒阅读模式
BST:一款功能强大的二进制字符串代码格式转换工具
关于BST

BST是一款功能强大的二进制字符串代码格式转换工具,该工具可以将二进制字符串转换为能够兼容不同语言源代码的各种格式,以满足各种安全开发领域中的渗透测试或漏洞利用开发场景。

BST:一款功能强大的二进制字符串代码格式转换工具
功能介绍
1、将二进制文件转换并转储为二进制字符串格式的标准输出;
2、将纯十六进制输入字符串转换为十六进制转义版本;
3、支持生成字符串序列,用于检测缓冲区中的字符;
4、限制二进制字符串的宽度以提高漏洞利用代码的可读性;
5、使用不同的编程语言或脚本语言来设置二进制字符串的格式,例如C/C++、Python和PowerShell;
6、执行自动化可变代码块缩进,以方便代码的复制/粘贴;
依赖组件

1、POSIX C库;

2、C编译器:GCC、LLVM Clang;

3、GNU Make;

4、Git;

工具下载&配置

广大研究人员可以直接使用下列命令将该项目源码克隆至本地:

$ git clone https://github.com/e3prom/bst

然后切换到项目目录中,使用make命令完成项目代码构建,默认配置下BST将会安装在“/usr/local/bin”路径下:

$ cd bst$ make$ sudo make install
工具使用

下列命令可以查看工具的帮助信息:

$ bstrings --helpUsage: bstrings [OPTION]... Convert input to specified binary string format. At least one of the below options must be given:    -D, --dump-file=FILE    恢复和转储文件元数据内容    -x, --hex-escape        转义输入十六进制字符串    -b, --gen-badchar       生成一个恶意序列字符串 The below switches are optional:    -f, --file=FILE            从文件读取十六进制输入    -w, --width=BYTES       将二进制字符串按指定字节长度拆分    -s, --syntax=LANG        使用指定编程语言语句输出变量    -i, --indent=LENGTH      对给定的字符长度执行缩进    -n, --var-name=VAR      指定字符串变量名(Verbose模式)    -h, --help              显示工具帮助信息       --interactive         进入交互式模式       --verbose           启用Verbose输出       --version            打印工具版本信息 The below languages are supported (case-sensitive):    C                       C语言    python                  Python语言    powershell              PowerShell自动化脚本语言

在下面的演示样例中,我们将使用BST来编译Shellcode,示例中使用Python语法格式和4个空格字符的代码缩进级别,并将Shellcode转储(-D)为十六进制转义(-x)二进制字符串的标准输出,字符长度为8字节:

$ bstrings --verbose -x -D lnx-execve-setreuid-x86_64 -w8 -i 4 --syntax=python[*] Convert hexadecimal input to an escaped binary string.[+] Binary string width is limited to 8 bytes.[+] Output binary string using python language syntax.[+] Indentation level set to 4 space character(s).    shellcode =  ""    shellcode += "x31xc0x48x89xc7x48x89xc6"    shellcode += "x48x89xc2xb0x71x0fx05x31"    shellcode += "xc0x50x48xbbx2fx62x69x6e"    shellcode += "x2fx2fx73x68x53x48x89xe7"    shellcode += "x50x48x89xe6x57x48x89xe2"shellcode += "xb0x3bx0fx05"

我们还可以使用BST以我们熟悉的编程语言代码格式自动化输出恶意字符序列:

$ bstrings --verbose -b -w12 -i 4 --syntax=c -n badchar[*] Generating bad character binary string.[+] Binary string width is limited to 12 bytes.    unsigned char badchar[] =        "x01x02x03x04x05x06x07x08x09x0ax0bx0c"        "x0dx0ex0fx10x11x12x13x14x15x16x17x18"        "x19x1ax1bx1cx1dx1ex1fx20x21x22x23x24"        "x25x26x27x28x29x2ax2bx2cx2dx2ex2fx30"        "x31x32x33x34x35x36x37x38x39x3ax3bx3c"        "x3dx3ex3fx40x41x42x43x44x45x46x47x48"        "x49x4ax4bx4cx4dx4ex4fx50x51x52x53x54"        "x55x56x57x58x59x5ax5bx5cx5dx5ex5fx60"        "x61x62x63x64x65x66x67x68x69x6ax6bx6c"        "x6dx6ex6fx70x71x72x73x74x75x76x77x78"        "x79x7ax7bx7cx7dx7ex7fx80x81x82x83x84"        "x85x86x87x88x89x8ax8bx8cx8dx8ex8fx90"        "x91x92x93x94x95x96x97x98x99x9ax9bx9c"        "x9dx9ex9fxa0xa1xa2xa3xa4xa5xa6xa7xa8"        "xa9xaaxabxacxadxaexafxb0xb1xb2xb3xb4"        "xb5xb6xb7xb8xb9xbaxbbxbcxbdxbexbfxc0"        "xc1xc2xc3xc4xc5xc6xc7xc8xc9xcaxcbxcc"        "xcdxcexcfxd0xd1xd2xd3xd4xd5xd6xd7xd8"        "xd9xdaxdbxdcxddxdexdfxe0xe1xe2xe3xe4"        "xe5xe6xe7xe8xe9xeaxebxecxedxeexefxf0"        "xf1xf2xf3xf4xf5xf6xf7xf8xf9xfaxfbxfc"        "xfdxfexff"
许可证协议

本项目的开发与发布遵循GPL-2.0开源许可证协议。

项目地址

BST:

https://github.com/e3prom/bst

原文始发于微信公众号(FreeBuf):BST:一款功能强大的二进制字符串代码格式转换工具

 

  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2024年4月12日23:52:55
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   BST:一款功能强大的二进制字符串代码格式转换工具http://cn-sec.com/archives/2653624.html

发表评论

匿名网友 填写信息