Last active
January 3, 2024 12:51
-
-
Save 0x07CB/d5e24a6761b3e3fee7f54ec228631914 to your computer and use it in GitHub Desktop.
OpenSSL Commands Extraction
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
#coding: utf-8 | |
import os | |
import subprocess | |
from base64 import b64encode as b64enc | |
from base64 import b64decode as b64dec | |
def gen_tpl_sub_opt_help_call_cmnd(opt_helper_0=""): | |
tpl_shell_command = "openssl {sub0a} --help".format(sub0a = opt_helper_0) | |
# Run the command and capture stderr | |
proc = subprocess.Popen(tpl_shell_command, stderr=subprocess.PIPE, shell=True, text=True) | |
(stdout, stderr) = proc.communicate() | |
return stderr | |
class list_commands_openssl_cli: | |
standard_commands = [ "asn1parse", "ca", "ciphers", "cmp", "cms", "crl", "crl2pkcs7", "dgst", "dhparam", "dsa", "dsaparam", "ec", "ecparam" , | |
"enc", "engine", "errstr", "fipsinstall gendsa", "genpkey", "genrsa", "help", "info", "kdf", "list", "mac", "nseq", "ocsp" , | |
"passwd", "pkcs12", "pkcs7", "pkcs8", "pkey", "pkeyparam", "pkeyutl", "prime", "rand", "rehash", "req", "rsa", "rsautl", "s_client", | |
"s_server", "s_time", "sess_id", "smime", "speed", "spkac", "srp", "storeutl", "ts", "verify", "version", "x509" ] | |
message_digest_commands = ['blake2b512', 'blake2s256', 'md4', 'md5', 'rmd160', 'sha1', 'sha224', 'sha256', 'sha3-224', | |
'sha3-256', 'sha3-384', 'sha3-512', 'sha384', 'sha512', 'sha512-224', 'sha512-256', 'shake128', | |
'shake256', 'sm3'] | |
cipher_commands = ['aes-128-cbc', 'aes-128-ecb', 'aes-192-cbc', 'aes-192-ecb', 'aes-256-cbc', 'aes-256-ecb', 'aria-128-cbc', | |
'aria-128-cfb', 'aria-128-cfb1', 'aria-128-cfb8', 'aria-128-ctr', 'aria-128-ecb', 'aria-128-ofb', 'aria-192-cbc', 'aria-192-cfb', | |
'aria-192-cfb1', 'aria-192-cfb8', 'aria-192-ctr', 'aria-192-ecb', 'aria-192-ofb', 'aria-256-cbc', 'aria-256-cfb', 'aria-256-cfb1', | |
'aria-256-cfb8', 'aria-256-ctr', 'aria-256-ecb', 'aria-256-ofb', 'base64', 'bf', 'bf-cbc', 'bf-cfb', 'bf-ecb', 'bf-ofb', 'camellia-128-cbc', | |
'camellia-128-ecb', 'camellia-192-cbc', 'camellia-192-ecb', 'camellia-256-cbc', 'camellia-256-ecb', 'cast', 'cast-cbc', 'cast5-cbc', 'cast5-cfb', | |
'cast5-ecb', 'cast5-ofb', 'des', 'des-cbc', 'des-cfb', 'des-ecb', 'des-ede', 'des-ede-cbc', 'des-ede-cfb', 'des-ede-ofb', 'des-ede3', 'des-ede3-cbc', | |
'des-ede3-cfb', 'des-ede3-ofb', 'des-ofb', 'des3', 'desx', 'rc2', 'rc2-40-cbc', 'rc2-64-cbc', 'rc2-cbc', 'rc2-cfb', 'rc2-ecb', 'rc2-ofb', 'rc4', 'rc4-40', | |
'seed', 'seed-cbc', 'seed-cfb', 'seed-ecb', 'seed-ofb', 'sm4-cbc', 'sm4-cfb', 'sm4-ctr', 'sm4-ecb', 'sm4-ofb'] | |
def openssl_command_extraction(): | |
targets_commands_list = { | |
"standard_commands": list_commands_openssl_cli.standard_commands, | |
"message_digest_commands": list_commands_openssl_cli.message_digest_commands, | |
"cipher_commands": list_commands_openssl_cli.cipher_commands, | |
} | |
for target_key, target_value in targets_commands_list.items(): | |
folder_name="{tname}".format(tname=target_key) | |
os.mkdir(folder_name) | |
print("The folder: '{tname}' created.".format(tname=target_key)) | |
for target_command in target_value: | |
filepath_output = "{folder_category}/openssl_help_{tcommand}_command.txt".format( | |
folder_category = folder_name, | |
tcommand = target_command | |
) | |
data = gen_tpl_sub_opt_help_call_cmnd(target_command) | |
with open(filepath_output, 'wb') as f_out: | |
f_out.write(data.encode()) | |
f_out.close() | |
data = None | |
def main(): | |
openssl_command_extraction() | |
return True | |
if __name__ == '__main__': | |
try: | |
end_code = main() | |
if end_code: exit(0) | |
except KeyboardInterrupt: | |
exit(0) | |
exit(1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I continue and push next version ... maybe