Exemplo n.º 1
0
def sendHtmlMail(subject, content, recipient):
    """Fonction d'envoie de mail en html"""
    sender = Config.email
    #recipient = "*****@*****.**"

    # Create message container - the correct MIME type is multipart/alternative.
    msg = MIMEMultipart('alternative')
    msg['Subject'] = subject
    msg['From'] = sender
    msg['To'] = recipient
    # Create the body of the message (a plain-text and an HTML version).
    text = content
    html = content
    # Record the MIME types of both parts - text/plain and text/html.
    part1 = MIMEText(text, 'plain')
    part2 = MIMEText(html, 'html')
    # Attach parts into message container.
    # According to RFC 2046, the last part of a multipart message, in this case
    # the HTML message, is best and preferred.
    msg.attach(part1)
    msg.attach(part2)
    # Send the message via local SMTP server.
    smtp = smtplib.SMTP(Config.smtp, Config.smtpPort)
    smtp.ehlo()
    smtp.starttls()
    smtp.login(sender, Securite.vigenere(Config.password, Config.clef, '2'))
    # sendmail function takes 3 arguments: sender's address, recipient's address
    # and message to send - here it is sent as one string.
    smtp.sendmail(sender, recipient, msg.as_string())
    smtp.quit()
    return "ok"
Exemplo n.º 2
0
def sendTextMail(subject,content,dest):
    fromaddr = Config.email
    smtp = smtplib.SMTP(Config.smtp,Config.smtpPort)
    smtp.ehlo()
    smtp.starttls()
    smtp.login(Config.email,Securite.vigenere(Config.password,Config.clef,'2'))
    msg=MIMEText(content)
    #print(dest)
    msg['Subject'] = subject
    msg['From'] = fromaddr
    msg['To'] = dest
    smtp.sendmail(fromaddr,dest,msg.as_string())
    smtp.close()
    return "ok"
Exemplo n.º 3
0
def checkGmail():
    obj = imaplib.IMAP4_SSL(Config.smtp,Config.smtpPortSSL)
    obj.login(Config.email,Securite.vigenere(Config.password,Config.clef,'2'))
    obj.select()
    obj.fetch("1", "(RFC822)")
    rep=obj.search(None,'UnSeen')
    rep=str(rep[1]).replace('[','')
    rep=rep.replace(']','')
    if rep == "b''":
        nb=0
        listeMail=[]
    else:
        nb=len(rep.split(" "))
        listeMail=rep[0]
    return nb,listeMail
Exemplo n.º 4
0
def readMail(id):
    exp,dest,sujet,contenu="","","",""
    mail = imaplib.IMAP4_SSL(Config.smtp,Config.smtpPortSSL)
    mail.login(Config.email,Securite.vigenere(Config.password,Config.clef,"2"))
    mail.select("inbox")
    r,d=mail.fetch(str(id),"(RFC822)")
    message=d[0][1].decode('utf-8')
    email_message=email.message_from_string(message)
    dest=email_message['To']
    exp=email_message['From']
    exp=exp[10:]
    exp=exp.replace("?= "," ")
    exp=exp.replace("=","\\x")
    exp=exp.replace("_"," ")
    exp=exp.lower()
    print(exp.encode('iso-8859-1').decode())
    return exp,dest,sujet,contenu
Exemplo n.º 5
0
def decodeMsg(message):
    """Permet de déchiffrer un message"""
    texte = Securite.vigenere(message, CLEF, "2")
    return texte
Exemplo n.º 6
0
    def handle(self):
        logFile = open("logs", "a")
        builtins.sendHandler = self
        builtins.init = 1
        essai = 0
        identify = 0
        while essai < 3:
            rec = self.request.recv(1024).strip()
            if len(rec) > 0:
                clair = Securite.vigenere(rec[2:].decode(), clef, "2")
                r = clair.split(";,;")
                password = r[1]
                username = r[0]
                mp = Database.searchUser(username).strip()
                if mp == "invalide":
                    self.sendMsg("L", "identify=0")
                    essai = essai + 1
                else:
                    if hashlib.sha224(password.encode("utf-8")).hexdigest() == mp:
                        identify = 1
                        self.sendMsg("L", "identify=1")
                        logFile.write(username + ";" + datetime.datetime.now().isoformat())
                        break
                    else:
                        self.sendMsg("L", "identify=0")
                        essai = essai + 1
                # print(identify)
            else:
                builtins.init = 0
                print("client deconnecte")
                break

        while 1 and identify == 1:
            suivi = open("suivi", "r")
            nbUser = 0
            for ligne in suivi:
                nbUser = int(ligne.strip())
            nbUser = nbUser + 1
            suivi = open("suivi", "w")
            suivi.write(str(nbUser))
            suivi.close()
            d = self.request.recv(1024).strip()
            if len(d) > 0:
                t = d.decode()
                temp = t.split(";")
                typ = temp[0]
                if typ == "T":
                    data = Securite.vigenere(temp[1], clef, "2")
                    cur_thread = threading.current_thread()
                    typ, answer = Cerveau.analyse(data, username)

                    if username == "florent":
                        answer += " (from" + str(cur_thread.name) + ")"
                    self.sendMsg(typ, answer)
                elif typ == "F":
                    complete = False
                    while not complete:
                        d += self.request.recv(1024).strip()
                        t = d.decode()
                        if re.search(";[A-Za-z]*.\.[A-Za-z]*", t):
                            complete = True
                    temp = t.split(";")
                    data = temp[1]
                    fileName = temp[2]
                    FileManager.convertFileReceive(data, fileName)
                    self.sendMsg("T", "Fichier " + fileName + " bien recu")
            else:
                essai = 0
                identify = 0
                builtins.init = 0
                print("client deconnecte")
                #                Cerveau.cleanHistory()
                break
