Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #The code serial number function(getMachine_addr) belongs to https://gist.github.com/angeloped/3febaaf71ac083bc2cd5d99d775921d0
- # wmic bios get serialnumber#Windows
- # hal-get-property --udi /org/freedesktop/Hal/devices/computer --key system.hardware.uuid#Linux
- # ioreg -l | grep IOPlatformSerialNumber#Mac OS X
- import os, sys, subprocess
- import getpass
- system_password = "$ub_Z3r0"
- def getMachine_addr():
- os_type = sys.platform.lower()
- command = None
- if "win" in os_type:
- command = "wmic bios get serialnumber"
- elif "linux" in os_type:
- command = "hal-get-property --udi /org/freedesktop/Hal/devices/computer --key system.hardware.uuid"
- elif "darwin" in os_type:
- command = "ioreg -l | grep IOPlatformSerialNumber"
- return os.popen(command).read().replace("\n","").replace(" ","").replace(" ","")
- #Save the serial number into the file
- def save_serial_number(serial_number):
- with open("dev_ser.txt", "w") as serial_file:
- serial_file.write(serial_number)
- #Check if the program will run for the first time on the device
- def check_for_first_run():
- with open("dev_ser.txt", "r") as serial_file:
- for line in serial_file:
- first_line = line.rstrip('\n')
- break
- print("First line is")
- print(first_line)
- if first_line == '':
- print("Line")
- return True
- return False
- #Get the serial number from the saved device
- def read_serial_number_from_file():
- with open("dev_ser.txt", "r") as serial_file:
- for line in serial_file:
- return line
- if __name__ == "__main__":
- serial_number = getMachine_addr()
- if check_for_first_run():
- print("Please enter the system's password")
- password = getpass.getpass()
- if password == system_password:
- save_serial_number(serial_number)
- print("You can run the program now")
- else:
- print("Wrong password")
- else:
- serial_number_in_file = read_serial_number_from_file()
- if serial_number == serial_number_in_file:
- #Put the program path here
- subprocess.call("ls")
- else:
- print("Error while running the program please contact Subzero")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement