Audit Scheduled Tasks
Silent install package for Audit Scheduled Tasks
2-12
System and network
System and network
- package: tis-audit-scheduled-tasks
- name: Audit Scheduled Tasks
- version: 2-12
- categories: System and network
- maintainer: WAPT Team,Tranquil IT,Jimmy PELÉ
- licence: wapt_public
- locale: all
- target_os: windows
- architecture: all
- signature_date:
- size: 10.00 Ko
package : tis-audit-scheduled-tasks
version : 2-12
architecture : all
section : base
priority : optional
name : Audit Scheduled Tasks
categories : System and network
maintainer : WAPT Team,Tranquil IT,Jimmy PELÉ
description : Audit enabled and disabled scheduled tasks
depends :
conflicts :
maturity : PROD
locale : all
target_os : windows
min_wapt_version : 2.3
sources :
installed_size :
impacted_process :
description_fr : Audit des tâches planifiées activées et désactivées
description_pl : Audyt aktywowanych i dezaktywowanych zaplanowanych zadań
description_de : Prüfung von aktivierten und deaktivierten geplanten Aufgaben
description_es : Auditoría de las tareas programadas activadas y desactivadas
description_pt : Auditoria de tarefas programadas activadas e desactivadas
description_it : Audit delle attività pianificate attivate e disattivate
description_nl : Audit van geactiveerde en gedeactiveerde geplande taken
description_ru : Аудит активированных и деактивированных запланированных задач
audit_schedule :
editor :
keywords :
licence : wapt_public
homepage :
package_uuid : efef2519-1c3d-4364-806e-74dbb6682ed1
valid_from :
valid_until :
forced_install_on :
changelog :
min_os_version :
max_os_version :
icon_sha256sum : 14802353e0babcfecb7df81727f2746e262a3e6994a515bfabb4daf247d74f9e
signer : Tranquil IT
signer_fingerprint: 8c5127a75392be9cc9afd0dbae1222a673072c308c14d88ab246e23832e8c6bb
signature : m/eI+TxIdiZZ7QnlkUxp4Wa7hcJyuSaP8RLIvKjTSb14WhGxGVp8trNmPGaa4YrQwQN/NPGL1wEs/udbJBNS4TyGY3I8ex1ixGJeP0eNRtmX76MneNo5HkccXF0zf9SJaRbuS6+Nlw3VRbtZ4EdWz6th17/qGJ0YO1iqZdnMvsuYnucKFXpGq8Ev8McuPM6kGYs/ULWRPSAbc+haUF2oUj/IFNv76AdxlkJxDyTWsboVzwoqxQ5Ti0sVLFVgg2wmRNRFx90RQNn1z2oGSqSn6+yeiPk7YvvnxxgfXVp4cM73YuyjxJdAARO06VxfivZyhZx+7dJpsVn08KlzSYxGQA==
signature_date : 2023-12-23T16:00:06.371736
signed_attributes : package,version,architecture,section,priority,name,categories,maintainer,description,depends,conflicts,maturity,locale,target_os,min_wapt_version,sources,installed_size,impacted_process,description_fr,description_pl,description_de,description_es,description_pt,description_it,description_nl,description_ru,audit_schedule,editor,keywords,licence,homepage,package_uuid,valid_from,valid_until,forced_install_on,changelog,min_os_version,max_os_version,icon_sha256sum,signer,signer_fingerprint,signature_date,signed_attributes
# -*- coding: utf-8 -*-
from setuphelpers import *
def install():
pass
def audit():
root_scheduled_tasks = get_scheduled_tasks()
microsoft_scheduled_tasks = get_scheduled_tasks(location="Microsoft", recursive=True)
enabled_scheduled_tasks = get_scheduled_tasks(enabled=True, recursive=True)
enabled_scheduled_tasks = {key: value for key, value in enabled_scheduled_tasks.items() if key not in microsoft_scheduled_tasks}
all_scheduled_tasks = get_scheduled_tasks(recursive=True)
others_scheduled_tasks = {key: value for key, value in all_scheduled_tasks.items() if key not in microsoft_scheduled_tasks}
others_scheduled_tasks = {key: value for key, value in others_scheduled_tasks.items() if key not in root_scheduled_tasks}
audit_scheduled_tasks_dict = {
"root": root_scheduled_tasks,
"enabled": enabled_scheduled_tasks,
"others": others_scheduled_tasks,
"microsoft": microsoft_scheduled_tasks,
}
WAPT.write_audit_data_if_changed("audit-scheduled-tasks", "audit-scheduled-tasks", audit_scheduled_tasks_dict)
# WAPT.write_audit_data_if_changed("audit-scheduled-tasks", "all-scheduled-tasks", root_scheduled_tasks)
# WAPT.write_audit_data_if_changed("audit-scheduled-tasks", "enabled-scheduled-tasks", enabled_scheduled_tasks)
print('You can now check this host Audit Data: "audit-scheduled-tasks"')
return "OK"
import os
import re
import sys
import shutil
import tempfile
import win32com.client
def win32com_ensure_dispatch_patch(prog_id):
global win32com
try:
return win32com.client.gencache.EnsureDispatch(prog_id)
except AttributeError:
# Remove cache and try again.
MODULE_LIST = [m.__name__ for m in sys.modules.values()]
for module in MODULE_LIST:
if re.match(r"win32com\.gen_py\..+", module):
del sys.modules[module]
shutil.rmtree(os.path.join(tempfile.gettempdir(), "gen_py"))
import win32com.client
return win32com.client.gencache.EnsureDispatch(prog_id)
def get_scheduled_tasks(location="\\", enabled=None, recursive=False):
"""
Retrieve information about scheduled tasks from the Windows Task Scheduler.
Args:
location (str): The location of the tasks in the Task Scheduler hierarchy. Default is root ("\\").
enabled (bool): If specified, filter tasks based on their enabled status.
recursive (bool): If True, recursively retrieve tasks from subfolders; otherwise, only
retrieve tasks from the specified location.
Returns:
dict: A dictionary containing information about scheduled tasks.
The keys are task paths, and the values are dictionaries with task information,
including 'Name', 'Enabled', 'LastRunTime', 'LastTaskResult', 'NextRunTime',
'NumberOfMissedRuns', 'State', and 'Path'.
"""
# Ensure that location starts with "\\"
location = "\\" + location.lstrip("\\")
scheduler = win32com_ensure_dispatch_patch("Schedule.Service")
scheduler.Connect()
root_folder = scheduler.GetFolder(location)
dict_tasks = get_all_tasks_in_folder(root_folder, enabled)
if recursive:
collect_subfolder_tasks(root_folder, dict_tasks, enabled)
return dict_tasks
def collect_subfolder_tasks(folder, dict_tasks, enabled):
subfolders = folder.GetFolders(1) # 1 means include subfolders
for subfolder in subfolders:
subfolder_tasks = get_all_tasks_in_folder(subfolder, enabled)
dict_tasks.update(subfolder_tasks)
collect_subfolder_tasks(subfolder, dict_tasks, enabled)
def get_all_tasks_in_folder(folder, enabled=None):
tasks = {}
colTasks = folder.GetTasks(1)
for task in colTasks:
if enabled is not None and task.Enabled != enabled:
continue
tasks[task.Path] = {
"Name": task.Name,
"Enabled": task.Enabled,
"LastRunTime": task.LastRunTime,
"LastTaskResult": task.LastTaskResult,
"NextRunTime": task.NextRunTime,
"NumberOfMissedRuns": task.NumberOfMissedRuns,
"State": task.State,
"Path": task.Path,
}
return tasks
cd2e803f90ce7ee381d75a6a899f3e4a815295bde96840c3ef8f9dbbfd48bcff : setup.py
14802353e0babcfecb7df81727f2746e262a3e6994a515bfabb4daf247d74f9e : WAPT/icon.png
a5a97261381e1d0ad46ee15916abec9c2631d0201f5cc50ceb0197a165a0bbbf : WAPT/certificate.crt
581943cc49b7cebc427d389f3c218b1fd80cce85aee07c57c67a7eaf6a7a551c : luti.json
0b17990dc37b01ff10b8bbf5012f68be80639f1d4fbb3f037ef01b3430841508 : WAPT/control