Pentest Helper Script: Hash Generator

Another Script i wrote long back and have been using to in various capacities.

This script allows you to quickly generate various types of hashes for a specific string.

Sample usage

$ hash_generator.py  --string="letstrythisone"
Input  : letstrythisone
***************  Various Bases  ******************************
Binary : 1101100 1100101 1110100 1110011 1110100 1110010 1111001 1110100 1101000 1101001 1110011 1101111 1101110 1100101
Octal  : 154 145 164 163 164 162 171 164 150 151 163 157 156 145
Hex    : 6c 65 74 73 74 72 79 74 68 69 73 6f 6e 65
***************  Common Hashes  ******************************
MD5    : 90be9de2525df4c5c440010e72e23a56
SHA1   : 2abd153b8047e04fa5a1b3bbeb96cddac544a9a9
SHA224 : 8595225ea708215c4ab9eddb639087ce0dd77d6d52692db3bc8e9976
SHA256 : 7e59182af28cf652267dd2eb0ad9f5c1aa4bf5cfcabad46f610c779f140c9b79
SHA384 : 13b17d6b0cca166b96f8511ffbd224e265dd060ed5009a0a5e1994b71b37bc2005b1fe08a78044afca778f8753605c41
SHA512 : 1a385e05c323a2908c4ee0912420e2ebb1fba0698d7a812f932fd88a224e9e5e19c6d6b1ee9e46b5ad2e93afdf8dc7bb1e522bf6919251ab392131306f5815c9
***************  Various Encodings ****************************
Base64 : bGV0c3RyeXRoaXNvbmU=
Base16 : 6C657473747279746869736F6E65
Base32 : NRSXI43UOJ4XI2DJONXW4ZI=

Script available here and also included below for reference

#!/usr/bin/env python
import sys
import argparse
import hashlib
import base64

def main(argv):
    target=''
    hax=''
    desc="""This program is used to print various encoded and encrypted version of the same string"""
    epilog="""Credit (C) Anant Shrivastava http://anantshri.info"""
    parser = argparse.ArgumentParser(description=desc,epilog=epilog)
    parser.add_argument("--string",help="Provide URL",dest='input',required=True)
    parser.add_argument("--type",help="[Optional] Type of Encoding / Encryption",dest='type',required=False)
    x=parser.parse_args()
    input=x.input
    type=x.type
    #print hashlib.algorithm_available
    print "Input  : " + input.encode()
    print "***************  Various Bases  ******************************"
    print "Binary : " + ' '.join(format(ord(x), 'b') for x in input) 
    print "Octal  : " + ' '.join(format(ord(a),'o') for a in input)
    print "Hex    : " + ' '.join(format(ord(a),'x') for a in input)
    print "***************  Common Hashes  ******************************"
    print "MD5    : " + hashlib.md5(input.encode()).hexdigest()
    print "SHA1   : " + hashlib.sha1(input.encode()).hexdigest()
    print "SHA224 : " + hashlib.sha224(input.encode()).hexdigest()
    print "SHA256 : " + hashlib.sha256(input.encode()).hexdigest()
    print "SHA384 : " + hashlib.sha384(input.encode()).hexdigest()
    print "SHA512 : " + hashlib.sha512(input.encode()).hexdigest()
    print "***************  Various Encodings ****************************"
    print "Base64 : " + base64.b64encode(input.encode())
    print "Base16 : " + base64.b16encode(input.encode())
    print "Base32 : " + base64.b32encode(input.encode())

if __name__ == "__main__":
   main(sys.argv[1:])

If you are looking for generating various hashing combinations as a brute force method you might be better of using HashMash by @rebootuser

Do you like what you read, What to share it

Leave a Reply

Your email address will not be published. Required fields are marked *