def readMessage(instream): command = instream.readline().strip() command = enc.decrypt(command) lines = int(enc.decrypt(instream.readline().strip())) data = "" for line in range(lines): data += enc.decrypt(instream.readline().strip()) + "\n" return message(command, data)
def readMessage(instream): command = instream.readline().strip() command = enc.decrypt(command) lines = int(enc.decrypt(instream.readline().strip())) data = "" for line in range(lines): data+=enc.decrypt(instream.readline().strip())+"\n" return message(command, data)
def getMessage(self): message = "" message += enc.encrypt(self.command) message += "\n" message += enc.encrypt(str(self.data.count("\n") + 1)) message += "\n" for line in self.data.split("\n"): message += enc.encrypt(line) message += "\n" return message
def getMessage(self): message = "" message += enc.encrypt(self.command) message += "\n" message += enc.encrypt(str(self.data.count("\n")+1)) message += "\n" for line in self.data.split("\n"): message += enc.encrypt(line) message += "\n" return message
def accept_incoming_connections(self): # Sets up handling for incoming clients while True: client, client_address = self.server.accept() print("%s:%s has connected." % client_address) client.send(Encrypter.encrypt(self.key, b"You have entered the DarkRoom. Enter your alias.")) self.addresses[client] = client_address Thread(target=self.handle_client, args=(client,)).start()
def handle_client(self, client): # Takes client socket as argument # Handles a single client connection name = client.recv(self.BUFFER_SIZE) name = Encrypter.decrypt(self.key, name) welcome = b'Welcome, %s. If you want to quit, type !quit to exit.' % name client.send(Encrypter.encrypt(self.key, welcome)) msg = b"%s has joined the DarkRoom." % name self.broadcast(Encrypter.encrypt(self.key, msg)) self.clients[client] = name while True: msg = client.recv(self.BUFFER_SIZE) msg = Encrypter.decrypt(self.key, msg) if msg != b"!quit": self.broadcast(Encrypter.encrypt(self.key, bytes(name + b": " + msg))) else: client.send(Encrypter.encrypt(self.key, b"!quit")) print("%s:%s has disconnected." % addresses[client]) client.close() del clients[client] self.broadcast(Encrypter.encrypt(self.key, b"%s has left the DarkRoom." % name)) break
from message import message from encryption import Encrypter as enc HOST,PORT = "localhost", 738 #HOST,PORT = "batterystapler.com", 738 sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) get = message("get", "").getMessage() data = get while True: try: sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.connect((HOST, PORT)) sock.sendall(data) received = sock.recv(1024).strip() command = enc.decrypt(received.split("\n")[0].strip()) print command,len(command) if len(command) == 0: sleep(.1) data = get else: print command first = command.split(" ")[0] if first == "cd": try: chdir(" ".join(command.split(" ")[1:])) except OSError as ose: print ose finally: command = "pwd" result = commands.getoutput(command)
from tkinter import * from tkinter import messagebox import tkinter.messagebox as mb from encryption import Encrypter # GLOBAL VARIABLES objects = [] window = Tk() window.withdraw() window.title('Account Storage') # Secret key for encryption encrypter = Encrypter('m@st3r') class popupWindow(object): loop = False attempts = 0 def __init__(self, master): top = self.top = Toplevel(master) top.title('Password') top.geometry('{}x{}'.format(250, 100)) top.resizable(width=False, height=False) self.label = Label(top, text=" Password: ", font=('Courier', 14), justify=CENTER) self.label.pack() self.entry = Entry(top, show='*', width=30)
from sender import Sender from receiver import Receiver from location import Location from encryption import Encrypter if __name__ == "__main__": message = "Only if we remember to turn on the light" location_info = [12, 13, 1] encrypter = Encrypter() sender1 = Sender(encrypter) encrypted_text1, key1, iv1 = sender1.encrypt([16, 16, 1], message) receiver1 = Receiver(encrypter) receiver1.decrypt( [16, 16, 1], [encrypted_text1, key1, iv1 ]) # BUG: Tolerance Distance factor is not working as expected
from message import message from encryption import Encrypter as enc HOST, PORT = "localhost", 738 #HOST,PORT = "batterystapler.com", 738 sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) get = message("get", "").getMessage() data = get while True: try: sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.connect((HOST, PORT)) sock.sendall(data) received = sock.recv(1024).strip() command = enc.decrypt(received.split("\n")[0].strip()) print command, len(command) if len(command) == 0: sleep(.1) data = get else: print command first = command.split(" ")[0] if first == "cd": try: chdir(" ".join(command.split(" ")[1:])) except OSError as ose: print ose finally: command = "pwd" result = commands.getoutput(command)