Question

CAN BE DONE IN ANY LANGUAGE

In this assignment you will implement a password salt verification system and brute force attack. You will be given a UID and

UID Values will be from 000 to 100:

001
002
003
004
005
006
007
008
009
010
011
012
013
014
015
016
017
018
019
020
021
022
023
024
025
026
027
028
029
030
031
032
033
034
035
036
037
038
039
040
041
042
043
044
045
046
047
048
049
050
051
052
053
054
055
056
057
058
059
060
061
062
063
064
065
066
067
068
069
070
071
072
073
074
075
076
077
078
079
080
081
082
083
084
085
086
087
088
089
090
091
092
093
094
095
096
097
098
099
100

Hash Values are the following:

a9154393f28581eff2ca3b84b44f8702
89bf097de1f883368ef00e652fa2ae8d
04117ec99be1bcbd9f42da3228685f26
a5eec6aa303a169368cdb7a1b7818be8
e307b0acf8b5896c62ec0372ed3b7a38
594a723309b9b0bf3ca081ef4008c709
d303dd9e216a31f4f3422877b25012c6
fc97bd45eed421fd859d0a57d3c9168c
5689bc7ae71a56ca02f4a6fbeb221a65
ecf00e96b47634d0edd411a3ecd16d45
e2e9fbc8ee758be468a2f3e8164d5995
3f34c28d953d4279e7fec04cddf69d61
7b86f90ffebabff0bc29ed460da38414
9e537436c7751a0f75acee353f4e7fa3
e8e3742add907f94d2534e6c1431c021
74f4d9a79a5a4f17e231008269d8f126
9d016be6b4b7a8e0abbd7e81d48d54ad
926183d9745a0ad9531e339cecc27c32
b7321bde18b5bcabab68dcb2a3b59d8b
89f18f046ac58603900a73c34f5c88ac
c9781a494696f39198bd87f863ffd2f1
cba36fe41dd35e38934109092111cb94
8c0f135b3e798427eee61cd59a377895
4d4ab45bff506e6f8b2530a60e4fbc84
093c57314f26e564f1edb847edf691f4
6ca04238450d2d76affc85441bfba832
e05b02d5732d420bb62c3175413b8f45
ecf7f3478a26f387d045956adf3b048b
1d706464afbf3138772167e9cd5ac648
2dfb337ff8cde7515ea3d99d169b6ab3
9c45c74b86973fb81748008496e643ea
2e86861267dfd51df069325ef8586eb1
814a5a817f7cecf59321d7b1b59512eb
760d293372257cd0af2c83d33a69e992
1ad2721523dcc547cbee3d4823c5f9cc
55df2796fee19ddd3860b950350fad28
cf855b8878ca23707b21abb06e6e9bfe
0460cf935180a5fb1bee794d2166dcc8
6ee6e1f98bb64faecf719fdec5935285
711a31e3af8b42f1af1dc30b747a4043
1de0c17431522b41496f4617b34ccbb6
c6ccbdd6e0e99d15738141c0882fc703
21542a4afaa446283d9dac62816b6f4f
fe3d4de9a42fc0fbc0c7c7702149ddac
f8c74793ea1534a510cd4c43c6724f98
3911e13c8f3345418ec1e756e0cc2325
170df1ce6c4cf82375cdf5751324666f
06c47b7fcf6fac367bd36a833a9ac627
eb42658c3b74e64470f1ce96dca09a97
8ac8b25c4ffdd19f40be9e9f121a8400
864287113da1db156d23553e91af2bca
8a1e10f94d0478895afc263478f5367f
8d361f8aa92bd601f06a0f050533edab
f0ef3ea13c7f4d2a21a59d3daae7b73e
2ead2c8aec52e72dc872df8a9989517c
35b9853368c995b693cf0d0bafed0a03
8b981b46577e36238d238c88fd5502af
e5c6d48896c5b988be046f8a48951f83
49868b6ce89f70b6b9b9e8c7cc1999c2
a288f9ce0700f58d67f8ad727fd6d7e8
5c3c31e58e5cbeabd7985226cf121152
986c5cbeb003ffa0751fcaacf650794c
766d04efe8bfbfbc59bd5dd3be786450
8016329915a96453c55c92f7ee06498f
ea3a2dd7805e8ba5b7a3935971d37b48
5f6930065352317503ed73554b4270aa
6c2a30349ab3254936aa5eb587706a7f
a52703e5c0850231e1b3f357a3b2eb11
380b6a7fc5116344ded301fe43add105
74140677f7e93c0faf8a40c21ac21d77
69a3a2c54b7c26c51b58983d092debf8
189c892a88ad58ed15210ee2168a2d77
690b0614d891d57c4300cba80e85a234
00662a81551bacf3f8dd738e2f429eef
9774c80bb94fa9dd404519895403e113
e8294e389ce622c139aa4d7c498763de
7a59c3ad66de26084c3085d98b8393f8
cf0bfe66bc5e6fc77a9db06699a8d6c0
6a2c733c6cc3fc8a548386d9daac24d2
8e7f3ac790fbdc624e01d9ec50071752

0 0
Add a comment Improve this question Transcribed image text
Answer #1

There was an issue with the hash values, the number of hash values is 80 and user id 100, so I could not test the code.

We need to have separate files for hash as well as uid.

import hashlib def computeMD5hash(my_string): m= hashlib.md5() m.update(my_string.encode(utf-8)); return m.hexdigest() 5 6

#Task2 finalPasswords = {} passwords = [0*(4-len(str(x)) +str(x) for x in range(0,1001)] salts=[0*(3-len(str(x)))+str(x)

Here is the code that you can copy, take care of indentation as this is written in python.

Change the filenames as per your files.

import hashlib

def computeMD5hash(my_string):

    m= hashlib.md5()

    m.update(my_string.encode('utf-8'))

    return m.hexdigest()

if __name__=='__main__':

    #Create a dictionary to store files

    database = {}

    #read from files

    file = open('hash.txt','r')

    hashes = file.readlines()

    file.close()

    file = open('uid.txt','r')

    uids = file.readlines()

    file.close()

    #add values to dictionary

    for i in range(len(hashes)):

        uid = uids[i].strip()

        uids[i]=uid

        hashVal = hashes[i].strip()

        database[uid]=hashVal

        

    #Task1

    uid = '001'

    password = '0599'

    salt = '054'

    hashedPass = computeMD5hash(password+salt)

    if(database[uid]==hashedPass):

        print('Correct Password and Salt Value')

    else:

        print('Incorrect Password and Salt')

    #Task2

    finalPasswords = {}

    passwords = ['0'*(4-len(str(x)))+str(x) for x in range(0,1001)]

    salts=['0'*(3-len(str(x)))+str(x) for x in range(0,101)]

    for i in uids:

        hashPass = database[i]

        for j in passwords:

            flag=0

            for k in salts:

                hashGen = computeMD5hash(j+k)

                if(hashGen==hashPass):

                    finalPasswords[i]=[hashPass,j,k]

                    flag=1

                    break

            if(flag==1):

                break

    print('[ UID\t\tHashed Password\t\t\tPassword\tSalt ]')

    for i in uids:

        detail = finalPasswords[i]

        print("['{}'\t'{}'\t'{}'\t\t'{}']".format(i,detail[0],detail[1],detail[2]))

    #Task3

    iD = input('Please enter Username:')

    pS = input('Please enter Password:')

    print(iD,pS)

    salt = finalPasswords[iD][2]

    hashVal = computeMD5hash(pS+salt)

    if(hashVal==finalPasswords[iD][0]):

        print('The input password and salt matches the hash value in database')

    else:

        print('The input password and salt does not match the hash value in database')

If you liked the answer, do give a thumbs up. Comment for more help.

Add a comment
Know the answer?
Add Answer to:
CAN BE DONE IN ANY LANGUAGE UID Values will be from 000 to 100: 001 002...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT