# Scheduled tasks

There might be a possibility that a scheduled task on a Windows machine may have lost the attached binary, or using one that we have write permissions on. The `schtasks` command can be utilized to view scheduled tasks.

```powershell
C:\> schtasks

Folder: \                                                                                                               
TaskName                                 Next Run Time          Status                                                  
======================================== ====================== ===============                                         
vulntask                                 N/A                    Ready

...
...
```

**Perform the following command to view detailed information about a particular task:**

```powershell
C:\> schtasks /query /tn <taskname> /fo list /v
```

**Eg**. To view the detailed information about the ***vulntask*** task

```powershell
C:\> schtasks /query /tn vulntask /fo list /v

Folder: \ 
HostName:                             WPRIVESC1                                                                         
TaskName:                             \vulntask                    
Next Run Time:                        N/A                                                                               
Status:                               Ready                                                                             
...                                                        
Task To Run:                          C:\tasks\schtask.bat   
...
...
```

`schtasks` command flags:

a) `/query`: To list information&#x20;

b) `/tn`: Task name

c) `/fo`: Output format (*list* in this case)

d) `/v`: Verbose

The important value to note is ***Task To Run***. The `icacls` command can be used to find out if we are able to modify the contents of the `C:\tasks\schtask.bat` *(Task To Run)* file.

```powershell
C:\> icacls c:\tasks\schtask.bat
c:\tasks\schtask.bat NT AUTHORITY\SYSTEM:(I)(F)
                    BUILTIN\Administrators:(I)(F)
                    BUILTIN\Users:(I)(F)
```

Explanation of the`(I)` and `(F)` permissions:

1. `(I)`:  Inherited permissions - from a parent folder
2. `(F)`: Full control

As all the account and groups: `SYSTEM`, `Administrator` and Users have `(F)` permissions, it means all of them can read, write and modify the file.

The `BUILTIN\Users:(I)(F)` group permissions means that every single user on the system (privileged or non-privileged) are able to modify the file. This can exploited to insert malicious code into the `schtask.bat` file, such as a reverse shell.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://jarrettgxz-sec.gitbook.io/penetration-testing-ethical-hacking-concepts/privilege-escalation/windows/vulnerabilities-exploit/scheduled-tasks.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
