Advertisement
ra2of

Untitled

Nov 21st, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.62 KB | None | 0 0
  1. import winreg
  2.  
  3. def set_run_key(key, value):
  4.     # This is for the system run variable
  5.     reg_key = winreg.OpenKey(
  6.         winreg.HKEY_CURRENT_USER,
  7.         r'Software\Microsoft\Windows\CurrentVersion\Run',
  8.         0, winreg.KEY_SET_VALUE)
  9.  
  10.     with reg_key:
  11.         if value is None:
  12.             winreg.DeleteValue(reg_key, key)
  13.         else:
  14.             if '%' in value:
  15.                 var_type = winreg.REG_EXPAND_SZ
  16.             else:
  17.                 var_type = winreg.REG_SZ
  18.             winreg.SetValueEx(reg_key, key, 0, var_type, value)
  19.  
  20. def main():
  21.     set_run_key('malicious', 'calc.exe')
  22.  
  23.  
  24. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement