Exemple #1
0
#!/usr/bin/env python3

import sys
import math
import socket
import readline

import dsa
import messageUtils
import minilogger

MAX_SIZE = int(160)
MAX_LEN = int(1024)
PORT = int(9292)
HOST = ''
ml = minilogger.minilogger('client.log')


def getlocalip(h):
    # tries to retrieve local ip in respect to server
    try:
        global PORT, HOST
        s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        s.connect((h, PORT))
        return s.getsockname()[0]
    except:
        return HOST


if __name__ == '__main__':
Exemple #2
0
#!/usr/bin/env python3
import minilogger
ml = minilogger.minilogger('crypto.log')


def code(c):
    # single function for coding decoding
    if type(c) == type('a'):
        # perform range based ASCII comparison
        if c >= 'a' and c <= 'z':
            return (ord(c) - ord('a')) + 40
        if c >= 'A' and c <= 'Z':
            return (ord(c) - ord('A')) + 1
        if c >= '0' and c <= '9':
            return (ord(c) - ord('0')) + 30
        else:
            spl = {' ': 0, ',': 27, '.': 28, '?': 29, '!': 66, ' ': 67}
            return spl[c]
    else:
        # perform range based numeric ord() check
        if c >= 1 and c <= 26:
            return chr(c + 64)
        if c >= 40 and c <= 65:
            return chr(c + 57)
        if c >= 30 and c <= 39:
            return chr(c + 18)
        ispl = {0: ' ', 27: ',', 28: '.', 29: '?', 66: '!', 67: ' '}
        return ispl[c]


def ROT(k, s, delim):
Exemple #3
0
import socketserver

import caesar
import diffie
import minilogger
import messageUtils
import fileUtils as fdriver
import passwordDBUtils as pdriver

MAX_SIZE = int(80)
MAX_LEN = int(1024)
PASSWORD_DB_FILE = 'password.db'
FILE_SERVING_DIR = 'uploads/'
PORT = int(9191)
HOST = '127.0.0.1'
ml = minilogger.minilogger('server.log')

# using these as global [ in memory hash table ]
passwordDB_d = dict()
# keeps a lock while modifying hash table
password_Mutex = threading.Lock()


class LoginHandler(socketserver.BaseRequestHandler):
    def handle(self):
        # this is a universal target function for our client
        global HOST
        # initialising a blank MSG structure
        msg = messageUtils.Message(self.client_address[0], HOST)
        ml.writer(('[+] Client request : ' + self.client_address[0]))
        self.data = self.request.recv(2048).strip()