{"id":7719,"date":"2021-02-26T19:18:16","date_gmt":"2021-02-26T19:18:16","guid":{"rendered":"https:\/\/www.hexacorn.com\/blog\/?p=7719"},"modified":"2021-02-26T19:18:16","modified_gmt":"2021-02-26T19:18:16","slug":"event-id-7039-out-pid-a-pid","status":"publish","type":"post","link":"https:\/\/www.hexacorn.com\/blog\/2021\/02\/26\/event-id-7039-out-pid-a-pid\/","title":{"rendered":"Event ID 7039 &#8211; out&#8230;pid a pid"},"content":{"rendered":"\n<p>This event is not very well explained on the internet, so I took a liberty of describing it below:<\/p>\n\n\n\n<p>The event message is as follows:<\/p>\n\n\n\n<blockquote class=\"wp-block-quote\"><p>A service process other than the one launched by the Service Control Manager connected when starting the [SERVICE_NAME] service. The Service Control Manager launched process [PID1] and process [PID2] connected instead.<\/p><p>Note that if this service is configured to start under a debugger, this behavior is expected.<\/p><\/blockquote>\n\n\n\n<p>The message kinda tells us what happened &#8211; two different processes talk to SCM instead of one. It doesn&#8217;t really tell us WHY this happens.<\/p>\n\n\n\n<p>Example from a case I looked at in response to a query on <a href=\"https:\/\/twitter.com\/eric_capuano\/status\/1364688728204210177?s=20\">Twitter<\/a>:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" loading=\"lazy\" width=\"551\" height=\"482\" src=\"https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2021\/02\/7039.png\" alt=\"\" class=\"wp-image-7720\" srcset=\"https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2021\/02\/7039.png 551w, https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2021\/02\/7039-300x262.png 300w\" sizes=\"(max-width: 551px) 100vw, 551px\" \/><\/figure>\n\n\n\n<p>In this particular case the c:\\windows\\sysmon.exe was registered as a program that service process starts from. I believe this file was later manually replaced with a newer version of sysmon.exe. The little-known fact about distributable version of Sysmon (sysmon.exe from the sysinternals page) is that it is built as a 32-bit executable with an embedded 64-bit executable inside its resources. When launched on a 64-bit system the 32-bit version extracts and spawns that 64-bit version executable (note the PIDs and compare them against the Event Log):<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" loading=\"lazy\" width=\"425\" height=\"62\" src=\"https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2021\/02\/7039_2-1.png\" alt=\"\" class=\"wp-image-7722\" srcset=\"https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2021\/02\/7039_2-1.png 425w, https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2021\/02\/7039_2-1-300x44.png 300w\" sizes=\"(max-width: 425px) 100vw, 425px\" \/><\/figure>\n\n\n\n<p>Looking at it in general terms: when you register a service its configuration in Registry points to an executable file. This executable is then used to launch a service. Some services are not designed in a very good way. Once such programs are launched as a service, they spawn other processes, sometimes even batch files that may as well launch other programs. If one of these spawn programs talks to SCM the latter immediately recognizes that it&#8217;s not the same executable as the service process the service configuration points to. Such design is in general poor and could be a subject to possible privilege escalation (in a lolbinish way). And since this is a security concern the event 7039 is being logged. <\/p>\n\n\n\n<p>And this leads me to the key reason I wanted to write an article. The Event 7309 tells you two things:<\/p>\n\n\n\n<ul><li>Whoever designed the service didn&#8217;t do the best job, OR, more importantly, <\/li><li>A bad guy may be using a badly designed service to escalate privileges.<\/li><\/ul>\n\n\n\n<p>Hence, you should be looking at these.<\/p>\n\n\n\n<p>And last, but not least &#8211; does it mean Sysmon is designed badly? Nope. It&#8217;s designed in a clever way to use a single portable executable for 32-bit and 64-bit systems. The problem arises from a corner case in a way it was manually upgraded, instead of  using the &#8220;-u&#8221; switch.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This event is not very well explained on the internet, so I took a liberty of describing it below: The event message is as follows: A service process other than the one launched by the Service Control Manager connected when &hellip; <a href=\"https:\/\/www.hexacorn.com\/blog\/2021\/02\/26\/event-id-7039-out-pid-a-pid\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[15,82,79],"tags":[],"_links":{"self":[{"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/posts\/7719"}],"collection":[{"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/comments?post=7719"}],"version-history":[{"count":3,"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/posts\/7719\/revisions"}],"predecessor-version":[{"id":7725,"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/posts\/7719\/revisions\/7725"}],"wp:attachment":[{"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/media?parent=7719"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/categories?post=7719"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/tags?post=7719"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}