{"id":806,"date":"2020-02-03T23:28:17","date_gmt":"2020-02-04T05:28:17","guid":{"rendered":"http:\/\/zewwy.ca\/?p=806"},"modified":"2020-02-03T23:28:17","modified_gmt":"2020-02-04T05:28:17","slug":"wmic-fun","status":"publish","type":"post","link":"https:\/\/zewwy.ca\/index.php\/2020\/02\/03\/wmic-fun\/","title":{"rendered":"WMIC Fun!"},"content":{"rendered":"<p>I&#8217;ve<a href=\"https:\/\/zewwy.ca\/index.php\/2019\/02\/21\/wmi-and-the-wbemtest\/\"> blogged about WMI<\/a> before, more for setting up dedicated accounts for monitoring purposes.<\/p>\n<p>Today we are going to have some fun with WMIC, the command line interface for simple and quick query data.<\/p>\n<p>I got these ideas after <a href=\"https:\/\/www.andreafortuna.org\/2017\/08\/09\/windows-command-line-cheatsheet-part-2-wmic\/\">reading this source blog<\/a>&#8230; and I was curious at what level these worked (admin or not)<\/p>\n<h1 style=\"text-align: center;\"><span class=\"ez-toc-section\" id=\"Using_WMI\"><\/span>Using WMI<span class=\"ez-toc-section-end\"><\/span><\/h1>\n<p>Most WMIC commands are issued in the following format:<\/p>\n<pre>wmic [Object Class] [Action] [Parameters]<\/pre>\n<p>For example, you can collect a list of groups or users on the local system and domain using the following commands:<\/p>\n<pre>wmic group list brief\r\nwmic useraccount get name,sid<\/pre>\n<p>Yup, SIDs are no secret and you can pretty much query the whole domain if there&#8217;s been no hardening done. I haven&#8217;t tested this on a hardened domain but out of the box all users login name and SID are open for any standard user to query.<\/p>\n<p>You can also perform the same data collection over the network without ever logging into the remote machine provided you know have some administrative credentials that the remote system will accept.<\/p>\n<p>The same command issued against a remote system in another domain looks like this:<\/p>\n<pre>wmic \/user:\"FOREIGN_DOMAIN\\Admin\" \/password:\"Password\" \/node:192.168.33.25 group list brief<\/pre>\n<p>I can&#8217;t test this in my lab as I don&#8217;t have an alternative domain to play with (yet), but let&#8217;s see if I can query a member server using a standard domain account:<\/p>\n<pre>wmic \/node:subca.zewwy.ca group list brief<\/pre>\n<p><a href=\"https:\/\/i.imgur.com\/7dnEItr.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter\" src=\"https:\/\/i.imgur.com\/7dnEItr.png\" alt=\"\" width=\"512\" height=\"78\" \/><\/a><\/p>\n<p><a href=\"https:\/\/i.imgur.com\/A14N6Mi.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter\" src=\"https:\/\/i.imgur.com\/A14N6Mi.png\" alt=\"\" width=\"863\" height=\"548\" \/><\/a><\/p>\n<p>nope well that&#8217;s good&#8230;<\/p>\n<p>Processes<br \/>\nWMIC can collect a list of the currently running processes similar to what you\u2019d see in \u201cTask Manager\u201d using the following command:<\/p>\n<pre>wmic process list\r\nwmic process get name<\/pre>\n<p>Note that some of the WMIC built-ins can also be used in \u201cbrief\u201d mode to display a less verbose output. The process built-in is one of these, so you could collect more refined output using the command:<\/p>\n<pre>wmic process list brief<\/pre>\n<p>Yup, those all work, even as standard user.<\/p>\n<h2 style=\"text-align: center;\"><span class=\"ez-toc-section\" id=\"Some_examples\"><\/span>Some examples<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Start an Application<\/p>\n<pre>wmic process call create \"calc.exe\"<\/pre>\n<p>Yeah&#8230; that worked&#8230;<\/p>\n<p><a href=\"https:\/\/i.imgur.com\/lIjidYl.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter\" src=\"https:\/\/i.imgur.com\/lIjidYl.png\" alt=\"\" width=\"665\" height=\"370\" \/><\/a><\/p>\n<p>I decided to see if I could somehow exploit these to get elevated rights, so far no dice.. but I did<a href=\"https:\/\/superuser.com\/questions\/106848\/batch-file-that-runs-cmd-exe-a-command-and-then-stays-open-at-prompt\"> find this randomly<\/a> while searching for a possible way&#8230;<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/i.imgur.com\/cANO7aT.png\" \/><\/p>\n<p>sure enough, if you add start cmd.exe \/k &#8220;net use&#8221; and name it net use.bat it will go into and endless loop. Mhmm interesting and easiest way to do a Denial Of Service attack.<\/p>\n<p>anyway moving on&#8230;<\/p>\n<h2 style=\"text-align: center;\"><span class=\"ez-toc-section\" id=\"System_Information_and_Settings\"><\/span>System Information and Settings<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>You can collect a listing of the environment variables (including the PATH) with this command: (standard User works)<\/p>\n<pre>wmic environment list<\/pre>\n<p>OS\/System Report HTML Formatted<\/p>\n<pre>wmic \/output:c:os.html os get \/format:hform<\/pre>\n<p><a href=\"https:\/\/i.imgur.com\/SAeISnn.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter\" src=\"https:\/\/i.imgur.com\/SAeISnn.png\" alt=\"\" width=\"586\" height=\"78\" \/><\/a><\/p>\n<p>This was literally cause my standard account didn&#8217;t have access to C:\\temp cause I created the folder using my admin account at some earlier point in time.<\/p>\n<p>Products\/Programs Installed Report HTML Formatted<\/p>\n<pre>wmic \/output:c:product.html product get \/format:hform<\/pre>\n<p>Turn on Remoted Desktop Remotely<\/p>\n<pre>Wmic \/node:\"servername\" \/user:\"user@domain\" \/password: \"password\" RDToggle where ServerName=\"server name\" call SetAllowTSConnections 1<\/pre>\n<p><a href=\"https:\/\/i.imgur.com\/IyLwOEW.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter\" src=\"https:\/\/i.imgur.com\/IyLwOEW.png\" alt=\"\" width=\"1170\" height=\"313\" \/><\/a><\/p>\n<p>Get Server Drive Space Usage Remotely (any node commands require elevated permissions, standard user fails at these generally)<\/p>\n<pre>WMIC \/Node:%%A LogicalDisk Where DriveType=\"3\" Get DeviceID,FileSystem,FreeSpace,Size \/Format:csv MORE \/E +2 &gt;&gt; SRVSPACE.CSV<\/pre>\n<p>Get PC Serial Number (works as standard user)<\/p>\n<pre>wmic bios get serialnumber<\/pre>\n<p>Get PC Product Number (works as standard user)<\/p>\n<pre>wmic baseboard get product<\/pre>\n<p>Find stuff that starts on boot (works as standard user)<\/p>\n<pre>wmic STARTUP GET Caption, Command, User<\/pre>\n<p>Reboot or Shutdown (works as standard user)<\/p>\n<pre>wmic os get buildnumber\r\nwmic os where buildnumber=\"2600\" call reboot<\/pre>\n<p>Get Startup List (works as standard user)<\/p>\n<pre>wmic startup list full<\/pre>\n<p>Information About Harddrives (works as standard user)<\/p>\n<pre>wmic logicaldisk where drivetype=3 get name, freespace, systemname, filesystem, size, volumeserialnumber<\/pre>\n<p>Information about OS (works as standard user)<\/p>\n<pre class=\"wp-block-preformatted\">wmic os get bootdevice, buildnumber, caption, freespaceinpagingfiles, installdate, name, systemdrive, windowsdirectory \/format:htable &gt; c:osinfo.htm<\/pre>\n<h2 style=\"text-align: center;\"><span class=\"ez-toc-section\" id=\"User_and_Groups\"><\/span>User and Groups<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Local user and group information can be obtained using these commands:<\/p>\n<pre class=\"wp-block-preformatted\">wmic useraccount list<\/pre>\n<pre class=\"wp-block-preformatted\">wmic group list<\/pre>\n<pre class=\"wp-block-preformatted\">wmic sysaccount list<\/pre>\n<p>For domain controllers, this should provide a listing of all user accounts and groups in the domain. The \u201csysaccount\u201d version provides you with system accounts built-in and otherwise,which is useful for any extra accounts that may have been added by rootkits.<\/p>\n<p>Identify any local system accounts that are enabled (guest, etc.)<\/p>\n<pre class=\"wp-block-preformatted\">wmic USERACCOUNT WHERE \"Disabled=0 AND LocalAccount=1\" GET Name<\/pre>\n<p>Number of Logons Per USERID<\/p>\n<pre class=\"wp-block-preformatted\">wmic netlogin where (name like \"%skodo\") get numberoflogons<\/pre>\n<p>Get Domain Names And When Account PWD set to Expire<\/p>\n<pre class=\"wp-block-preformatted\">WMIC UserAccount GET name,PasswordExpires \/Value<\/pre>\n<h2 style=\"text-align: center;\"><span class=\"ez-toc-section\" id=\"Patch_Management\"><\/span>Patch Management<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Need to know if there are any missing patches on the system? WMIC can help you find out with this command:<\/p>\n<pre class=\"wp-block-preformatted\">wmic qfe list<\/pre>\n<p>The QFE here stands for \u201cQuick Fix Engineering\u201d.<br \/>\nThe results also include the dates of install should that be needed from an auditing standpoint.<\/p>\n<h2 style=\"text-align: center;\"><span class=\"ez-toc-section\" id=\"Shares\"><\/span>Shares<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Enumeration of all of the local shares can be collected using the command:<\/p>\n<pre class=\"wp-block-preformatted\">wmic share list<\/pre>\n<p>The result will also include hidden shares (named with a $ at the end).<\/p>\n<p>Find user-created shares (usually not hidden)<\/p>\n<pre class=\"wp-block-preformatted\">wmic SHARE WHERE \"NOT Name LIKE '%$'\" GET Name, Path<\/pre>\n<p>so far all these are working as standard user, but that doesn&#8217;t mean anything.<\/p>\n<h2 style=\"text-align: center;\"><span class=\"ez-toc-section\" id=\"Networking\"><\/span>Networking<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Use the following command to extract a list of network adapters and IP address information:<\/p>\n<pre class=\"wp-block-preformatted\">wmic nicconfig list<\/pre>\n<p>Get Mac Address:<\/p>\n<pre class=\"wp-block-preformatted\">wmic nic get macaddress<\/pre>\n<p>Update static IP address:<\/p>\n<pre class=\"wp-block-preformatted\">wmic nicconfig get description, index\r\nwmic nicconfig where index=9 call enablestatic(\"192.168.16.4\"), (\"255.255.255.0\")<\/pre>\n<p><a href=\"https:\/\/i.imgur.com\/8B3u88u.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter\" src=\"https:\/\/i.imgur.com\/8B3u88u.png\" alt=\"\" width=\"890\" height=\"403\" \/><\/a><\/p>\n<p>Yup got to be an admin for that one<\/p>\n<p>Change network gateway:<\/p>\n<pre class=\"wp-block-preformatted\">wmic nicconfig where index=9 call setgateways(\"192.168.16.4\", \"192.168.16.5\"),(1,2)<\/pre>\n<p>Enable DHCP:<\/p>\n<pre class=\"wp-block-preformatted\">wmic nicconfig where index=9 call enabledhcp<\/pre>\n<p>Get List of IP Interfaces<\/p>\n<pre class=\"wp-block-preformatted\">wmic nicconfig where IPEnabled='true'<\/pre>\n<h2 style=\"text-align: center;\"><span class=\"ez-toc-section\" id=\"Services\"><\/span>Services<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>WMIC can list all of the installed services and their configurations using this command:<\/p>\n<pre class=\"wp-block-preformatted\">wmic service list<\/pre>\n<p>The output will include the full command used for starting the service and its verbose description.<\/p>\n<h2 style=\"text-align: center;\"><span class=\"ez-toc-section\" id=\"Other_examples\"><\/span>Other examples<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Service Management<\/p>\n<pre class=\"wp-block-preformatted\"> wmic service where caption=\"DHCP Client\" call changestartmode \"Disabled\"<\/pre>\n<p>Look at services that are set to start automatically<\/p>\n<pre class=\"wp-block-preformatted\">wmic SERVICE WHERE StartMode=\"Auto\" GET Name, State<\/pre>\n<p>Services Report on a Remote Machine HTML Formatted:<\/p>\n<pre class=\"wp-block-preformatted\">wmic \/output:c:services.htm \/node:server1 service list full \/ format:htable<\/pre>\n<p>Get Startmode of Services<\/p>\n<pre class=\"wp-block-preformatted\">Wmic service get caption, name, startmode, state<\/pre>\n<p>Change Start Mode of Service:<\/p>\n<pre class=\"wp-block-preformatted\">wmic service where (name like \"Fax\" OR name like \"Alerter\") CALL ChangeStartMode Disabled<\/pre>\n<p>Get Running Services Information<\/p>\n<pre class=\"wp-block-preformatted\">Wmic service where (state=\"running\") get caption, name, startmode, state<\/pre>\n<p>Another interesting feature of WMIC is its ability to record the run-time command executed and runtime configuration all in one XML file. A recorded session might look something like this:<\/p>\n<pre class=\"wp-block-preformatted\">wmic \/record:users_list.xml useraccount list<\/pre>\n<p>Of course, since WMIC wasn\u2019t designed as a recording device, there are some caveats to using the XML. First, you can only use XML output, there are no other formats defined.<\/p>\n<h2 style=\"text-align: center;\"><span class=\"ez-toc-section\" id=\"Event_logs\"><\/span>Event logs<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Obtain a Certain Kind of Event from Eventlog<\/p>\n<pre class=\"wp-block-preformatted\">wmic ntevent where (message like \"%logon%\") list brief<\/pre>\n<p>Clear the Eventlog<\/p>\n<pre class=\"wp-block-preformatted\">wmic nteventlog where (description like \"%secevent%\") call cleareventlog<\/pre>\n<p>Retrieve list of warning and error events not from system or security logs<\/p>\n<pre class=\"wp-block-preformatted\">WMIC NTEVENT WHERE \u201cEventType &lt; 3 AND LogFile != \u2018System\u2019 AND LogFile != \u2018Security\u2019\u201d GET LogFile, SourceName, EventType, Message, TimeGenerated \/FORMAT:\u201dhtable.xsl\u201d:\u201d datatype = number\u201d:\u201d sortby = EventType\u201d &gt; c:appevent.htm<\/pre>\n<p>Thanks Andrea!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;ve blogged about WMI before, more for setting up dedicated accounts for monitoring purposes. Today we are going to have some fun with WMIC, the command line interface for simple and quick query data. I got these ideas after reading this source blog&#8230; and I was curious at what level these worked (admin or not) &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/zewwy.ca\/index.php\/2020\/02\/03\/wmic-fun\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;WMIC Fun!&#8221;<\/span><\/a><\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"sfsi_plus_gutenberg_text_before_share":"","sfsi_plus_gutenberg_show_text_before_share":"","sfsi_plus_gutenberg_icon_type":"","sfsi_plus_gutenberg_icon_alignemt":"","sfsi_plus_gutenburg_max_per_row":"","footnotes":""},"categories":[8,197],"tags":[273],"class_list":["post-806","post","type-post","status-publish","format-standard","hentry","category-server-administration","category-windows","tag-wmic"],"_links":{"self":[{"href":"https:\/\/zewwy.ca\/index.php\/wp-json\/wp\/v2\/posts\/806","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/zewwy.ca\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/zewwy.ca\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/zewwy.ca\/index.php\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/zewwy.ca\/index.php\/wp-json\/wp\/v2\/comments?post=806"}],"version-history":[{"count":3,"href":"https:\/\/zewwy.ca\/index.php\/wp-json\/wp\/v2\/posts\/806\/revisions"}],"predecessor-version":[{"id":809,"href":"https:\/\/zewwy.ca\/index.php\/wp-json\/wp\/v2\/posts\/806\/revisions\/809"}],"wp:attachment":[{"href":"https:\/\/zewwy.ca\/index.php\/wp-json\/wp\/v2\/media?parent=806"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/zewwy.ca\/index.php\/wp-json\/wp\/v2\/categories?post=806"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/zewwy.ca\/index.php\/wp-json\/wp\/v2\/tags?post=806"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}