Skip to content

Instantly share code, notes, and snippets.

@timfallmk
Last active June 21, 2017 18:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save timfallmk/32dca5c7f2a9eef8a34e4d1e7873ef30 to your computer and use it in GitHub Desktop.
Save timfallmk/32dca5c7f2a9eef8a34e4d1e7873ef30 to your computer and use it in GitHub Desktop.
Look at all the work!
FROM ubuntu
COPY ./* /
RUN chmod +x /*.sh
CMD /run.sh
#/bin/bash
# this script helps you do hackerish stuff
if [ "$EUID" -ne 0 ]
then
echo "Please run as root to be hackerish."
exit
fi
# turn off globbing
set -f
# split on newlines only for for loops
IFS='
'
for log in $(find /var/log -type f); do
# only use the log if it's a text file; we _will_ encounter some archived logs
if [ `file $log | grep -e text | wc -l` -ne 0 ]
then
echo $log
for line in $(cat $log); do
echo $line
# sleep for a random duration between 0 and 1/4 seconds to indicate hard hackerish work
bc -l <<< $(bc <<< "$RANDOM % 10")" / 40" | xargs sleep
done
fi
done
#!/bin/bash
collect()
{
while read line;do
if [ -d "$line" ];then
(for i in "$line"/*;do echo $i;done)|sort -R|collect
echo $line
elif [[ "$line" == *".h" ]];then
echo $line
fi
done
}
sse="$(awk '/flags/{print;exit}' </proc/cpuinfo|grep -o 'sse\S*'|sed 's/^/-m/'|xargs)"
flags=""
pd="\\"
while true;do
collect <<< /usr/include|cut -d/ -f4-|
(
while read line;do
if [ "$(dirname "$line")" != "$pd" ];then
x=$((RANDOM%8-3))
if [[ "$x" != "-"* ]];then
ssef="$(sed 's/\( *\S\S*\)\{'"$x,$x"'\}$//' <<< "$sse")"
fi
pd="$(dirname "$line")"
opt="-O$((RANDOM%4))"
if [[ "$((RANDOM%2))" == 0 ]];then
pipe=-pipe
fi
case $((RANDOM%4)) in
0) arch=-m32;;
1) arch="";;
*) arch=-m64;;
esac
if [[ "$((RANDOM%3))" == 0 ]];then
gnu="-D_GNU_SOURCE=1 -D_REENTRANT -D_POSIX_C_SOURCE=200112L "
fi
flags="gcc -w $(xargs -n1 <<< "opt pipe gnu ssef arch"|sort -R|(while read line;do eval echo \$$line;done))"
fi
if [ -d "/usr/include/$line" ];then
echo $flags -shared $(for i in /usr/include/$line/*.h;do cut -d/ -f4- <<< "$i"|sed 's/h$/o/';done) -o "$line"".so"
sleep $((RANDOM%2+1))
else
line=$(sed 's/h$//' <<< "$line")
echo $flags -c $line"c" -o $line"o"
sleep 0.$((RANDOM%4))
fi
done
)
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment