Skip to content

Commit

Permalink
Add some comments to ragg2-cc
Browse files Browse the repository at this point in the history
  • Loading branch information
jvoisin committed Oct 9, 2014
1 parent d184819 commit b4a56e3
Showing 1 changed file with 19 additions and 15 deletions.
34 changes: 19 additions & 15 deletions binr/ragg2/ragg2-cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# add support for arm
# add support for nested shellcodes

# Find which compiler is installed
if [ -z "${CC}" ]; then
for a in llvm-gcc clang gcc ; do
$a --version >/dev/null 2>&1
Expand All @@ -26,12 +27,15 @@ if [ -z "${CC}" ]; then
exit 1
fi
fi
A=x86

# Get path for sflib
SFLIBPATH=`ragg2 -v | cut -d ' ' -f 3-`
if [ ! -d "${SFLIBPATH}" ]; then
echo "Cannot find ${SFLIBPATH}"
exit 1
fi

# Get local architecture
case "`uname -m`" in
"x86_64")
B=64
Expand Down Expand Up @@ -63,62 +67,65 @@ Darwin)
K=linux
;;
esac

X=0
C=""
D=""
O=""
F=""
ASM=0
A=x86
while : ; do
[ -z "$1" ] && break
F=$1
case "$F" in
-a)
-a) # architecture (x86, mips, arm)
shift
A=$1
[ -z "$A" ] && { echo "Missing argument for -a" ; exit 1; }
;;
-b)
-b) # register size (32, 64, ...)
shift
B=$1
[ -z "$B" ] && { echo "Missing argument for -b" ; exit 1; }
;;
-k)
-k) # kernel
shift
K=$1
[ -z "$K" ] && { echo "Missing argument for -k" ; exit 1; }
;;
-x)
-x) # execute
X=1
;;
-c)
-c) # set configuration option
C=1
;;
-d)
-d) # patch dword (4 bytes) at given offset
D=1
;;
-s)
-s) # show assembler
ASM=1
;;
-o)
-o) # output file
shift
O=$1
if [ -z "$O" ]; then
echo "Missing argument for -o"
exit 1
fi
;;
-h)
-h) # help
dohelp
exit 0
;;
-v)
-v) # version
ragg2 -v | sed -e 's,2,2-cc,'
exit 0
;;
esac
shift
done

if [ -z "$F" ]; then
dohelp
exit 1
Expand Down Expand Up @@ -163,11 +170,8 @@ fi
[ "$A$K" ] && ARCH="$K-$A-$B"

OPT=-Os

#/usr/include/libr/sflib/
#CFLAGS="-shared -fPIC -fPIE -pie "
#CFLAGS="${CFLAGS} -shared -fPIC -fPIE -pie "
CFLAGS="${CFLAGS} -nostdinc -include ${SFLIBPATH}/${ARCH}/sflib.h"
CFLAGS="${CFLAGS} -z execstack"
CFLAGS="${CFLAGS} -fomit-frame-pointer -finline-functions -fno-zero-initialized-in-bss"
LDFLAGS="${LDFLAGS} -nostdlib"

Expand Down

0 comments on commit b4a56e3

Please sign in to comment.