[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[OT] Testate lo script per la webmail di wind, grazie ;)



Dopo aver cambiato indirizzo e-mail, può capitare di voler scaricare i sorgenti dei messaggi del vecchio account dall'interfaccia web in automatico. Finchè non tolgono la feature, lo script che segue fa proprio questo, se magari lo testate e lo correggete un po' mi fate un grande favore. Scusate i commenti in inglese ma uno comincia per abitudine e poi si rende conto che è ridicolo ;-) Se le linee lunghe non sono venute bene, boh! Spero che siano venute bene...

Nick Name

#!/bin/sh

### This script is provided under the GNU general public licence.

# Please understand that this is a temporary way to get e-mail, if you plan 
# to use this as a long term-service, you'll surely get disappointed

# Why is this all in english? Humm, bella domanda!!! Oramai è tardi ;-)

#######customize here

user=REMOTEUSERNAME
pass=REMOTEPASSWORD
domain=inwind #libero, inwind or blu
spoolfile=/var/mail/LOCALUSERNAME #where to save e-mails (append mode)

#######end customization

###### TO DO !!! 
######
###### * delete files on the server after download
######
###### * the script is fragile, even minimal changes can hurt it
######   improve the regexps.


#choose a random number between 1 and 20 for load-balancing on libero servers
num=$((`date +%s` % 19 + 1))

#choose the server
server=wpop$num.$domain.libero.it

#cookies in this file please
cookies=$(mktemp /tmp/redirect.XXXXXXXX)

#index is processed more than once so it needs to be saved
indexfile=$(mktemp /tmp/redirect.XXXXXXXX)

#user agent
agent="Mozilla/5.0"

#options for user agent and cookies
curlopts="-D $cookies -A $agent"

#get the webmail page address
webmail=$(curl $server/email.php $curlopts -d dominio=$domain.it -d LOGIN=$user -d PASSWD=$pass -d choice=$domain -d Act_Login.x=9 -d Act_Login.y=9 -d Act_Login=Entra | grep "login-inbox.*>mail<" | sed 's@.*href="\(.*inbox\).*@\1@')

#get the index frame address
index=$(curl $curlopts $server/$webmail | grep main_Win | sed 's@.*src="\(.*\)" marginwidth=.*@\1@')

#download the index file
curl $curlopts $server/$index > $indexfile

#a bit of magic

ID=$(grep 'name="ID"' $indexfile|sed 's@.*value="\(.*\)".*@\1@')

savemsg() {
# the following line enters the view message window in case you need it
# curl $curlopts $server/cgi-bin/webmail.cgi -d ID=$ID -d $1=$2 -d msgID=$4 -d C_Folder=$5 -d R_Folder=$6 -d Msg_Read=$7
    curl $curlopts $server/cgi-bin/webmail.cgi -d ID=$ID -d Act_V_Save=1 -d R_Folder=$6 -d msgID=$4 -d Body=0 -d filename=message.txt >> $spoolfile
}

for f in $(grep "doitMsg(" $indexfile |sed 's@.*doitMsg(\(.*\))"><IMG.*@\1@'|tr -d "',"| tr " " "§")
  do savemsg $(echo $f | tr "§" " ")
done

rm $cookies -f $indexfile -f



Reply to: