FROM ubuntu:22.04

ENV DEBIAN_FRONTEND=noninteractive
ENV LANG=C.UTF-8

RUN apt update
RUN apt install -y \
    curl \
    wget \
    less \
    netcat-openbsd \
    socat \
    make \
    vim \
    gdb \
    zsh \
    git \
    gcc \
    python3 \
    python3-pip \
    sudo \
    file \
    unar \
    python-is-python3 \
    ripgrep \
    patchelf \
    liblzma-dev \
    pkg-config \
    libssl-dev \
    qemu-system \
    qemu-efi-aarch64

RUN apt install -y jq

RUN pip install nclib pandas openpyxl capstone IPython

## angr Install

WORKDIR /work/angr
RUN wget https://raw.githubusercontent.com/angr/angr-dev/refs/heads/master/extremely-simple-setup.sh
RUN chmod +x ./extremely-simple-setup.sh
RUN ./extremely-simple-setup.sh

## Patch Vex

WORKDIR /work/angr/pyvex/vex
ADD ./vex.patch .
RUN git apply ./vex.patch
RUN rm libvex.so && cd .. && pip install -e .

## angrop Install

WORKDIR /work/angr
RUN git clone https://github.com/angr/angrop
WORKDIR /work/angr/angrop
RUN git checkout f671363f15ead720af068ae4e17787c6d690b0fd
RUN pip install -e .

WORKDIR /work

ADD ./analyze.sh .
ADD ./container-scripts ./container-scripts
ADD ./kernel_sources ./kernel_sources
ADD ./rootfs ./rootfs
ADD ./scripts ./scripts
ADD ./sysgadget ./sysgadget

RUN apt install -y rpm2cpio cpio

RUN curl https://sh.rustup.rs -sSf | sh -s -- -y
ENV PATH $HOME/.cargo/.bin:$PATH

ENTRYPOINT ["./container-scripts/run-all.sh"]
