Exemplo n.º 1
0
 def checkForErrors(self, page):
     """Solleva un'eccezione se la pagina contiene una segnalazione d'errore dal sito."""
     if (re.search('0 messages left', page) is not None):
         raise SiteCustomError(self.__class__.__name__, u"SMS terminati.")
     if (re.search('Please enter a destination number', page) is not None):
         raise SiteCustomError(self.__class__.__name__,
                               u"Destinatario errato")
     if (re.search('Please write your message', page) is not None):
         raise SiteCustomError(self.__class__.__name__, u"Testo mancante")
Exemplo n.º 2
0
 def checkForErrors(self, page):
     """Solleva un'eccezione se la pagina contiene una segnalazione d'errore dal sito."""
     if (re.search("numero massimo di accessi", page) is not None):
         raise SiteCustomError(
             self.__class__.__name__,
             u"Ci sono troppi utenti sul sito, riprova più tardi.")
     if (re.search("a causa di attività di manutezione sul sito",
                   page) is not None):
         raise SiteCustomError(
             self.__class__.__name__,
             u"Il sito è in manutenzione, riprova più tardi.")
Exemplo n.º 3
0
 def checkForErrors(self, page, last = None):
     """Solleva un'eccezione se la pagina contiene una segnalazione d'errore dal sito."""
     if(re.search("Access denied", page) is not None):
         raise SiteAuthError(self.__class__.__name__)
     if(re.search("destination invalid parameter type", page) is not None):
         raise SiteCustomError(self.__class__.__name__, u"Destinatario non valido")
     if(re.search("body not specified", page) is not None):
         raise SiteCustomError(self.__class__.__name__, u"Manca il testo")
     if(re.search("sender contains invalid characters or is too long", page) is not None):
         raise SiteCustomError(self.__class__.__name__, u"Mittente non valido")
     if(re.search("Not enough credit", page) is not None):
         raise SiteCustomError(self.__class__.__name__, u"Credito esaurito")
     if(re.search("body contains invalid characters or is too long", page) is not None):
         raise SiteCustomError(self.__class__.__name__, u"Testo non valido")
Exemplo n.º 4
0
 def checkForErrors(self, page):
     """Solleva un'eccezione se la pagina contiene una segnalazione d'errore dal sito."""
     if (re.search("verificato un errore durante la procedura", page)
             is not None):
         raise SiteCustomError(
             self.__class__.__name__,
             u"Il sito è in manutenzione, riprova più tardi.")
Exemplo n.º 5
0
 def checkForErrors(self, page):
     """Solleva un'eccezione se la pagina contiene una segnalazione d'errore dal sito."""
     if (re.search("Please check your details", page) is not None):
         raise SiteAuthError(self.__class__.__name__)
     if (re.search(
             "Current customers may need to reactivate their mobiles by Topping Up your Call Credit",
             page) is not None):
         raise SiteCustomError(
             self.__class__.__name__,
             u"Devi ricaricare la sim per tornare ad inviare SMS gratis")
     if (re.search("One or more Numbers is required", page) is not None):
         raise SiteCustomError(self.__class__.__name__,
                               u"Numero del destinatario mancante")
     if (re.search("Message is required", page) is not None):
         raise SiteCustomError(self.__class__.__name__,
                               u"Testo del messaggio mancante")
     if (re.search("We're sorry, an error has occurred", page) is not None):
         raise SiteCustomError(self.__class__.__name__,
                               u"Errore del server")
Exemplo n.º 6
0
 def checkForErrors(self, page):
     if (re.search(u'"Messaggio Errore"', page) is not None) or \
        (re.search(u'Bad Gateway', page) is not None) or \
        (re.search(u'Il servizio è momentaneamente non disponibile', page) is not None) or \
        (re.search(u'Siamo spiacenti, la pagina che hai richiesto al momento non è disponibile.', page) is not None) or \
        (re.search(u'Internal Server Error', page) is not None):
         raise SiteCustomError(
             self.__class__.__name__,
             u"Il servizio non \W?\W? al momento disponibile.")
     if (re.search(u'SMS non inviato, il numero non \W?\W? TIM', page)
             is not None):
         raise SiteCustomError(self.__class__.__name__,
                               u"Il destinatario non e' un numero Tim.")
     if (re.search(u'numero massimo di SMS', page) is not None):
         raise SiteCustomError(self.__class__.__name__,
                               u"Hai raggiunto il limite di SMS per oggi.")
     if (re.search(u'essere autenticati', page) is not None) or \
        (re.search(u'loginerror.do', page) is not None):
         raise SiteAuthError(self.__class__.__name__)
Exemplo n.º 7
0
 def checkForErrors(self, page):
     """Solleva un'eccezione se la pagina contiene una segnalazione d'errore dal sito."""
     if (re.search("Invalid Login", page) is not None):
         raise SiteAuthError(self.__class__.__name__)
     if (re.search("no recipient specified", page) is not None):
         raise SiteCustomError(self.__class__.__name__,
                               u"Numero di telefono non valido")
     if (re.search("no message written", page) is not None):
         raise SiteCustomError(self.__class__.__name__,
                               u"Non hai inserito il messaggio")
     if (re.search("Daily limit reached to the numbers outside wadja.",
                   page) is not None):
         raise SiteCustomError(self.__class__.__name__,
                               u"Limite di messaggi inviati per oggi.")
     if (re.search("Daily limit reached to the same number outside wadja.",
                   page) is not None):
         raise SiteCustomError(
             self.__class__.__name__,
             u"Limite di messaggi inviati oggi allo stesso numero")
