Sitemap

AWS Cloud Pentesting Notes

7 min readMay 7, 2023

AWS GOAT PART 1 Solution

Press enter or click to view image in full size

What is The AWSGoat?

AWSGoat is a Vulnerable AWS Infrastructure for teaching people to AWS cloud vulnerabilities and pentesting. It has some vulnerabilities like;

· XSS

· SQL Injection

· Insecure Direct Object Reference

· Server Side Request Forgery on Lambda Environment

· Sensitive Data Exposure and Password Reset

· S3 Misconfigurations

· IAM Privilege Escalations

· ECS Container Breakout

AWS goat has several scenerios. Please visit the github page for more information.

Press enter or click to view image in full size

In this web page as you see that when you search something it is printed to web page. It can be causes to basic reflected XSS.

Press enter or click to view image in full size

When I used the <img src=’a’ onerror=alert(‘XSS’)> payload I have already seen the page is vulnerable against the XSS attacks.

Press enter or click to view image in full size
Press enter or click to view image in full size

I tried to search a user for testing SQL issues.

Press enter or click to view image in full size

I tried very basic SQL payload for understanding the existence of the sql injection vulnerability and I could see the SQL injection vulnerability.

Press enter or click to view image in full size

I tried to intercept request and send it to repeater. The first sight I realized the lamba function was used. It is clearly seen from the HTTP response.

Press enter or click to view image in full size
Press enter or click to view image in full size

Then I tried to sql injection basic payloads I can see the other information from database.

Press enter or click to view image in full size
Press enter or click to view image in full size
Press enter or click to view image in full size

I navigated to another web page which is utilized for password reseting. IDOR vulnerability may be exist in here so I tried to manipılate is values and watched the responses. Reset action should be completed by using cross check mechanism.

Press enter or click to view image in full size

It is the normal intercepted request but I manipulated id value as 22 and I took Internal Server error in the response.

Press enter or click to view image in full size

When I changed the id value as 1 another accounts password (who has id 1) was changed. I detected IDOR vulnerabiity in here.

Press enter or click to view image in full size

I tried to reset password for another user who has 3 id number.

Press enter or click to view image in full size

I can successfully reset the pasword by using IDOR vulnerability. I navigated to Post page for testing SSRF. I tried to reach /etc/passwd file by using upload.

Press enter or click to view image in full size

When I watch the Network activities of the web traffic frome Chrome debug, I saw the file was saved to server directory as accessible.

Press enter or click to view image in full size
Press enter or click to view image in full size

I downloaded the picture. I use the string tool for extracting the /etc/passwd file content.

Press enter or click to view image in full size
Press enter or click to view image in full size

/etc/passwd file was successfully extracted from image file.

Press enter or click to view image in full size

I intercepted request for sending it to repeater. I tried to retriew the content of /proc/self/environ.

Press enter or click to view image in full size
Press enter or click to view image in full size

I can see the output file which is given under s3 bucket as png and I downloaded the file content with wget;

Press enter or click to view image in full size

When I extracted the strings I have already grabbed the credentials for connecting AWS as programatically.

Press enter or click to view image in full size

AWS Lambda provides an HTTP API for custom runtimes to receive invocation events from Lambda and send response data back within the Lambda execution environment. On the other hand I tried to access next invocation with lambda api.

Press enter or click to view image in full size
Press enter or click to view image in full size

I opened the related png file and I obtained jwt_tokens paths requestTimes and more information like Source IP addresses.

Press enter or click to view image in full size

I intercepted request for sending it to repeater. I tried to retriew the content of /proc/self/environ again for compromising access key id, secret access key and security token.

Press enter or click to view image in full size
Press enter or click to view image in full size

I exported the values of the TOKEN, ACCESS KEY ID AND ACCESS SECRET KEY, for connecting AWS account as programatically.

Press enter or click to view image in full size

I used sts get-callaer-identity for seeing whoami.

Press enter or click to view image in full size

I tried to list users but I wasn’t authorized for this.

Press enter or click to view image in full size

I decided to to follow lambda and I listed lambda functions.

Press enter or click to view image in full size

After that I tried to list policies but I couldn’t be successfull.

Press enter or click to view image in full size

I tried to get list-attached-role-policies and listed described instances but couldn’t be successfull due to privilige or authorization issues.

Press enter or click to view image in full size

I reached the blog_users table content and I retriewed it. Password are hashed with bcrypypt so I decided to create a new bcrypt password and change the old one in the database.

Press enter or click to view image in full size

I saved the table content as user_item and modify it with new user password which I want to reset or modify.

Press enter or click to view image in full size
Press enter or click to view image in full size

After modification the password, I upload the new file to dynomodb with put-item. Finally I could create different user and different password by manipulating the database.

Press enter or click to view image in full size

For listing buckets I used aws s3 ls command;

Press enter or click to view image in full size

I followed by inspecting the source of the website and I reached the bucket link for displaying bucket contents;

Press enter or click to view image in full size

Dev-blog is useful for me. I saw ssh config files and some ssh keys in the output.

Press enter or click to view image in full size

I downloaded ssh config and I retriewed the IP adderesses and hostnames. I also knew the ssh private key paths. Cool…

Press enter or click to view image in full size

I found which IP adderess on the config has opened SSH port;

Press enter or click to view image in full size

I downloaded SSH pem file;

Press enter or click to view image in full size
Press enter or click to view image in full size

Finally I can connect to the target via SSH.

--

--

No responses yet