WMI Commands


  • Get-WmiObject -class Win32_Product
    • Gets a listing of all the installed software on a machine.
  • Get-WmiObject - class Win32_Account
    • Gets a listing of all the user accounts
  • Get-WmiObject - class Win32_BIOS
    • Many times used by malware to determine if the host is a virtual machine or not.
  • Set up a remote windows command
    • $command =  "ipconfig /all >> c:\users\all users\desktop\results.txt"
    • $cmd = "cmd.exe /c $command"
    • Invoke-Method -class Win32_Process -name Create -ArgumentList $cmd -ComputerName \\Desktopname\
  • wmic /node:172.16.27.38 process call create "cmd.exe /c /net user dude /add"
    • uses WMIC to add a user on a remote machine




Powershell Fun

  •  Link Ref
    • Invoke-WmiMethod -Class Win32_Process -Name Create -ArgumentList cmd.exe 
    • Invoke-CimMethod -ClassName Win32_Process -MethodName create -Arguments @{commandline="notepad.exe"}

 



One Attack Example

  1. From a powershell command prompt, attacker launches WMIC with the intent of creating a process on the remote machine and adding a user to that remote machine.
    1. wmic /node:172.16.27.38 process call create "cmd.exe /c /net user dude /add"
  2. On the remote machine wmiprvse.exe gets the call and will run the commands. To find this attack in Carbon Black, check out this search:
    1. process_name:cmd.exe AND parent_name:wmiprvse.exe AND childproc_name:net.exe cmdline:user
    2. Event IDs on the remote machine are:
      1. 4720; 4722; 4738; 4732
       

Some Articles from my Bookmarks

https://www.secureworks.com/blog/malware-lingers-with-bits

https://azeria-labs.com/advanced-persistent-threat/

https://digitalguardian.com/blog/seek-evil-and-ye-shall-find-guide-cyber-threat-hunting-operations

https://www.rsaconference.com/writable/presentations/file_upload/hta-w05-tracking_hackers_on_your_network_with_sysinternals_sysmon.pdf

http://security-research.dyndns.org/pub/slides/BotConf/2016/Botconf-2016_Tom-Ueltschi_Sysmon_notes.pdf

https://www.endgame.com/blog/technical-blog/detecting-spectre-and-meltdown-using-hardware-performance-counters

https://blogs.jpcert.or.jp/en/2016/01/windows-commands-abused-by-attackers.html
--> NOTE: this was a really good article!

http://techgenix.com/Dissecting-Pass-Hash-Attack/

Passive Reconnaissance

Some Manual Searching:

You can find some really good stuff sometimes at a site like Data.com.  It is worth it to spend some time here, and search around. Besides, accounts are free.

Tools to Consider:

Discover scripts by Lee baird
Recon-NG

Online Searches

Shodan
Google
Bing
Have I been pwned
Hunter.io

Authenticated WMI Exec Via Powershell

https://packetstormsecurity.com/files/139762/Authenticated-WMI-Exec-Via-Powershell.html

This Metasploit module uses WMI execution to launch a payload instance on a remote machine. In order to avoid AV detection, all execution is performed in memory via psh-net encoded payload. Persistence option can be set to keep the payload looping while a handler is present to receive it. By default the module runs as the current process owner. The module can be configured with credentials for the remote host with which to launch the process.

3 new VMs to test with

https://www.vulnhub.com/entry/readme_1,336/

https://www.vulnhub.com/entry/jigsaw_2,337/

https://www.vulnhub.com/entry/sunset_1,339/