<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	 xmlns:media="http://search.yahoo.com/mrss/" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" >

<channel>
	<title>Kaushal Bhavsar</title>
	<atom:link href="https://kaushalbhavsar.com/knowledgabase/feed/" rel="self" type="application/rss+xml" />
	<link>https://kaushalbhavsar.com</link>
	<description>Diary of a Tech Geek</description>
	<lastBuildDate>Wed, 12 Jul 2023 10:46:20 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.7.2</generator>
	<itunes:subtitle>Kaushal Bhavsar</itunes:subtitle>
	<itunes:summary>Diary of a Tech Geek</itunes:summary>
	<itunes:explicit>clean</itunes:explicit>
	<item>
		<title>How to Perform Forensic Investigation on an AWS Instance without a Public Key</title>
		<link>https://kaushalbhavsar.com/knowledgabase/how-to-perform-forensic-investigation-on-an-aws-instance-without-a-public-key/</link>
					<comments>https://kaushalbhavsar.com/knowledgabase/how-to-perform-forensic-investigation-on-an-aws-instance-without-a-public-key/#respond</comments>
		
		<dc:creator><![CDATA[Kaushal Bhavsar]]></dc:creator>
		<pubDate>Wed, 12 Jul 2023 10:43:54 +0000</pubDate>
				<category><![CDATA[knowledgabase]]></category>
		<guid isPermaLink="false">https://kaushalbhavsar.com/?p=2912</guid>

					<description><![CDATA[Introduction Performing a forensic investigation on an AWS EC2 instance can become complicated if access to the instance is lost or the SSH key is unavailable. Recently, I came upon a case where I did not have the private key to the instance. The only details I had, were the AWS portal login and password. [&#8230;]]]></description>
										<content:encoded><![CDATA[
<h2 class="wp-block-heading">Introduction</h2>



<p>Performing a forensic investigation on an AWS EC2 instance can become complicated if access to the instance is lost or the SSH key is unavailable. Recently, I came upon a case where I did not have the private key to the instance. The only details I had, were the AWS portal login and password. </p>



<p>The private key does not serve any other purpose except SSH authentication. So, if we bypass the authentication, we don&#8217;t need the key.  But the fact is, the cloud is just another computer and so, I figured out a way to make this work just like I would do it on a physical computer. </p>



<p>Here&#8217;s the process: <br>1. Detach the hard drive<br>2. Attach the hard drive to another machine<br>3. Access the data of our target system through the new machine. <br><br>Here&#8217;s a step-by-step guide on how to accomplish the same on AWS:</p>



<p></p>



<h2 class="wp-block-heading">Step 1: Creating a Snapshot of the EBS Volume</h2>



<p>The first step involves creating a snapshot of the EBS volume that&#8217;s attached to the EC2 instance. You can use the AWS CLI to accomplish this:</p>



<pre class="wp-block-code has-light-green-cyan-color has-ast-global-color-3-background-color has-text-color has-background has-medium-font-size"><code><code>aws ec2 create-snapshot --volume-id vol-049df61146f12f951 --description "Forensic snapshot"
</code></code></pre>



<h2 class="wp-block-heading">Step 2: Creating a New Volume from the Snapshot</h2>



<p>Once the snapshot is ready, you can create a new volume from it. Make sure to create it in the same availability zone as the instance you&#8217;ll be attaching it to:</p>



<pre class="wp-block-preformatted has-light-green-cyan-color has-ast-global-color-3-background-color has-text-color has-background has-medium-font-size"><code>aws ec2 create-volume --availability-zone us-west-2a --snapshot-id snap-01234567890abcdef0
</code></pre>



<h2 class="wp-block-heading">Step 3: Launching a New EC2 Instance</h2>



<p>Next, launch a new EC2 instance in the same availability zone as your volume. This instance will act as a bridge to access the data:</p>



<pre class="wp-block-preformatted has-light-green-cyan-color has-ast-global-color-3-background-color has-text-color has-background"><code>aws ec2 run-instances --image-id ami-abcd1234 --count 1 --instance-type t2.micro --key-name MyKeyPair
</code></pre>



<h2 class="wp-block-heading">Step 4: Attaching the New Volume to the New EC2 Instance</h2>



<pre class="wp-block-code has-light-green-cyan-color has-ast-global-color-3-background-color has-text-color has-background"><code><code>aws ec2 attach-volume --volume-id vol-049df61146f12f951 --instance-id i-01474ef662b89480 --device /dev/sdf<br></code></code></pre>



<h2 class="wp-block-heading">Step 5: SSH into the New EC2 Instance</h2>



<p>Next, SSH into the new EC2 instance using its own key:</p>



<pre class="wp-block-preformatted has-light-green-cyan-color has-ast-global-color-3-background-color has-text-color has-background"><code>ssh -i "/path/my-key-pair.pem" ec2-user@ec2-198-51-100-1.compute-1.amazonaws.com
</code></pre>



<h2 class="wp-block-heading">Step 6: Mounting the New Volume in Read-Only Mode</h2>



<p>This step involves creating a new directory and mounting the new volume in read-only mode. This ensures that the data on the volume isn&#8217;t altered during the investigation:</p>



<pre class="wp-block-code has-light-green-cyan-color has-ast-global-color-3-background-color has-text-color has-background"><code><code>sudo mkdir /my_new_volume
sudo mount -o ro /dev/xvdf /my_new_volume
</code></code></pre>



<h2 class="wp-block-heading">Step 7: Performing the Forensic Investigation</h2>



<p>Finally, you can navigate to the directory where you mounted the new volume and start your forensic investigation.</p>



<h2 class="wp-block-heading">Conclusion</h2>



<p>Losing SSH access to an EC2 instance doesn&#8217;t mean your investigation has to come to a halt. AWS provides a workaround by creating and using snapshots of the EBS volume associated with the instance. Remember, while performing the investigation, it&#8217;s important to ensure that the data remains unaltered. Therefore, always mount your volume in read-only mode. With these steps, you should be able to continue your investigation even in challenging scenarios.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://kaushalbhavsar.com/knowledgabase/how-to-perform-forensic-investigation-on-an-aws-instance-without-a-public-key/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
