/usr/lib/radare/bin/rfile is in radare-common 1:1.5.2-6.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | #!/bin/sh
#
# author: pancake
#
PREFIX="/usr/share" # XXX
MAGICS="${PREFIX}/radare/magic/"
HOMAGIC="${HOME}/.radare/magic/"
TARGET="$1"
OFFSET="$2"
MAGICF="$3"
show_help() {
echo "Usage: rfile [-l|-h] [file] [[offset] [magic-file]]"
exit 0
}
mkdir -p ${HOMAGIC}
if [ -z "${EME}" ]; then
EME=`find ${MAGICS} ${HOMAGIC} -type f | sed -e 's. .,.g'`
else
if [ -f "${MAGICF}" ]; then
EME=${MAGICF}
else
if [ -f "${MAGICS}/${MAGICF}" ]; then
EME=${MAGICS}/${MAGICF}
else
EME=`echo ${MAGICS}/* ${HOMAGIC}/* | sed -e 's. .,.g'`
fi
fi
fi
[ "${TARGET}" = "-h" ] && TARGET=""
if [ -n "`echo ${TARGET}| grep -e '^-'`" ]; then
cd ${MAGICS} && ls
exit 0
fi
[ -z "$TARGET" ] && show_help
OFILE=`mktemp`
filter="cut -d : -f 2- | sed -e s,.,,"
if [ -n "${OFFSET}" ]; then
out=`dd if=${TARGET} of=$OFILE bs=1 count=4096 skip=${OFFSET} 2>&1`
file -m ${EME} $OFILE | eval $filter
else
file -m ${EME} ${TARGET} | eval $filter
fi
rm -f $OFILE
|