Skip to main content

Commands

Terminal

:: Detect Terminal Type [CMD]
(dir 2>&1 *`|echo CMD);&

:: Print current Directory
echo %cd%

Executing

:: Execute [PSH] Commands from [CMD]
powershell -c "<Command>"

:: Execute [CMD] Commands from [PSH]
cmd /c "<Command>"
:: List Saved Credentials
cmdkey /list

:: Run Windows Applications or Tools under different Users Permissions
runas /savecred /user:<UserName> cmd.exe

:: Run Specific Commands [Password Piping is Not Allowed]
runas /user:<UserName> "cmd /c dir C:\"

:: [/netonly] Indicates that the User Information specified is for Remote Access Only
runas /netonly /user:<UserName> cmd.exe

Permissions

:: List Permissions
icacls <FileName>

:: Grant Permissions
icacls <FileName> /grant Everyone:F

:: Take File/Folder Ownership
takeown /f <FileName>

Services

:: List Services [Filter]
sc queryex type=service state=all

:: Find Services
sc queryex type=service state=all | find /i <ServiceName>

:: Service Information
sc qc <ServiceName>
:: Start - Stop - Delete
sc start <ServiceName>
sc stop <ServiceName>
sc delete <ServiceName>

Tasks

:: Show Tasks
tasklist /v

:: Kill Tasks
taskkill /F /im <TaskName>
:: Show Tasks Detailed Info
schtasks /query /fo LIST /v

:: Show Specific Task Info
schtasks /query /tn "TaskName" /fo list /v
:: Enable - Disable
schtasks /Change /TN "TaskName" /Enable

:: Run
schtasks /run /tn <TaskName>

:: End
schtasks /end /tn <TaskName>

Search - Delete

:: Search Files [Current Folder/Subfolder]
dir /s <FileName>

:: Search Files [C:\ Drive]
where /r C:\ <FileName>

:: Force Delete Files [CMD]
del /f <FileName>

Network

:: List [Active - Listening] Ports
netstat -a

:: List Listening [Windows Processes] [Requires Elevated Prompt]
netstat -anb

Script Execution

# Unblocks files that were Downloaded from the Internet
Get-ChildItem -Recurse | Unblock-File

# Sets Execution Policies for Windows Computers
# [Bypass] Nothing is Blocked and there are no Warnings or Prompts
Set-ExecutionPolicy Bypass -Scope process -Force

# List Execution Policy Rules
Get-ExecutionPolicy -List | Format-Table -AutoSize

Archiving

# Extracts files from a Specified Archive [Zipped]
Expand-Archive <SourcePathOfZipFile> -DestinationPath <DestinationPath>

# Creates a Compressed Archive
Compress-Archive -Path <SourcePathOfZipFile> -DestinationPath <DestinationPath>

Other

:: Running [.msi] Installer
msiexec /quiet /qn /i C:\Windows\Temp\Installer.msi

:: Connect using RDP from Linux
xfreerdp /v:<IP> /u:<Username> /p:'<Password>'
rdesktop <IP> -u <Username> -p '<Password>'