{"id":3883,"date":"2016-10-16T17:27:34","date_gmt":"2016-10-16T17:27:34","guid":{"rendered":"http:\/\/www.hexacorn.com\/blog\/?p=3883"},"modified":"2016-10-16T22:17:08","modified_gmt":"2016-10-16T22:17:08","slug":"the-threat-hunting-the-anomaly-hunting-the-data-eyeballing","status":"publish","type":"post","link":"https:\/\/www.hexacorn.com\/blog\/2016\/10\/16\/the-threat-hunting-the-anomaly-hunting-the-data-eyeballing\/","title":{"rendered":"The Threat Hunting -> the anomaly hunting -> the data eyeballing"},"content":{"rendered":"<p>In my last post I described my opinion about current state of affairs of the fashionable IR trend called <a href=\"https:\/\/www.hexacorn.com\/blog\/2016\/10\/15\/threat-hunting-a-tale-of-wishful-thinking-and-willful-ignorance\/\">threat hunting<\/a>. Since I am advocating it myself for a number of years I probably shoot myself in a foot by being openly critical about its potentials, but if there is one way for this discipline to progress it is to question your own doing&#8230;<\/p>\n<p>Since I posted it I received a rebuttal from <a href=\"https:\/\/twitter.com\/jackcr\">Jack Crook<\/a> and a couple of answers on Twitter. Jack&#8217;s rebuttal starts by hinting at my inexperience in a field and then goes all the way to promote the very wishful thinking that I decided to criticize. The simple answer to Jack&#8217;s post is this: theory vs. practice. The fundamental problem of threat hunting is not how we detect specific things, or how we generate better ideas how to correlate data for specific cases. This is easy. Once you have that data, that correlation engine in place and that specific idea &#8211; you just implement it. It is a simple engineering work. The &#8216;fun&#8217; begins afterwards &#8211; the tweaking. When I brought up a couple of examples of potential (but naive) threat hunting rules that could be used to detect badness in the environment, it was not to highlight them as examples of rules that could be potentially improved. We can always do so, and can\/should look at more holistic way these events correlate with each other. I agree, I actually do, because I practice it too and quite a lot. Yet, I don&#8217;t want these two points I made to be missed:<\/p>\n<ol>\n<li>The threat hunting _is_ signature writing. How far is it from IOCs, yara and lo and behold &#8211; virus signatures? And we know it doesn&#8217;t work.<\/li>\n<li>The error of availability makes us a subject to naive assumptions &#8211; one that complex correlations will help us to get rid of False Positives easily (which we are not aware of until we test it on large corpora of data)<\/li>\n<\/ol>\n<p>I have already covered the signature writing, let me discuss the error of availability a bit more. We write rules for what we have seen (btw. antivirus works the same, reactive way). Our exposure to the knowledge about BAD actors and behaviors is limited, but we are getting better and better at it. Yet I can bet that neither you nor myself know, or remember all the tricks of the trade. Will your threat hunting cover everything? Does it cover everything inside the <a href=\"https:\/\/www.amazon.co.uk\/Rtfm-Red-Team-Field-Manual\/dp\/1494295504\">Rtfm-Red-Team-Field-Manual<\/a> and <a href=\"https:\/\/github.com\/mubix\/post-exploitation-wiki\">Post Exploitation Wiki<\/a>? I published over 40 posts about various <a href=\"https:\/\/www.hexacorn.com\/blog\/category\/autostart-persistence\/\">persistent mechanisms<\/a> in last couple of years &#8211; I bet most of the threat hunters do NOT look at these cases (full disclosure: I don&#8217;t). The avalanche of clever tricks developed by <a href=\"https:\/\/twitter.com\/subTee\">SubTee<\/a> is definitely NOT covered by most of us either. Add to it the variations of OS commands, tools, various WMI, kiosk-escape, pentesting kung-fu trickery, and also unpublished research, and a few thousands blogs one would need to follow (and constantly discover new ones: don&#8217;t forget Chinese, Korean, Arabic, Spanish, etc. blogospheres) to stay on top of things and you know that we would still be behind. I did mention before that we want to detect the insider threat too. Wishful thinking it is.<\/p>\n<p>But let&#8217;s &#8211; for the sake of the argument &#8211; assume that we read all blogs, APT reports, did our homework and collected all the trickery in our head and we know what to hunt for. Here comes the error of availability number two &#8211; our exposure to the knowledge about GOOD actors and behaviors. It is extremely limited. And it is the latter that makes the Threat Hunting extremely challenging. Because while we successfully leverage our (limited) knowledge about the BAD guys, most of the time we completely ignore the one about the GOOD guys. Once we apply this approach in practice, the False Positives show up immediately. I have already listed a number of examples of GOOD actors&#8217; behaviors in my previous posts. If you simply ignore them in a discussion then I suspect you don&#8217;t have the exposure to a corpora of real security events from a large organization. Support\/Admin scripts often launch a number of lateral movement tools one by one, people use Excel and Word to launch cmd.exe, and other tools, the enterprise solutions use psexec, autoruns, cmd, cscript, xcmd, nmap, WMI, MSI, they load drivers, create scheduled tasks, services, google chrome with its updates is a &#8216;nice&#8217; event generator, people use crazy number of variants of putty, kitty, ssh, winscp placed all over their systems, they download files using wget, curl, even bitsadmin is used either by good guys, or by software, then there is cygwin, a number of users learning hacking in-house, and so on and so forth&#8230; Having a tree and ability to correlate the events is often NOT enough. The sad truth is that behaviors of BAD and GOOD guys are often indistinguishable!<\/p>\n<p>The lack of public data for researchers&#8217; consumption is a problem in this space and one that can be hopefully addressed one day. The threat hunting discussions need to be very data-specific. Threat hunting today is data eyeballing. Just saying that &#8216;we need to look at better rules or correlations and leverage our knowledge about bad actors&#8217; is simply vague. And vague Threat Hunting cannot be. I guess it&#8217;s really time to engage data scientists.<\/p>\n<p>Being critical is constructive only if we discuss next steps. I believe that there is a list of must-do things for any threat hunter &#8211; they may act as an eye opener:<\/p>\n<ul>\n<li>Look at clusters of events generated across large environment (not just one or a few system)\n<ul>\n<li>any event related to execution of wmic.exe, powershell.exe, cscript.exe, wscript.exe, mshta.exe, and pretty much any legitimate .EXE from the OS<\/li>\n<li>any event related to loading of pretty much any .DLL<\/li>\n<\/ul>\n<\/li>\n<li>Look at clusters of commands intercepted from sandboxing of large malware samplesets\n<ul>\n<li>Here I can help with some real data\n<ul>\n<li>How would you discover chrome.exe dropped shown in these <a href=\"https:\/\/www.hexacorn.com\/blog\/2015\/12\/22\/the-art-of-stuffing-and-dressing-of-application-data-folder\/\">events<\/a>?<\/li>\n<li>What rule could you write to discover variants of <a href=\"https:\/\/www.hexacorn.com\/blog\/2015\/12\/18\/the-typographical-and-homomorphic-abuse-of-svchost-exe-and-other-popular-file-names\/\">svchost.exe<\/a> ?<\/li>\n<li>How would you detect artifacts dropped by <a href=\"https:\/\/www.hexacorn.com\/blog\/2013\/03\/04\/clustering-and-batch-analysis-of-apt1-sampleset1\/\">APT1 set<\/a>?<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<li>Read as much as you can not only about new malware and hacking tricks, but also about architecture of the OS, and&#8230; programming manuals, including the OLD school stuff like Win32API, COM, DDE, etc. (I am very Windows-specific in this post, but same applies to other OSes)<\/li>\n<li>Promote science of data analysis &#8211; I am personally way behind and feel there is a need to get better at it<\/li>\n<\/ul>\n<p>Last, but not last&#8230;here&#8217;s a couple of questions to highlight the ambiguities you may come across:<\/p>\n<ul>\n<li>Is a parent-child relationship between the following processes a sign of malicious activity?\n<ul>\n<li>svchost.exe -&gt; iexplore.exe<\/li>\n<\/ul>\n<\/li>\n<li>What about this one?\n<ul>\n<li>svchost.exe -&gt; winword.exe<\/li>\n<\/ul>\n<\/li>\n<li>And this one?\n<ul>\n<li>cmd.exe -&gt; cscript.exe -&gt; nmap.exe<\/li>\n<\/ul>\n<\/li>\n<li>And this one?\n<ul>\n<li>&lt;Non-existent process (70564)&gt; -&gt; cmd.exe -&gt; putty.exe<\/li>\n<\/ul>\n<\/li>\n<li>What events are triggered when you launch a new process via WMI?\n<ul>\n<li>Is the detection of processes opened this way a good threat hunting rule?<\/li>\n<\/ul>\n<\/li>\n<li>Is injection of a remote thread into a foreign process (via CreateRemoteThread API) always a sign of malicious activity ?<\/li>\n<li>The see 50 systems with a number of events indicating randomly named DLLs were loaded from the %TEMP% folder &#8211; would you consider it a malicious activity?<\/li>\n<li>You find traces of radmin, logmein, team viewer executed on a number of systems; would you consider them a malicious activity? (bonus question: how would you codify a Business Unit-specific case)<\/li>\n<li>Is modification of \u00a0c:\\WINDOWS\\system32\\drivers\\etc\\hosts an alertable event?<\/li>\n<li>Finally, since I mentioned we need to be specific and talk about real data &#8211; here&#8217;s a top of the list from the histogram of commands executed by malware samples\u00a0 &#8211; I generated it over 2 years ago from a decent cluster of sandboxed samples &#8211; which ones would you say are bad? Let me remind you &#8211; most of them are associated with malicious activity one way or another&#8230; but are they?<\/li>\n<\/ul>\n<pre>\u00a0 69830 cmd \/c at\r\n\u00a0 69829 cmd \/c rmdir\r\n\u00a0 69829 cmd \/c attrib -s -h -r\r\n\u00a0 21710 msiexec \/i \r\n\u00a0 18872 ipconfig \/all\r\n\u00a0 10859 cmd \/q\r\n\u00a0\u00a0 8367 cmd \/c del \r\n\u00a0\u00a0 8055 regsvr32 \/s \r\n\u00a0\u00a0 7520 cmd \/c \r\n\u00a0\u00a0 6906 msiexec \/quiet \/i \r\n\u00a0\u00a0 6227 net share admin$ \/delete \/y\r\n\u00a0\u00a0 6226 net share ipc$ \/delete \/y\r\n\u00a0\u00a0 6225 net share d$ \/delete \/y\r\n\u00a0\u00a0 6221 net share c$ \/delete \/y\r\n\u00a0\u00a0 5307 ipconfig \/renew\r\n\u00a0\u00a0 5264 regsvr32\u00a0 \/s \u00a0\r\n\u00a0\u00a0 5177 ipconfig \/release\r\n\u00a0\u00a0 3783 taskkill \/f \/im zhudongfangyu.exe\r\n\u00a0\u00a0 3428 taskkill \/f \/im explorer.exe\r\n\u00a0\u00a0 3373 reg add hklm\\system\\currentcontrolset\\control\\terminal\" \"server\\winstations\\rdp-tcp \/v portnumber \/t reg_dword \/d \r\n\u00a0\u00a0 3371 reg add hklm\\system\\currentcontrolset\\control\\terminal\" \"server\\wds\\rdpwd\\tds\\tcp \/v portnumber \/t reg_dword \/d \r\n\u00a0\u00a0 3254 taskkill \/f \/im firefox.exe\r\n\u00a0\u00a0 3207 cmd \/c reg add hklm\\system\\currentcontrolset\\services\\sharedaccess\\parameters\\firewallpolicy\\standardprofile\\authorizedapplications\\list \/v \"\r\n\u00a0\u00a0 3013 taskkill \/f \/im wmplayer.exe\r\n\u00a0\u00a0 2996 taskkill \/f \/im winamp.exe\r\n\u00a0\u00a0 2987 taskkill \/f \/im iexplorer.exe\r\n\u00a0\u00a0 2981 taskkill \/f \/im ansav.exe\r\n\u00a0\u00a0 2977 taskkill \/f \/im winampa.exe\r\n\u00a0\u00a0 2977 taskkill \/f \/im pcmav-cln.exe \/im pcmav-rtp.exe\r\n\u00a0\u00a0 2977 taskkill \/f \/im ansavgd.exe\r\n\u00a0\u00a0 2961 regsvr32 \/s \/u \r\n\u00a0\u00a0 2683 cmd \/c rd \r\n\u00a0\u00a0 2496 cmd \/c net stop sharedaccess\r\n\u00a0\u00a0 2404 regsvr32 \/u \/s \r\n\u00a0\u00a0 2399 cmd \/c reg add hklm\\system\\currentcontrolset\\services\\sharedaccess\\parameters\\firewallpolicy\\standardprofile \/v \"donotallowexceptions\" \/t reg_dword \/d \"0\" \/f\r\n\u00a0\u00a0 2356 regsvr32 \/u \r\n\u00a0\u00a0 2088 cmd \/c net stop wscsvc\r\n\u00a0\u00a0 2082 taskkill \/f \/t \/im zhudongfangyu.exe\r\n\u00a0\u00a0 1988 gpupdate \/force\r\n\u00a0\u00a0 1954 reg delete hkey_current_user\\software\\microsoft\\windows\\currentversion\\explorer\\runmru \/f\r\n\u00a0\u00a0 1915 taskkill \/f \/im dnf.exe.manifest\r\n\u00a0\u00a0 1846 reg add hkcu\\software\\microsoft\\windows\\currentversion\\policies\\associations \/v modriskfiletypes \/t reg_sz \/d .exe \/f\r\n\u00a0\u00a0 1770 taskkill \/f \/im wscript.exe\r\n\u00a0\u00a0 1761 taskkill \/f \/im sys.exe\r\n\u00a0\u00a0 1760 taskkill \/f \/im tati.exe\r\n\u00a0\u00a0 1760 taskkill \/f \/im kspoold.exe \/im kspool.exe\r\n\u00a0\u00a0 1760 taskkill \/f \/im ansav.exe \/im ansavgd.exe\r\n\u00a0\u00a0 1661 cmd \/c sc config sharedaccess start= disabled\r\n\u00a0\u00a0 1654 ipconfig \/flushdns\r\n\u00a0\u00a0 1639 cmd \/c cacls \"&lt;file&gt;\" \/e \/p everyone:f\r\n\u00a0\u00a0 1623 cmd \/c sc delete javaserve\r\n\u00a0\u00a0 1619 cmd \/k \r\n\u00a0\u00a0 1474 cmd \/c del \/f \/s \/q \"%userprofile%\\local settings\\temporary internet files\\*.*\"\r\n\u00a0\u00a0 1474 cmd \/c del \/f \/s \/q \"%userprofile%\\local settings\\temp\\cookies\\*.*\"\r\n\u00a0\u00a0 1474 cmd \/c del \/f \/s \/q \"%userprofile%\\cookies\\*.*\r\n\u00a0\u00a0 1474 cmd \/c attrib -h -s -r -a \"%userprofile%\\local settings\\temp\\cookies\\*.*\"\r\n\u00a0\u00a0 1474 cmd \/c attrib -h -s -r -a \"%userprofile%\\cookies\\*.*\"\r\n\u00a0\u00a0 1457 taskkill \/f \/im ksafetray.exe\r\n\u00a0\u00a0 1417 cmd \/c taskkill \/im ekrn.exe \/f\r\n\u00a0\u00a0 1350 reg add hkcu\\software\\microsoft\\windows\\currentversion\\policies\\system \/v disabletaskmgr \/t reg_dword \/d 1 \/f\r\n\u00a0\u00a0 1320 reg add hkey_local_machine\\software\\microsoft\\windows\\currentversion\\policies\\explorer \/v nofolderoptions \/t reg_dword \/d 1 \/f\r\n\u00a0\u00a0 1294 cmd \/c\r\n\u00a0\u00a0 1239 taskkill \/f \/pid \r\n\u00a0\u00a0 1218 cmd \/c regedit \/s c:\\system.reg\r\n\u00a0\u00a0 1099 cmd \/c taskkill \/im egui.exe \/f\r\n\u00a0\u00a0 1086 cmd \/c sc config avp start= disabled\r\n\u00a0\u00a0 1048 regsvr32 \/s \/u \"\r\n\u00a0\u00a0 1025 regsvr32\u00a0 \/s \r\n\u00a0\u00a0\u00a0 985 cmd \/c reg delete hkcu\\software\\microsoft\\windows\\currentversion\\r\r\n\u00a0\u00a0\u00a0 982 taskkill \/f \/t \/im rstray.exe\r\n\u00a0\u00a0\u00a0 970 cmd \/c echo y| cacls \r\n\u00a0\u00a0\u00a0 928 cmd \/c ping 127.0.0.1&amp;&amp;del \r\n\u00a0\u00a0\u00a0 909 cmd \/c sc config ekrn start= disabled\r\n\u00a0\u00a0\u00a0 867 taskkill \/f \/t \/im ksafetray.exe\r\n\u00a0\u00a0\u00a0 855 taskkill \/f \/im knightonline.exe\r\n\u00a0\u00a0\u00a0 828 cmd \/c start \r\n\u00a0\u00a0\u00a0 755 cmd \/c reg add hkcu\\software\\microsoft\\windows\\currentversion\\run \/v ctfmon \/t reg_sz \/d \r\n\u00a0\u00a0\u00a0 708 cmd \/c c:\\mysql.exe -u\r\n\u00a0\u00a0\u00a0 708 cmd \/c app.path &amp; \\mysqldump.exe -u\r\n\u00a0\u00a0\u00a0 699 cmd \/c net stop mpssvc\r\n\u00a0\u00a0\u00a0 667 cmd \/c taskkill \/f \/im qq.exe\u00a0 \/t\r\n\u00a0\u00a0\u00a0 654 taskkill \/f \/im rstray.exe\r\n\u00a0\u00a0\u00a0 654 taskkill \/f \/im iexplore.exe\r\n\u00a0\u00a0\u00a0 648 cmd \/c sc delete ekrn\r\n\u00a0\u00a0\u00a0 636 cmd \/c taskkill \/im avp.exe \/f\r\n\u00a0\u00a0\u00a0 611 cmd \/c sc config \r\n\u00a0\u00a0\u00a0 606 taskkill \/f \/im gbpsv.exe &gt;nul\r\n\u00a0\u00a0\u00a0 599 cmd \/c reg add hkcu\\software\\microsoft\\windows\\currentversion\\run \/v msmmsgr \/t reg_sz \/d \r\n\u00a0\u00a0\u00a0 592 schtasks \/create \/sc onlogon \/tn \":schname\" \/tr \":path\"\u00a0 :vista\r\n\u00a0\u00a0\u00a0 586 cmd \/c reg add hkcu\\software\\microsoft\\windows\\currentversion\\run \/v \r\n\u00a0\u00a0\u00a0 583 cmd \/c del \"\r\n\u00a0\u00a0\u00a0 564 cmd \/c taskkill \/im scanfrm.exe \/f\r\n\u00a0\u00a0\u00a0 560 reg add \"hklm\\software\\microsoft\\windows\\currentversion\\internet settings\" \/v proxyenable \/t reg_dword \/d 00 \/f\r\n\u00a0\u00a0\u00a0 560 reg add \"hkcu\\software\\microsoft\\windows\\currentversion\\internet settings\" \/v proxyenable \/t reg_dword \/d 00 \/f\r\n\u00a0\u00a0\u00a0 558 reg add hklm\\software\\microsoft\\windows\\currentversion\\explorer\\cabinetstate \/f \/v fullpath \/t reg_dword \/d 1\r\n\u00a0\u00a0\u00a0 552 reg add \"hkcu\\software\\microsoft\\windows nt\\currentversion\\winlogon\" \/v \"shell\" \/t \"reg_sz\" \/d \"explorer.exe,\r\n\u00a0\u00a0\u00a0 539 regsvr32 \/s mswinsck.ocx\r\n\u00a0\u00a0\u00a0 530 cmd \/c ping 127.0.0.1 -n 3 &amp;&amp; del \"\r\n\u00a0\u00a0\u00a0 525 cmd \/c erase \/f \"<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>In my last post I described my opinion about current state of affairs of the fashionable IR trend called threat hunting. Since I am advocating it myself for a number of years I probably shoot myself in a foot by &hellip; <a href=\"https:\/\/www.hexacorn.com\/blog\/2016\/10\/16\/the-threat-hunting-the-anomaly-hunting-the-data-eyeballing\/\">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":[8],"tags":[],"_links":{"self":[{"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/posts\/3883"}],"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=3883"}],"version-history":[{"count":4,"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/posts\/3883\/revisions"}],"predecessor-version":[{"id":3887,"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/posts\/3883\/revisions\/3887"}],"wp:attachment":[{"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/media?parent=3883"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/categories?post=3883"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/tags?post=3883"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}