Windows Commands Abused by Attackers 2016

In Windows OS, various commands (hereafter “Windows commands”) are installed by default. However, what is actually used by general users is just a small part of it. On the other hand, JPCERT/CC has observed that attackers intruding into a network also use Windows commands in order to collect information and/or to spread malware infection within the network. What is worth noting here is the gap between those Window commands used by general users and by attackers. If there is a huge difference, it would be possible to detect or limit the attackers’ behaviour by monitoring/controlling the Windows command execution.
This entry will demonstrate how to mitigate the attack impact by revealing Windows commands that attackers use on the intruded Windows OS, and by restricting the execution of those commands that are unnecessary for general users.
Malware for remote control (Remote Access Tool/Trojan – RAT) has a function to execute shell commands from a remote environment. With this, attackers can execute Windows commands from a remote environment.
Attackers who successfully installed such malware in a network will attempt to take control of the system within the network in the following sequence in order to collect confidential information, etc.
  1. Initial investigation: Collect information of the infected machine
  2. Reconnaissance: Look for information saved in the machine and remote machines within the network
  3. Spread of infection: Infect the machine with other malware or try to access other machines
Windows commands are used in all of the phases above. Respective Windows commands used in each phase are introduced here below.

Initial Investigation

Table 1 lists the commands that are often used by attackers in an attempt to collect information of the infected machine. “Times executed” is derived from the sum of Windows commands used by 3 different attack groups in their respective C&C servers (Please refer to Appendix A, B and C for details).
Table 1: Initial Investigation (Top 10 commands)
RankingCommandTimes executed
1tasklist155
2ver95
3ipconfig76
4systeminfo40
5net time31
6netstat27
7whoami22
8net start16
9qprocess15
10query14
Attackers use commands such as “tasklist”, “ver”, “ipconfig” and “systeminfo”, etc., and collect information of the network, process and OS in order to investigate what kind of machine they succeeded in infecting. This is presumably how they make sure that the machine is not a sandbox for malware analysis purposes and so on.

Reconnaissance

Commands shown in Table 2 are often used to search for confidential information and remote machines within the network.
Table 2: Reconnaissance (Top 10 commands)
RankingCommandTimes executed
1dir976
2net view236
3ping200
4net use194
5type120
6net user95
7net localgroup39
8net group20
9net config16
10net share11
Attackers use “dir” and “type” to search for files. Sometimes they collect a list of all the document files in the infected machine by setting appropriate options and arguments for “dir” command.
For searching networks, “net” is used. In particular, the following commands are often seen:
  • net view: Obtain a list of connectable domain resources
  • net user: Manage local/domain accounts
  • net localgroup: Obtain a list of users belonging to local groups
  • net group: Obtain a list of users belonging to certain domain groups
  • net use: Access to resources
Furthermore, the following commands may be used in an environment where Active Directory is used (Please refer to Table 5 in Appendix A). These commands are installed in Windows Server and do not originally exist in client OS such as Windows 7 and 8.1 – but attackers download and install these commands from outside and execute them.
  • dsquery: Search for accounts in Active Directory
  • csvde: Obtain account information in Active Directory

Spread of Infection

To intrude remote machines and spread malware infection within the network, the following commands are often executed:
Table 3: Spread of Infection
RankingCommandTimes executed
1at103
2reg31
3wmic24
4wusa7
5netsh advfirewall4
6sc4
7rundll322
*”wmic” is also used for reconnaissance.
“at” and “wmic” are often used to execute malware on remote machines.
With “at” command, attackers can execute commands on remote machines, by registering tasks to execute files against connectable machines as follows.
at \\[remote host name or IP address] 12:00 cmd /c "C:\windows\temp\mal.exe"
Also, by setting the following options and arguments with “wmic” command, attackers can execute commands on remote machines.
wmic /node:[IP address] /user:”[user name]” /password:”[password]” process call create “cmd /c c:\Windows\System32\net.exe user”

Restricting Execution of Unnecessary Windows Commands

It is fair to say that these Windows commands used by attackers include those that are unused by general users, if carefully selected. With AppLocker and software restriction policy, which restrict such commands from being executed, it would be possible to limit the attackers’ behaviour. For example, if you wish to restrict “net” commands, you can set rules as in Figure 1. (For details of AppLocker configuration, please see Microsoft’s Website [1]).
Figure 1: AppLocker Rules
Also, by enabling AppLocker, events where selected Windows commands were executed or attempted but denied will be recorded in the event logs, which can be utilized for investigation on Windows commands that attackers executed after infecting the machine with malware.
Figure 2: Logs of the Processes Restricted by AppLocker
Figure2
AppLocker can also just monitor Windows commands [2]. With this, AppLocker cannot prevent unintended Windows commands from being executed, but the execution history will be recorded in the event log. If the users themselves use Windows commands that may be used for attacks, it is a good idea to set AppLocker just for monitoring purpose. (Windows command execution can also be monitored by activating “Audit Process Creation” in the local security policy.)

Conclusion

In targeted attacks, attackers not only use functions implemented in the malware, but also often use Windows commands to pursue their purposes. If such activities can be hindered, spread of incidents can be prevented in a fairly early stage. However, it may be difficult to limit the usage of Windows commands right away – so our recommendation is to start by collecting logs of executed processes by using AppLocker, etc.
Thank you for reading and best wishes for the New Year!
- Shusei Tomonaga

Reference:
[2] Microsoft – Using Auditing to Track Which Applications Are Used
Appendix A: List of Executed Commands by respective Attack Groups (Attack Group A)
Table 4: Initial Investigation (Attack Group A)
RankingCommandTimes executedOption
1tasklist119/s /v
2ver92
3ipconfig58/all
4net time30
5systeminfo24
6netstat22-ano
7qprocess15
8query14user
9whoami14/all
10net start10
11nslookup4
12fsutil3fsinfo drives
13time2/t
14set1
Table 5: Reconnaissance (Attack Group A)
RankingCommandTimes executedOption
1dir903
2net view226
3ping196
4net use193
5type118
6net user74
7net localgroup35
8net group19
9net config16
10net share11
11dsquery6
12csvde5/f /q
13nbtstat5-a
14net session3
15nltest3/dclist
16wevtutil2
Table 6: Spread of Infection (Attack Group A)
RankingCommandTimes executedOption
1at98
2reg29add export query
3wmic24
4netsh advfirewall4
5sc4qc query
6wusa2
Appendix B: List of Executed Commands by respective Attack Groups (Attack Group B)
Table 7: Initial Investigation (Attack Group B)
RankingCommandTimes executedOption
1tasklist29/m /svc
2whoami6
3ipconfig5/all
4net start4
5netstat3-ano
6nslookup3
7ver2
8time1/t
Table 8: Reconnaissance (Attack Group B)
RankingCommandTimes executedOption
1dir62
2net user21/domain /add
3net view9/domain
4ping4
5net localgroup4/add
6tree3/F
7type2
8net group1/domain
Table 9: Spread of Infection (Attack Group B)
RankingCommandTimes executedOption
1at5
2wusa5
3reg2
4rundll322
Appendix C: List of Executed Commands by respective Attack Groups (Attack Group C)
Table 10: Initial Investigation (Attack Group C)
RankingCommandTimes executedOption
1systeminfo16
2ipconfig13/all /?
3tasklist7
4netstat5-ano
5whoami2
6net start2
7arp1-a
8chcp1
9net time1
10ver1
Table 11: Reconnaissance (Attack Group C)
RankingCommandTimes executedOption
1dir11
2net user1/all /?
3net view1
4qwinsta1-ano
*Commands for “Spread of Infection” by Attack Group C are omitted since they did not spread the infection.

No comments :