binaryanalysis-ng icon indicating copy to clipboard operation
binaryanalysis-ng copied to clipboard

Issue Building with Docker

Open djmccarthy12 opened this issue 4 years ago • 6 comments

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.

djmccarthy12 avatar May 06 '21 13:05 djmccarthy12

It's because you need to build the kaitai docker image in the util folder locally. I updated the README intructions and included fixes for other problems you will run into afterwards in #141.

seihtam avatar May 07 '21 10:05 seihtam

Thanks, I went ahead and installed podman, and made the other handful of changes in #141, however I am still running into a different issue now while building the Kaitai image:

> make docker-kaitai
[ -d kaitai_struct ] || git clone --recursive https://github.com/kaitai-io/kaitai_struct.git
podman image build -t kaitai -f Dockerfile.kaitai .
WARN[0000] Failed to detect the owner for the current cgroup: stat /sys/fs/cgroup/systemd: no such file or directory 
STEP 1: FROM mozilla/sbt AS builder
STEP 2: FROM openjdk:jre-slim
ERRO[0000] unable to write build event: "write unixgram @00011->/run/systemd/journal/socket: sendmsg: no such file or directory"
Error: error creating build container: short-name "mozilla/sbt" did not resolve to an alias and no unqualified-search registries are defined in "/etc/containers/registries.conf"
make: *** [Makefile:12: docker-kaitai] Error 125

djmccarthy12 avatar May 07 '21 16:05 djmccarthy12

I'm actually using docker, I just didn't change that in the pull request since I didn't want to change their default setting.

seihtam avatar May 09 '21 18:05 seihtam

Ok, I switched to using Docker instead of podman, and was able to get the docker container built, and running the BANG shell now works.

Still experiencing an issue when invoking the scanner as described however:

python3 bang-scanner -c bang.config -f /home/dj/go/src/netrise/parser-framework/data/tmp/squashfs-root/bin/busybox
Traceback (most recent call last):
  File "/home/dj/binaryanalysis-ng/src/bang-scanner", line 59, in <module>
    from bangsignatures import maxsignaturesoffset
  File "/home/dj/binaryanalysis-ng/src/bangsignatures.py", line 470, in <module>
    extension_to_unpackparser = get_unpackers_for_extensions()
  File "/home/dj/binaryanalysis-ng/src/bangsignatures.py", line 464, in get_unpackers_for_extensions
    for u in get_unpackers():
  File "/home/dj/binaryanalysis-ng/src/bangsignatures.py", line 458, in get_unpackers
    unpackers = _get_unpackers_recursive(
  File "/home/dj/binaryanalysis-ng/src/bangsignatures.py", line 452, in _get_unpackers_recursive
    unpackers.extend(_get_unpackers_recursive(
  File "/home/dj/binaryanalysis-ng/src/bangsignatures.py", line 444, in _get_unpackers_recursive
    module = importlib.import_module(module_name)
  File "/usr/lib/python3.9/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "/home/dj/binaryanalysis-ng/src/parsers/archivers/cpio/UnpackParser.py", line 4, in <module>
    from . import cpio_new_ascii
ImportError: cannot import name 'cpio_new_ascii' from 'parsers.archivers.cpio' (/home/dj/binaryanalysis-ng/src/parsers/archivers/cpio/__init__.py)

I've installed all dependencies, any idea what else I need to do to get this running properly?

djmccarthy12 avatar May 10 '21 14:05 djmccarthy12

I do not see the text added in #141 in current master was it removed? I modified the docker file to use librespace/kaitai as a base image for the build image. It bulds stuff for a very long time, but can not find the kaitai_struct folder.

CsatariGergely avatar May 18 '23 10:05 CsatariGergely

I do not see the text added in #141 in current master was it removed? I modified the docker file to use librespace/kaitai as a base image for the build image. It bulds stuff for a very long time, but can not find the kaitai_struct folder.

A lot has changed and is still in flux, so this should be considered broken at the moment. I will fix it but don't know when I will have the time for it.

armijnhemel avatar May 18 '23 10:05 armijnhemel