Last active
December 12, 2015 10:48
-
-
Save omgmog/4761436 to your computer and use it in GitHub Desktop.
Script to complete a 'hack' turn on hackcess.net using curl.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
USERNAME="yourusername" | |
PASSWORD="yourpass" | |
TARGET=$1 | |
repeat() { | |
# repeat <n> <command> | |
n=$1 | |
shift | |
while [ $(( n -= 1 )) -ge 0 ] | |
do | |
"$@" | |
done | |
} | |
clean_up(){ | |
echo "Cleaning up tmp files..." | |
[[ -f "/tmp/result.txt" ]] && rm -f /tmp/result.txt | |
[[ -f "/tmp/message.txt" ]] && rm -f /tmp/message.txt | |
[[ -f "/tmp/hacklist.txt" ]] && rm -f /tmp/hacklist.txt | |
[[ -f "/tmp/targets.txt" ]] && rm -f /tmp/targets.txt | |
[[ -f "/tmp/result.txt" ]] && rm -f /tmp/result.txt | |
[[ -f "/tmp/cjar" ]] && rm -f /tmp/cjar | |
} | |
set_cookie(){ | |
# set login cookie | |
curl --cookie-jar /tmp/cjar --data "username=${USERNAME}&password=${PASSWORD}&remember=yes" http://hackcess.net/do_login.php | |
} | |
get_hack_count(){ | |
# get available hacks | |
curl -b /tmp/cjar -L http://hackcess.net/hack.php -o /tmp/hacklist.txt >/dev/null 2>&1 | |
cat /tmp/hacklist.txt | grep "<li><a href=\"/hack.php\">" | cut -d')' -f1 | cut -d'(' -f2 > /tmp/hackcount.txt | |
COUNT=`cat /tmp/hackcount.txt` | |
[[ -f "/tmp/hackcount.txt" ]] && rm -f /tmp/hackcount.txt | |
} | |
get_targets(){ | |
# get available targets | |
cat /tmp/hacklist.txt | grep "<input type=\"radio\" name=\"attack\" value=\"" | sed 's/^.*value=\"//' | cut -d'"' -f1 > /tmp/targets.txt | |
# pick one at random | |
PICKED_TARGET=`cat /tmp/targets.txt | perl -e 'rand($.) < 1 && ($it = $_) while <>; print "$it"'` | |
echo "We're gonna hack ${PICKED_TARGET}!" | |
} | |
do_hack(){ | |
# do hack | |
curl -b /tmp/cjar -d "attack=${1}" --verbose -H "Content-Type: application/x-www-form-urlencoded" -H "Host: hackcess.net" -H "Referer: http://hackcess.net/hack.php" -L http://hackcess.net/do_hack.php -o /tmp/result.txt >/dev/null 2>&1 | |
# hack results | |
cat /tmp/result.txt | grep "<h2>Hack\!</h2>" | cut -d')' -f1 | cut -d'(' -f2-3 | sed -e "s/^\'//" -e "s/\'$//" > /tmp/message.txt | |
MESSAGE=`cat /tmp/message.txt` | |
DATE=`date` | |
echo "${DATE} - ${MESSAGE}" | |
} | |
run_it_all(){ | |
set_cookie | |
get_hack_count | |
if [[ "$COUNT" > 0 ]]; then | |
echo "${COUNT} hacks available..." | |
if [ -z "$TARGET" -a "${TARGET+__null__}" = "__null__" ]; then | |
get_targets | |
else | |
PICKED_TARGET=$TARGET | |
fi | |
repeat $COUNT do_hack $PICKED_TARGET | |
else | |
echo "No hacks available..." | |
fi | |
# unset the PICKED_TARGET once we've used them, so we can pick another | |
unset PICKED_TARGET | |
clean_up | |
# run at random interval | |
INTERVAL=`echo $(( ( ($RANDOM % 10) + 1) * 60 ))` | |
echo "Waiting for ${INTERVAL} seconds..." | |
sleep ${INTERVAL} | |
run_it_all | |
} | |
run_it_all |
With new version, run sh hack.sh <user to hack>
and it will then continue to run at random intervals (or as random as it can be, if you can work out my maths!) until you kill it with ctrl+c
Okay now it will randomly pick a target user if none is specified:
sh hack.sh
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add your username and password to the script on lines 2 and 3, and then run the script as:
sh hack.sh <user to hack>