All posts
Adli BilişimSiber Güvenlik

Windows Commands Every Incident Responder Should Know

In this article I'll cover the commands you need to know when investigating Windows systems. The commands I'll cover here are the fundamental commands an…

Hello everyone,

In this article I’ll cover the commands you need to know when investigating Windows systems. The commands I’ll cover here are the fundamental commands an incident response analyst needs to know.

In the article, I’ll go through the following topics in order.

  • User accounts,
  • Processes,
  • Services,
  • Task Scheduler,
  • Run/Startup,
  • Registry entries,
  • Active TCP and UDP ports,
  • File shares,
  • Files,
  • Firewall settings,
  • Open sessions,
  • Log entries

User Logins

Investigating user activity is very important during the Incident Response process. It’s used to find out whether there are any suspicious user accounts or whether any restriction has been applied to a user. It also lets us check a user account to see which user is currently logged on and what type of user account they have.

User accounts can be viewed as follows:

To view user accounts in the GUI, we press “Win+R” and type the following command.

lusrmgr.msc

1,

To view the user accounts on the system and what type each account is, we open a command prompt and type the following command.

net user

2,

To view local user accounts on the system, the net localgroup command is used together with the group name. An administrator can use this command to add a user to a group, remove a user, create a new group, or delete an existing group.

After opening the command line, we type the following commands:

net localgroup administrators

3,

To view local user accounts, their names, and descriptions, PowerShell is opened as administrator and the following command is run:

Get-LocalUser

4,

Processes

The “tasklist” command is used to get a list of all processes running on the system. Using this command, you can obtain a lot of relevant information, such as memory usage, uptime, file names, and running services.

To view processes, as mentioned above, we press “Win+R” and then type the following command.

5,

Then we click “OK” and view all the processes running on the system. This way, we can track the processes running on the system.

6,

To see the Process ID (PID), session name, and amount of memory used by all running processes, we run the following command:

tasklist

7,

To view a list of all active processes running on the computer, we open PowerShell as administrator and type the following command.

get-process

8,

Windows systems have an extremely powerful tool in WMIC. WMIC is extremely important and useful during incident response. This tool can be used both in Command Prompt and in PowerShell. It also lets us perform anomaly detection on the system.

wmic process list full

9,

We’ve identified which process is generating abnormal network activity. Next, to get more detailed information about process IDs, process name, and parent process ID, we run the following command.

wmic process get name,parentprocessid,processid

10,

To find the path of the WMIC process, we type the following command into PowerShell.

wmic process where 'ProcessID=PID’ get CommandLine

11,

Services

This lets us view whether there is any abnormal service running on the system, or whether certain services are running properly.

We do “Win+R”, and type the following command:

services.msc

12,

Here we view the list of processes.

13,

To start and view the list of services running from the command line, we type the following command as administrator.

net start

14,

To see whether a service is running, and for more information;

sc query | more

15,

If we want to view, from the command line, the list of processes associated with and running alongside a given one,

tasklist /svc

16,

Task Scheduler

Task Scheduler is a Windows component that allows scripts or programs to be launched at a predefined time or after certain intervals. This is also one of the most important areas to check during Incident Response processes. This is where suspicious scheduled tasks can be spotted.

To view Task Scheduler in the GUI;

C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Administrative Tools

17,

To view Task Scheduler from the command line, we run the command prompt as administrator and type the following command:

schtasks

18,

Run/Startup

The Startup folder in Windows automatically launches applications when you log on. Because of this, applications that run automatically absolutely must be checked and monitored.

We open Task Manager. Here we can see which applications are enabled and which are disabled.

taskmgr

19,

To view startup applications in PowerShell, we run PowerShell as administrator and type the following command:

wmic startup get caption,command

20,

To see a detailed list of AutoStart, i.e. automatically launched applications, in PowerShell, we run it as administrator and type the following;

Get-CimInstance Win32_StartupCommand | Select-Object Name, command, Location, User | Format-List

21,

Registry Entries

“Win+R” > “regedit”

22,

This is how the Registry is displayed.

23,

To view it in PowerShell;

reg query HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run

24,

reg query HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Run

25,

The following command is used to remove registry entries;

Remove-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion -Name PSHome

Active TCP and UDP Ports (the netstat command)

This is where we get detailed information about inbound and outbound connections on the network, routing tables, listening ports, and usage statistics.

netstat -ano

26,

A different command can also be run in PowerShell to view the IP address and local ports.

Get-NetTCPConnection -LocalAddress 192.168.1.145 | Sort-Object LocalPort

27,

File Shares

The following command can be used in PowerShell to view file shares.

Get-SMBShare

28,

Files

The “forfiles” command is used to view files that may be malicious or that have a specific extension. Forfiles is a command-line utility.

For example,

To view .exe files along with their paths on the command line;

forfiles /D -10 /S /M *.exe /C "cmd /c echo @path"

29,

To view files without further detail about their path, specific file extension, and modification date,

forfiles /D -10 /S /M *.exe /C "cmd /c echo @ext @fname @fdate"

30,

To check files that have been modified in the last 10 days;

forfiles /pc: /S /D -10

31,

Firewall Settings

To view firewall configurations and inbound/outbound traffic at the command prompt;

netsh firewall show config

32,

To view firewall settings at the command prompt;

netsh advfirewall show currentprofile

33,

Open Sessions

To see any open session on the system;

net session

35,

Log Entries

“Win+R”

eventvwr.msc

36,

To export the logs for a specific event;

wevtutil qe security

37,

To get the list of event logs in PowerShell;

Get-EventLog -List

38,

Thanks for reading this far. :)

sources: