Advertisement
OstrichSquad

Syntax's Multitool

Nov 4th, 2014
248
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 5.80 KB | None | 0 0
  1. !#/usr/bin/python
  2. # Hey, Feel free to scrap, edit, and do whatever you wish to this code
  3. # All I ask is that you give me some credit if you decide to go public.
  4. print("Welcome to Syntax's multitool!\n")
  5. print("1: Cipher")
  6. print("2: Hash")
  7. print("3: Calculator")
  8. select = raw_input("Please make a selection based on the number associated: ")
  9. if select == "1":
  10.     print("1: AES")
  11.     print("2: Blowfish")
  12.     print("3: DES")
  13.     print("4: Base64")
  14.     print("5: CAST")
  15.     select = raw_input("Please make a selection based on the number associated: ")
  16.     if select == "1":
  17.         from Crypto.Cipher import AES
  18.         from Crypto import Random
  19.         key = b'Sixteen byte key'
  20.         iv = Random.new().read(AES.block_size)
  21.         cipher = AES.new(key, AES.MODE_CFB, iv)
  22.         raw_msg = raw_input("Please enter the string you would like to encrypt: ")
  23.         msg = iv + cipher.encrypt(b"'" + raw_msg + "'")
  24.         print("Your output is: " + msg)
  25.     elif select == "2":
  26.         from Crypto.Cipher import Blowfish
  27.         from Crypto import Random
  28.         from struct import pack
  29.         import base64
  30.         bs = Blowfish.block_size
  31.         raw_key = raw_input("Please enter your arbitrarily long encryption key: ")
  32.         key = b"'" + raw_key + "'"
  33.         iv = Random.new().read(bs)
  34.         cipher = Blowfish.new(key, Blowfish.MODE_CBC, iv)
  35.         plaintext = raw_input("Please enter the string you would like to encrypt: ")
  36.         plaintext0 = b"'" + plaintext + "'"
  37.         plen = bs - divmod(len(plaintext),bs)[1]
  38.         padding = [plen]*plen
  39.         padding = pack('b'*plen, *padding)
  40.         msg = iv + cipher.encrypt(plaintext0 + padding)
  41.         encoded = base64.b64encode(msg)
  42.         print("Your output is: " + msg)
  43.         print("Your output encoded with base64 is: " + encoded)
  44.     elif select == "3":
  45.         from Crypto.Cipher import DES
  46.         from Crypto import Random
  47.         from Crypto.Util import Counter
  48.         raw_key = raw_input("Please enter your sixteen byte encryption key: ")
  49.         key = b"'" + raw_key + "'"
  50.         nonce = Random.new().read(DES.block_size/2)
  51.         ctr = Counter.new(DES.block_size*8/2, prefix=nonce)
  52.         cipher = DES.new(key, DES.MODE_CTR, counter=ctr)
  53.         plaintext = raw_input("Please enter the string you would like to encrypt: ")
  54.         plaintext0 = b"'" + plaintext + "'"
  55.         msg = nonce + cipher.encrypt(plaintext0)
  56.         print("Your output is:" + msg)
  57.     elif select == "4":
  58.         import base64
  59.         print("1: Encryption")
  60.         print("2: Decryption")
  61.         select = raw_input("Please make a selection based on the number associated: ")
  62.         if select == "1":
  63.             msg = raw_input("Please enter the string you would like to encrypt: ")
  64.             encode = base64.b64encode(msg)
  65.         elif select == "2":
  66.             msg = raw_input("Please enter the encrypted string you would like to decrypt: ")
  67.             decode = base64.b64decode(msg)
  68.         else:
  69.             print("Please choose a real option...")
  70.     elif select == "5":
  71.         from Crypto.Cipher import CAST
  72.         from Crypto import Random
  73.         import base64
  74.         print("1: Encryption")
  75.         print("2: Decryption")
  76.         select = raw_input("Please enter your selection based on the number associated: ")
  77.         if select == "1":
  78.             key = b'Sixteen byte key'
  79.             iv = Random.new().read(CAST.block_size)
  80.             cipher = CAST.new(key, CAST.MODE_OPENPGP, iv)
  81.             plaintext0 = raw_input("Please enter the string you wish to encrypt: ")
  82.             plaintext1 = b"'" + plaintext0 + "'"
  83.             msg = cipher.encrypt(plaintext1)
  84.             encode = base64.b64encode(msg)
  85.             print("Your output encoded with base64 is: " + encode)
  86.         elif select == "2":
  87.             encoded = raw_input("Please enter your encoded string: ")
  88.             decode = base64.b64decode(encoded)
  89.             key = b'Sixteen byte key'
  90.             iv = Random.new().read(CAST.block_size)
  91.             cipher = CAST.new(key, CAST.MODE_OPENPGP, iv)
  92.             plaintext1 = b"'" + decode + "'"
  93.             msg = cipher.encrypt(plaintext1)
  94.             eiv = msg[:CAST.block_size+2]
  95.             ciphertext = msg[CAST.block_size+2:]
  96.             cipher = CAST.new(key, CAST.MODE_OPENPGP, eiv)
  97.             decrypt = cipher.decrypt(ciphertext)
  98.             print(decrypt)
  99.         else:
  100.             print("Please choose a real option...")
  101.     else:
  102.         print("Please enter a real option...")
  103. elif select == "2":
  104.     print("1: MD4")
  105.     print("2: MD5")
  106.     print("3: SHA")
  107.     print("4: SHA512")
  108.     select = raw_input("Please make your selection based on the number associated: ")
  109.     if select == "1":
  110.         from Crypto.Hash import MD4
  111.         h = MD4.new()
  112.         hash = raw_input("Please enter ther string you would like to hash: ")
  113.         h.update(b"'" + hash + "'")
  114.         print(h.hexdigest())
  115.     elif select == "2":
  116.         from Crypto.Hash import MD5
  117.         h = MD5.new()
  118.         hash = raw_input("Please enter ther string you would like to hash: ")
  119.         h.update(b"'" + hash + "'")
  120.         print(h.hexdigest())
  121.     elif select == "3":
  122.         from Crypto.Hash import SHA
  123.         h = SHA.new()
  124.         hash = raw_input("Please enter ther string you would like to hash: ")
  125.         h.update(b"'" + hash + "'")
  126.         print(h.hexdigest())
  127.     elif select == "4":
  128.         from Crypto.Hash import SHA512
  129.         h = SHA512.new()
  130.         hash = raw_input("Please enter ther string you would like to hash: ")
  131.         h.update(b"'" + hash + "'")
  132.         print(h.hexdigest())
  133.     else:
  134.         print("Please enter a real option...")
  135. elif select == "3":
  136.     def get_float(prompt):
  137.         while True:
  138.             try:
  139.                 return float(raw_input(prompt))
  140.             except ValueError, e:
  141.                 print "Invalid input"
  142.     print("1: ADDITION")
  143.     print("2: SUBTRACTION")
  144.     print("3: MULTIPLICATION")
  145.     print("4: DIVISION")
  146.     CHOICE = raw_input("Enter the Numbers:")
  147.     if CHOICE == "1":
  148.         a = get_float("Enter the value of a: ")
  149.         b = get_float("Enter the value of b: ")
  150.         c = a + b
  151.         print(c)
  152.     elif CHOICE == "2":
  153.         a = get_float("Enter the value of a: ")
  154.         b = get_float("Enter the value of b: ")
  155.         c = a - b
  156.         print(c)
  157.     elif CHOICE == "3":
  158.         a = get_float("Enter the value of a: ")
  159.         b = get_float("Enter the value of b: ")
  160.         c = a * b
  161.         print(c)
  162.     elif CHOICE == "4":
  163.         a = get_float("Enter the value of a: ")
  164.         b = get_float("Enter the value of b: ")
  165.         c = a / b
  166.         print(c)
  167.     else:
  168.         print "Invalid Number"
  169.         print "\n"
  170. else:
  171.     print("Please enter a real option...")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement