<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Cyber Notebook</title>
    <description>Personal blog for Marco Mancini. Posts and projects have a focus on Cybersecurity, Incident Response , Threat Hunting, Data Analysis and Malware Analysis. 
</description>
    <link>https://marcojmancini.github.io/</link>
    <atom:link href="https://marcojmancini.github.io/feed.xml" rel="self" type="application/rss+xml"/>
    <pubDate>Sat, 07 Dec 2024 16:43:44 +0000</pubDate>
    <lastBuildDate>Sat, 07 Dec 2024 16:43:44 +0000</lastBuildDate>
    <generator>Jekyll v4.3.4</generator>
    
      <item>
        <title>GKE forensics 2 - How to Extract and Mount GKE VMDK files</title>
        <description>&lt;h1 id=&quot;gke-forensics-2---how-to-extract-and-mount-gke-vmdk-files&quot;&gt;GKE forensics 2 - How to Extract and Mount GKE VMDK files&lt;/h1&gt;

&lt;h1 id=&quot;introduction&quot;&gt;Introduction&lt;/h1&gt;

&lt;p&gt;Now you have a .vmdk file  (otherwise you can check the previous article) and an Ubuntu machine, but how to actually do something useful with this?&lt;/p&gt;

&lt;p&gt;This guide is the second part of the GKE forensics series. So, you have a snapshot of a GKE node and you have downloaded the result as a .vmdk file.&lt;/p&gt;

&lt;p&gt;This article will only explain how to mount and be able to analyse the .vmdk file, the next article explains how to analyse and extract insights from this.&lt;/p&gt;

&lt;h1 id=&quot;vmdk-format&quot;&gt;VMDK format&lt;/h1&gt;

&lt;p&gt;The .vmdk (Virtual Machine Disk) file is a an image that contains metadata and virtual hard drives that can be used with virtual machines. This was created by VMware and it’s mostly used by their hypervisor to store the data of a running virtual machine.&lt;/p&gt;

&lt;h2 id=&quot;file-structure&quot;&gt;File Structure&lt;/h2&gt;

&lt;p&gt;We could use vmware (or other hypervisor) to understand the file. On the other hand there is an easy way out.&lt;/p&gt;

&lt;p&gt;We can just extract the files using 7zip. This will “extract” all the partitions inside the vmdk file.&lt;/p&gt;

&lt;p&gt;There is 2 important commands related to 7zip.&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;7zip -l gke-forensics.vmdk
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This command will list all the metadata files and hard drives.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Add output of files&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The most important of which is the STATE.img file.&lt;/p&gt;

&lt;p&gt;There are also the ROOT and KERNEL files, but these files should be analysed only if the GKE node is deeply compromised. The state.img is the best one to start with.&lt;/p&gt;

&lt;h2 id=&quot;extract-partitions&quot;&gt;Extract partitions&lt;/h2&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;7zip -x gke-forensics.vmdk
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This command will extract the files inside the vmdk file.&lt;/p&gt;

&lt;h1 id=&quot;mount-partitions&quot;&gt;Mount partitions&lt;/h1&gt;

&lt;p&gt;Once you have the files extracted from the .vmdk you will want to mount them in your own file system. This will make the hard drive a normal folder in your filesystem so all files can be read.&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;Add format to hard drive
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This will add the necesary format to the hard drive so we can do the following command,&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;guestmount
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This command has the following operators:&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;-o  means read only&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;output folder&lt;/p&gt;

&lt;p&gt;Finally when you are done analysing the information you can use the following command to unmount the filesystem.&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;use the umount the remove the folder
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h1 id=&quot;conclusions&quot;&gt;Conclusions&lt;/h1&gt;

&lt;p&gt;I hope this guide is useful, there are many ways to access the information in the .vmdk. I have found however this is the easiest.&lt;/p&gt;

&lt;p&gt;Now in the next article I will explain how to collect information from the STATE.img file.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://www.notion.so/GKE-forensics-3-STATE-img-and-how-to-do-forensics-on-a-GKE-Node-faeff495d27a4dc4b46ea3adb5ed2426&quot;&gt;GKE forensics 3 - STATE.img and how to do forensics on a GKE Node &lt;/a&gt;&lt;/p&gt;

&lt;h1 id=&quot;references&quot;&gt;References&lt;/h1&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.nakivo.com/blog/extract-content-vmdk-files-step-step-guide/&quot;&gt;https://www.nakivo.com/blog/extract-content-vmdk-files-step-step-guide/&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.altaro.com/vmware/extract-content-vmdk-files/&quot;&gt;https://www.altaro.com/vmware/extract-content-vmdk-files/&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.poftut.com/mount-vm-images-guestmount/&quot;&gt;https://www.poftut.com/mount-vm-images-guestmount/&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://linux.die.net/man/1/guestmount&quot;&gt;https://linux.die.net/man/1/guestmount&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://manpages.ubuntu.com/manpages/precise/man1/guestmount.1.html&quot;&gt;http://manpages.ubuntu.com/manpages/precise/man1/guestmount.1.html&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</description>
        <pubDate>Sat, 30 May 2020 18:55:27 +0000</pubDate>
        <link>https://marcojmancini.github.io/forensics/gke/2020/05/30/GKE-forensics-2.html</link>
        <guid isPermaLink="true">https://marcojmancini.github.io/forensics/gke/2020/05/30/GKE-forensics-2.html</guid>
        
        
        <category>forensics</category>
        
        <category>GKE</category>
        
      </item>
    
      <item>
        <title>GKE forensics 1 - How to take a snapshot</title>
        <description>&lt;p&gt;After not finding a lot of sources in how to do forensics analysis on GKE nodes I have decided to make a guide for future me (and hopefully future you). The whole series should equip you with the knowledge to collect the virtual disk of a GKE node and analyze the data that contains this.&lt;/p&gt;

&lt;p&gt;This guide only explains how to collect the filesystem. Moreover, you could collect the RAM of a virtual node if you have a strong suspicion that malware is running. But I may leave this to a later guide.&lt;/p&gt;
&lt;h1 id=&quot;gke-node-snapshot-collection&quot;&gt;GKE Node snapshot collection&lt;/h1&gt;

&lt;h2 id=&quot;what-is-a-gke-node&quot;&gt;What is a GKE Node?&lt;/h2&gt;

&lt;p&gt;A GKE (Google Kubernetes Engine) node is the virtual machine in which k8s pods and docker containers will run when you create a Kubernetes cluster with the GCP Kubernetes managed service.&lt;/p&gt;

&lt;p&gt;This node is bare-bones but is based on a Linux system, the most important details you will find in these systems are logs (journal) and the docker repositories and container metadata. This can be useful if a pod has been breached and illicit pods have been spun out as images and logs will appear.&lt;/p&gt;

&lt;h2 id=&quot;create-snapshot-from-gke-node&quot;&gt;Create Snapshot from GKE node&lt;/h2&gt;

&lt;p&gt;The first step is to create a snapshot for the GKE node (Which will appear as a VM instance). You need to go to &lt;a href=&quot;https://console.cloud.google.com/compute/snapshots&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Compute Engine &amp;gt; Storage &amp;gt; Snapshots&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In this view, you need to go to &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;CREATE SNAPSHOT&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/a6882c7d55f649ae826f200e4d352d0c/Screenshot_from_2021-03-13_15-31-27.png&quot; alt=&quot;Screenshot_from_2021-03-13_15-31-27.png&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Once in &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;CREATE SNAPSHOT&lt;/code&gt; you need to select the disk from a GKE virtual machine.&lt;/p&gt;
&lt;p align=&quot;center&quot;&gt;
 &lt;img src=&quot;/images/a6882c7d55f649ae826f200e4d352d0c/Untitled.png&quot; alt=&quot;Create Snapshot&quot; /&gt;
&lt;/p&gt;

&lt;p&gt;This process will create a snapshot, this can be used to create a new machine, but there is no way of extracting a snapshot from GCP directly.&lt;/p&gt;

&lt;h2 id=&quot;create-image-from-snapshot&quot;&gt;Create Image from Snapshot&lt;/h2&gt;

&lt;p&gt;To be able to extract the information you will need to turn the snapshot into an image. Images can be used to create completely new virtual machines.&lt;/p&gt;

&lt;p&gt;Moreover, Images can be exported. This is not the case with snapshots.&lt;/p&gt;

&lt;p&gt;You need to go to the &lt;a href=&quot;https://console.cloud.google.com/compute/images&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Compute Engine &amp;gt; Storage &amp;gt; Images&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/a6882c7d55f649ae826f200e4d352d0c/Screenshot_from_2021-03-13_15-31-54.png&quot; alt=&quot;Screenshot_from_2021-03-13_15-31-54.png&quot; /&gt;&lt;/p&gt;

&lt;p&gt;There you need to &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;CREATE IMAGE&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/a6882c7d55f649ae826f200e4d352d0c/Screenshot_from_2021-03-13_15-32-29.png&quot; alt=&quot;Screenshot_from_2021-03-13_15-32-29.png&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Give a clear name and use the source snapshot of the GKE node you want to analyze.&lt;/p&gt;

&lt;p&gt;Once the image is complete, it will look like this.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/a6882c7d55f649ae826f200e4d352d0c/Screenshot_from_2021-03-13_15-32-57.png&quot; alt=&quot;Screenshot_from_2021-03-13_15-32-57.png&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Take note of the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;EXPORT&lt;/code&gt; function, This will be used to move the image to a bucket. (If you have already a bucket to store the exported files you can skip the next chapter)&lt;/p&gt;

&lt;h2 id=&quot;create-new-bucket&quot;&gt;Create new Bucket&lt;/h2&gt;

&lt;p&gt;You still cannot download the image directly, you need to store it in a bucket. To create one you need to go to &lt;a href=&quot;https://console.cloud.google.com/storage/browser&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Storage &amp;gt; Browser&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/a6882c7d55f649ae826f200e4d352d0c/Screenshot_from_2021-03-13_15-36-55.png&quot; alt=&quot;Screenshot_from_2021-03-13_15-36-55.png&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Here you can see &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;CREATE BUCKET&lt;/code&gt;. Make sure it’s in the region closest to your operations and also it should only be accessible by the analysts that need access to the forensic images.&lt;/p&gt;

&lt;p&gt;The images shouldn’t contain secrets but if the docker images are configured improperly. Proprietary information could be present.&lt;/p&gt;

&lt;p align=&quot;center&quot;&gt;
 &lt;img src=&quot;/images/a6882c7d55f649ae826f200e4d352d0c/Screenshot_from_2021-03-13_15-37-48.png&quot; alt=&quot;Screenshot_from_2021-03-13_15-37-48.png&quot; /&gt;
&lt;/p&gt;

&lt;h2 id=&quot;move-image-to-bucket&quot;&gt;Move Image to Bucket&lt;/h2&gt;

&lt;p&gt;The last step is to move the image to a bucket, so it can be imported.&lt;/p&gt;

&lt;p&gt;Here you will see all the available buckets. Use the one created for the forensic analysis.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/a6882c7d55f649ae826f200e4d352d0c/Screenshot_from_2021-03-13_15-33-40.png&quot; alt=&quot;Screenshot_from_2021-03-13_15-33-40.png&quot; /&gt;&lt;/p&gt;

&lt;p&gt;This process will take a while but after it’s completed you will find the file in your bucket.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/a6882c7d55f649ae826f200e4d352d0c/Untitled1.png&quot; alt=&quot;Untitled1.png&quot; /&gt;&lt;/p&gt;

&lt;p&gt;From here you can download the file into your filesystem and initiate the investigation.&lt;/p&gt;

&lt;h1 id=&quot;conclusions&quot;&gt;Conclusions&lt;/h1&gt;

&lt;p&gt;&lt;strong&gt;This process can be used for any virtual machine in GCP, not only GKE.&lt;/strong&gt; Collecting a file that can be used for forensics is not a straightforward process but with this mini-guide, you should be able to do it without much problem.&lt;/p&gt;

&lt;p&gt;I will see you in the next piece of this guide, in which we will learn to extract and mount the VMDK file.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://www.notion.so/GKE-forensics-2-How-to-Extract-and-Mount-GKE-VMDK-files-1b0a1d9ae98d4cc3a4b7506dbe38dc99&quot;&gt;GKE forensics 2 - How to Extract and Mount GKE VMDK files&lt;/a&gt;&lt;/p&gt;

&lt;h1 id=&quot;references&quot;&gt;References&lt;/h1&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://cloud.google.com/compute/docs/disks/create-snapshots&quot;&gt;GCP - create-snapshots&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://cloud.google.com/compute/docs/images/export-image&quot;&gt;GCP - export-image&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://cloud.google.com/kubernetes-engine/docs/concepts/security-overview&quot;&gt;GCP - security-overview&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://cloud.google.com/blog/products/containers-kubernetes&quot;&gt;GCP - containers-kubernetes&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://cloud.google.com/blog/products/gcp/introducing-google-container-engine-gke-node-pools&quot;&gt;GCP - Blog - introducing-google-container-engine-gke-node-pools&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</description>
        <pubDate>Fri, 13 Mar 2020 18:55:27 +0000</pubDate>
        <link>https://marcojmancini.github.io/forensics/gke/2020/03/13/GKE-forensics-1.html</link>
        <guid isPermaLink="true">https://marcojmancini.github.io/forensics/gke/2020/03/13/GKE-forensics-1.html</guid>
        
        
        <category>forensics</category>
        
        <category>GKE</category>
        
      </item>
    
      <item>
        <title>Welcome to my blog</title>
        <description>&lt;p&gt;Welcome to my new blog. I am Marco Mancini. The purpose of this blog is to organize my projects and thoughts on different topics.&lt;/p&gt;

&lt;p&gt;My focus is Cybersecurity, but I like to explore all kinds of topics, I will have some categories for philosophy, statics. I may add just curious facts and hypothesis about the world.&lt;/p&gt;

&lt;p&gt;I don’t have the ultimate truth, and I am delighted to be proven wrong. Feel free to tell me if I am wrong; you can find my email in the about section.
And always doubt what people write on the internet.&lt;/p&gt;

&lt;p&gt;Finally, I hope you find something interesting in my ramblings!&lt;/p&gt;
</description>
        <pubDate>Mon, 30 Dec 2019 18:55:27 +0000</pubDate>
        <link>https://marcojmancini.github.io/introduction/about/2019/12/30/first-post.html</link>
        <guid isPermaLink="true">https://marcojmancini.github.io/introduction/about/2019/12/30/first-post.html</guid>
        
        
        <category>Introduction</category>
        
        <category>about</category>
        
      </item>
    
  </channel>
</rss>
