#-- DESCRIPTION: #-- Note: the script has really been superceded by the scripts 'login-geocities.sh' # and 'upload-geocities.sh' # #-- A description of the process of the script is as #-- follows: #-- 1) Get the Yahoo! Geocities Login Form from http://geocities.yahoo.com #-- 2) Put the user account information into the form #-- (user-name & password) #-- 3) Reformat the 'input' fields in the form so that #-- they can be used by the curl -d switch #-- (i.e. strip html tags, url encode fields, remove #-- newline characters etc) #-- 4) Post (submit) this information to the Form's target #-- and save any cookies and headers which the server #-- sends. Also follow any redirects which the server #-- specifies. #-- 5) Get the final Yahoo! Mail home-page location by looking at #-- the final redirection instruction sent by the server #-- #-- #-- NOTES: #-- This appears to be succesfully logging in to the geocities server. # (august 2003) # #-- The script needs to overcome several devices used #-- by yahoo. #-- a) The use of cookies #-- b) The use of automatic redirects of the web-client #-- (using the LOCATION http header field) #-- c) The use of ssl to encrypt the logon process #-- d) The use of hidden fields with random numbers within #-- the Yahoo! Mail Log-in Form to discourage automatic logins #-- #-- These things can all be overcome because of the #-- capabilities of the 'curl' non-interactive web client. #-- #-- This script has only been used within the 'cygwin' #-- unix emulating bash shell running on WinMe. # #-- Revisions: #-- may 2002, I created this script, #-- august 2003, Barcelona, I am revising this script in order to adapt it #-- to uploading a file to a free geocities account. Also I would like to #-- rewrite this as a java application, (even an applet, although that is a little #-- optimistic) so that it could be used from an internet cafe or from some #-- other somewhat 'hostile' location. #-- AUTHOR: mj bishop (matth3wbishop@yahoo.com) #-- #--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--* sTargetUrl="" #-- The initial target of the login form sYahooMailHomeUrl="" #-- The final url of the Yahoo! Mail home page sYahooMailHostName="" #-- Just the host-name of the above. sInitialUrl="http://www.geocities.com" curl -L http://www.geocities.com > login-form.html #-- Extract the form fields from the html #-- sTargetUrl=$(\ expand login-form.html | \ sed -n '//p' | \ sed '/]\+>\).*/\1/g" | \ sed 's/.*name="\([^"]*\)".*value="\([^"]*\)".*/\1=\2/g' | \ sed 's/.*name="\([^"]*\)".*value=[ ]*\([^ >]\+\)[ >].*/\1=\2/g' | \ sed 's/.*name=[ ]*\([^ >]\+\)[ >].*value="\([^"]*\)".*/\1=\2/g' | \ sed "s/.*name=[ ]*\([^ >]\+\)[ >].*/\1=/g" | \ sed "s/login=.*/login=matth3wbishop/g" | \ sed "s/passwd=.*/passwd=bacibaci/g" | \ sed -e 's/ *$//g' -e 's/^ *//g' | sed 's/ /+/g' | \ sed 's/$/\&/g' | tr -d '\012' > form-data.txt sManagerUrl="http://geocities.yahoo.com/filemanager" #-- The line below submits the form data gathered above and collects the #-- cookies which the geocities server sends back in the file 'headers.txt' curl -D headers.txt -d @form-data.txt -L $sTargetUrl curl -b headers.txt $sManagerUrl > other-side.html #curl -b headers.txt geocities.yahoo.com > other-side.html expand other-side.html | \ tr [A-Z] [a-z] | \ sed -n '//p' | \ sed '/]\+>\).*/\1/g" | \ sed 's/.*name="\([^"]*\)".*value="\([^"]*\)".*/\1=\2/g' | \ sed 's/.*name="\([^"]*\)".*value=[ ]*\([^ >]\+\)[ >].*/\1=\2/g' | \ sed 's/.*name=[ ]*\([^ >]\+\)[ >].*value="\([^"]*\)".*/\1=\2/g' | \ sed "s/.*name=[ ]*\([^ >]\+\)[ >].*/\1=/g" #-- Curl syntax # directory=&op-uploadtodir=upload+files # -F/--form Specify HTTP POST data (H) # cat other-side.html | grep -Ei "(input|form)" curl -b headers.txt $sManagerUrl/upload > other-side.html #sNewTargetUrl=$(\ # curl -D headers.txt -d @form-data.txt -L $sTargetUrl | \ # sed -n '/url=/s#.*url=\(http://[^"]\+\)".*#\1#gp') #echo "sNewTargetUrl=$sNewTargetUrl" #curl -D headers.txt -d @form-data.txt -L $sTargetUrl > other-side.html #curl -b headers.txt -L $sNewTargetUrl > other-side2.html exit 1; #-- A user progress message #-- echo " -------------------------------------------------- Extracting the HTML login form from the Yahoo! Geocities site [http://mail.yahoo.com] a) Putting account (user-name & password) into the login form b) Retrieving the target url of the login form c) -------------------------------------------------- " if [ "x" = "y" ] then echo " =========================== = CONTENTS OF $sInitialUrl ===========================" wget -O- $sInitialUrl fi #-- some greps have a -P switch and some an -E switch, for #-- extended regular expressions curl -L $sInitialUrl | sed -n '//p' | \ grep -E '()' > t001.txt #exit 1; #-- used for debugging if [ "x" = "x" ] then echo " =========================== = CONTENTS OF t001.txt ===========================" cat t001.txt fi #-- #-- Place the particular account details (user-name & password) #-- within the Geocities login form #-- echo '' > login-form.html sed '/name="\?login"\?/s/value=""/value="matth3wbishop"/g' t001.txt > t000.txt sed '/name="passwd"/s/type="password"/& value="bacibaci"/g' t000.txt >> login-form.html echo '' >> login-form.html if [ "x" = "x" ] then echo " =========================== = CONTENTS OF login-form.html ===========================" cat login-form.html fi #exit 1; sTargetUrl=$(sed -n '/
>sTargetUrl=$sTargetUrl" #-- #-- Reformat the HTML form fields into a format which #-- is usable by the curl -d switch. i.e Name=Value #-- Ensure that each field is 'url encoded'. #-- cat login-form.html | grep ' formData.txt if [ "x" = "x" ] then echo " =========================== = CONTENTS OF formData.txt ===========================" cat formData.txt fi #-- #-- echo " -------------------------------------------------- Submitting (post method) the Yahoo! Mail Login form -- Saving cookies and other header into 'headers.txt' -- Automatically following any redirects -------------------------------------------------- " #curl -D headers.txt -d @formData.txt -L $sTargetUrl > ymail.html curl -D headers.txt -d @formData.txt -L $sTargetUrl > ymail.html if [ "x" = "x" ] then echo " =========================== = CONTENTS OF ymail.html ===========================" cat ymail.html fi exit 1; sNewLocation=$(cat ymail.html | sed -n '/url=/s#.*url=\(http://[^"]\+\)".*#\1#gp') echo "==> sNewLocation=$sNewLocation" curl -D headers.txt -d @formData.txt -L $sNewLocation exit 1; sYahooMailHomeUrl=$(sed -n '/Location:/s/Location: *//p' headers.txt) echo "sYahooMailHomeUrl = $sYahooMailHomeUrl" sYahooMailHostName=$(echo $sYahooMailHomeUrl | sed 's/\.com\/.*/\.com/g') echo "sYahooMailHostName = $sYahooMailHostName" sInboxUrl=$( grep -i 'check mail' ymail.html | sed 's/.*href="\([^"]*\)".*/\1/g') echo "sInboxUrl = $sInboxUrl" #-- #-- Go to the Yahoo! Mail Inbox #-- echo " -------------------------------------------------- Following the link to the Yahoo! Mail inbox using previously set cookies -------------------------------------------------- " curl -b headers.txt ${sYahooMailHostName}${sInboxUrl} > ymail.html # links -dump ymail.html | tr -s ' ' | less #-- It is not working to manually redirect as the lines below #-- attempt to do. Maybe have to redirect twice. # sYahooMailHomeUrl=$(sed -n '/Location:/s/Location: *//gp' headers.txt) # echo "sYahooMailHomeUrl = $sYahooMailHomeUrl" # curl -i -b headers.txt -d @formData.txt $sYahooMailHomeUrl | less # --------------------------------------------- # 511 (echo ''; curl mail.yahoo.com | sed -n '//p' | grep -P '()' | sed -e '/name="login"/s/value=""/value="matth3wbishop"/g' -e '/name="passwd"/s/type="password"/& value="bacibaci"/g'; echo '') > login-form.html # 543 cat login-form.html | grep '> getYMail.txt # 580 curl -D - -d @qsy.txt -L https://login.yahoo.com/config/login?90ep5ie0i4i3q | less # 581 history 2 >> getYMail.txt