This Repository is a collection of different ethical hacking tools and malware's for penetration testing and research purpose written in python, ruby, rust, c++, go and c.
JavaScript algorithmsartificial-intelligencebugbountycryptographycyber-threat-intelligencecybersecurity-projectsethical-hackinghacking-toolsmalwarenessusnetwork-monitoringnetwork-securitynmapportscannerpythonpythonprojectsthreat-intelligencevirus-scanning
Add files via upload
Abdul Wahab Junaid54a37d079918
diff --git a/Cryptography/AES_encrypt_decrypt.py b/Cryptography/AES_encrypt_decrypt.pynew file mode 100644index 0000000..36c4cf2--- /dev/null+++ b/Cryptography/AES_encrypt_decrypt.py@@ -0,0 +1,17 @@+from Crypto.Cipher import AES++# key has to be 16, 24 or 32 bytes long+key="secret-key-12345"++encrypt_AES = AES.new(key.encode("utf8"), AES.MODE_CBC, 'This is an IV-12'.encode("utf8"))++# Fill with spaces the user until 32 characters+message = "This is the secret message ".encode("utf8")++ciphertext = encrypt_AES.encrypt(message)+print("Cipher text: " , ciphertext)++decrypt_AES = AES.new(key.encode("utf8"), AES.MODE_CBC, 'This is an IV-12'.encode("utf8"))+message_decrypted = decrypt_AES.decrypt(ciphertext)++print("Decrypted text: ", message_decrypted.strip().decode())diff --git a/Cryptography/AES_encrypt_decrypt_PBKDF2.py b/Cryptography/AES_encrypt_decrypt_PBKDF2.pynew file mode 100644index 0000000..544a1a3--- /dev/null+++ b/Cryptography/AES_encrypt_decrypt_PBKDF2.py@@ -0,0 +1,26 @@+from Crypto.Cipher import AES+from Crypto.Protocol.KDF import PBKDF2+from Crypto import Random++# key has to be 16, 24 or 32 bytes long+key="secret-key-12345"++iterations = 10000+key_size = 16+salt = Random.new().read(key_size)+iv = Random.new().read(AES.block_size)+derived_key = PBKDF2(key, salt, key_size, iterations)++encrypt_AES = AES.new(derived_key, AES.MODE_CBC, iv)++# Fill with spaces the user until 32 characters+message = "This is the secret message ".encode("utf8")++ciphertext = encrypt_AES.encrypt(message)+print("Cipher text: " , ciphertext)++decrypt_AES = AES.new(derived_key, AES.MODE_CBC, iv)+message_decrypted = decrypt_AES.decrypt(ciphertext)++print("Decrypted text: ", message_decrypted.strip().decode())+diff --git a/Cryptography/AES_encrypt_decrypt_file.py b/Cryptography/AES_encrypt_decrypt_file.pynew file mode 100644index 0000000..c805ce4--- /dev/null+++ b/Cryptography/AES_encrypt_decrypt_file.py@@ -0,0 +1,89 @@+from Crypto.Cipher import AES+from Crypto.Hash import SHA256+import os, random, struct+from Crypto import Random++def encrypt_file(key, filename):+ chunk_size = 64*1024++ output_filename = filename + '.encrypted'++ # Random Initialization vector+ iv = Random.new().read(AES.block_size)++ #create the encryption cipher+ encryptor = AES.new(key, AES.MODE_CBC, iv)++ #Determine the size of the file+ filesize = os.path.getsize(filename)++ #Open the output file and write the size of the file.+ #We use the struct package for the purpose.+ with open(filename, 'rb') as inputfile:+ with open(output_filename, 'wb') as outputfile:+ outputfile.write(struct.pack('<Q', filesize))+ outputfile.write(iv)++ while True:+ chunk = inputfile.read(chunk_size)+ if len(chunk) == 0:+ break+ elif len(chunk) % 16 != 0:+ chunk += bytes(' ','utf-8') * (16 - len(chunk) % 16)++ outputfile.write(encryptor.encrypt(chunk))+++def decrypt_file(key, filename):+ chunk_size = 64*1024++ output_filename = os.path.splitext(filename)[0]++ #open the encrypted file and read the file size and the initialization vector.+ #The IV is required for creating the cipher.+ with open(filename, 'rb') as infile:+ origsize = struct.unpack('<Q', infile.read(struct.calcsize('Q')))[0]+ iv = infile.read(16)++ #create the cipher using the key and the IV.+ decryptor = AES.new(key, AES.MODE_CBC, iv)++ #We also write the decrypted data to a verification file,+ #so we can check the results of the encryption+ #and decryption by comparing with the original file.+ with open(output_filename, 'wb') as outfile:+ while True:+ chunk = infile.read(chunk_size)+ if len(chunk) == 0:+ break+ outfile.write(decryptor.decrypt(chunk))++ outfile.truncate(origsize)+++def getKey(password):+ hasher = SHA256.new(password)+ return hasher.digest()+++def main():+ choice = input("do you want to (E)ncrypt or (D)ecrypt?: ")++ if choice == 'E':+ filename = input('file to encrypt: ')+ password = input('password: ')+ encrypt_file(getKey(password.encode("utf8")), filename)+ print('done.')++ elif choice == 'D':+ filename = input('file to decrypt: ')+ password = input('password: ')+ decrypt_file(getKey(password.encode("utf8")), filename)+ print('done.')++ else:+ print('no option selected.')++if __name__ == "__main__":+ main()+diff --git a/Cryptography/DES_encrypt_decrypt.py b/Cryptography/DES_encrypt_decrypt.pynew file mode 100644index 0000000..89d2a36--- /dev/null+++ b/Cryptography/DES_encrypt_decrypt.py@@ -0,0 +1,25 @@+from Crypto.Cipher import DES++# Fill with spaces the user until 8 characters+user = "user ".encode("utf8")+message = "message ".encode("utf8")++key='mycipher'++# we create the cipher with DES+cipher = DES.new(key.encode("utf8"),DES.MODE_ECB)++# encrypt username and message+cipher_user = cipher.encrypt(user)+cipher_message = cipher.encrypt(message)++print("Cipher User: " + str(cipher_user))+print("Cipher message: " + str(cipher_message))++# We simulate the server where the messages arrive encrypted+cipher = DES.new(key.encode("utf8"),DES.MODE_ECB)+decipher_user = cipher.decrypt(cipher_user)+decipher_message = cipher.decrypt(cipher_message)++print("Decipher user: " + str(decipher_user.decode()))+print("Decipher Message: " + str(decipher_message.decode()))diff --git a/Cryptography/RSA_generate_pair_keys.py b/Cryptography/RSA_generate_pair_keys.pynew file mode 100644index 0000000..a07f909--- /dev/null+++ b/Cryptography/RSA_generate_pair_keys.py@@ -0,0 +1,48 @@+from Crypto.PublicKey import RSA+from Crypto.Cipher import PKCS1_OAEP+from Crypto.Hash import SHA256+from Crypto.Signature import PKCS1_v1_5++def generate(bit_size):+ keys = RSA.generate(bit_size)+ return keys++def encrypt(pub_key, data):+ cipher = PKCS1_OAEP.new(pub_key)+ return cipher.encrypt(data)++def decrypt(priv_key, data):+ cipher = PKCS1_OAEP.new(priv_key)+ return cipher.decrypt(data)++keys = generate(2048)++print("Public key:")+print(keys.publickey().export_key('PEM').decode(), end='\n\n')+with open("public.key",'wb') as file:+ file.write(keys.publickey().export_key())++print("Private Key:")+print(keys.export_key('PEM').decode())+with open("private.key",'wb') as file:+ file.write(keys.export_key('PEM'))++text2cipher = "text2cipher".encode("utf8")++hasher = SHA256.new(text2cipher)+signer = PKCS1_v1_5.new(keys)+signature = signer.sign(hasher)++verifier = PKCS1_v1_5.new(keys)+if verifier.verify(hasher, signature):+ print('The signature is valid!')+else:+ print('The message was signed with the wrong private key or modified')++encrypted_data = encrypt(keys.publickey(),text2cipher)+print("Text encrypted:",encrypted_data)++decrypted_data = decrypt(keys,encrypted_data)+print("Text Decrypted:",decrypted_data.decode())++diff --git a/Cryptography/checksSumFile.py b/Cryptography/checksSumFile.pynew file mode 100644index 0000000..99239b3--- /dev/null+++ b/Cryptography/checksSumFile.py@@ -0,0 +1,14 @@+from Crypto.Hash import MD5++def get_file_checksum(filename):+ hash = MD5.new()+ chunk_size = 8191+ with open(filename, 'rb') as file:+ while True:+ chunk = file.read(chunk_size)+ if len(chunk) == 0:+ break+ hash.update(chunk)+ return hash.hexdigest()++print('The MD5 checksum is',get_file_checksum('checksSumFile.py'))diff --git a/Cryptography/file.txt b/Cryptography/file.txtnew file mode 100644index 0000000..a1a7b99--- /dev/null+++ b/Cryptography/file.txt@@ -0,0 +1 @@+fdfdiff --git a/Cryptography/file.txt.encrypted b/Cryptography/file.txt.encryptednew file mode 100644index 0000000..f7abca5Binary files /dev/null and b/Cryptography/file.txt.encrypted differdiff --git a/Cryptography/private.key b/Cryptography/private.keynew file mode 100644index 0000000..c7acdae--- /dev/null+++ b/Cryptography/private.key@@ -0,0 +1,27 @@+-----BEGIN RSA PRIVATE KEY-----+MIIEpAIBAAKCAQEA2uPHnvHYOecE60WCSsu/ceS/PZNKXRKu+2P90kL1Mb2H9RSV+RlCpDZzNFz0JaaPF+7F5auPwxhYWOxpj92rc7ma9axhvLTkup1qoC3MCazPBQ/Vq+gac5ggkphdW24oIxJt9CQ2SyTOkmbarRrRAubTvY25ttGaajGZsPxKpdzjWn8aiK+YEmKj6JOJpbC4VunUgS4dWNFu3Fqh+HlvF3GSINshThOtvh5hzXEfoO1M8eHfDxt+3I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BWCbGLV2Ai51sICe099Wfi/AnB4XPuXr3+hZ+kNQrPwdEgbId+Y+76qk1L3LG4x7OCkOmk3nREIIWSmqanzHdtWkpaUZrPSNAU+bkBF/QKBgQCYFmFl55W0EpFhFfqdzdpoMDp2G1SjT3SikWjNSc9UzghPEHnlbo1m+WDjttuT08pTPy3yf6LZguBvaMuJJVmVsa1YasSxaHy+b3NcMForIi58IUzj/tlZt+A4W/D4rBVs/dR9oQds2118vQh8HvO89nNx0IlE4+0A/NO+It1vb4dg==+-----END RSA PRIVATE KEY-----\ No newline at end of filediff --git a/Cryptography/public.key b/Cryptography/public.keynew file mode 100644index 0000000..ae7baa9--- /dev/null+++ b/Cryptography/public.key@@ -0,0 +1,9 @@+-----BEGIN PUBLIC KEY-----+MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA2uPHnvHYOecE60WCSsu/+ceS/PZNKXRKu+2P90kL1Mb2H9RSVRlCpDZzNFz0JaaPF+7F5auPwxhYWOxpj92rc+7ma9axhvLTkup1qoC3MCazPBQ/Vqgac5ggkphdW24oIxJt9CQ2SyTOkmbarRrRAu+bTvY25ttGaajGZsPxKpdzjWn8aiKYEmKj6JOJpbC4VunUgS4dWNFu3Fqh+HlvF3G+SINshThOtvh5hzXEfoO1M8eHfDxt3IRT8X4A1Gawu6bjSdHypcx6ZR3ArL01Px2S+7k7tDuZXWtXLf/h+GdQkkd2Z5TeamhIfaQOf6z7I4EnU5f2ZCI9zgM+ukDsenQu7+iQIDAQAB+-----END PUBLIC KEY-----\ No newline at end of file