diff --git a/README.md b/README.md index 28d4d48..551e3ea 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,8 @@ options: --colors print with colors ``` +The `value` argument accepts any standard Python integer literal: decimal (`512`), hexadecimal (`0x200`), binary (`0b1000000000`), or octal (`0o1000`). + ## Contributing Pull requests are welcome. Feel free to open an issue if you want to add other features. diff --git a/msFlagsDecoder.py b/msFlagsDecoder.py index 5483698..1e6df4f 100755 --- a/msFlagsDecoder.py +++ b/msFlagsDecoder.py @@ -73,9 +73,14 @@ def parseArgs(): if __name__ == '__main__': options = parseArgs() + try: + options.value = int(options.value, 0) + except ValueError: + print("[!] Invalid value %r: expected an integer (decimal, 0x… hex, 0b… binary, or 0o… octal)" % options.value) + exit(1) + if options.attribute.lower() == "userAccountControl".lower(): bits = 32 - options.value = int(options.value) if options.bits == True: print("[>] %-30s : %s" % ("userAccountControl value", bin(options.value)[2:].rjust(bits, '0').replace('0', '.'))) else: @@ -119,7 +124,6 @@ def parseArgs(): elif options.attribute.lower() == "sAMAccountType".lower(): bits = 32 - options.value = int(options.value) if options.bits == True: print("[>] %-25s : %s" % ("sAMAccountType value", bin(options.value)[2:].rjust(bits, '0').replace('0', '.'))) else: