diff --git a/setup.py b/setup.py index 4fe2688..7867818 100644 --- a/setup.py +++ b/setup.py @@ -11,7 +11,7 @@ setup(name='wdpass', version=__version__, - description='Wester Digital My Passport Utility', + description='Western Digital My Passport Utility', long_description=long_description, long_description_content_type='text/markdown', url='http://github.com/7aman/wdpass', @@ -22,7 +22,7 @@ entry_points={ 'console_scripts': ['wdpass=wdpass:main'], }, - install_requires=["py3_sg"], + install_requires=["py3_sg >= 0.0.3"], python_requires='>=3.6', zip_safe=False, keywords='HDD WD MyPassport Unlocker WesternDigital', diff --git a/wdpass/__init__.py b/wdpass/__init__.py index 62a4448..f9e4887 100644 --- a/wdpass/__init__.py +++ b/wdpass/__init__.py @@ -21,6 +21,7 @@ HANDSTORESECURITYBLOCK = 1 dev = None + def parse_args(argv): parser = argparse.ArgumentParser(add_help=True) parser.add_argument( @@ -81,6 +82,7 @@ def parse_args(argv): return parser.parse_args(argv) + def fail(msg): '''Print fail message with red leading characters''' print("\033[91m" + "[!]" + "\033[0m" + " " + msg) @@ -291,7 +293,8 @@ def unlock(save_passwd, unlock_with_saved_passwd): cdb[8] = pwblen + 8 try: - py_sg.write(dev, _scsi_pack_cdb(cdb), _scsi_pack_cdb(pw_block) + pwd_hashed) + py_sg.write(dev, _scsi_pack_cdb(cdb), + _scsi_pack_cdb(pw_block) + pwd_hashed) success("Device unlocked.") except: fail("Wrong password? Or something bad is happened. Try again") @@ -361,12 +364,13 @@ def change_password(): cdb[8] = 8 + 2 * pwblen try: - py_sg.write(dev, _scsi_pack_cdb(cdb), _scsi_pack_cdb(pw_block) + old_passwd_hashed + new_passwd_hashed) + py_sg.write(dev, _scsi_pack_cdb(cdb), _scsi_pack_cdb( + pw_block) + old_passwd_hashed + new_passwd_hashed) success("Password changed.") except: fail("Error changing password: Wrong password or something bad is happened.") pass - + def secure_erase(cipher_id=0): ''' @@ -468,7 +472,7 @@ def enable_mount(device): f"echo 1 > /sys/block/{rp}/device/delete", shell=True ) - + subprocess.Popen( f"echo \"- - -\" > /sys/class/scsi_host/host{hn}/scan", shell=True @@ -498,14 +502,16 @@ def get_device(device): return get_device_info()[0] # Main function, get parameters and manage operations + + def main(): global dev title("WD Passport Ultra linux utility v0.1 by duke") args = parse_args(sys.argv[1:]) if len(sys.argv) == 1: args.status = True - - check_root_user() + + check_root_user() DEVICE = get_device(args.device) try: dev = open(DEVICE, "r+b") @@ -527,7 +533,6 @@ def main(): if args.change_passwd: change_password() - if args.erase: question( "Any data on the device will be lost. Are you sure you want to continue? [y/N]") @@ -542,4 +547,4 @@ def main(): if __name__ == "__main__": - main() \ No newline at end of file + main() diff --git a/wdpass/version.py b/wdpass/version.py index 8dbfdad..cba8e59 100644 --- a/wdpass/version.py +++ b/wdpass/version.py @@ -1 +1 @@ -__version__ = '0.0.3' \ No newline at end of file +__version__ = '0.0.4' \ No newline at end of file