Skip to content

Commit

Permalink
fix typo + requre latest py3_sg
Browse files Browse the repository at this point in the history
  • Loading branch information
7aman committed Jan 12, 2022
1 parent 4778430 commit 13af566
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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',
Expand Down
21 changes: 13 additions & 8 deletions wdpass/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
HANDSTORESECURITYBLOCK = 1
dev = None


def parse_args(argv):
parser = argparse.ArgumentParser(add_help=True)
parser.add_argument(
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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):
'''
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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")
Expand All @@ -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]")
Expand All @@ -542,4 +547,4 @@ def main():


if __name__ == "__main__":
main()
main()
2 changes: 1 addition & 1 deletion wdpass/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.0.3'
__version__ = '0.0.4'

0 comments on commit 13af566

Please sign in to comment.