Exemplo n.º 8
0
 def checkForErrors(self, page):
     """Solleva un'eccezione se la pagina contiene una segnalazione d'errore dal sito."""
     if (re.search("Username o Password errati", page) is not None):
         raise SiteAuthError(self.__class__.__name__)
     if (re.search("Credito non sufficiente", page) is not None):
         raise SiteCustomError(self.__class__.__name__,
                               u"SMS gratuiti esauriti")
     if (re.search("Mittente non valido", page) is not None):
         raise SiteCustomError(
             self.__class__.__name__,
             u"Il mittente deve essere un numero di telefono")
     if (re.search("Destinatario richiesto", page) is not None):
         raise SiteCustomError(self.__class__.__name__,
                               u"Manca il numero a cui inviare")
     if (re.search("Testo richiesto", page) is not None):
         raise SiteCustomError(self.__class__.__name__,
                               u"Testo messaggio vuoto")
     if (re.search("Messaggio non inviato per errore di spedizione", page)
             is not None):
         raise SiteSenderError(self.__class__.__name__)
     if (re.search("limite massimo di sms inviabili gratis in 24 ore", page)
             is not None):
         raise SiteCustomError(
             self.__class__.__name__,
             u"Troppi sms in 24h per questo destinatario")
     if (re.search("limite massimo di sms inviabili gratis in 30 giorni",
                   page) is not None):
         raise SiteCustomError(
             self.__class__.__name__,
             u"Troppi sms in 30g per questo destinatario")
Exemplo n.º 9
0
    def sendOne(self, number, text, dati=None, ui=None):
        """Spedisce un SMS con soli caratteri ASCII e di lunghezza massima maxLength
        con le credenziali specificate, supponendo Internet raggiungibile.
        """
        try:
            #Costruisco un nuovo oggetto Curl e lo inizializzo
            c = self.connectionManager.getCurl()

            #Assegna le variabili standard
            mittente = dati['Mittente']

            if number[:3] == "+39":
                number = number[3:]
            elif number[0] == "+":
                raise SiteCustomError(
                    self.__class__.__name__,
                    u"Questo sito permette di inviare SMS solo verso cellulari italiani."
                )

            #Invio l'sms
            saver = StringIO()
            postFields = {}
            postFields["recipient"] = "+39" + number
            postFields["subjecttosend"] = "Da: " + mittente
            postFields["SmilName"] = ""
            postFields["TextName"] = text
            postFields["ImageName"] = ""
            postFields["AudioName"] = ""
            postFields["nextPage"] = "/web/servletresult.html"
            c.setopt(pycurl.POST, True)
            c.setopt(pycurl.POSTFIELDS,
                     self.codingManager.urlEncode(postFields))
            c.setopt(
                pycurl.URL,
                "http://mmsviaweb.net.vodafone.it/WebComposer/web/elaborapop.jsp"
            )
            self.perform(self.stop, saver)
            self.checkForErrors(saver.getvalue())

            if (re.search("Il tuo messaggio è stato inviato",
                          saver.getvalue()) is None):
                raise SenderError(self.__class__.__name__)

        except pycurl.error, e:
            errno, msg = e
            raise SiteConnectionError(
                self.__class__.__name__,
                self.codingManager.iso88591ToUnicode(msg))
Exemplo n.º 10
0
    def sendOne(self, number, text, dati=None, ui=None):
        """Spedisce un SMS con soli caratteri ASCII e di lunghezza massima maxLength
        con le credenziali specificate, supponendo Internet raggiungibile.
        """
        try:
            #Costruisco un nuovo oggetto Curl e lo inizializzo
            c = self.connectionManager.getCurl()

            #Assegna le variabili standard
            username = dati['Nome utente']
            password = dati['Password']
            sim = str(dati['SIM'])

            if number[:3] == "+39":
                number = number[3:]
            elif number[0] == "+":
                raise SiteCustomError(
                    self.__class__.__name__,
                    u"Questo sito permette di inviare SMS solo verso cellulari italiani."
                )

            #Visito la pagina iniziale
            saver = StringIO()
            c.setopt(pycurl.URL,
                     "http://www.vodafone.it/190/trilogy/jsp/home.do")
            self.perform(self.stop, saver)
            self.checkForErrors(saver.getvalue())
            self.checkManteinance(c.getinfo(pycurl.EFFECTIVE_URL))

            if ui: ui.gaugeIncrement(self.incValue)

            #Sono già autenticato?
            if (re.search("Ciao ", saver.getvalue()) is None):
                #No, ammazzo i vecchi cookie e mi riautentico
                self.connectionManager.forgetCookiesFromDomain("190.it")
                self.connectionManager.forgetCookiesFromDomain("vodafone.it")
                saver = StringIO()
                c.setopt(pycurl.URL,
                         "https://www.vodafone.it/190/trilogy/jsp/login.do")
                postFields = {}
                postFields["username"] = username
                postFields["password"] = password
                c.setopt(pycurl.POST, True)
                c.setopt(pycurl.POSTFIELDS,
                         self.codingManager.urlEncode(postFields))
                self.perform(self.stop, saver)

                self.checkForErrors(saver.getvalue())
                self.checkManteinance(c.getinfo(pycurl.EFFECTIVE_URL))

                if (re.search("Ciao ", saver.getvalue()) is None):
                    raise SiteAuthError(self.__class__.__name__)

            if ui: ui.gaugeIncrement(self.incValue)

            #se Sim e se non è attiva, cambio la SIM attiva
            if sim and (re.search('value="' + sim + '" selected >',
                                  saver.getvalue()) is None):
                saver = StringIO()
                c.setopt(
                    pycurl.URL,
                    "http://www.areaprivati.vodafone.it/190/trilogy/jsp/swapSim.do?tk=9616,1&ty_sim="
                    + sim)
                self.perform(self.stop, saver)
                self.checkForErrors(saver.getvalue())
                self.checkManteinance(c.getinfo(pycurl.EFFECTIVE_URL))

            if ui: ui.gaugeIncrement(self.incValue)

            #Visito la pubblicità obbligatoria
            c.setopt(pycurl.POST, False)
            c.setopt(
                pycurl.URL,
                "http://www.vodafone.it/190/trilogy/jsp/dispatcher.do?ty_key=fdt_invia_sms&tk=9616,2"
            )
            self.perform(self.stop)

            self.checkForErrors(saver.getvalue())
            self.checkManteinance(c.getinfo(pycurl.EFFECTIVE_URL))

            if ui: ui.gaugeIncrement(self.incValue)

            #Visito il form degli SMS (anche qui obbligatoriamente...)
            c.setopt(
                pycurl.URL,
                "http://www.areaprivati.vodafone.it/190/trilogy/jsp/dispatcher.do?ty_key=fsms_hp&ipage=next"
            )
            self.perform(self.stop)

            if ui: ui.gaugeIncrement(self.incValue)

            #Spedisco l'SMS
            saver = StringIO()
            postFields = {}
            postFields["pageTypeId"] = "9604"
            postFields["programId"] = "10384"
            postFields["chanelId"] = "-18126"
            postFields["receiverNumber"] = number
            postFields["message"] = text
            c.setopt(pycurl.POST, True)
            c.setopt(pycurl.POSTFIELDS,
                     self.codingManager.urlEncode(postFields))
            c.setopt(pycurl.URL,
                     "http://www.areaprivati.vodafone.it/190/fsms/prepare.do")
            self.perform(self.stop, saver)

            self.checkForErrors(saver.getvalue())
            self.checkManteinance(c.getinfo(pycurl.EFFECTIVE_URL))

            if (re.search(
                    "Ti ricordiamo che puoi inviare SMS via Web solo a numeri di cellulare Vodafone",
                    saver.getvalue()
            ) is not None or re.search(
                    "Il numero di telefono del destinatario del messaggio non e' valido",
                    saver.getvalue()) is not None):
                raise SiteCustomError(
                    self.__class__.__name__,
                    u"Questo sito permette di inviare " +
                    u"SMS solo ai cellulari Vodafone.")
            if (re.search("box_sup_limitesms.gif", saver.getvalue())
                    is not None):
                raise SiteCustomError(self.__class__.__name__,
                                      u"Hai esaurito gli SMS gratis di oggi.")

            captchaBroken = False
            while captchaBroken == False:

                postFields = {}
                if re.search("generateimg.do", saver.getvalue()) is not None:
                    try:
                        saver = StringIO()
                        c.setopt(pycurl.POST, False)
                        c.setopt(
                            pycurl.URL,
                            "http://www.areaprivati.vodafone.it/190/fsms/generateimg.do"
                        )
                        self.perform(self.stop, saver)

                        self.checkForErrors(saver.getvalue())
                        self.checkManteinance(c.getinfo(pycurl.EFFECTIVE_URL))
                        postFields[
                            "verifyCode"] = CaptchaDecoder.getBestPlugin(
                            ).decodeCaptcha(saver, self.__class__.__name__)
                        c.setopt(pycurl.POST, True)
                    except CaptchaError:
                        raise SenderError(self.__class__.__name__)
                    if not postFields["verifyCode"]:
                        raise SiteCustomError(
                            self.__class__.__name__,
                            u"Captcha non inserito. Invio interrotto.")

                if ui: ui.gaugeIncrement(self.incValue)
                postFields["pageTypeId"] = "9604"
                postFields["programId"] = "10384"
                postFields["chanelId"] = "-18126"
                postFields["receiverNumber"] = number
                postFields["message"] = text

                c.setopt(pycurl.POST, True)
                c.setopt(pycurl.POSTFIELDS,
                         self.codingManager.urlEncode(postFields))

                #Confermo l'invio
                saver = StringIO()
                c.setopt(
                    pycurl.URL,
                    "http://www.areaprivati.vodafone.it/190/fsms/send.do")
                self.perform(self.stop, saver)

                if (re.search("generateimg.do", saver.getvalue()) is None):
                    captchaBroken = True
                elif ui:
                    ui.gaugeIncrement(-self.incValue)

            if (re.search("Hai superato il limite giornaliero di SMS",
                          saver.getvalue()) is not None):
                raise SiteCustomError(
                    self.__class__.__name__,
                    u"Sono esauriti gli SMS gratuiti di oggi.")

            self.checkForErrors(saver.getvalue())
            self.checkManteinance(c.getinfo(pycurl.EFFECTIVE_URL))
            if (re.search("elaborata correttamente", saver.getvalue()) is
                    None):
                raise SenderError(self.__class__.__name__)

        except pycurl.error, e:
            errno, msg = e
            raise SiteConnectionError(
                self.__class__.__name__,
                self.codingManager.iso88591ToUnicode(msg))
Exemplo n.º 11
0
 def checkManteinance(self, url):
     if "courtesy" in url:
         raise SiteCustomError(
             self.__class__.__name__,
             u"Il sito è in manutenzione, riprova più tardi.")
Exemplo n.º 12
0
    def sendOne(self, number, text, dati = None, ui = None):
        """Spedisce un SMS con soli caratteri ASCII e di lunghezza massima maxLength
        con le credenziali specificate, supponendo Internet raggiungibile.
        """
        try:
            c = self.connectionManager.getCurl()

            #Assegna le variabili standard
            username = dati['Nome utente']
            password = dati['Password']

            #Ammazzo i vecchi cookie
            self.connectionManager.forgetCookiesFromDomain("alice.it")

            #Faccio il login
            saver = StringIO()
            c.setopt(pycurl.POST, True)
            postFields = {}
            postFields["URL_OK"] = "http://portale.rossoalice.alice.it/ps/HomePS.do?area=posta&settore=sms"
            postFields["URL_KO"] = "http://portale.rossoalice.alice.it/ps/ManageCodError.do?channel=mail_ra&area=posta&settore=sms"
            postFields["usr"] = username
            postFields["channel"] = "mail_ra"
            postFields["login"] = username + "@alice.it"
            postFields["password"] = password
            c.setopt(pycurl.POSTFIELDS,
                self.codingManager.urlEncode(postFields))
            c.setopt(pycurl.URL,
                "http://authsrs.alice.it/aap/validatecredential")
            self.perform(self.stop, saver)
            if ((re.search(u'non sono corretti', saver.getvalue()) is not None) or
               (re.search(u"utenza inserita al momento non ", saver.getvalue()) is not None) or
               (re.search(u"Riprova più tardi ad accedere ad Alice Mail e servizi.", saver.getvalue()) is not None)):
                raise SiteAuthError(self.__class__.__name__)
            if ui: ui.gaugeIncrement(self.incValue)

            c.setopt(pycurl.URL, "http://auth.rossoalice.alice.it/aap/serviceforwarder?sf_dest=click_to_send_sms&ID_Value=&ID_Field=mobilphone")
            self.perform(self.stop)

            saver = StringIO()
            c.setopt(pycurl.URL, "http://webloginmobile.rossoalice.alice.it/alice/jsp/SMS/composer.jsp?ID_Field=0&ID_Value=0&id_clickto=0&dummy=dummy")
            self.perform(self.stop, saver)

            #Patch di Laurento Frittella
            if (re.search("L'invio dell'SMS ad ogni destinatario ha un costo di", saver.getvalue()) is not None):
                raise SiteCustomError(self.__class__.__name__, u"Sono esauriti gli SMS gratuiti di oggi.")

            if ui: ui.gaugeIncrement(self.incValue)

            #Spedisco l'SMS
            postFields = {}
            postFields["DEST"] = number
            postFields["TYPE"] = "smsp"
            postFields["SHORT_MESSAGE2"] = text
            postFields["SHORT_MESSAGE"] = text
            postFields["INVIA_SUBITO"] = "true"

            c.setopt(pycurl.URL, "http://webloginmobile.rossoalice.alice.it/alice/jsp/SMS/CheckDest.jsp")
            c.setopt(pycurl.POSTFIELDS,
                self.codingManager.urlEncode(postFields))
            self.perform(self.stop)

            c.setopt(pycurl.URL, "http://webloginmobile.rossoalice.alice.it/alice/jsp/SMS/inviaSms.jsp")
            c.setopt(pycurl.POSTFIELDS,
                self.codingManager.urlEncode(postFields))
            self.perform(self.stop)

            if ui: ui.gaugeIncrement(self.incValue)

            saver = StringIO()
            c.setopt(pycurl.POST, False)
            c.setopt(pycurl.REFERER, "http://webloginmobile.rossoalice.alice.it/alice/jsp/SMS/inviaSms.jsp")
            c.setopt(pycurl.URL, "http://webloginmobile.rossoalice.alice.it/alice/jsp/EwsJCaptcha.jpg")
            self.perform(self.stop, saver)
            if saver.getvalue() == "":
                raise SiteCustomError(self.__class__.__name__, u"Il sito non è disponibile, riprova più tardi.")

            if ui: ui.gaugeIncrement(self.incValue)

            postFields = {}
            postFields["DEST"] = number
            postFields["TYPE"] = "smsp"
            postFields["SHORT_MESSAGE2"] = text
            postFields["SHORT_MESSAGE"] = text
            postFields["INVIA_SUBITO"] = "true"
            try:
                postFields["captchafield"]=AskUserCaptchaDecoder.getInstance().decodeCaptcha(saver, self.__class__.__name__)
            except CaptchaError: print "An error occurred while trying to decode captcha"
            c.setopt(pycurl.POST, True)
            c.setopt(pycurl.POSTFIELDS,
                  self.codingManager.urlEncode(postFields))
            saver = StringIO()
            c.setopt(pycurl.URL, "http://webloginmobile.rossoalice.alice.it/alice/jsp/SMS/inviaSms.jsp")
            self.perform(self.stop, saver)
            if (re.search("Attenzione! I caratteri inseriti non sono corretti.",
                saver.getvalue()) is not None):
                raise SiteCustomError(self.__class__.__name__, u"I caratteri inseriti non sono corretti.")

            if (re.search(
                "È possibile inviare gratuitamente fino a 10 SMS al giorno",
                saver.getvalue()) is not None):
                raise SiteCustomError(self.__class__.__name__,
                    u"Sono esauriti gli SMS gratuiti di oggi.")

            if (re.search("inviato con successo", saver.getvalue()) is None):
                raise SenderError(self.__class__.__name__)

        except pycurl.error, e:
            errno, msg = e
            raise SiteConnectionError(self.__class__.__name__, self.codingManager.iso88591ToUnicode(msg))
