Exemplo n.º 1
0
def main(mode):
    if(mode=='Cryptage/Decryptage symetrique'):
        SymmetricEncryption.menu()
    if(mode=='Codage'):
        Encoding.menu()
    if(mode=='Hachage'):
        Hashing.hash_menu()
    if(mode=='Cracker mot de passe'):
        Hashing.crack_menu()
    if(mode=='Cryptage/Decryptage asymetrique'):
        AsymmetricEncryption.menu()


    if(mode=='rien'):
        menu()
Exemplo n.º 2
0
def menu():
    while(True):
        choice = pyip.inputMenu(['Codage','Hachage','Cracker mot de passe','Cryptage/Decryptage symetrique','Cryptage/Decryptage asymetrique','Quitter'])
        if(choice=='Codage'):
            Encoding.menu()
        elif(choice=='Hachage'):
            Hashing.hash_menu()
        elif(choice=='Cracker mot de passe'):
            Hashing.crack_menu()
        elif(choice=='Cryptage/Decryptage symetrique'):
            SymmetricEncryption.menu()
        elif(choice=='Cryptage/Decryptage asymetrique'):
            AsymmetricEncryption.menu()
        
        elif(choice=='Quitter'):
            return
Exemplo n.º 3
0
def menu():
    while (True):
        choice = pyip.inputMenu([
            'encoding', 'hashing', 'pwdCracker', 'symmetric-encrypt',
            'asymmetric-encrypt', 'quit'
        ])
        if (choice == 'encoding'):
            Encoding.menu()
        elif (choice == 'hashing'):
            Hashing.hash_menu()
        elif (choice == 'pwdCracker'):
            Hashing.crack_menu()
        elif (choice == 'symmetric-encrypt'):
            SymmetricEncryption.menu()
        elif (choice == 'asymmetric-encrypt'):
            AsymmetricEncryption.menu()

        elif (choice == 'quit'):
            return
Exemplo n.º 4
0
 def __init__(self, args):
     self.args = args
     self.thug_version = __thug_version__
     log.ThugOpts = ThugOpts()
     log.ThugVulnModules = ThugVulnModules()
     log.MIMEHandler = MIMEHandler.MIMEHandler()
     log.SchemeHandler = SchemeHandler.SchemeHandler()
     log.JSClassifier = JSClassifier.JSClassifier()
     log.URLClassifier = URLClassifier.URLClassifier()
     log.SampleClassifier = SampleClassifier.SampleClassifier()
     log.Encoding = Encoding.Encoding()
    def get_file(self, fileName):
        fileValue = self.buffer.search_retNode(fileName)

        if(fileValue != None):
            if(type(fileValue) == str):
                fileValue = Meta.getMetaObject(fileValue)


            if fileValue != None:
                for value in self.buffer.interate():
                    if type(value) == str:
                        if(Meta.genarte_hash(value) == fileValue.hash):
                            return Encoding.decode64BitEncoding(value)
Exemplo n.º 6
0
 def __init__(self, args, configuration_path = None):
     self.args               = args
     self.thug_version       = __thug_version__
     log.configuration_path  = configuration_path
     log.personalities_path  = os.path.join(configuration_path, "personalities") if configuration_path else None
     log.ThugOpts            = ThugOpts()
     log.ThugVulnModules     = ThugVulnModules()
     log.WebTracking         = WebTracking.WebTracking()
     log.MIMEHandler         = MIMEHandler.MIMEHandler()
     log.SchemeHandler       = SchemeHandler.SchemeHandler()
     log.JSClassifier        = JSClassifier.JSClassifier()
     log.URLClassifier       = URLClassifier.URLClassifier()
     log.SampleClassifier    = SampleClassifier.SampleClassifier()
     log.Encoding            = Encoding.Encoding()
Exemplo n.º 7
0
def main(mode):
    """
        -----------------------------------------------------------------------
        --------------------------Security Project-----------------------------
        -----------------------------------------------------------------------
        The first menu does the following : encode and decode a given text to 
          various types of encoding utf8, ascii, base16, base32, base64        
        -----------------------------------------------------------------------

    """
    if (mode == 'Cryptage/Decryptage symétrique'):
        SymmetricEncryption.menu()
    if (mode == 'Codage'):
        Encoding.menu()
    if (mode == 'Hachage'):
        Hashing.hash_menu()
    if (mode == 'Cracker mot de passe'):
        Hashing.crack_menu()
    if (mode == 'Cryptage/Decryptage asymétrique'):
        AsymmetricEncryption.menu()

    if (mode == 'rien'):
        menu()
Exemplo n.º 8
0
    def getMetaData(f):
        if type(f) is file:
            strBuffer = ""

            encoding = Encoding.get64BitEncoding(f.read())

            buffer = MetaObject(Meta.genarte_hash(encoding), str(Meta.getFileSize(f)), f.name, str(datetime.datetime.now()))

            strBuffer += Meta.genarte_hash(encoding) + ","
            strBuffer += str(Meta.getFileSize(f)) + ","
            strBuffer += f.name + ","
            strBuffer += str(datetime.datetime.now())

            return buffer, encoding

        return None
Exemplo n.º 9
0
def main():
    # https://docs.python.org/3.1/library/getopt.html
    try:
        opts, args = getopt.getopt(sys.argv[1:], "edi:o:",
                                   ["encode", "decode", "infile=", "outfile="])

    except getopt.GetoptError as err:
        print(err)
        usage()
        sys.exit(2)

    fn = None
    output = None
    command = None

    for o, a in opts:
        if o == "--encode":
            if (command == "decode"):
                print("Error 1: Two commands have been requested.")
                exit()
            command = "encode"
        elif o == "--decode":
            if (command == "encode"):
                print("Error 1: Two commands have been requested.")
            command = "decode"
        elif o == "--infile":
            fn = a
        elif o == "--outfile":
            output = a

    scanned_text = ""

    with open(fn, encoding="latin-1", mode="r") as fp:
        for line in fp:
            scanned_text += line

    first_chars = list(scanned_text[:4])

    ints = [ord(c) for c in first_chars]
    bytes = bytearray(ints)
    hex_chars_tuple = struct.unpack("I", bytes)

    first_chars_hex = hex_chars_tuple[0]

    if (command == "encode"):
        if (first_chars_hex != 0xefbebaab):
            print("Error 2: The file you entered is not a .ph1 file.")
            exit()

        block = scanned_text[4:8]
        enco = Encoding(scanned_text[8:])

        enco.mtf_encode()

        enco.run_length_encode()

        ascii_list = into_ascii(enco.run_length_list)

        joined_string = "".join(ascii_list)

        with open(output, encoding="latin-1", mode="w") as fp:
            fp.write("\xda\xaa\xaa\xad")
            fp.write(block)
            fp.write(joined_string)

    elif (command == "decode"):
        if (first_chars_hex != 0xadaaaada):
            print("Error 3: The file you entered is not a .ph2 file.")
            exit()

        block = scanned_text[4:8]
        deco = Decoding(scanned_text[8:])

        deco.run_length_list = from_ascii(deco.initial_string)
        deco.run_length_decode()

        deco.mtf_decode()

        result_string = "".join(deco.result_list)

        with open(output, encoding="latin-1", mode="w") as fp:
            fp.write("\xab\xba\xbe\xef")
            fp.write(block)

            fp.write(result_string)
Exemplo n.º 10
0
from Encryption import Encryption
from Decryption import Decryption
from Encoding import Encoding
# Fix --- Handle One Character -> Also, Build Interface
# Instances of Classes
encryp = Encryption()
decrypt = Decryption()
encode = Encoding()

message = raw_input("Enter your message: ")

count = 0
count2 = 0

while len(message) == 0 and count2 != 1:
    if count2 == 1:
        print "Try again some other time."
    count2 += 1
    message = raw_input("Enter some text for your message: ")

print

while encode.checkCharacters(message) and count2 < 1:
    if count == 1:
        print "There was a character in your message that is not supported.\nPlease try again later."
        break
    count += 1
    print "Please enter only the following characters within your message:\nA-Z\n.\n?\n,\n:\nspace\n'\n_____________________________________________"
    message = raw_input("Re-enter your message: ")

if count < 2 and count2 < 2:
Exemplo n.º 11
0
class Encryption:
    # Creating Instance of Encodings
    _encryption = Encoding()
    _alphaBank = _encryption.getAlphaFigures()
    _encodingBank = _encryption.getEncoding()

    # Initializing the Psi-key, Chi-key, Key, Message, Encoding Array and Code
    _psiKey = ""
    _chiKey = ""
    _code = ""
    _message = ""
    _count = 0
    _key = ""
    _encodings = []

    # All Keys will be Generated as Letters
    def _generatingKey(self):
        length_message = len(self._message)

        # Message length of 1
        if length_message == 1:
            randomIndex = random.randint(0, 31)
            self._key = self._alphaBank[randomIndex]
            self._encodings.append(self._encodingBank[randomIndex])
        # Message length is Divisible by 2
        elif (length_message % 2) == 0:
            _half = length_message / 2
            for i in range(length_message):
                randomIndex = random.randint(0, 31)
                if i < _half:
                    self._psiKey += self._alphaBank[randomIndex]
                    self._encodings.append(self._encodingBank[randomIndex])
                if i >= _half and self._count < length_message:
                    self._chiKey += self._alphaBank[randomIndex]
                    self._encodings.append(self._encodingBank[randomIndex])
            self._key = self._psiKey + self._chiKey
        # Message length is a Odd Number
        else:
            firstHalf = length_message / 2
            for i in range(length_message):
                randomIndex = random.randint(0, 31)
                if i < firstHalf:
                    self._psiKey += self._alphaBank[randomIndex]
                    self._encodings.append(self._encodingBank[randomIndex])
                if i >= firstHalf and self._count < length_message:
                    self._chiKey += self._alphaBank[randomIndex]
                    self._encodings.append(self._encodingBank[randomIndex])
            self._key = self._psiKey + self._chiKey

        return self._key

    # Key Alpha
    def getKey(self):
        return self._key

    # Key Encoding
    def getKeyEncode(self):
        return self._encodings

    # Code
    def getCode(self):
        return self._code

    # Collects the User's Message
    def getMessage(self, message):
        if True:
            self._message = message
            print "Successfully received the message."
        else:
            print "Did not receive the message."

    # Encodes the User's Message
    def generatingEncryptionCode(self, _userMessage):
        # Creates the Key
        key = self._generatingKey()

        values = []

        print "Message: " + _userMessage
        print "Key Alpha_Symbols: " + key + "\n"
        code = self._encodingMessageBinary(key, _userMessage)
        alphaCode = self._encodingMessageAlphaSymbols(code)

        # Setting Key & Code Values for Decryption
        self._key = key
        self._code = code[0]

        # UNCOMMENT TO SEE KEY ENCODINGS
        messageLength = len(self._message)
        for i in range(messageLength):
            print "Key Encodings " + str(i) + ": " + self._encodings[i]

        print "\nEncryption: " + code[1]

        print "Encryption in Alpha_Symbols: " + alphaCode

        values.append(code[1])
        values.append(alphaCode)
        return values

    # Encryption Generator --> Adding Key and Message Together --> Binary Display
    def _encodingMessageBinary(self, key, _usermessage):
        code = ""
        codeDisplay = ""
        coder = []

        # Converting the Message to its Binary Correspondence Values
        messageEncodings = self._convertMessage(_usermessage)
        # Message Length in Characters
        messageCodeLength = len(_usermessage)
        i = 0
        k = 0

        while i < messageCodeLength:
            j = 0

            for character in messageEncodings[i]:
                if (j % 5) == 0:
                    codeDisplay += " "
                if character == self._encodings[i][j]:
                    code += "0"
                    codeDisplay += "0"
                else:
                    code += "1"
                    codeDisplay += "1"
                j += 1
            i += 1

        # Used for Alpha Conversion Category
        coder.append(code)

        # Code Display --> Used for Elegant Display to User
        coder.append(codeDisplay)
        return coder

    # Encryption Generator --> Adding Key and Message Together --> Letters & Symbols Display
    def _encodingMessageAlphaSymbols(self, code):
        alphaCoding = []
        alpha = ""
        alphaEncoding = ""
        for index in code[0]:
            alpha += index
            if (len(alpha) % 5) == 0:
                alphaCoding.append(alpha)
                alpha = ""
        for index in range(len(alphaCoding)):
            i = 0
            while i < len(self._encodingBank):
                if self._encodingBank[i] == alphaCoding[index]:
                    alphaEncoding += self._alphaBank[i]
                i += 1
            i = 0
        return alphaEncoding

    # Converting the Message to its Binary Correspondence Values
    def _convertMessage(self, userMessage):
        messagePiece = []
        message = userMessage.upper()
        print "Message: (Read into Bank) " + message + "\nLength of Message: " + str(range(0, len(message)))
        # Converting the Message into Corresponding Encodings
        for index in range(0, len(message)):
            count = 0
            while count < len(self._alphaBank):
                if message[index] == self._alphaBank[count]:
                    messagePiece.append(self._encodingBank[count])
                    print "Message Encodings " + str(index) + ": " + messagePiece[index]

                count += 1
        return messagePiece