{"id":8757,"date":"2021-09-27T03:33:26","date_gmt":"2021-09-27T01:33:26","guid":{"rendered":"https:\/\/tajdini.net\/blog\/?p=8757"},"modified":"2021-09-27T03:33:27","modified_gmt":"2021-09-27T01:33:27","slug":"windows-processes-investigation","status":"publish","type":"post","link":"https:\/\/tajdini.net\/blog\/dfir-and-incident-response\/windows-processes-investigation\/","title":{"rendered":"Windows Processes Investigation"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\" id=\"smss-exe\">smss.exe<a href=\"#smss-exe\"><\/a><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">It&#8217;s called <strong>Session Manager<\/strong>. Session 0 starts <strong>csrss.exe<\/strong> and <strong>wininit.exe<\/strong> (<strong>OS<\/strong> <strong>services<\/strong>) while Session 1 starts <strong>csrss.exe<\/strong> and <strong>winlogon.exe<\/strong> (<strong>User<\/strong> <strong>session<\/strong>). However, you should see <strong>only one process<\/strong> of that <strong>binary<\/strong> without children in the processes tree. Also, more sessions apart from 0 and 1 may mean that RDP sessions are occurring.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"csrss-exe\">csrss.exe<a href=\"#csrss-exe\"><\/a><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Is the <strong>Client\/Server Run Subsystem Process<\/strong>. It manages <strong>processes<\/strong> and <strong>threads<\/strong>, makes the <strong>Windows<\/strong> <strong>API<\/strong> available for other processes and also <strong>maps<\/strong> <strong>drive<\/strong> <strong>letters<\/strong>, create <strong>temp<\/strong> <strong>files<\/strong> and handles the <strong>shutdown<\/strong> <strong>process<\/strong>. There is one <strong>running in Session 0 and another one in Session 1<\/strong> (so <strong>2 processes<\/strong> in the processes tree). Another one is created <strong>per new Session<\/strong>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"winlogon-exe\">winlogon.exe<a href=\"#winlogon-exe\"><\/a><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">This is Windows Logon Process. It&#8217;s responsible for user <strong>logon<\/strong>\/<strong>logoffs<\/strong>. It launches <strong>logonui.exe<\/strong> to ask for username and password and then calls <strong>lsass.exe<\/strong> to verify them. Then it launches <strong>userinit.exe<\/strong> which is specified in <code><strong>HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon<\/strong><\/code> with key <strong>Userinit<\/strong>. Mover over, the previous registry should have <strong>explorer.exe<\/strong> in the <strong>Shell key<\/strong> or it might be abused as a <strong>malware persistence method<\/strong>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"wininit-exe\">wininit.exe<a href=\"#wininit-exe\"><\/a><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">This is the <strong>Windows Initialization Process<\/strong>. It launches <strong>services.exe<\/strong>, <strong>lsass.exe<\/strong> and <strong>lsm.exe<\/strong> in Session 0. There should only be 1 process.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"userinit-exe\">userinit.exe<a href=\"#userinit-exe\"><\/a><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Load the <strong>ntduser.dat in HKCU<\/strong> and initialises the <strong>user<\/strong> <strong>environment<\/strong> and runs <strong>logon<\/strong> <strong>scripts<\/strong> and <strong>GPO<\/strong>. It launches <strong>explorer.exe<\/strong>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"lsm-exe\">lsm.exe<a href=\"#lsm-exe\"><\/a><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">This is the <strong>Local Session Manager<\/strong>. It works with smss.exe to manipulate use sessions: Logon\/logoff, shell start, lock\/unlock desktop&#8230; After W7 lsm.exe was transformed into a service (lsm.dll). There should only be 1 process in W7 and from them a service running the DLL.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"services-exe\">services.exe<a href=\"#services-exe\"><\/a><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">This is the <strong>Service Control Manager<\/strong>. It <strong>loads<\/strong> <strong>services<\/strong> configured as <strong>auto-start<\/strong> and <strong>drivers<\/strong>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">It&#8217;s the parent process of <strong>svchost.exe<\/strong>, <strong>dllhost.exe<\/strong>, <strong>taskhost.exe<\/strong>, <strong>spoolsv.exe<\/strong> and many more. Note that services are defined in <code>HKLM\\SYSTEM\\CurrentControlSet\\Services<\/code> and this process maintains a DB in memory of service info that can be queried by sc.exe.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Note how <strong>some<\/strong> <strong>services<\/strong> are going to be running in a <strong>process of their own<\/strong> and others are going to be <strong>sharing a svchost.exe process<\/strong>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">There should only be 1 process.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"lsass-exe\">lsass.exe<a href=\"#lsass-exe\"><\/a><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">This the <strong>Local Security Authority Subsystem<\/strong>. It&#8217;s responsible for the user <strong>authentication<\/strong> and create the <strong>security<\/strong> <strong>tokens<\/strong>. It uses authentication packages located in <code>HKLM\\System\\CurrentControlSet\\Control\\Lsa<\/code>. It writes to the <strong>Security<\/strong> <strong>event<\/strong> <strong>log<\/strong>. There should only be 1 process. Keep in mind that this process is highly attacked to dump passwords.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"svchost-exe\">svchost.exe<a href=\"#svchost-exe\"><\/a><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">This is the <strong>Generic Service Host Process<\/strong>. It hosts multiple DLL services in one shared process. Usually you will find that <strong>svchost.exe<\/strong> is launched with <code>-k<\/code> flag. This will launch a query to the registry <strong>HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Svchost <\/strong>where there will be a key with the argument mentioned in -k that will contain the services to launch in the same process.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For example: <code>-k UnistackSvcGroup<\/code> will launch: <code>PimIndexMaintenanceSvc MessagingService WpnUserService CDPUserSvc UnistoreSvc UserDataSvc OneSyncSvc<\/code><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If the <strong>flag <\/strong><strong><code>-s<\/code><\/strong> is also used with an argument, then svchost is asked to <strong>only launch the specified service<\/strong> in this argument.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">There will be several process of <code>svchost.exe<\/code>. If any of them is <strong>not using the <\/strong><strong><code>-k<\/code><\/strong><strong> flag<\/strong>, then thats very suspicious. If you find that <strong>services.exe is not the parent<\/strong>, thats also very suspicious.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"taskhost-exe\">taskhost.exe<a href=\"#taskhost-exe\"><\/a><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">This process act as host for processes run from DLLs. It loads the services that are run from DLLs. In W8 is called taskhostex.exe and in W10 taskhostw.exe.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"explorer-exe\">explorer.exe<a href=\"#explorer-exe\"><\/a><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">This is the process responsible for the <strong>user&#8217;s desktop<\/strong> and launching files via file extensions. <strong>Only 1<\/strong> process should be spawned <strong>per logged on user.<\/strong> This is run from <strong>userinit.exe<\/strong> which should be terminated, so <strong>no parent <\/strong>should appear for this process.<\/p>\n\n\n\n<h1 class=\"wp-block-heading\" id=\"catching-malicious-processes\">Catching Malicious Processes<a href=\"#catching-malicious-processes\"><\/a><\/h1>\n\n\n\n<ul class=\"wp-block-list\"><li class=\"\">Is it running from the expected path? (No Windows binaries run from temp location)<\/li><li class=\"\">Is it communicating with weird IPs?<\/li><li class=\"\">Check digital signatures (Microsoft artefacts should be signed)<\/li><li class=\"\">Is it spelled correctly?<\/li><li class=\"\">Is running under the expected SID?<\/li><li class=\"\">Is the parent process the expected one (if any)?<\/li><li class=\"\">Are the children processes the expecting ones? (no cmd.exe, wscript.exe, powershell.exe..?)<\/li><\/ul>\n","protected":false},"excerpt":{"rendered":"<p>smss.exe It&#8217;s called Session Manager. Session 0 starts csrss.exe and wininit.exe (OS services) while Session 1 starts csrss.exe and winlogon.exe (User session). However, you should see [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":8758,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[224,235],"tags":[179,180,176],"class_list":["post-8757","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-dfir-and-incident-response","category-windows-and-server","tag-dfir","tag-rdp","tag-windows"],"_links":{"self":[{"href":"https:\/\/tajdini.net\/blog\/wp-json\/wp\/v2\/posts\/8757","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tajdini.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tajdini.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tajdini.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/tajdini.net\/blog\/wp-json\/wp\/v2\/comments?post=8757"}],"version-history":[{"count":1,"href":"https:\/\/tajdini.net\/blog\/wp-json\/wp\/v2\/posts\/8757\/revisions"}],"predecessor-version":[{"id":8759,"href":"https:\/\/tajdini.net\/blog\/wp-json\/wp\/v2\/posts\/8757\/revisions\/8759"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/tajdini.net\/blog\/wp-json\/wp\/v2\/media\/8758"}],"wp:attachment":[{"href":"https:\/\/tajdini.net\/blog\/wp-json\/wp\/v2\/media?parent=8757"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tajdini.net\/blog\/wp-json\/wp\/v2\/categories?post=8757"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tajdini.net\/blog\/wp-json\/wp\/v2\/tags?post=8757"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}