Last active
October 11, 2016 03:38
-
-
Save ilovezfs/b7e283d4fcdd6f6bcf24 to your computer and use it in GitHub Desktop.
phpbb-auto-login.sh
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/sh | |
# phpbb-auto-login.sh copyleft Fabio Z 2009 | |
# login & logout user to phpBB forum boards | |
# http://www.zoros.org/wiki/index.php?title=A_script_to_login_phpbb_forum_using_wget | |
if [ $# -le 1 ] || [ $# -gt 3 ]; then | |
echo "Usage $0 URL user pass --> to login" | |
echo "Usage $0 URL user --> to logout" | |
fi | |
PHPBB_URL=http://$1 | |
USER=$2 | |
PASS=$3 | |
#--------------------------- login --------------------------- | |
if [ $# -eq 3 ] ; then | |
wget --save-cookies=./session-cookies-$USER $PHPBB_URL/ucp.php?mode=login -O - 1> /dev/null 2> /dev/null | |
SID=`cat ./session-cookies-$USER | grep _sid | cut -d$'\011' -f7` | |
echo "Login $USER --> $PHPBB_URL SID=$SID" | |
wget --save-cookies=./session-cookies-$USER \ | |
--post-data="username=$USER&password=$PASS&redirect=index.php&sid=$SID&login=Login" \ | |
$PHPBB_URL/ucp.php?mode=login --referer="$PHPBB_URL/ucp.php?mode=login" \ | |
-O - 1> /dev/null 2> /dev/null | |
fi | |
#-------------------------- logout -------------------------- | |
if [ $# -eq 2 ] ; then | |
SID=`cat ./session-cookies-$USER | grep _sid | cut -d$'\011' -f7` | |
echo "Logout $USER <-- $PHPBB_URL SID=$SID" | |
wget --load-cookies=./session-cookies-$USER "$PHPBB_URL/ucp.php?mode=logout&sid=$SID" --referer="$PHPBB_URL/index.php" -O - 1> /dev/null 2> /dev/null | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment