Example #1
0
def getEntries():
    """Get rows of encrypted data and decrypted data for gui. The encrypted
    data is used in other functions for the gui buttons."""

    encryptObj = Encrypt()
    rows = dbq.selectEntries()

    decryptedRows = [[] for i in range(len(rows))]
    i = 0
    for row in rows:
        web = encryptObj.decrypt(row[0])
        user = encryptObj.decrypt(row[1])
        passwd = encryptObj.decrypt(row[2])
        decryptedRows[i].extend((web, user, passwd))
        i += 1

    return (decryptedRows, rows)
Example #2
0
def main(argv, gateway=GATEWAY, uuid=UUID, f_hex=HEX):
    help_msg = argv[0] + ' -g <gateway> -u <uuid>' 

    try:
        opts, args = getopt.getopt(argv[1:], "hxg:u:", ["gateway=", "uuid="])
    except getopt.GetoptError:
        print help_msg
        sys.exit(2)
    for opt, arg in opts:
        if opt == '-h':
            print help_msg
            sys.exit()
        elif opt in ("-g", "--gateway"):
            gateway = arg
        elif opt in ("-u", "--uuid"):
            uuid = arg
        elif opt in ("-x", "--hex"):
            f_hex = True


    register = REQ_PHONE_ID.format(uuid=uuid)
    print register
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    s.connect((gateway, TCP_PORT))
    s.send(register)
    data = s.recv(BUFFER_SIZE)
    print '[HANDSHAKE]', data
    if len(data) != 11:
        print 'Incorrect message'
        sys.exit(1)
    e = Encrypt(uuid=uuid, phone_id=data[4])
    while True:
        data = s.recv(BUFFER_SIZE)
        if not data or len(data) < 1:
            s.close()
            print 'Disconnected'
            sys.exit()
        print "[RECV %s]" % (strftime("%H:%M:%S", localtime())), len(data), \
                remove_newline(data[:2] + e.decrypt(data))
        if f_hex:
            print_hex(data, True)
Example #3
0
locale.setlocale(locale.LC_ALL, "tr_TR.UTF-8")
TIME = time.strftime("%X")
DATE = time.strftime("%d.%m.%Y")
DATETIME = DATE, TIME  

MINUTE = int("30")
AMOUNT = int("2")
fileDirectory = "/tmp/whoyou"
VIDEO_X = "video0"


encryp = Encrypt()
key = open("%s/wykey" % fileDirectory).read()
openPass = encryp.xor(key, False)
MAIL_PASSWORD = encryp.decrypt(openPass)
MAIL = open("%s/usernames" % fileDirectory).readlines()[0]
tweet_user = open("%s/usernames" % fileDirectory).readlines()[1]
SUBJECT = "-*-whoyou-*-"

VALUEURL = "http://twitter.com/%s" % tweet_user # command: PC:Close and PC:Open


TEXT = """
Merhaba %s,\n%s tarhinde sisteminize giriş yapıldı. 
Bilgisayarınız ile ilgili işlem yapmak için verdiğiniz adrese (%s) bir değer giriniz. Aksi halde bilgisayarınız açık kalacaktır.
İlgili görsellere "%s" dizininden bakabilirsiniz.""" % (MAIL.split("@")[0], DATETIME, VALUEURL, fileDirectory)
  

if os.path.isdir(fileDirectory) == True:
  pass
Example #4
0
from encrypt import Encrypt

unchanged_sentence = raw_input('Type some words to encrypt\n')

our_encryptor = Encrypt()


encrypted_text = our_encryptor.encrypt( unchanged_sentence )
print encrypted_text


decrypted_message = our_encryptor.decrypt(encrypted_text)

if decrypted_message == unchanged_sentence:
	print 'it worked'
	print decrypted_message







Example #5
0
    parser = ArgumentParser(
        description='CSC 376 Final Project : Interview Portal')
    parser.add_argument('host', type=str, help='Host Address of the Server')
    parser.add_argument('port',
                        type=int,
                        help='Port used to connect to Server')
    args = parser.parse_args()
    _HOST = socket.gethostbyname(args.host)
    _PORT = args.port
    client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    client_socket.connect((_HOST, _PORT))
    key = key_exchange()
    enc = Encrypt(key)
    in_data = client_socket.recv(1024)
    in_data = enc.decrypt(in_data)
    print(in_data)
    credentials()
    loggedInAs = client_socket.recv(1024)
    loggedInAs = enc.decrypt(loggedInAs)
    if (validate(loggedInAs)):
        if (loggedInAs == "Interviewee"):
            startinterview()
        elif (loggedInAs == "Lawyer"):
            adminMenu()
        elif (loggedInAs == "System Admin"):
            adminMenu()
        elif (loggedInAs == "Legal Aide"):
            reviewInterview()
    print("Logging Out...")
Example #6
0
def main(argv, gateway=GATEWAY, uuid=UUID, f_hex=HEX):
    q_gw_recv = Queue()
    help_msg = argv[0] + "-h <host> -g <gateway> -u <uuid>"
    local = HOST

    try:
        opts, args = getopt.getopt(argv[1:], "xh:g:u:", ["host", "gateway=", "uuid="])
    except getopt.GetoptError:
        print help_msg
        sys.exit(2)
    for opt, arg in opts:
        if opt in ("-h", "--host"):
            local = arg
        elif opt in ("-g", "--gateway"):
            gateway = arg
        elif opt in ("-u", "--uuid"):
            uuid = arg
        elif opt == "-x":
            f_hex = True

    print "[VERSION]", __version__
    print "[GATEWAY]", gateway, uuid
    s = socket(AF_INET, SOCK_STREAM)
    s.connect((gateway, TCP_PORT))
    s.send(REQ_PHONE_ID.format(uuid=uuid))
    data = s.recv(BUFFER_SIZE)
    print "[HANDSHAKE]", data
    if len(data) != 11:
        print "Incorrect message"
        sys.exit(1)
    e = Encrypt(uuid=uuid, phone_id=data[6], only_compatible=ONLY)
    t = Thread(target=listen_gateway, args=(s, q_gw_recv))
    t.daemon = True
    t.start()

    host = socket(AF_INET, SOCK_STREAM)
    host.bind((local, TCP_PORT))
    host.listen(1)
    print "[HOST]", local, TCP_PORT
    conn, addr = host.accept()
    conn.settimeout(TIMEOUT)
    print "Connected by", addr
    cnt = 0
    while True:
        try:
            data = q_gw_recv.get(timeout=TIMEOUT)
            dec = e.decrypt(data)
            print "[RECV %s]" % (strftime("%H:%M:%S", localtime())), len(data), remove_newline(data[:2] + dec)
            conn.sendall(data[:2])
            # tm.sleep(0.5)
            conn.sendall(data[2:])
            if f_hex:
                print_hex(data, True)
        except Empty:
            pass

        try:
            data = conn.recv(1024)
            if REQ_UUID in data:
                e.uuid = data[(data.index(REQ_UUID) + 6) :]
                print "[ENC UUID]", e.uuid
            if len(data) < 1:
                print "[CLIENT] Disconnected"
                conn, addr = host.accept()
                conn.settimeout(TIMEOUT)
                print "[CLIENT] Connected by", addr
                continue
            dec = e.decrypt(data)
            print "[SENT %s]" % (strftime("%H:%M:%S", localtime())), len(data), remove_newline(data[:2] + dec)
            s.sendall(data)
        except timeout:
            if cnt > 1000:
                cnt = 0
                print "tout"

    conn.close()