Exemplo n.º 13
0
    def sendOne(self, number, text, dati=None, ui=None):
        """Spedisce un SMS con soli caratteri ASCII e di lunghezza massima maxLength
        con le credenziali specificate, supponendo Internet raggiungibile.
        """
        try:
            c = self.connectionManager.getCurl()

            #Assegna le variabili standard
            username = dati['Nome utente']
            password = dati['Password']

            if number[:3] == "+39":
                number = number[3:]
            elif number[0] == "+":
                raise SiteCustomError(
                    self.__class__.__name__,
                    u"Questo sito permette di inviare SMS solo verso cellulari italiani."
                )

            #Visito la pagina iniziale
            c.setopt(pycurl.URL, "http://www.enel.it")
            self.perform(self.stop)

            if ui: ui.gaugeIncrement(self.incValue)

            #Faccio il login
            saver = StringIO()
            c.setopt(pycurl.POST, True)
            postFields = {}
            postFields["SpontaneousLogon"] = "/Index.asp"
            postFields["txtUsername"] = username
            postFields["txtPassword"] = password
            c.setopt(pycurl.POSTFIELDS,
                     self.codingManager.urlEncode(postFields))
            c.setopt(pycurl.URL, "http://www.enel.it/AuthFiles/Login.aspx")
            self.perform(self.stop, saver)

            if (re.search("Autenticazione fallita", saver.getvalue()) != None):
                raise SiteAuthError(self.__class__.__name__)

            if ui: ui.gaugeIncrement(self.incValue)

            #Visito la pagina degli SMS
            saver = StringIO()
            c.setopt(pycurl.POST, False)
            c.setopt(pycurl.REFERER, "http://www.enel.it/Index.asp")
            c.setopt(pycurl.URL, "http://servizi.enel.it/sms/")
            self.perform(self.stop, saver)

            checkCode = ""
            try:
                checkCode = re.search(
                    '<input type="hidden" name="cksmsenel" value="([A-Z0-9]+)"',
                    saver.getvalue()).group(1)
            except AttributeError:
                raise SenderError(self.__class__.__name__)

            if ui: ui.gaugeIncrement(self.incValue)

            #Pre-invio
            saver = StringIO()
            c.setopt(pycurl.POST, True)
            postFields = {}
            postFields["message"] = text
            postFields["prefix"] = number[0:3]
            postFields["gsm"] = number[3:]
            postFields["cksmsenel"] = checkCode
            c.setopt(pycurl.POSTFIELDS,
                     self.codingManager.urlEncode(postFields))
            c.setopt(
                pycurl.URL,
                "http://servizi.enel.it/sms/service/scrivisms.asp?SMSstartpage=http://www.enel.it/Index.asp"
            )
            self.perform(self.stop, saver)

            if (re.search("superato il limite massimo", saver.getvalue()) !=
                    None):
                raise SiteCustomError(
                    self.__class__.__name__,
                    u"Sono esauriti gli SMS gratuiti di oggi.")

            checkCode = ""
            xFieldKey = ""
            xFieldValue = ""
            try:
                checkCode = re.search(
                    '<INPUT TYPE=hidden NAME=cksmsenel VALUE="([A-Z0-9]+)"',
                    saver.getvalue()).group(1)
                match = re.search(
                    '<INPUT TYPE=hidden NAME=x([0-9]+) VALUE=\'([0-9]+)\'>',
                    saver.getvalue())
                xFieldKey = match.group(1)
                xFieldValue = match.group(2)
            except AttributeError:
                raise SenderError(self.__class__.__name__)

            if ui: ui.gaugeIncrement(self.incValue)

            #Accetto il contratto
            saver = StringIO()
            c.setopt(pycurl.POST, True)
            postFields = {}
            postFields["message"] = text
            postFields["prefix"] = number[0:3]
            postFields["gsm"] = number[3:]
            postFields["accetta"] = "yes"
            postFields["x" + str(xFieldKey)] = str(xFieldValue)
            postFields["cksmsenel"] = checkCode
            c.setopt(pycurl.POSTFIELDS,
                     self.codingManager.urlEncode(postFields))

            c.setopt(pycurl.URL,
                     "http://servizi.enel.it/sms/service/scrivisms.asp")
            self.perform(self.stop, saver)

            if (re.search("superato il limite massimo", saver.getvalue()) !=
                    None):
                raise SiteCustomError(
                    self.__class__.__name__,
                    u"Sono esauriti gli SMS gratuiti di oggi.")
            if (re.search("inviato correttamente", saver.getvalue()) is None):
                raise SenderError(self.__class__.__name__)

        except pycurl.error, e:
            errno, msg = e
            raise SiteConnectionError(
                self.__class__.__name__,
                self.codingManager.iso88591ToUnicode(msg))
Exemplo n.º 14
0
    def sendOne(self, number, text, dati=None, ui=None):
        """Spedisce un SMS con soli caratteri ASCII e di lunghezza massima maxLength
        con le credenziali specificate, supponendo Internet raggiungibile.
        """
        try:
            #Costruisco un nuovo oggetto Curl e lo inizializzo
            c = self.connectionManager.getCurl()

            if not number[0] == "+": number = '+39' + number

            #Assegna le variabili standard
            username = dati['Nome utente']
            password = dati['Password']

            #Visito la pagina iniziale
            saver = StringIO()
            c.setopt(pycurl.POST, True)
            postFields = {}
            postFields["B1"] = 'logon'
            postFields["action"] = 'login'
            postFields["nick"] = username
            postFields["password"] = password
            c.setopt(pycurl.POSTFIELDS,
                     self.codingManager.urlEncode(postFields))
            c.setopt(pycurl.URL,
                     "http://www.yesmms.com/cgi-bin/yesmms/yesstart.cgi")
            self.perform(self.stop, saver)

            if (re.search("Wrong Password", saver.getvalue()) is not None):
                raise SiteAuthError(self.__class__.__name__)
            if (re.search("Login again at", saver.getvalue()) is not None):
                raise SiteCustomError(self.__class__.__name__,
                                      u"Errore di Login")
            if (re.search("did not logout correctly", saver.getvalue())
                    is not None):
                raise SiteCustomError(
                    self.__class__.__name__,
                    u"Utente gia' loggato, riprova tra 30 minuti")

            try:
                session = re.search('(?<=(session" value="))[^"]+',
                                    saver.getvalue()).group(0)
                time = re.search('(?<=(nowtime" value="))[^"]+',
                                 saver.getvalue()).group(0)
            except AttributeError:
                raise SenderError(self.__class__.__name__)

            if ui: ui.gaugeIncrement(self.incValue)

            #Visito la pagina intermedia
            saver = StringIO()
            c.setopt(pycurl.POST, True)
            postFields = {}
            postFields["session"] = session
            postFields["nowtime"] = time
            postFields["country"] = '212'
            postFields["lang"] = 'it'
            postFields["submit"] = 'continue'
            c.setopt(pycurl.POSTFIELDS,
                     self.codingManager.urlEncode(postFields))
            c.setopt(pycurl.URL,
                     "http://www.yesmms.com/cgi-bin/yesmms/yesintro.cgi")
            self.perform(self.stop, saver)

            if ui: ui.gaugeIncrement(self.incValue)

            #Visito la una pagina degli sms
            saver = StringIO()
            c.setopt(pycurl.POST, True)
            postFields = {}
            postFields["session"] = session
            postFields["lang"] = 'it'
            c.setopt(pycurl.POSTFIELDS,
                     self.codingManager.urlEncode(postFields))
            c.setopt(pycurl.URL,
                     "http://www.yesmms.com/cgi-bin/yesmms/yeslogin.cgi")
            self.perform(self.stop, saver)

            if ui: ui.gaugeIncrement(self.incValue)

            #Spedisco l'SMS
            saver = StringIO()
            postFields = {}
            postFields["number_friend"] = 'NO'
            postFields["number"] = number
            postFields["message"] = text
            postFields["session"] = session
            postFields["action"] = 'send'
            c.setopt(pycurl.POST, True)
            c.setopt(pycurl.POSTFIELDS,
                     self.codingManager.urlEncode(postFields))
            c.setopt(pycurl.URL,
                     "http://www.yesmms.com/cgi-bin/yesmms/yesmms.cgi")
            self.perform(self.stop, saver)

            #Eseguo il logout
            postFields = {}
            postFields["session"] = session
            c.setopt(pycurl.POST, True)
            c.setopt(pycurl.POSTFIELDS,
                     self.codingManager.urlEncode(postFields))
            c.setopt(pycurl.URL,
                     "http://www.yesmms.com/cgi-bin/yesmms/yeslogout.cgi")
            self.perform(self.stop)

            if (re.search("SMS sent", saver.getvalue()) is None):
                if (re.search("The message contains bad", saver.getvalue())
                        is not None):
                    raise SiteCustomError(
                        self.__class__.__name__,
                        u"Il messaggio contiene parole proibite")
                elif (re.search("You already sent a", saver.getvalue())
                      is not None):
                    raise SiteCustomError(
                        self.__class__.__name__,
                        u"Hai gia' inviato un SMS a questo numero")
                elif (re.search("You need at least", saver.getvalue())
                      is not None):
                    raise SiteCustomError(
                        self.__class__.__name__,
                        u"Hai esaurito i crediti disponibili")
                elif (re.search("not been sent", saver.getvalue())
                      is not None):
                    raise SiteCustomError(self.__class__.__name__,
                                          u"Messaggio non inviato")
                elif (re.search(
                        "The max. number of FREE SMS per hour has been reached",
                        saver.getvalue()) is not None):
                    raise SiteCustomError(
                        self.__class__.__name__,
                        u"Limite orario di sms raggiunto, riprova piu' tardi")
                else:
                    raise SenderError(self.__class__.__name__)

        except pycurl.error, e:
            errno, msg = e
            raise SiteConnectionError(
                self.__class__.__name__,
                self.codingManager.iso88591ToUnicode(msg))
Exemplo n.º 15
0
 def checkForErrors(self, page):
     """Solleva un'eccezione se la pagina contiene una segnalazione d'errore dal sito."""
     if (re.search('n="ERRORCODE" v="100"', page) is not None):
         raise SiteCustomError(
             self.__class__.__name__,
             u"Il servizio non e' al momento disponibile.")
     if (re.search('n="ERRORCODE" v="101"', page) is not None):
         raise SiteCustomError(
             self.__class__.__name__,
             u"Il servizio non e' al momento disponibile.")
     if (re.search('n="ERRORCODE" v="102"', page) is not None):
         raise SiteCustomError(self.__class__.__name__,
                               u"Sessione scaduta.")
     if (re.search('n="ERRORCODE" v="103"', page) is not None):
         raise SiteCustomError(
             self.__class__.__name__,
             u"Siamo spiacenti. Il tuo profilo di registrazione non e' abilitato a questo servizio."
         )
     if (re.search('n="ERRORCODE" v="104"', page) is not None):
         raise SiteCustomError(
             self.__class__.__name__,
             u"Il servizio non e' al momento disponibile.")
     if (re.search('n="ERRORCODE" v="105"', page) is not None):
         raise SiteCustomError(
             self.__class__.__name__,
             u"Il servizio non e' al momento disponibile.")
     if (re.search('n="ERRORCODE" v="106"', page) is not None):
         raise SiteCustomError(self.__class__.__name__,
                               u"Contenuto non disponibile.")
     if (re.search('n="ERRORCODE" v="107"', page) is not None):
         raise SiteCustomError(
             self.__class__.__name__,
             u"Hai raggiunto il numero massimo di SMS a tua disposizione oggi."
         )
     if (re.search('n="ERRORCODE" v="108"', page) is not None):
         raise SiteCustomError(
             self.__class__.__name__,
             u"E' stato raggiunto il numero massimo di SMS verso il numero destinatario."
         )
     if (re.search('n="ERRORCODE" v="109"', page) is not None):
         raise SiteCustomError(self.__class__.__name__,
                               u"Attenzione! Messaggio vuoto.")
     if (re.search('n="ERRORCODE" v="110"', page) is not None):
         raise SiteCustomError(
             self.__class__.__name__,
             u"Hai superato il numero di caratteri disponibili.")
     if (re.search('n="ERRORCODE" v="111"', page) is not None):
         raise SiteCustomError(
             self.__class__.__name__,
             u"Inserisci il numero di cellulare del destinatario.")
     if (re.search('n="ERRORCODE" v="112"', page) is not None):
         raise SiteCustomError(
             self.__class__.__name__,
             u"Il numero di cellulare deve essere di nove o dieci cifre e contenere solo caratteri numerici."
         )
     if (re.search('n="ERRORCODE" v="113"', page) is not None):
         raise SiteCustomError(
             self.__class__.__name__,
             u"Il destinatario non e' un utente Vodafone.")
     if (re.search('n="ERRORCODE" v="114"', page) is not None):
         raise SiteCustomError(self.__class__.__name__,
                               u"Verifica il numero mittente")
     if (re.search('n="ERRORCODE" v="115"', page) is not None):
         raise SiteCustomError(self.__class__.__name__,
                               u"Attenzione! Errore SIM.")
     if (re.search('n="ERRORCODE" v="116"', page) is not None):
         raise SiteCustomError(
             self.__class__.__name__,
             u"Verifica il codice inserito e invia il tuo SMS.")
     if (re.search('n="ERRORCODE" v="117"', page) is not None):
         raise SiteCustomError(self.__class__.__name__,
                               u"Contenuto non disponibile.")
Exemplo n.º 16
0
    def sendOne(self, number, text, dati=None, ui=None):
        """Spedisce un SMS con soli caratteri ASCII e di lunghezza massima maxLength
        con le credenziali specificate, supponendo Internet raggiungibile.
        """
        try:
            #Costruisco un nuovo oggetto Curl e lo inizializzo
            c = self.connectionManager.getCurl()

            #Assegna le variabili standard
            username = dati['Nome utente']
            password = dati['Password']
            sim = str(dati['SIM'])

            if number[:3] == "+39":
                number = number[3:]
            elif number[0] == "+":
                raise SiteCustomError(
                    self.__class__.__name__,
                    u"Questo sito permette di inviare SMS solo verso cellulari italiani."
                )

            c.setopt(pycurl.HTTPHEADER, [
                'X-Flash-Version: 10,0,45,2;', 'Accept: */*;',
                'Accept-Encoding: gzip,deflate;', 'Accept-Language: it-it;'
                'Connection: keep-alive;'
            ])
            c.setopt(pycurl.USERAGENT, 'Vodafone_DW')
            c.setopt(pycurl.REFERER, 'http://www.vodafone.it/')

            #faccio il login
            saver = StringIO()
            c.setopt(pycurl.URL,
                     "https://widget.vodafone.it/190/trilogy/jsp/login.do")
            postFields = {}
            postFields["username"] = username
            postFields["password"] = password
            postFields["cu_channel"] = 'MM'
            postFields["cu_notrace"] = 'true'
            c.setopt(pycurl.POST, True)
            c.setopt(pycurl.POSTFIELDS,
                     self.codingManager.urlEncode(postFields))
            self.perform(self.stop, saver)

            self.checkForErrors(saver.getvalue())

            if (re.search("Ciao ", saver.getvalue()) is None):
                raise SiteAuthError(self.__class__.__name__)

            if ui: ui.gaugeIncrement(self.incValue)

            #eventuale cambio sim
            if sim and (re.search('value="' + sim + '" selected >',
                                  saver.getvalue()) is None):
                saver = StringIO()
                c.setopt(
                    pycurl.URL,
                    "http://www.areaprivati.vodafone.it/190/trilogy/jsp/swapSim.do?channel=VODAFONE_DW&tk=9604,l&ty_sim="
                    + sim)
                self.perform(self.stop, saver)
                self.checkForErrors(saver.getvalue())

            if ui: ui.gaugeIncrement(self.incValue)

            #Visito pagina intermedia
            c.setopt(pycurl.POST, False)
            c.setopt(
                pycurl.URL,
                "https://widget.vodafone.it/190/fsms/precheck.do?channel=VODAFONE_DW"
            )
            self.perform(self.stop)

            self.checkForErrors(saver.getvalue())
            if ui: ui.gaugeIncrement(self.incValue)

            #Spedisco l'SMS
            saver = StringIO()
            postFields = {}
            postFields["receiverNumber"] = number
            postFields["message"] = text
            c.setopt(pycurl.POST, True)
            c.setopt(pycurl.POSTFIELDS,
                     self.codingManager.urlEncode(postFields))
            c.setopt(
                pycurl.URL,
                "https://widget.vodafone.it/190/fsms/prepare.do?channel=VODAFONE_DW"
            )
            self.perform(self.stop, saver)

            self.checkForErrors(saver.getvalue())

            captchaBroken = False
            while captchaBroken == False:
                postFields = {}
                if re.search('CODEIMG', saver.getvalue()) is not None:
                    try:
                        captchaimage = re.search(
                            '(?<=(<e n="CODEIMG" ><!\[CDATA\[))[^\]]+',
                            saver.getvalue()).group(0)
                        captchaimage = captchaimage.decode("base64")
                        saver = StringIO(captchaimage)
                        postFields[
                            "verifyCode"] = CaptchaDecoder.getBestPlugin(
                            ).decodeCaptcha(saver, 'Vodafone')
                    except CaptchaError:
                        raise SenderError(self.__class__.__name__)

                    if not postFields["verifyCode"]:
                        raise SiteCustomError(
                            self.__class__.__name__,
                            u"Captcha non inserito. Invio interrotto.")

                #Confermo l'invio
                if ui: ui.gaugeIncrement(self.incValue)
                postFields["receiverNumber"] = number
                postFields["message"] = text

                c.setopt(pycurl.POST, True)
                c.setopt(pycurl.POSTFIELDS,
                         self.codingManager.urlEncode(postFields))
                saver = StringIO()
                c.setopt(
                    pycurl.URL,
                    "https://widget.vodafone.it/190/fsms/send.do?channel=VODAFONE_DW"
                )
                self.perform(self.stop, saver)

                if re.search('CODEIMG', saver.getvalue()) is None:
                    captchaBroken = True
                elif ui:
                    ui.gaugeIncrement(-self.incValue)

            self.checkForErrors(saver.getvalue())

            if (re.search("inviati correttamente", saver.getvalue()) is None):
                raise SenderError(self.__class__.__name__)

        except pycurl.error, e:
            errno, msg = e
            raise SiteConnectionError(
                self.__class__.__name__,
                self.codingManager.iso88591ToUnicode(msg))
Exemplo n.º 17
0
    def sendOne(self, number, text, dati=None, ui=None):
        """Spedisce un SMS con soli caratteri ASCII e di lunghezza massima
        maxLength con le credenziali specificate, supponendo Internet
        raggiungibile."""

        try:
            #Costruisco un nuovo oggetto Curl e lo inizializzo
            c = self.connectionManager.getCurl()

            if number[:3] == "+39":
                number = number[3:]
            elif number[0] == "+":
                raise SiteCustomError(
                    self.__class__.__name__,
                    u"Questo sito permette di inviare SMS solo verso cellulari italiani."
                )

            #Assegna le variabili standard
            username = dati['Nome utente']
            password = dati['Password']

            c.setopt(pycurl.URL, "http://www.tim.it")
            self.perform(self.stop)

            if ui: ui.gaugeIncrement(self.incValue)

            #Faccio il login
            saver = StringIO()
            c.setopt(pycurl.POST, True)
            postFields = {}
            postFields["urlOk"] = "https://www.tim.it/119/consumerdispatcher"
            postFields["portale"] = "timPortale"
            postFields["login"] = username
            postFields["password"] = password
            c.setopt(pycurl.POSTFIELDS,
                     self.codingManager.urlEncode(postFields))
            c.setopt(pycurl.URL, "https://www.tim.it/authfe/login.do")
            self.perform(self.stop, saver)
            self.checkForErrors(saver.getvalue())

            if ui: ui.gaugeIncrement(self.incValue)

            c.setopt(pycurl.URL,
                     "https://smsweb.tim.it/sms-web/adddispatch?start=new")
            saver = StringIO()
            self.perform(self.stop, saver)
            self.checkForErrors(saver.getvalue())

            try:
                formdata1 = re.search(
                    '(?<=(name="addDispatchForm"><div class="t-invisible"><input name="t:formdata" type="hidden" value="))[^"]+',
                    saver.getvalue()).group(0)
                formdata2 = re.search(
                    '(?<=(seperateFreeNumbers:hidden" name="t:formdata" type="hidden" value="))[^"]+',
                    saver.getvalue()).group(0)
            except AttributeError:
                raise SenderError(self.__class__.__name__)

            try:
                jsession = re.search(
                    '(?<=(adddispatch.adddispatchform;jsessionid=))[^"]+',
                    saver.getvalue()).group(0)
            except:
                jsession = None

            if ui: ui.gaugeIncrement(self.incValue)

            postFields = {}
            postFields["t:formdata"] = formdata2
            postFields["recipientType"] = 'FREE_NUMBERS'
            postFields["freeNumbers"] = number
            postFields["textAreaStandard"] = text
            postFields["deliverySmsClass"] = 'STANDARD'
            postdata = self.codingManager.urlEncode(postFields)+"&"+\
                       urllib.urlencode({"t:formdata":formdata1})
            c.setopt(pycurl.POSTFIELDS, postdata)
            c.setopt(pycurl.POST, True)
            url = "https://smsweb.tim.it/sms-web/adddispatch.adddispatchform"
            if jsession: url += ";jsessionid=" + jsession
            c.setopt(pycurl.URL, url)
            saver = StringIO()
            self.perform(self.stop, saver)
            self.checkForErrors(saver.getvalue())

            try:
                formdata = re.search(
                    '(?<=(value="Dispatch"></input><input name="t:formdata" type="hidden" value="))[^"]+',
                    saver.getvalue()).group(0)
            except AttributeError:
                raise SenderError(self.__class__.__name__)

            captchaBroken = False
            while captchaBroken == False:
                postFields = {}
                try:
                    saver = StringIO()
                    c.setopt(pycurl.POST, False)
                    c.setopt(
                        pycurl.URL,
                        "https://smsweb.tim.it/sms-web/validatecaptcha:image/false?t:ac=Dispatch"
                    )
                    self.perform(self.stop, saver)
                    #postFields["verificationCode"] = CaptchaDecoder.getBestPlugin().decodeCaptcha(saver, self.__class__.__name__)
                    postFields[
                        "verificationCode"] = AskUserCaptchaDecoder.getInstance(
                        ).decodeCaptcha(saver, self.__class__.__name__)
                except CaptchaError:
                    raise SenderError(self.__class__.__name__)

                if not postFields["verificationCode"]:
                    raise SiteCustomError(
                        self.__class__.__name__,
                        u"Captcha non inserito. Invio interrotto.")

                postFields["t:formdata"] = formdata
                postFields["t:ac"] = "Dispatch"
                c.setopt(pycurl.POSTFIELDS,
                         self.codingManager.urlEncode(postFields))
                c.setopt(pycurl.POST, True)
                c.setopt(
                    pycurl.URL,
                    "https://smsweb.tim.it/sms-web/validatecaptcha.validatecaptchaform"
                )
                saver = StringIO()
                self.perform(self.stop, saver)

                if not re.search(
                        u"Le lettere che hai inserito non corrispondono a quelle presenti nell'immagine",
                        saver.getvalue()):
                    captchaBroken = True

            self.checkForErrors(saver.getvalue())

            if (re.search("SMS inviato", saver.getvalue()) is None):
                raise SenderError(self.__class__.__name__)

        except pycurl.error, e:
            errno, msg = e
            raise SiteConnectionError(
                self.__class__.__name__,
                self.codingManager.iso88591ToUnicode(msg))