Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import hashlib
- import os
- # see https://cryptography.io
- from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
- from cryptography.hazmat.backends import default_backend
- passwords = '''1d6f01294dd449889d58cec0d7778476
- ceca75998b6f412d89107a547edd89eb
- 65ffce5b584a46628c7237ebb4249a79
- 10a9873f50344226a9defbad15c91d21
- 184cec1173d04418bc588099d94d9eda
- 16589fa9e7444f238e980e2eabbe1a91
- 7de85e2732584b559ce34531748547c2
- 5f09b9dc9f1347d1912a279dd30c62c2
- 513368585cc64d9fba12d78645411c5a
- 57d0f15fb0d447d395321cd2debcde0b
- 22ef5bb093a14152a0bdd2f9bdea1fb7
- 7b3592b8a4aa4caea4d94b898a81efe1
- bc1b4c144cb74bc0981e1e88a73381e7
- f66dfeab81a247268f66650fbe132ec8
- 704ff0cdee73439b80a8d0af1ed4c5ab
- 7b7d6dd186384bb0b8e4bb5736148dbd
- ad9dc6e9c1b3495aa8a95fc58db35776
- a77ce16930c84884810812b7bcd69fbd
- ffcb22fb9aea4718b1df016a333c281c
- f4fd104640df46968d6345372aea3c93
- ded3d46500c340c196cafaec10c33729
- 9fce3b0400574265afad3d6ec3b0698a
- f487949839224aa3a1cc728caaade0dd
- a9d97a170b4848fab44f97af053eb166
- 8d9a6e11cfc942c7951e462166ec670a
- 577fc2feda5a422aa1eac2886de479da
- 0df5b458ca334d4287fd9fe767c36b78
- e40d1437c98243c8bb515b0bd32fca6d
- 05db16c557db413cb2cac96e65989eee
- 187d73349e344ab880939ded883c3304
- 19c5bbb6a702426c8ff75ac5342c9e3b
- 8379b9001598425f9d7638614f2626b3
- 574cabad49814673897306e080b32003
- 2361f05c70084aae87009f0713921885
- d183887a0bfc49f0ae0dd39e2ec52ffc
- cfc62137f7f74d8d8bfca117c7fefeec
- 7f12ef3af006467eb73434ad85e103e9
- 242683f132f04f0ba21909cc1d790d62
- 0c47259dd6e344dbbb3294f240a60080
- b141bb75f86748889a571c90b5bd9348
- 21fb8799faef48c9bc75499fd0c9efd7
- f0dd3e6d874d4745a978d191d9590dd6
- 2f3d6f53d51d4540b3634f7228db890d
- ef7a20115ff64ce8b359b6dfb32b6b15
- d17ae816bd464141adf67daa9dcdb832
- 22c44563b04d478bb444c665dff073f5
- 70c83a88658549d2bef40cbcf5ca4986
- d77c5e729d1549a88f1923ce82e7ae62
- e19c938582b145e5906f6fea89b0d44e
- 07df85cc6fd94a7fb483598287fd5190
- 9cd0b9a6f99e46e08878cfde7ea118ad
- d7da820a2bba48abbbd261ba5fcce79f
- 1f098b5bd0c74e0e914633db9cad262d
- 1c9370d10e8f4bc89d5a8b61c0064289
- ce3d546ad7d448d2bfb47f8cc59b9570
- 2b329abfe39a413da295b6294d6d0eb8
- 7f5e4da6457443eda464eef749a2bb5a
- 14f3ccaf0cdc4456a14c5c927e0a1680
- 3fe72a73ce664a03822facc739424941
- fc19798f336444068398125fe6125229
- 52d849fe8fca4ef8813420a26587f02c'''
- passwords = passwords.splitlines()
- # >Salt Bytes 1-8 was made custom. Salt chosen is 0 1 2 3 4 5 6 7 8.
- # >Encryption Scheme chosen was AES256.
- # >If you use c# with rijndaelmanaged couldn't you set the salt to an array of custom salt bytes?
- #
- # >Also I've tried using databases of passwords for the salt values and still can't get it to work so I dunno what I'm doing wrong.
- #
- # >I got it. I copy/pasted the C# example AES from the MSDN tutorial but changed salt from all 0's to 0, 1, 2, etc. Each password goes 1-1 to each file.
- # >I used the encrypttext/decrypttext portions.
- # stil unable to find any "MSDN tutorial" that uses a salt with all 0's
- # Aesmanaged class:
- # https://msdn.microsoft.com/en-us/library/system.security.cryptography.aesmanaged(v=vs.95).aspx
- # "The AES algorithm is essentially the Rijndael symmetric algorithm with a fixed block size and iteration count. This class functions the same way as the .NET Framework RijndaelManaged class but limits blocks to 128 bits and does not allow feedback modes.
- #
- # The cipher mode is always CBC, and the padding mode is always PKCS7."
- # https://www.codeproject.com/Articles/769741/Csharp-AES-bits-Encryption-Library-with-Salt
- # https://social.msdn.microsoft.com/Forums/windowsdesktop/en-US/65ef9da0-788c-41ee-af46-3ee3a77eaea1/aes-decrypted-value-issue?forum=csharpgeneral
- # bytearray.fromhex(password) or password.encode('ascii')?
- # How many iterations, 1, 1000, 1042 from one of those links? Brute force it using the md5 hash of the decrypted file?
- salt = bytes([0,1,2,3,4,5,6,7,8])
- for index, password in enumerate(passwords):
- passwords[index] = hashlib.pbkdf2_hmac("sha1", bytearray.fromhex(password), salt, 1000, 48)
- backend = default_backend()
- directory_in = "asc"
- directory_out = "asc-out"
- # try the first file only for now until we can get this to work
- for index, filename in list(enumerate(sorted(os.listdir(directory_in))))[0:1]:
- password = passwords[index]
- key = password[0:32]
- # The GetBytes in the example consumes the bytes across calls: https://msdn.microsoft.com/en-us/library/system.security.cryptography.rfc2898derivebytes.getbytes(v=vs.110).aspx
- iv = password[32:48]
- with open(os.path.join(directory_in, filename), 'rb') as encrypted_file:
- encrypted_bytes = encrypted_file.read()
- cipher = Cipher(algorithms.AES(key), modes.CBC(iv), backend=backend) # create the ass-wiper object before you can actually wipe your ass
- decryptor = cipher.decryptor()
- decrypted_bytes = decryptor.update(encrypted_bytes) + decryptor.finalize()
- with open(os.path.join(directory_out, filename), 'wb') as decrypted_file:
- decrypted_file.write(decrypted_bytes)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement