Skip to content

Instantly share code, notes, and snippets.

@sh1dow3r
Last active June 7, 2023 11:42
Show Gist options
  • Save sh1dow3r/44053630c5830deba71f8fa6d8b1a4c2 to your computer and use it in GitHub Desktop.
Save sh1dow3r/44053630c5830deba71f8fa6d8b1a4c2 to your computer and use it in GitHub Desktop.
Convert reg binary type to datetime
from datetime import datetime, timedelta
# Prompt user for the REG_BINARY value
reg_binary_value = input("Enter the REG_BINARY value: ")
# Convert the REG_BINARY value to a list of integers
reg_values = [int(reg_binary_value[i:i+2], 16) for i in range(0, len(reg_binary_value), 2)]
# Perform the calculations
term = (
reg_values[7] * (2 ** 56) + reg_values[6] * (2 ** 48) +
reg_values[5] * (2 ** 40) + reg_values[4] * (2 ** 32) +
reg_values[3] * (2 ** 24) + reg_values[2] * (2 ** 16) +
reg_values[1] * (2 ** 8) + reg_values[0]
)
days = term / (1E7 * 86400)
shutdown_time = datetime(1601, 1, 1) + timedelta(days=days)
# Print the result
print("ShutdownTime =", shutdown_time, "UTC")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment