Initial import of r2-docker

This commit is contained in:
pancake 2017-03-10 10:24:43 +01:00
parent a02f09aae8
commit c588138fd0
4 changed files with 94 additions and 4 deletions

View File

@ -29,7 +29,8 @@
#
# using phusion/baseimage as base image.
FROM ubuntu
# FROM ubuntu
FROM phusion/baseimage
# Set correct environment variables.
ENV HOME /root
@ -45,8 +46,8 @@ RUN mkdir -p /opt/code/
# install packages required to compile vala and radare2
RUN apt-get update
RUN apt-get upgrade -y
RUN apt-get install -y software-properties-common wget python curl
RUN apt-get install -y gcc git bison pkg-config make glib-2.0
RUN apt-get install -y software-properties-common wget python curl valgrind
RUN apt-get install -y gcc git bison pkg-config make glib-2.0 unzip sudo
#RUN apt-get install -y swig flex bison git gcc g++ make pkg-config glib-2.0
#RUN apt-get install -y swig flex bison git gcc g++ make pkg-config glib-2.0
#RUN apt-get install -y python-gobject-dev valgrind gdb
@ -71,6 +72,16 @@ RUN curl -sL https://deb.nodesource.com/setup_7.x | bash - ; apt-get install -y
RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# build and install r2
RUN cd /opt/code; git clone https://github.com/radare/radare2.git; cd radare2; ./sys/install.sh ; make symstall
RUN cd /opt/code ; git clone --depth 1 https://github.com/radare/radare2.git; cd radare2; ./sys/install.sh
RUN cd /opt/code/radare2 ; make symstall
RUN npm install -g r2pipe
RUN useradd -m r2
RUN adduser r2 sudo
RUN (echo r2;echo r2) | passwd r2
USER r2
WORKDIR /home/r2
ENV HOME=/home/r2
RUN r2 -V

View File

@ -209,6 +209,7 @@ install love: install-doc install-man install-www
mkdir -p "${DESTDIR}${DATADIR}/radare2/${VERSION}/hud"
mkdir -p "${DESTDIR}${BINDIR}"
ln -fs "${PWD}/sys/indent.sh" "${DESTDIR}${BINDIR}/r2-indent"
ln -fs "${PWD}/sys/r2-docker.sh" "${DESTDIR}${BINDIR}/r2-docker"
cp -f doc/hud "${DESTDIR}${DATADIR}/radare2/${VERSION}/hud/main"
mkdir -p "${DESTDIR}${DATADIR}/radare2/${VERSION}/"
sys/ldconfig.sh
@ -250,6 +251,7 @@ symstall install-symlink: install-man-symlink install-doc-symlink install-pkgcon
done
mkdir -p "${DESTDIR}${BINDIR}"
ln -fs "${PWD}/sys/indent.sh" "${DESTDIR}${BINDIR}/r2-indent"
ln -fs "${PWD}/sys/r2-docker.sh" "${DESTDIR}${BINDIR}/r2-docker"
mkdir -p "${DESTDIR}${DATADIR}/radare2/${VERSION}/hud"
cd "$(DESTDIR)$(LIBDIR)/radare2/" ;\
rm -f last ; ln -fs $(VERSION) last
@ -262,6 +264,7 @@ symstall install-symlink: install-man-symlink install-doc-symlink install-pkgcon
deinstall uninstall:
rm -f $(DESTDIR)$(BINDIR)/r2-indent
rm -f $(DESTDIR)$(BINDIR)/r2-docker
cd libr && ${MAKE} uninstall PARENT=1
cd binr && ${MAKE} uninstall PARENT=1
cd shlr && ${MAKE} uninstall PARENT=1

28
man/r2-docker.1 Normal file
View File

@ -0,0 +1,28 @@
.Dd Mar 10, 2017
.Dt R2-DOCKER 1
.Sh NAME
.Nm r2-docker
.Nd Open files within an r2 contained in a Docker image
.Sh SYNOPSIS
.Nm r2-docker
.Op Fl s
.Op Fl u
.Op Fl l
.Ar file
.Sh DESCRIPTION
radare2 is a commandline hexadecimal editor, and this tool allows you to create a contained version inside a Docker image to open your files safely.
.Pp
The options are:
.Bl -tag -width Fl
.It Fl s
open shell inside the docker image (user r2, pass r2)
.It Fl u
update or create the docker image with r2 inside
.It Fl l
List all docker images with radare2
.Sh SEE ALSO
.Pp
.Xr radare2(1)
.Sh AUTHORS
.Pp
pancake <pancake@nopcode.org>

48
sys/r2-docker.sh Executable file
View File

@ -0,0 +1,48 @@
#!/bin/sh
IFILE="$1"
P=`readlink $0`
[ -z "$P" ] && P="$0"
cd `dirname $P`/..
CWD="$PWD"
if [ "`echo $IFILE | cut -c 1`" != / ]; then
IFILE="$OLDPWD/$IFILE"
fi
showHelp() {
echo "Usage: r2-docker [-u] [file] [...]"
echo " -u update/build the radare2 docker image"
echo " -l list radare2 docker images"
echo " -s enter the shell"
exit 1
}
case "$1" in
-u)
docker build -t radare2 .
;;
-l)
docker images | grep radare2
;;
shell|sh|-s)
docker run -ti radare2 || echo "run r2-docker -u to update the docker image"
;;
-h|'')
showHelp
;;
/*|*)
if [ -f "$1" ]; then
F=`basename $1`
D=`dirname $1`
# bypass home restriction
rm -rf dockervol
mkdir -p dockervol
cp -f "$1" "dockervol/$F"
docker run -v $PWD/dockervol:/mnt -p 9090:9090 -ti radare2 r2 /mnt/$F
rm -rf dockervol
else
docker run -v $PWD/dockervol:/mnt -p 9090:9090 -ti radare2 r2 $1
fi
;;
esac