pyscript_rexec.py 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. # A version of the ActiveScripting engine that enables rexec support
  2. # This version supports hosting by IE - however, due to Python's
  3. # rexec module being neither completely trusted nor private, it is
  4. # *not* enabled by default.
  5. # As of Python 2.2, rexec is simply not available - thus, if you use this,
  6. # a HTML page can do almost *anything* at all on your machine.
  7. # You almost certainly do NOT want to use thus!
  8. import pythoncom
  9. from win32com.axscript import axscript
  10. import winerror
  11. from . import pyscript
  12. INTERFACE_USES_DISPEX = 0x00000004 # Object knows to use IDispatchEx
  13. INTERFACE_USES_SECURITY_MANAGER = 0x00000008 # Object knows to use IInternetHostSecurityManager
  14. class PyScriptRExec(pyscript.PyScript):
  15. # Setup the auto-registration stuff...
  16. _reg_verprogid_ = "Python.AXScript-rexec.2"
  17. _reg_progid_ = "Python" # Same ProgID as the standard engine.
  18. # _reg_policy_spec_ = default
  19. _reg_catids_ = [axscript.CATID_ActiveScript,axscript.CATID_ActiveScriptParse]
  20. _reg_desc_ = "Python ActiveX Scripting Engine (with rexec support)"
  21. _reg_clsid_ = "{69c2454b-efa2-455b-988c-c3651c4a2f69}"
  22. _reg_class_spec_ = "win32com.axscript.client.pyscript_rexec.PyScriptRExec"
  23. _reg_remove_keys_ = [(".pys",), ("pysFile",)]
  24. _reg_threading_ = "Apartment"
  25. def _GetSupportedInterfaceSafetyOptions(self):
  26. # print "**** calling", pyscript.PyScript._GetSupportedInterfaceSafetyOptions, "**->", pyscript.PyScript._GetSupportedInterfaceSafetyOptions(self)
  27. return INTERFACE_USES_DISPEX | \
  28. INTERFACE_USES_SECURITY_MANAGER | \
  29. axscript.INTERFACESAFE_FOR_UNTRUSTED_DATA | \
  30. axscript.INTERFACESAFE_FOR_UNTRUSTED_CALLER
  31. if __name__=='__main__':
  32. print("WARNING: By registering this engine, you are giving remote HTML code")
  33. print("the ability to execute *any* code on your system.")
  34. print()
  35. print("You almost certainly do NOT want to do this.")
  36. print("You have been warned, and are doing this at your own (significant) risk")
  37. pyscript.Register(PyScriptRExec)