Add FilterRunOnce support (--no-run-once) to avoid duplicate GPO task runs - #28
Open
Byxs20 wants to merge 3 commits into
Open
Add FilterRunOnce support (--no-run-once) to avoid duplicate GPO task runs#28Byxs20 wants to merge 3 commits into
Byxs20 wants to merge 3 commits into
Conversation
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds FilterRunOnce support — an Item-Level Targeting filter that
ensures a Scheduled Task runs only once, preventing accidental repeated
execution across multiple GPO refresh cycles.
Problem
Without this filter, a GPO Scheduled Task re-executes on every Group Policy
refresh (default every 90 minutes on domain members). If the operator gets
pulled away or the task takes time to trigger, the command can run
multiple times — leaving unnecessary artifacts, creating duplicate accounts,
or triggering detection.
Solution
run_once=True— the task self-deletes after firstexecution via
<FilterRunOnce>in the ScheduledTasks XML.--no-run-oncedisables this behavior, restoring theoriginal "reapply on every refresh" behavior when intentionally needed.
Changes
pygpoabuse/scheduledtask.pyrun_onceparameter to__init__; generates<FilterRunOnce>XML blockpygpoabuse/gpo.pyupdate_scheduled_task()now accepts and passes throughrun_oncepygpoabuse/cli.py--no-run-onceargument; defaults toTrueExample
By default the task runs once and stops:
python3 pygpoabuse.py DOMAIN/user:password -gpo-id -command "..."
To allow repeated execution on every GPO refresh:
python3 pygpoabuse.py DOMAIN/user:password -gpo-id -command "..." --no-run-once