Exemplo n.º 7
0
 def sendMsg(self, typ, message):
     t = str(message)
     d = Securite.vigenere(t, clef, "1")
     self.request.sendall(bytes(typ + ";" + d + "\n", "utf-8"))
Exemplo n.º 8
0
def decodeMsg(message):
    message=unicode(message,'utf-8').encode('iso-8859-1')
    texte=Securite.vigenere(message,clef,"2")
    texte=texte.decode('iso-8859-1').encode('utf-8')
    return texte
Exemplo n.º 9
0
def encodeMsg(message):
	texte=unicode(Securite.vigenere(message,clef,"1"),'iso-8859-1').encode('utf-8')
	return texte
Exemplo n.º 10
0
 def sendMsg(self, typ, message):
     """Fonction d'envoie de message"""
     text = str(message)
     dec = Securite.vigenere(text, CLEF, "1")
     self.request.sendall(bytes(typ+";"+dec+"\n", 'utf-8'))
Exemplo n.º 11
0
email=EMAIL
password=PASSWORD
smtp="smtp.gmail.com"
smtpPort="587"
smtpPortSSL="993"

#Freebase
api_key="AIzaSyA-WMfgx3SUL4RAWRKiStbU8JV2al0DPQ0"
service_url="https://www.googleapis.com/freebase/v1/search"
defautFreebaseResponse="Impossible de trouver l'information"
"""

import getpass
import sys
sys.path.append('server')
import Securite

fichier=open("Config.py","w")
ip=input("Quelle est votre adresse ip?")
clef=input("Entrer la clef qui sera utiliser pour chiffrer les informations critiques:")
email=input("Entrer le compte gmail réservé pour votre IA, ou le votre")
password=getpass.getpass("Entrer le mot de passe associé: ")
config=config.replace("IPADDRESS","'"+ip+"'")
config=config.replace("CLEF","'"+clef+"'")
config=config.replace("EMAIL","'"+email+"'")
config=config.replace("PASSWORD","'"+Securite.vigenere(password,clef,"1")+"'")
fichier.write(config)

import Database
Database.run()
Exemplo n.º 12
0
import System
import Reload
import Server
import threading
import time
import builtins
import Mail
import time
import Proxy
import Config

if __name__ == '__main__':
    Proxy.connectProxy("http")
    starttime=time.time()
    print("Initialisation en cours")
    HOST, PORT = Config.address, Config.port
    LS = Server.ThreadedTCPServer((HOST, PORT), Server.ThreadedTCPRequestHandler)
    Securite.init()
    Cerveau.init()
    builtins.init=0
    server_thread = threading.Thread(target=LS.serve_forever)
    server_thread.start()
    print("initialisation réalisé en "+str(time.time()-starttime)+"sec")
    print('Serving')
#    a=System.MyMonitoringThread('Monitoring')
#    a.start()
    b=threading.Thread(None,Reload.verify,None)
    b.start()


Exemplo n.º 13
0
#News
news_url=[NEWS_URL]
topics=[TOPICS]
reddit=[REDDIT]
"""

fichier = open("CONFIG.py", "w")
ip = input("Quelle est votre adresse ip?")
clef = input("Entrer la clef qui sera utiliser pour chiffrer les informations critiques: ")
email = input("Entrer le compte gmail réservé pour votre IA, ou le votre: ")
password = getpass.getpass("Entrer le mot de passe associé: ")
freebase = input("Entrer votre clef api pour freebase:")
weather = input("Entrer votre clef api pour openweathermap:")
news_url = input("Entrer les urls des fluxs rss que vous voulez suivre (séparé par des virgules): ")
topics = input("Enter la liste des sujets qui vous intéressent (séparé par des virgules): ")
reddit = input("Enter la liste des subreddit qui vous intéressent (séparé par des virgules): ")
CONFIG = CONFIG.replace("IPADDRESS", "'"+ip+"'")
CONFIG = CONFIG.replace("CLEF", "'"+clef+"'")
CONFIG = CONFIG.replace("EMAIL", "'"+email+"'")
CONFIG = CONFIG.replace("FREEBASE_KEY", "'"+freebase+"'")
CONFIG = CONFIG.replace("OPENWEATHER_KEY", "'"+weather+"'")
CONFIG = CONFIG.replace("PASSWORD", "'"+Securite.vigenere(password, clef, "1")+"'")
CONFIG = CONFIG.replace("NEWS_URL", '","'.join(news_url.split(","))+'"')
CONFIG = CONFIG.replace("TOPICS", '"'+'","'.join(topics.split(","))+'"')
CONFIG = CONFIG.replace("REDDIT", '"'+'","'.join(reddit.split(","))+'"')
fichier.write(CONFIG)
fichier.close()

Database.run()