Skip to content

Add FilterRunOnce support (--no-run-once) to avoid duplicate GPO task runs - #28

Open
Byxs20 wants to merge 3 commits into
Hackndo:masterfrom
Byxs20:master
Open

Add FilterRunOnce support (--no-run-once) to avoid duplicate GPO task runs#28
Byxs20 wants to merge 3 commits into
Hackndo:masterfrom
Byxs20:master

Conversation

@Byxs20

@Byxs20 Byxs20 commented Jun 28, 2026

Copy link
Copy Markdown

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

  • Default behavior: run_once=True — the task self-deletes after first
    execution via <FilterRunOnce> in the ScheduledTasks XML.
  • New CLI flag: --no-run-once disables this behavior, restoring the
    original "reapply on every refresh" behavior when intentionally needed.

Changes

File Change
pygpoabuse/scheduledtask.py Added run_once parameter to __init__; generates <FilterRunOnce> XML block
pygpoabuse/gpo.py update_scheduled_task() now accepts and passes through run_once
pygpoabuse/cli.py New --no-run-once argument; defaults to True

Example

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant