Last active
September 2, 2020 15:26
-
-
Save wdormann/89fae036e58ea6043bd82bca9515749a to your computer and use it in GitHub Desktop.
List privileged scheduled tasks in Windows that don't come with Windows 10
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Don't use this version! | |
# Try https://gist.github.com/wdormann/8afe4edf605627ee4f203861b6cc3a1c instead | |
# | |
# Utility for listing SYSTEM-privileged scheduled tasks on Windows | |
# Tasks that come with Windows 10 are not included. | |
# Admin privileges are required to list all scheduled tasks. | |
import csv | |
import subprocess | |
import tempfile | |
import os | |
with tempfile.NamedTemporaryFile(suffix='.csv', delete=False) as tempcsv: | |
csvoutput = subprocess.call(['schtasks', '/v', '/fo', 'csv'], stdout=tempcsv) | |
with open(tempcsv.name) as f: | |
tasksreader = csv.reader(f) | |
for row in tasksreader: | |
enabled = row[3] | |
taskname = row[1] | |
if enabled != 'Disabled' and '\\Microsoft\\Windows' not in taskname and '\\Microsoft\\XblGameSave' not in taskname: | |
priv = row[14] | |
if priv.lower().strip() == 'system' or priv.lower().strip() == 'nt authority\\system': | |
if row[8].lower() != 'com handler': | |
print('%s : %s' %(row[10],row[8])) | |
os.remove(tempcsv.name) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment