timmy a révisé ce gist 9 months ago. Aller à la révision
1 file changed, 12 insertions
audit_hook_example.py(fichier créé)
| @@ -0,0 +1,12 @@ | |||
| 1 | + | import sys | |
| 2 | + | ||
| 3 | + | def audit_hook(event, args): | |
| 4 | + | print(f"Audit event: {event}, Arguments: {args}") | |
| 5 | + | ||
| 6 | + | # 註冊審計鉤子 | |
| 7 | + | sys.addaudithook(audit_hook) | |
| 8 | + | ||
| 9 | + | # 觸發一些事件 | |
| 10 | + | open("test.txt", "w").write("Hello") # 檔案寫入事件 | |
| 11 | + | import os # 模組導入事件 | |
| 12 | + | os.system("echo Security Check") # 執行命令事件 | |
Plus récent
Plus ancien