├── README.md ├── cookpw.py ├── drive.sh └── password.bin /README.md: -------------------------------------------------------------------------------- 1 | ## Unlocking WD Passport Hard Disk on Linux/ Ubuntu Operating System 2 | 3 | Steps to follow: 4 | 5 | 1. Open Terminal 6 | 2. Type Command : 7 | dmesg | grep -i scsi 8 | (This will provide your WD Passport drive name) 9 | 10 | ![screenshot from 2018-08-28 06-11-54](https://user-images.githubusercontent.com/42756579/44694630-3835e680-aa8c-11e8-8163-14d51ca14337.png) 11 | 12 | 13 | Example : In my case its "sdb" (See the line [sdb] Attached SCSI disk above the WD My Passport) 14 | 3. Download the code zip file 15 | 4. Unzip the files downloaded in the Download folder 16 | 5. Type in Terminal : 17 | * cd Downloads/ 18 | * cd WD-Passport-Unlock-Linux-master/ 19 | * chmod u+x cookpw.py 20 | * ./cookpw.py THEPASSWORD >password.bin 21 | 22 | (Note: Enter your Password instead of THEPASSWORD. Its done twice since you will get an error after running once) 23 | 6. Install 'sg3_utils' package for your distro depends on the distro you use ! 24 | * Example for debian : 25 | * http://sg.danny.cz/sg/sg3_utils.html 26 | * Then go to Download and Build 27 | * Then scroll down to download 1.42 --- sg3-utils_1.42-0.1_i386.deb (for 32 bit system) or sg3-utils_1.42-0.1_amd64.deb (for 64 bit system) and install it by just opening it. 28 | 29 | * In case link expires refer my github link for sg3_utils -- https://github.com/geekhaidar/sg3_utils_WD 30 | 31 | 7. sudo sg_raw -s 40 -i password.bin /dev/sdb c1 e1 00 00 00 00 00 00 28 00 32 | * (Note : Instead of "sdb" enter the name of your WD as acquired in Step 2) 33 | * It will ask your password enter it. 34 | 8. You will get an output : "SCSI Status : Good" on being successful 35 | 36 | -------------------------------------------------------------------------------- /cookpw.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | from __future__ import print_function 4 | import sys 5 | import argparse 6 | import codecs 7 | 8 | def wdc(password): 9 | password = "WDC." + password 10 | password = password.encode("utf-16")[2:] 11 | from hashlib import sha256 12 | for _ in range(1000): 13 | password = sha256(password).digest() 14 | return password 15 | 16 | def hdparm(password): 17 | if password == 'NULL': 18 | password = '' 19 | return bytes(password.ljust(32, '\0').encode('ascii')) 20 | 21 | def generate_password(password, cook_method, cmd): 22 | password = cook_method(password) 23 | 24 | if cmd == 'unlock': 25 | field = b'00' 26 | else: 27 | password = password + password 28 | if cmd == 'unset': 29 | field = b'10' 30 | if cmd == 'set': 31 | field = b'01' 32 | 33 | header = b'450000' + field + b'00000020' 34 | header = codecs.getdecoder('hex')(header)[0] 35 | 36 | return header + password 37 | 38 | def main(): 39 | parser = argparse.ArgumentParser() 40 | parser.add_argument("passwd", type=str) 41 | parser.add_argument("--hdparm", action="store_true") 42 | group = parser.add_mutually_exclusive_group() 43 | group.add_argument("--unset", action="store_true") 44 | group.add_argument("--set", action="store_true") 45 | 46 | args = parser.parse_args() 47 | 48 | if args.hdparm: 49 | if len(args.passwd) > 32: 50 | sys.exit('Password length cannot be larger than 32!') 51 | method = hdparm 52 | else: 53 | method = wdc 54 | 55 | if args.unset: 56 | # sg_raw -s 72 -i OUTPUT_FILE DEVICE c1 e2 00 00 00 00 00 00 48 00 57 | cmd = 'unset' 58 | elif args.set: 59 | # sg_raw -s 72 -i OUTPUT_FILE DEVICE c1 e2 00 00 00 00 00 00 48 00 60 | cmd = 'set' 61 | else: 62 | # sg_raw -s 40 -i OUTPUT_FILE DEVICE c1 e1 00 00 00 00 00 00 28 00 63 | cmd = 'unlock' 64 | 65 | password = generate_password(args.passwd, method, cmd) 66 | 67 | out = getattr(sys.stdout, 'buffer', sys.stdout) 68 | out.write(password) 69 | 70 | if __name__ == '__main__': 71 | main() 72 | -------------------------------------------------------------------------------- /drive.sh: -------------------------------------------------------------------------------- 1 | python ./home/Sifo/Desktop/cookpw.py SIFO123 >password.bin 2 | sudo sg_raw -s 40 -i password.bin /dev/SDD c1 e1 00 00 00 00 00 00 28 00 3 | -------------------------------------------------------------------------------- /password.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/geekhaidar/WD-Passport-Unlock-Linux/e142a09d37aa9decb0102d6a85fc83eb6d1cd322/password.bin --------------------------------------------------------------------------------