你是否厌倦首先登录phpBB3前面板,然后做更多点击最终到达phpBB管理控制面板?你怎么能直接和auotmated到phpBB3管理控制面板?
答案 0 :(得分:0)
解决方案是这个小bash shell脚本:
#!/bin/bash
# phpBB Automated and Direct Login to Administration Control Panel
# Version: phpBB SEO 3.0.12
# This phpBB version does not use cookies at all, it only works with Session-IDs (sid)
# If your phpBB version works with cookies, try to use the the "-c" option in curl to write a cookie-file
# and the "-b" command to load a cookie-file
LOGINURL="http://yoursite.com/phpbb/ucp.php?mode=login"
LOGINURL_ADM="http://yoursite.com/phpbb/adm/index.php"
BOARDURL="http://yoursite.com/phpbb/index.php"
# IMPORTANT: In this script you have to use the same User Agent as your Browser does, otherwise it won't work.
# find it out for example on: http://www.whatsmyuseragent.com/
USERAGENT="Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:31.0) Gecko/20100101 Firefox/31.0"
# Login Data
USERNAME="yourAdminAccount"
PASSWORD="yourAdminPassowrdTopSecret"
# Login to phpBB like a normal user
curl -s -d "username=$USERNAME" \
-d "password=$PASSWORD" \
-d "login=Login" --user-agent "$USERAGENT" $LOGINURL -o "login.html"
# Get Session ID for this Login
SID=$(egrep -o "sid.*\>" login.html | sed -n '1p' | sed 's/sid=//')
echo "sid= $SID"
# Now go to the Administration Control Panel Login Area
curl -s --user-agent "$USERAGENT" "$LOGINURL_ADM?sid=$SID" -o "login_adm.html"
# And get the "credential"-value, which is essential
credential=$(egrep -o "credential.*\>" login_adm.html | sed -n '1p' | sed 's/credential" value="//')
echo "credential=$credential"
# Login to the Administration Control Panel, POST all essential data including the "credential"-value
curl -s -d "credential=$credential" \
-d "login=Login" \
-d "username=$USERNAME" \
-d "password_$credential=$PASSWORD" \
-d "redirect=./../adm/index.php?sid=$SID" \
--user-agent "$USERAGENT" "$LOGINURL_ADM?sid=$SID" -o "login_adm2.html"
echo ""
# Let's see, if everything worked:
# Error:
cat login_adm2.html | grep "Access to the Administration Control Panel is not allowed as you do not have administrative permissions." | sed 's/\t<p>//' | sed 's/<\/p>.*//'
# Success:
cat login_adm2.html | grep "You have successfully authenticated and will now be redirected to the Administration Control Panel." | sed 's/\t<p>//' | sed 's/<br \/>.*//'
# Get the new Session ID:
SID_ADM=$(egrep -o "sid.*\>" login_adm2.html | sed -n '1p' | sed 's/sid=//')
echo "old sid = $SID"
echo "new sid = $SID_ADM"
# Start the browser, whose User Agent you specified at the beginning of this script
firefox "$LOGINURL_ADM?sid=$SID_ADM"
firefox "$BOARDURL?sid=$SID_ADM"
# Clean up
rm login.html
rm login_adm.html
rm login_adm2.html
exit