Giter Site home page Giter Site logo

armijnhemel / binaryanalysis-ng Goto Github PK

View Code? Open in Web Editor NEW
460.0 26.0 66.0 51.66 MB

Binary Analysis Next Generation (BANG)

License: GNU Affero General Public License v3.0

Python 42.21% Dockerfile 0.03% Shell 0.15% Nix 0.26% Makefile 0.06% Kaitai Struct 33.87% YARA 0.78% Cypher 22.63% CSS 0.01%
compliance reverseengineering licensecompliance security

binaryanalysis-ng's Introduction

binaryanalysis-ng

Binary Analysis Next Generation (BANG)

BANG is a framework for processing binary files (like firmware). It consists of an unpacker that recursively unpacks and classifies/labels files and separate analysis programs that work on the results of the unpacker.

Some intended uses:

  • provenance detection ("what is inside this file")
  • security scans ("are there any known security risks associated with this file")

Requirements

The recommended way is to use Nix, run nix-shell to load all the dependencies for the unpacker, nix-shell maintenance.nix for the maintenance scripts, nix-shell analysis.nix for the analysis scripts and nix-shell scraper.nix for the firmware scraper.

nix will make sure that everything is downloaded and installed to run BANG.

Other distributions without Nix

Note: this list is vastly incomplete. It is highly recommended to use Nix.

  • a recent Linux distribution (Fedora 36 or higher, or equivalent)
  • Python 3.10.x or higher
  • pillow (possibly named python3-pillow), a drop in replacement for PIL ( http://python-pillow.github.io/ )
  • GNU binutils (for 'ar')
  • squashfs-tools (for 'unsquashfs')
  • cabextract
  • 7z
  • e2tools (for 'e2ls' and 'e2cp')
  • zstd
  • python-lz4 (possibly named python3-lz4)
  • qemu-img (for VMDK files)
  • psycopg2 (possibly named python3-psycopg2)
  • python-snappy (possibly named python3-snappy)
  • python-tlsh (possibly named python3-tlsh)
  • dockerfile-parse (possibly named python3-dockerfile-parse)
  • openssl
  • rzip
  • lzop
  • defusedxml (possibly named python3-defusedxml)
  • icalendar (possibly named python3-icalendar)
  • pyyaml (possibly named python3-pyyaml)
  • ncompress
  • util-linux (for 'fsck.cramfs')
  • lz4 (for 'lz4c')
  • bzip3

and many others (see shell.nix, maintenance.nix and analysis.nix for a full list).

You will also need to install the Kaitai Struct compiler. This is described in the file doc/kaitai-struct.md.

Additionally install sasquatch:

https://github.com/devttys0/sasquatch

Supported hardware

It is assumed that BANG is run on little endian hardware (such as x86 or x86-64).

Verified unsupported distributions

  • Fedora 35 and earlier
  • Ubuntu 16.04 and lower (Python version too old)

This doesn't mean that newer versions of Ubuntu are supported, they just haven't been tested.

Docker container (recently untested, assume broken)

docker image build -t bang .
docker container run --rm -it bang

or from the src directory, type

make dockerbuild

Supported file types

The following files can be unpacked, or verified, including carving from a larger file, unless stated otherwise.

  1. WebP
  2. WAV
  3. ANI
  4. gzip
  5. LZMA
  6. XZ
  7. timezone files
  8. tar
  9. Apple Double encoded files
  10. ICC (colour profile)
  11. ZIP (store, deflate, bzip2, but lzma needs some more testing), also JAR, APK (possible with extra Android signing bytes) and other ZIP-based formats, dangling entries without a valid central directory
  12. U-Boot image
  13. XAR (no compression, gzip, bzip2, XZ, LZMA)
  14. ISO9660 (including RockRidge and zisofs)
  15. lzip
  16. WOFF (Web Open Font Format)
  17. TrueType fonts/sfnt-housed fonts
  18. OpenType fonts
  19. Vim swap files (whole file only)
  20. Android sparse data image (regular and Brotli compression, no bsdiff/imgdiff)
  21. Android backup files
  22. ICO (MS Windows icons)
  23. Chrome PAK (version 4 & 5, only if offset starts at 0)
  24. GNU message catalog
  25. RPM (gzip, XZ, bzip2, LZMA, zstd, not: delta RPM)
  26. AIFF/AIFF-C
  27. terminfo (little endian, regular and extended storage format, not extended number format)
  28. AU (Sun/NeXT audio)
  29. JFFS2 (uncompressed, zlib, rtime, lzo, LZMA from OpenWrt)
  30. CPIO (various flavours, little endian)
  31. Sun Raster files (standard type only)
  32. Intel Hex (text files only)
  33. Motorola SREC (text files only)
  34. Quicktime
  35. Android sparse image files
  36. Java class file
  37. Android Dex/Odex (not OAT, just carving)
  38. ELF
  39. SWF (uncompressed, zlib, LZMA)
  40. Android resource files (table type, but possibly not all types, binary XML)
  41. base64/32/16 (whole file)
  42. FLV (Macromedia Flash Video)
  43. Git index files
  44. JSON (whole file)
  45. D-Link ROMFS
  46. bzip2
  47. GIF (needs PIL)
  48. JPEG (needs PIL)
  49. Microsoft Cabinet archives (needs cabextract)
  50. RZIP (requires rzip)
  51. 7z (requires external tools), single frame(?)
  52. Windows Compiled HTML Help (needs external tools, version 3 only)
  53. Windows Imaging file format (needs external tools, single image only)
  54. ext2/3/4 (missing: symbolic link support)
  55. zstd (needs zstd package)
  56. SGI image files (needs PIL)
  57. Apple Icon Image (needs PIL)
  58. LZ4 (requires LZ4 Python bindings), LZ4 legacy (requires 'lz4c')
  59. VMware VMDK (needs qemu-img, whole file only)
  60. QEMU qcow2 (needs qemu-img, whole file only)
  61. VirtualBox VDI (needs qemu-img, whole file only, Oracle flavour only)
  62. XML (whole file)
  63. Snappy framing2 format (needs python-snappy)
  64. various certificates (PEM, private key, etc., needs openssl)
  65. lzop
  66. PNG/APNG (needs PIL)
  67. ar/deb (needs binutils)
  68. squashfs (using squashfs-tools), vendor specific exotic variants (using sasquatch)
  69. BMP (needs PIL)
  70. PDF (simple verification, no object streams, incremental updates at end of the file)
  71. GIMP brush (needs PIL)
  72. ZIM (Wikipedia archive format)
  73. MIDI
  74. Android tzdata
  75. Java key store (version 2 only)
  76. XG3D (proprietary file format from 3D Studio Max, labeling only)
  77. ACDB (audio callibration database, proprietary file format from Qualcomm, labeling only)
  78. Microsoft DirectDraw Surface (structure checks and very limited sanity checking)
  79. Khronos KTX files (version 1)
  80. Android verified boot image
  81. SQLite 3
  82. Linux flattened device tree
  83. Broadcom TRX
  84. Photoshop PSD (raw bytes and RLE encoding only)
  85. minidump files
  86. PPM files ('raw' PPM only)
  87. PGM files ('raw' PGM only)
  88. PBM files ('raw' PBM only)
  89. Android bootloader image for Qualcomm Snapdragon (MSM)
  90. Android bootloader image (also a Little Kernel based variant)
  91. Android bootloader image for Huawei devices
  92. FAT16 file systems (8.3 file names)
  93. Coreboot images
  94. Minix V1 file system (Linux variant)
  95. Unix compress (needs 'uncompress'), only if end of the file is compress'd data
  96. romfs
  97. cramfs (version 2 only)
  98. nb0 Android updates
  99. Quake PAK files
  100. Doom WAD files (IWAD only)
  101. Ambarella firmware files
  102. Ambarella romfs (used in Ambarella firmware files)
  103. bFLT
  104. UBI, fastmap not supported
  105. GRUB2 font files
  106. BitTorrent files (subset)
  107. pcapng (carving, structural checks, little endian only)
  108. pcap (carving, structural checks)
  109. serialized Java (block data only, carving, structural checks)
  110. mapsforge map files (very basic structural checks)
  111. Parrot PLF files
  112. PFS file system
  113. YAFFS2 (including inband tags)
  114. Qualcomm QCDT files
  115. Chrome extensions (.crx)
  116. Windows shell link file (.lnk)
  117. PCF fonts (that actually follow the specification, little endian only)
  118. DS_Store
  119. libminikin hyb text layout format
  120. Mozilla ARchive (.mar)
  121. OpenFst (subset, identification only)
  122. SELinux file context
  123. Ogg
  124. Allwinner images
  125. DFU (Device Firmware Upgrade)
  126. Key Character Map binary files
  127. USB Flashing Format (UF2)
  128. Android VDEX (identification only)
  129. SEAMA firmware files
  130. LLVM IR wrapper format (identification only)
  131. OpenWrt LXL firmware header
  132. Mediatek BootROM (header only)
  133. Rockchip RKFW and RKAF
  134. systemd journal files
  135. Rockchip rkboot
  136. Python pickle
  137. glibc utmp/wtmp
  138. Android vendor boot
  139. Android FBPK
  140. Samsung Tzar
  141. Qualcomm aboot (version 3 only, no unified boot)
  142. Rockchip resource files
  143. Socionext Milbeaut firmware files
  144. zchunk
  145. ubifs
  146. Performance Co-Pilot metadata files
  147. data URI (PNG, GIF, JPEG, WEBP, certain fonts, SVG, PDF, JSON and octet-stream objects)
  148. DHTB signed files
  149. Android AAPT2 container format
  150. Android update image (version 2 only, full OTA image only)
  151. Qt resource files (.rcc)
  152. glibc locale archive file detection
  153. Sunplus BRN firmware
  154. xo65 object files
  155. DOS MZ, plus COFF for MS-DOS, DJGPP go32 DOS extender
  156. WinHelp (older formats only)
  157. PEF (Preferred Executable Format)
  158. Nano app header (Android)
  159. WebAssembly binaries
  160. Android super images
  161. Qualcomm QTI Chromatix (structural checks only)
  162. Mediatek images (including logo.bin)
  163. Android DTO
  164. Portable Image Format
  165. ResPack.cfg (seen in CPB firmware format)
  166. LOD (RDA/Coolsand phone firmware format)
  167. MediaTek secure ROM(?) info
  168. lrzip
  169. SerpentOS .stone package file
  170. systemd hwdb.bin
  171. Qt Translation files
  172. Reolink firmware
  173. Xiaomi firmware
  174. HP BDL firmware
  175. Netgear .chk firmware files
  176. Instar BNEG firmware files
  177. Huawei HWNP firmware files
  178. Reolink 'logo' file
  179. FLS firmware files (IP cameras)
  180. TP-Link TX6610v4 firmware
  181. Granite Devices firmware v300
  182. erofs
  183. bzip3
  184. PX4 autopilot firmware files
  185. SSH known hosts files (whole file)
  186. Unix passwd files (whole file)
  187. Unix group files (whole file)
  188. Unix shadow files (whole file)
  189. Samba password files
  190. Linux fstab files
  191. Java/Android MANIFEST.MF files (whole file)
  192. Linux kernel configuration files (whole file)
  193. pkg-config files
  194. iCalendar (RFC 5545) files (whole file only)
  195. Windows INI files (text only)
  196. Linux Software Map files
  197. exFAT ("no FAT chains" only)
  198. Subversion hash files (wcprops, all-wcprops, etc.)
  199. Python PKG-INFO files (whole file)
  200. Dockerfile files (whole file)
  201. TRANS.TBL files
  202. BTF and BTF.ext sections (BPF related)
  203. NibArchive
  204. EDID
  205. ld.so.conf files (subset, no include statements)
  206. old TP-Link firmware files
  207. certain VxWorks memfs file systems
  208. Realtek bootloader (subset of files)
  209. Linux kernel x86 images
  210. TP-Link minifs
  211. ANJVision IP camera firmware files
  212. Linux securetty files (whole file)

Getting started

This section assumes that you are using Nix to install all dependencies.

  1. git clone this repository
  2. run nix-shell to install all the dependencies and start a complete environment
  3. cd src
  4. run make to build all the Kaitai Struct parsers. Please note: this might take a while!

To unpack a file run (from the src directory):

$ python3 -m bang.cli scan -u /path/to/unpack/directory /path/to/binary

This will output a directory with inside a number of files and directories. The output directory can serve as input to the analysis scripts (and some knowledgebase scripts).

To process each file in a directory run (from the src directory):

$ python3 -m bang.cli scan-directory -u /path/to/unpack/directory /path/to/directory/with/binaries

This will create a directory with search results for each file that is scanned, with the same name as the file that is scanned, using the same structure as if the file was scanned in regular mode, not directory mode.

License

GNU Affero General Public License, version 3 (AGPL-3.0)

The code for verifying and labeling Android Verified Boot images was heavily inspired by code from Android (avbtool) found at:

https://android.googlesource.com/platform/external/avb/+/refs/heads/master/avbtool.py

The original license for avbtool:

Copyright 2016, The Android Open Source Project

Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use, copy,
modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

The code for rtime decompression was copied from:

https://github.com/sviehb/jefferson/blob/master/src/jefferson/rtime.py

The original license for jefferson:

The MIT License (MIT)

Copyright (c) 2015 Stefan Viehböck

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

Developing

The recommended coding style is described in PEP 8:

https://www.python.org/dev/peps/pep-0008/

It is recommended to run PEP 8 verification tools, for example python3-flake8 (on Fedora).

Another tool that is highly recommended is pylint.

Acknowledgement

This project has received funding from the European Union’s Horizon 2020 research and innovation programme within the framework of the NGI-POINTER Project funded under grant agreement No. 871528.

binaryanalysis-ng's People

Contributors

armijnhemel avatar kappapiana avatar oxr463 avatar timhemel avatar zimbatm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

binaryanalysis-ng's Issues

Re-engineering interest?

Are you interested perhaps in re-packing capabilities for reengineering?
Think e.g. round-tripping apk-s through apktool, repacking archives/installers after editing the contents, etc.

uncompress exception

I'm trying a program to explore the possibilities of scanning

[kea@localhost src]$ python3 ./bang-scanner -c ./bang.config -f ./openwrt-18.06.1-brcm2708-bcm2710-rpi-3-squashfs-factory.img.gz

and get errors

Process Process-4:
Traceback (most recent call last):
File "/home/kea/Загрузки/_soft/binaryanalysis/binaryanalysis-ng-master/src/ScanJob.py", line 673, in processfile scanjob.check_for_signatures(unpacker)
File "/home/kea/Загрузки/_soft/binaryanalysis/binaryanalysis-ng-master/src/ScanJob.py", line 297, in check_for_signatures signature, offset)
File "/home/kea/Загрузки/_soft/binaryanalysis/binaryanalysis-ng-master/src/Unpacker.py", line 198, in try_unpack_file_for_signatures return bangsignatures.signaturetofunction[signature](fileresult, scanenvironment, offset, self.dataunpackdirectory)
File "/home/kea/Загрузки/_soft/binaryanalysis/binaryanalysis-ng-master/src/bangunpack.py", line 12346, in unpack_compress p = subprocess.Popen(['uncompress'], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
File "/usr/lib64/python3.7/subprocess.py", line 775, in init restore_signals, start_new_session)
File "/usr/lib64/python3.7/subprocess.py", line 1522, in _execute_child raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'uncompress': 'uncompress'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/lib64/python3.7/multiprocessing/process.py", line 297, in _bootstrap self.run()
File "/usr/lib64/python3.7/multiprocessing/process.py", line 99, in run self._target(*self._args, **self._kwargs)
File "/home/kea/Загрузки/_soft/binaryanalysis/binaryanalysis-ng-master/src/ScanJob.py", line 745, in processfile raise ScanJobError(scanjob, e)
ScanJob.ScanJobError: Exception for scanjob:
file:
openwrt-18.06.1-brcm2708-bcm2710-rpi-3-squashfs-factory.img.gz-gzip-1/openwrt-18.06.1-brcm2708-bcm2710-rpi-3-squashfs-factory.img
labels:

Traceback (most recent call last):
File "/home/kea/Загрузки/_soft/binaryanalysis/binaryanalysis-ng-master/src/ScanJob.py", line 673, in processfile scanjob.check_for_signatures(unpacker)
File "/home/kea/Загрузки/_soft/binaryanalysis/binaryanalysis-ng-master/src/ScanJob.py", line 297, in check_for_signatures signature, offset)
File "/home/kea/Загрузки/_soft/binaryanalysis/binaryanalysis-ng-master/src/Unpacker.py", line 198, in try_unpack_file_for_signatures return bangsignatures.signaturetofunction[signature](fileresult, scanenvironment, offset, self.dataunpackdirectory)
File "/home/kea/Загрузки/_soft/binaryanalysis/binaryanalysis-ng-master/src/bangunpack.py", line 12346, in unpack_compress p = subprocess.Popen(['uncompress'], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
File "/usr/lib64/python3.7/subprocess.py", line 775, in init restore_signals, start_new_session)
File "/usr/lib64/python3.7/subprocess.py", line 1522, in _execute_child raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'uncompress': 'uncompress'

if interested, then this file https://cloud.mail.ru/public/4Znn/sNB3zAYja
openwrt-18.06.1-brcm2708-bcm2710-rpi-3-squashfs-factory.img.gz

merge scanning of various DOS/MZ/NE/PE files

there are various files that all have the same MZ signature. Right now BANG does not consistently unpack these: sometimes the PE unpacker is run first, sometimes the DOS MZ unpacker is run first. Merge these (as far as possible) so scanning is more consistent.

Open Source License scanning for Binary files

We installed BANG successfully and able to unpack binary files (.bin-flashwares).

But we are not able to locate result files for Open Source License scanning.
We see "LicenseIdentifierScanner.py" file in \src but not sure if it is called during unpacking or has to be called separately?

signature scanning behaviour for overlapping signatures

What is the expected behaviour for signature matching in the following situation?
signature = aba
string in which to search = abababc
There are three possibilities: position 0 only, position 2 only, or both positions. The current code picks the first alternative, but it might miss some signatures. Some signatures might overlap, e.g. ico and truetype combined with padding.

TypeError: invalid file: PosixPath('/root/tmp/bang-scan-r42t3f24/STARTED')

HI
I run bang-scanner for an error

root@ubuntu:/home/test/binaryanalysis-ng/src# python3 bang-scanner -c bang.config -f /home/test/Desktop/S29AL016D90-200000H.bin
Traceback (most recent call last):
File "bang-scanner", line 403, in
main(sys.argv)
File "bang-scanner", line 168, in main
startedfile = open(scandirectory / "STARTED", 'wb')
TypeError: invalid file: PosixPath('/root/tmp/bang-scan-r42t3f24/STARTED')
root@ubuntu:/home/test/binaryanalysis-ng/src#

VxWorks support

After cloning today from master and building the Docker container:

$ docker build -t bang
(...)
  python3-pytz-2018.5-1.fc29.noarch
  python3-webencodings-0.5.1-6.fc29.noarch
  yajl-2.1.0-11.fc29.x86_64

Complete!
Removing intermediate container 727e3b8f8134
 ---> 798710dfd0fb
Step 5/5 : CMD ["python3","bangshell"]
 ---> Running in de71b6f2177b
Removing intermediate container de71b6f2177b
 ---> eceae9b2e1dc
Successfully built eceae9b2e1dc
Successfully tagged bang:latest

Then inside the container itself interactively, bang-scanner does not seem to behave as specified in the README.md's invocation:

$ docker run -it bang /bin/bash
[root@b6cc367e62c7 bang]# ./src/bang-scanner
bash: ./src/bang-scanner: Permission denied
[root@b6cc367e62c7 src]# chmod +x bang-scanner
[root@b6cc367e62c7 src]# ./bang-scanner
Traceback (most recent call last):
  File "./bang-scanner", line 52, in <module>
    import elasticsearch
ModuleNotFoundError: No module named 'elasticsearch'

ext2 unpacking broken due to new e2tools

Since e2tools 0.1.0 the file mode is by default pretty printed with a 10 character string instead of numeric. There doesn't seem to be a way to get it in numeric.

new scanjob cannot process broken symbolic links

The new scanjob setup has a problem with broken links:

$ time python3 bang-scanner -c bang.config -f /tmp/TEW-636APB-1002.bin
Process Process-2:
Traceback (most recent call last):
File "/usr/lib64/python3.6/multiprocessing/process.py", line 258, in _bootstrap
self.run()
File "/usr/lib64/python3.6/multiprocessing/process.py", line 93, in run
self._target(*self._args, **self._kwargs)
File "bang-scanner", line 1120, in processfile
scanjob.check_for_signatures(unpacker, fileresult, scanfilequeue, scanenvironment, unpackdirectory, temporarydirectory)
File "bang-scanner", line 378, in check_for_signatures
j = ScanJob(pathlib.Path(unpackedfile), unpackedlabel, self.filename, [], {})
File "bang-scanner", line 107, in init
self._stat_file()
File "bang-scanner", line 119, in _stat_file
self.stat = os.stat(self.filename)
FileNotFoundError: [Errno 2] No such file or directory: '/home/armijn/tmp/bang-scan-2dchgsnf/unpack/TEW-636APB-1002.bin-squashfs-1/usr/sbin/rc'

This file is a broken symlink.

The init() method of the ScanJob class calls self.stat_file() which throws an exception.

creates a file of infinite size

I'm trying a program to explore the possibilities of scanning

[kea@localhost src]$ python3 ./bang-scanner -c ./bang.config -f ./fw-UR-825AC-12.11.15.bin

the program creates a file of infinite size ( I interrupted on a file size "sda" of 100GB )
bang-scan-ejl4sdbz/unpack/fw-UR-825AC-12.11.15.bin-0x0014c822-squashfs-1/dev/sda

if interested, then this file https://cloud.mail.ru/public/481V/5kbYd9dLz

ImportError: cannot import name 'cpio_new_ascii'

When I execute the following command, I report the following error. How can I solve it?

yqbboy@ubuntu:~/binaryanalysis-ng-master/src$ python3 bang-scanner -c bang.config -f /home/yq/samples/
/usr/lib/python3/dist-packages/requests/init.py:80: RequestsDependencyWarning: urllib3 (1.25.10) or chardet (3.0.4) doesn't match a supported version!
RequestsDependencyWarning)
Traceback (most recent call last):
File "bang-scanner", line 55, in
from bangsignatures import maxsignaturesoffset
File "/home/secneo/binaryanalysis-ng-master/src/bangsignatures.py", line 487, in
extension_to_unpackparser = get_unpackers_for_extensions()
File "/home/secneo/binaryanalysis-ng-master/src/bangsignatures.py", line 481, in get_unpackers_for_extensions
for u in get_unpackers():
File "/home/secneo/binaryanalysis-ng-master/src/bangsignatures.py", line 476, in get_unpackers
pathlib.Path(os.path.dirname(parsers.file)), pathlib.Path('.'))
File "/home/secneo/binaryanalysis-ng-master/src/bangsignatures.py", line 470, in _get_unpackers_recursive
unpackers_root, full_module_path ))
File "/home/secneo/binaryanalysis-ng-master/src/bangsignatures.py", line 461, in _get_unpackers_recursive
module = importlib.import_module(module_name)
File "/usr/lib/python3.6/importlib/init.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "/home/secneo/binaryanalysis-ng-master/src/parsers/archivers/cpio/UnpackParser.py", line 5, in
from . import cpio_new_ascii
ImportError: cannot import name 'cpio_new_ascii'

bang-scanner file name too long error

When I run the bang-scanner I get:

Traceback (most recent call last):
  File "/usr/src/bang/src/ScanJob.py", line 689, in processfile
    scanjob.carve_file_data(unpacker)
  File "/usr/src/bang/src/ScanJob.py", line 481, in carve_file_data
    outfile = open(outfile_full, 'wb')
OSError: [Errno 36] File name too long: '/usr/src/bang/src/unpacked/bang-scan-zzd2vg9u/unpack/firmware.bin-0x00000076-lz4-1/unpacked-from-lz4-0x00def93d-synthesized-3/unpacked-0xdef93d-0x109123c-0x00000000-synthesized-1/unpacked-0x0-0x2a1900-0x00000000-synthesized-1/unpacked-0x0-0x2a1900-0x00000000-synthesized-1/unpacked-0x0-0x2a1900-0x00000000-synthesized-1/unpacked-0x0-0x2a1900-0x00000000-synthesized-1/unpacked-0x0-0x2a1900-0x00000000-synthesized-1/unpacked-0x0-0x2a1900-0x00000000-synthesized-1/unpacked-0x0-0x2a1900-0x00000000-synthesized-1/unpacked-0x0-0x2a1900-0x00000000-synthesized-1/unpacked-0x0-0x2a1900-0x00000000-synthesized-1/unpacked-0x0-0x2a1900-0x00000000-synthesized-1/unpacked-0x0-0x2a1900-0x00000000-synthesized-1/unpacked-0x0-0x2a1900-0x00000000-synthesized-1/unpacked-0x0-0x2a1900-0x00000000-synthesized-1/unpacked-0x0-0x2a1900-0x00000000-synthesized-1/unpacked-0x0-0x2a1900-0x00000000-synthesized-1/unpacked-0x0-0x2a1900-0x00000000-synthesized-1/unpacked-0x0-0x2a1900-0x00000000-synthesized-1/unpacked-0x0-0x2a1900-0x00000000-synthesized-1/unpacked-0x0-0x2a1900-0x00000000-synthesized-1/unpacked-0x0-0x2a1900-0x00000000-synthesized-1/unpacked-0x0-0x2a1900-0x00000000-synthesized-1/unpacked-0x0-0x2a1900-0x00000000-synthesized-1/unpacked-0x0-0x2a1900-0x00000000-synthesized-1/unpacked-0x0-0x2a1900-0x00000000-synthesized-1/unpacked-0x0-0x2a1900-0x00000000-synthesized-1/unpacked-0x0-0x2a1900-0x00000000-synthesized-1/unpacked-0x0-0x2a1900-0x00000000-synthesized-1/unpacked-0x0-0x2a1900-0x00000000-synthesized-1/unpacked-0x0-0x2a1900-0x00000000-synthesized-1/unpacked-0x0-0x2a1900-0x00000000-synthesized-1/unpacked-0x0-0x2a1900-0x00000000-synthesized-1/unpacked-0x0-0x2a1900-0x00000000-synthesized-1/unpacked-0x0-0x2a1900-0x00000000-synthesized-1/unpacked-0x0-0x2a1900-0x00000000-synthesized-1/unpacked-0x0-0x2a1900-0x00000000-synthesized-1/unpacked-0x0-0x2a1900-0x00000000-synthesized-1/unpacked-0x0-0x2a1900-0x00000000-synthesized-1/unpacked-0x0-0x2a1900-0x00000000-synthesized-1/unpacked-0x0-0x2a1900-0x00000000-synthesized-1/unpacked-0x0-0x2a1900-0x00000000-synthesized-1/unpacked-0x0-0x2a1900-0x00000000-synthesized-1/unpacked-0x0-0x2a1900-0x00000000-synthesized-1/unpacked-0x0-0x2a1900-0x00000000-synthesized-1/unpacked-0x0-0x2a1900-0x00000000-synthesized-1/unpacked-0x0-0x2a1900-0x00000000-synthesized-1/unpacked-0x0-0x2a1900-0x00000000-synthesized-1/unpacked-0x0-0x2a1900-0x00000000-synthesized-1/unpacked-0x0-0x2a1900-0x00000000-synthesized-1/unpacked-0x0-0x2a1900-0x00000000-synthesized-1/unpacked-0x0-0x2a1900-0x00000000-synthesized-1/unpacked-0x0-0x2a1900-0x00000000-synthesized-1/unpacked-0x0-0x2a1900-0x00000000-synthesized-1/unpacked-0x0-0x2a1900-0x00000000-synthesized-1/unpacked-0x0-0x2a1900-0x00000000-synthesized-1/unpacked-0x0-0x2a1900-0x00000000-synthesized-1/unpacked-0x0-0x2a1900-0x00000000-synthesized-1/unpacked-0x0-0x2a1900-0x00000000-synthesized-1/unpacked-0x0-0x2a1900-0x00000000-synthesized-1/unpacked-0x0-0x2a1900-0x00000000-synthesized-1/unpacked-0x0-0x2a1900-0x00000000-synthesized-1/unpacked-0x0-0x2a1900-0x00000000-synthesized-1/unpacked-0x0-0x2a1900-0x00000000-synthesized-1/unpacked-0x0-0x2a1900-0x00000000-synthesized-1/unpacked-0x0-0x2a1900-0x00000000-synthesized-1/unpacked-0x0-0x2a1900-0x00000000-synthesized-1/unpacked-0x0-0x2a1900-0x00000000-synthesized-1/unpacked-0x0-0x2a1900-0x00000000-synthesized-1/unpacked-0x0-0x2a1900-0x00000000-synthesized-1/unpacked-0x0-0x2a1900-0x00000000-synthesized-1/unpacked-0x0-0x2a1900-0x00000000-synthesized-1/unpacked-0x0-0x2a1900-0x00000000-synthesized-1/unpacked-0x0-0x2a1900-0x00000000-synthesized-1/unpacked-0x0-0x2a1900-0x00000000-synthesized-1/unpacked-0x0-0x2a1900-0x00000000-synthesized-1/unpacked-0x0-0x2a1900-0x00000000-synthesized-1/unpacked-0x0-0x2a1900-0x00000000-synthesized-1/unpacked-0x0-0x2a1900-0x00000000-synthesized-1/unpacked-0x0-0x2a1900-0x00000000-synthesized-1/unpacked-0x0-0x2a1900-0x00000000-synthesized-1/unpacked-0x0-0x2a1900-0x00000000-synthesized-1/unpacked-0x0-0x2a1900-0x00000000-synthesized-1/unpacked-0x0-0x2a1900-0x00000000-synthesized-1/unpacked-0x0-0x2a1900-0x00000000-synthesized-1/unpacked-0x0-0x2a1900'


Is there a way to prevent this?

pillow checks throw errors

When scanning a JPEG file successfully the following is printed to the logs:

Error closing: 'NoneType' object has no attribute 'close'

This error message is coming from pillow and probably this is because of load() that is called unnecessarily and can likely be removed without affecting functionality.

bang-scanner gives: Base unpack directory /root/tmp does not exist, exiting

I used the Dockerfile to set up BANG and first, I couldn't figure out how to actually scan a file using the default bangshell. So instead, I modified the Dockerfile to just open up a bash instance and I'm trying to execute the following:

[root@0b7e5774a21c src]# python3 bang-scanner -c bang.config -f firmware.bin
I get:

Base unpack directory /root/tmp does not exist, exiting

At first, I thought this was due to where I had the . bin file but then I moved it to the current directory and I still get the error. In fact, I get it even if I just call python3 bang-scanner with no args at all.

What am I doing wrong? And Is there a way to do this from within the bangshell? Thanks!
Also note: root/tmp directory DOES exist...

python error

I've just been through the nix setup (ubuntu 23.04) and now at the stage of running for the first time, but i get the below error:

Are you able to expand on the usage info as there isn't much on the readme?
maybe some more examples or a yt video

thanks


[nix-shell:~/tools/binaryanalysis-ng]$ python3 -m bang.cli     
/nix/store/4agknr9yslk6rd1n5s45pgxlmpfb4vvq-python3-3.10.11-env/bin/python3.10: Error while finding module specification for 'bang.cli' (ModuleNotFoundError: No module named 'bang')

Docker issues

I tried to get binaryanalysis-ng working in docker. Here are the problems i encountered:

  1. The docker instructions in the README doesn't work
  2. In Dockerfile.kaitai the filename kaitai-struct-compiler-0.10-SNAPSHOT.zip is hardcoded but have since changed (same as issue #121 )
Step 7/12 : RUN unzip -d / jvm/target/universal/kaitai-struct-compiler-0.9-SNAPSHOT.zip
 ---> Running in b74c7540079c
unzip:  cannot find or open jvm/target/universal/kaitai-struct-compiler-0.9-SNAPSHOT.zip, jvm/target/universal/kaitai-struct-compiler-0.9-SNAPSHOT.zip.zip or jvm/target/universal/kaitai-struct-compiler-0.9-SNAPSHOT.zip.ZIP.
The command '/bin/sh -c unzip -d / jvm/target/universal/kaitai-struct-compiler-0.9-SNAPSHOT.zip' returned a non-zero code: 9
make: *** [Makefile:12: docker-kaitai] Error 9
  1. src/Makefile assumes that kaitai-struct-compiler is in PATH but it is not
Step 5/16 : RUN make
 ---> Running in b21cb46187e5
kaitai-struct-compiler  -t python --outdir `dirname "parsers/font/pcf/pcf_font.ksy"` parsers/font/pcf/pcf_font.ksy
/bin/sh: 1: kaitai-struct-compiler: not found
Makefile:25: recipe for target 'parsers/font/pcf/pcf_font.py' failed
make: *** [parsers/font/pcf/pcf_font.py] Error 127
The command '/bin/sh -c make' returned a non-zero code: 2
  1. src/Dockerfile assumes that bangshell is in the PATH which it is not
    python3: can't open file '/kaitai_struct/runtime/python/bangshell': [Errno 2] No such file or directory

I'm going to create a pull request that fixes these issues.

Besides that I think the following things could be changed:

  1. It's a little confusing that the makefile target is called "docker-kaitai" but the default value for "CTR_BUILDER" is not docker. Maybe podman and docker should just have different makefile targets instead of being dependent on the "CTR_BUILDER" variable.
  2. It's not clear how to invoke bang-scanner from the docker image.

css with non-printable characters is labeled 'text' and 'binary'

Steps to reproduce

load a css file with some non printable characters, my example had
['0xe2', '0x9e', '0x99'] in them.

Expected behaviour

file should have label the text, not binary

Observed behaviour

file has both text and binary as labels

Remarks

The extension unpacker adds the labels text and css, the IsTextComputer adds binary.
What is the correct labeling in this case?

Request for test corpus

Hi I am currently looking into the different unpackers of BANG. I notice that although BANG supports more than 100 different filetypes, only a few exists in the test directory. Do you have a test corpus of all the filetypes that BANG supports? If so, would you mind sharing the test corpus so I can also test BANG from my end? Thanks!

Release!

Can you tag a release and package it in nixpkgs?

Related to #26

"IndexError: list index out of range" and "Exceptions"

I'm trying a program to explore the possibilities of scanning

python3 ./bang-scanner -c ./bang.config -f ./gpt99_vfat16_sdb88.bin

and get errors

Process Process-2:
Traceback (most recent call last):
File "/home/kea/Загрузки/_soft/binaryanalysis/binaryanalysis-ng-master/src/ScanJob.py", line 673, in processfile scanjob.check_for_signatures(unpacker)
File "/home/kea/Загрузки/_soft/binaryanalysis/binaryanalysis-ng-master/src/ScanJob.py", line 297, in check_for_signatures signature, offset)
File "/home/kea/Загрузки/_soft/binaryanalysis/binaryanalysis-ng-master/src/Unpacker.py", line 198, in try_unpack_file_for_signatures return bangsignatures.signaturetofunction[signature](fileresult, scanenvironment, offset, self.dataunpackdirectory)
File "/home/kea/Загрузки/_soft/binaryanalysis/binaryanalysis-ng-master/src/bangfilesystems.py", line 3032, in unpack_fat chainindex = clustervals[chainindex]
IndexError: list index out of range

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/lib64/python3.7/multiprocessing/process.py", line 297, in _bootstrap self.run()
File "/usr/lib64/python3.7/multiprocessing/process.py", line 99, in run self._target(*self._args, **self._kwargs)
File "/home/kea/Загрузки/_soft/binaryanalysis/binaryanalysis-ng-master/src/ScanJob.py", line 745, in processfile raise ScanJobError(scanjob, e)

ScanJob.ScanJobError: Exception for scanjob:
file:
gpt99_vfat16_sdb88.bin
labels: root
Traceback (most recent call last):
File "/home/kea/Загрузки/_soft/binaryanalysis/binaryanalysis-ng-master/src/ScanJob.py", line 673, in processfile scanjob.check_for_signatures(unpacker)
File "/home/kea/Загрузки/_soft/binaryanalysis/binaryanalysis-ng-master/src/ScanJob.py", line 297, in check_for_signatures signature, offset)
File "/home/kea/Загрузки/_soft/binaryanalysis/binaryanalysis-ng-master/src/Unpacker.py", line 198, in try_unpack_file_for_signatures return bangsignatures.signaturetofunction[signature](fileresult, scanenvironment, offset, self.dataunpackdirectory)
File "/home/kea/Загрузки/_soft/binaryanalysis/binaryanalysis-ng-master/src/bangfilesystems.py", line 3032, in unpack_fat chainindex = clustervals[chainindex]
IndexError: list index out of range

if interested, then this file https://cloud.mail.ru/public/5MZc/4GfiFTVwq

gpt99_vfat16_sdb88.zip

configparser and nix don't cooperate well

When building the environment with nix-shell and then launching bang-scanner an error is thrown:

Traceback (most recent call last):
  File "bang-scanner", line 414, in <module>
    main(sys.argv)
  File "bang-scanner", line 87, in main
    options = BangScannerOptions().get()
  File "/home/armijn/tmp/binaryanalysis-ng/src/bangscanneroptions.py", line 43, in __init__
    self._read_configuration_file()
  File "/home/armijn/tmp/binaryanalysis-ng/src/bangscanneroptions.py", line 127, in _read_configuration_file
    self.config = configparser.ConfigParser(os.environ)
  File "/nix/store/yl69v76azrz4daiqksrhb8nnmdiqdjg9-python3-3.8.8/lib/python3.8/configparser.py", line 639, in __init__
    self._read_defaults(defaults)
  File "/nix/store/yl69v76azrz4daiqksrhb8nnmdiqdjg9-python3-3.8.8/lib/python3.8/configparser.py", line 1219, in _read_defaults
    self.read_dict({self.default_section: defaults})
  File "/nix/store/yl69v76azrz4daiqksrhb8nnmdiqdjg9-python3-3.8.8/lib/python3.8/configparser.py", line 752, in read_dict
    raise DuplicateOptionError(section, key, source)
configparser.DuplicateOptionError: While reading from '<dict>': option 'shell' in section 'DEFAULT' already exists

The bangscanneroptions.py code does the following:

self.config = configparser.ConfigParser(os.environ)

os.environ has an environment variable SHELL. The nix-shell command introduces a variable 'shell' to the environment. These conflict as configparser first lowercases everything before adding it to a ConfigParser instance.

Proposal: rewrite to something using YAML or so.

BANG no longer works with squashfs 4.4

squashfs 4.4 treats non-fatal errors the same as fatal errors and always exits with 1. In case a squashfs file system has files that cannot be unpacked, but which are irrelevant, such as device files, pipes, etc. then unsquashfs will exit with 1 which BANG will treat as an error although.

Newer versions of squashfs have a workaround, see plougher/squashfs-tools#94

Container depends on unspecified kaitai image

docker image build -t bang .
Sending build context to Docker daemon  2.027MB
Step 1/16 : FROM kaitai as builder
pull access denied for kaitai, repository does not exist or may require 'docker login': denied: requested access to the resource is denied
Makefile:52: recipe for target 'ctrbuild' failed
make: *** [ctrbuild] Error 1

I tried a few Docker images for kaitai:

  • blacktop/kaitai only provides 0.8
  • librespace/kaitai does not contain /kaitai_struct
  • kaitai/ksv also does not contain /kaitai_struct

So where does the kaitai image come from?

MBR image not properly detected (no unpacker?)

My test file openwrt-18.06.1-brcm2708-bcm2710-rpi-3-ext4-sysupgrade.img.gz contains an image, which file identifies as MBR image:

$ file openwrt-18.06.1-brcm2708-bcm2710-rpi-3-ext4-sysupgrade.img
openwrt-18.06.1-brcm2708-bcm2710-rpi-3-ext4-sysupgrade.img: DOS/MBR boot sector; partition 1 : ID=0xc, active, start-CHS (0x20,2,3), end-CHS (0xc3,0,12), startsector 8192, 40960 sectors; partition 2 : ID=0x83, start-CHS (0xe3,2,15), end-CHS (0x14,0,16), startsector 57344, 524288 sectors

Bang does not find it. It mistakenly identifies a FAT filesystem because it recognizes the magic number for MBR \x55\xaa. As a result, bang is trying many other filetypes and clutters the unpack directory.

There should be an unpacker for MBR images.

human readable reporting broken

$ python3 bang-scanner -f /tmp/test.wad
Traceback (most recent call last):
File "bang-scanner", line 414, in
main(sys.argv)
File "bang-scanner", line 380, in main
HumanReadableReporter(reportfile).report(scanresult)
File "/home/armijn/tmp/binaryanalysis-ng/src/reporter/humanreadablereport.py", line 101, in report
s += self._fileunpackedfiles(fn)
File "/home/armijn/tmp/binaryanalysis-ng/src/reporter/humanreadablereport.py", line 65, in _fileunpackedfiles
l['offset'], l['type'], " ".join(sorted(l['files']))
TypeError: sequence item 0: expected str instance, PosixPath found

android_sparse_data: not working well with multiple threads

There is a race condition that affects the android_sparse_data unpacker: successful unpacking of this format depends on the presence of other files (such as .transferlist). Since files are yielded by the other unpackers it could happen that the main file has already been yielded and in the scan queue, but that the transferlist file has not been yielded yet or is empty. This does not happen when running with a single thread.

Issue Building with Docker

Upon Running docker image build -t bang . I get the following error:

> docker image build -t bang .
[+] Building 2.0s (5/5) FINISHED
 => [internal] load build definition from Dockerfile                                                                                                                                                         0.0s 
 => => transferring dockerfile: 1.24kB                                                                                                                                                                       0.0s 
 => [internal] load .dockerignore                                                                                                                                                                            0.1s 
 => => transferring context: 45B                                                                                                                                                                             0.0s 
 => CANCELED [internal] load metadata for docker.io/library/fedora:33                                                                                                                                        1.9s 
 => ERROR [internal] load metadata for docker.io/library/kaitai:latest                                                                                                                                       1.9s 
 => [auth] library/kaitai:pull token for registry-1.docker.io                                                                                                                                                0.0s 

 > [internal] load metadata for docker.io/library/kaitai:latest:

failed to solve with frontend dockerfile.v0: failed to create LLB definition: pull access denied, repository does not exist or may require authorization: server message: insufficient_scope: authorization failed

I have authenticated to Docker Hub, so I'm not sure where the issue is stemming from here. I am running this on a Debian system under WSL2.

logging errors when files have non-unicode character file names

Error with Python's testtar.tar archive:

$ python3 bang-scanner -f /tmp/testtar.tar
--- Logging error ---
Traceback (most recent call last):
  File "/usr/lib64/python3.9/logging/__init__.py", line 1082, in emit
    stream.write(msg + self.terminator)
UnicodeEncodeError: 'utf-8' codec can't encode characters in position 50-56: surrogates not allowed
Call stack:
  File "/home/armijn/tmp/binaryanalysis-ng/src/bang-scanner", line 414, in <module>
    main(sys.argv)
  File "/home/armijn/tmp/binaryanalysis-ng/src/bang-scanner", line 294, in main
    process.start()
  File "/usr/lib64/python3.9/multiprocessing/process.py", line 121, in start
    self._popen = self._Popen(self)
  File "/usr/lib64/python3.9/multiprocessing/context.py", line 224, in _Popen
    return _default_context.get_context().Process._Popen(process_obj)
  File "/usr/lib64/python3.9/multiprocessing/context.py", line 277, in _Popen
    return Popen(process_obj)
  File "/usr/lib64/python3.9/multiprocessing/popen_fork.py", line 19, in __init__
    self._launch(process_obj)
  File "/usr/lib64/python3.9/multiprocessing/popen_fork.py", line 71, in _launch
    code = process_obj._bootstrap(parent_sentinel=child_r)
  File "/usr/lib64/python3.9/multiprocessing/process.py", line 315, in _bootstrap
    self.run()
  File "/usr/lib64/python3.9/multiprocessing/process.py", line 108, in run
    self._target(*self._args, **self._kwargs)
  File "/home/armijn/tmp/binaryanalysis-ng/src/ScanJob.py", line 694, in processfile
    scanjob.check_entire_file(unpacker)
  File "/home/armijn/tmp/binaryanalysis-ng/src/ScanJob.py", line 556, in check_entire_file
    log(logging.DEBUG, "TRYING %s %s at offset: 0" %
  File "/home/armijn/tmp/binaryanalysis-ng/src/banglogging.py", line 7, in log
    logging.log(level, message)
Message: 'TRYING testtar.tar-0x00000000-tar-1/ustar/umlauts-\udcc4\udcd6\udcdc\udce4\udcf6\udcfc\udcdf script at offset: 0'

Invocation instructions should specify expected result

Hi, I am trying to get BANG to work, believing that it's a tool that could be very useful, but I have not had a lot of success with it yet.

  1. The first invocation on a large (saved) docker image led to a lot of output, but then BANG would apparently hang. (I may open a separate issue about this.)
  2. I then tried with a much smaller, simpler docker image, and got no errors and no hang. Yet… I wonder what I output I should expect, and where? (There are only lines that look like filenames / image contents.) I could not find any created log file or report, for instance.

Since I used the command listed in the README, I would suggest to put a sentence below that (in the "Invocation" section) what kind of output one should expect.

Any usage?

what should I do after nix-shell is ready?

When I run "python3 -m bang.cli scan -u xxx xxx", It shows error: Error while finding module specification for 'bang.cli' (ModuleNotFoundError: No module named 'bang')

Execution of `nix-shell analysis.nix` fails

I'm trying out BANG for the first time. Executing nix-shell analysis.nix results in the following error message:

error: file 'nixpkgs' was not found in the Nix search path (add it using $NIX_PATH or -I)

I'm using an Ubuntu 22.04.2 LTS.

AttributeError: type object 'CyOpenGL.vector3' has no attribute '__reduce_cython__'

(venv) freedom@freedom-virtual-machine:~/project/newbinaryscan/binaryanalysis-ng/src$ sudo /home/freedom/project/newbinaryscan/venv/bin/python bang-scanner -c bang.config -f test/testdata/unpackers/
Traceback (most recent call last):
  File "bang-scanner", line 55, in <module>
    from bangsignatures import maxsignaturesoffset
  File "/home/freedom/project/newbinaryscan/binaryanalysis-ng/src/bangsignatures.py", line 27, in <module>
    import bangandroid
  File "/home/freedom/project/newbinaryscan/binaryanalysis-ng/src/bangandroid.py", line 37, in <module>
    import bangunpack
  File "/home/freedom/project/newbinaryscan/binaryanalysis-ng/src/bangunpack.py", line 58, in <module>
    import snappy
  File "/home/freedom/project/newbinaryscan/venv/lib/python3.6/site-packages/snappy/__init__.py", line 7, in <module>
    from .SnapPy import (AbelianGroup, HolonomyGroup, FundamentalGroup,
  File "cython/core/basic.pyx", line 45, in init SnapPy
  File "/home/freedom/project/newbinaryscan/venv/lib/python3.6/site-packages/snappy/horoviewer.py", line 3, in <module>
    from .CyOpenGL import (HoroballScene, OpenGLOrthoWidget,
  File "opengl/CyOpenGL.pyx", line 38, in init CyOpenGL
AttributeError: type object 'CyOpenGL.vector3' has no attribute '__reduce_cython__'
(venv) freedom@freedom-virtual-machine:~/project/newbinaryscan/binaryanalysis-ng/src$ 

python3.6.9
ubuntu18.04

JSON reporting seems to be broken

I am getting this after setting json = yes in my config:

Traceback (most recent call last):
  File "bang-scanner", line 414, in <module>
    main(sys.argv)
  File "bang-scanner", line 374, in main
    JsonReporter(jsonfile).report(scanresult)
  File "/home/hmeine/tmp/tern-test/binaryanalysis-ng/src/JsonReporter.py", line 43, in report
    for a, h in fileresult.get_hashresult().items():
AttributeError: 'dict' object has no attribute 'get_hashresult'

Organize an own repo with KS specs

It is a bit problematic to see all the specs in this repo when they reside in different branches. So I propose to organize an own separate repo mirroring kaitai_struct_formats (ksf) structure (so its contents can be copied over it (except the dotted dirs, of course) for the specs not yet merged into ksf.

Probably it may make sense to create an org first and move this repo into it.

nix-shell error

[davidak@ethmoid:~/code/binaryanalysis-ng]$ nix-shell 
error: undefined variable 'dockerfile-parse' at /home/davidak/code/binaryanalysis-ng/shell.nix:6:5
(use '--show-trace' to show detailed location information)

On which channel are you on?


  • system: "x86_64-linux"
  • host os: Linux 4.19.49, NixOS, 19.03.172866.4649b6ef4b5 (Koi)
  • multi-user?: yes
  • sandbox: yes
  • version: nix-env (Nix) 2.2.2
  • channels(root): "nixos-19.03.172979.8634c3b6199, nixos-hardware, nixos-unstable-19.09pre183392.83ba5afcc96"
  • nixpkgs: /nix/var/nix/profiles/per-user/root/channels/nixos

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.