Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Arrow up icon
GO TO TOP
Hands-On AWS Penetration Testing with Kali Linux

You're reading from   Hands-On AWS Penetration Testing with Kali Linux Set up a virtual lab and pentest major AWS services, including EC2, S3, Lambda, and CloudFormation

Arrow left icon
Product type Paperback
Published in Apr 2019
Publisher Packt
ISBN-13 9781789136722
Length 508 pages
Edition 1st Edition
Tools
Arrow right icon
Authors (2):
Arrow left icon
Benjamin Caudill Benjamin Caudill
Author Profile Icon Benjamin Caudill
Benjamin Caudill
Karl Gilbert Gupta Karl Gilbert Gupta
Author Profile Icon Karl Gilbert Gupta
Karl Gilbert Gupta
Arrow right icon
View More author details
Toc

Table of Contents (28) Chapters Close

Preface 1. Section 1: Kali Linux on AWS FREE CHAPTER
2. Setting Up a Pentesting Lab on AWS 3. Setting Up a Kali PentestBox on the Cloud 4. Exploitation on the Cloud using Kali Linux 5. Section 2: Pentesting AWS Elastic Compute Cloud Configuring and Securing
6. Setting Up Your First EC2 Instances 7. Penetration Testing of EC2 Instances using Kali Linux 8. Elastic Block Stores and Snapshots - Retrieving Deleted Data 9. Section 3: Pentesting AWS Simple Storage Service Configuring and Securing
10. Reconnaissance - Identifying Vulnerable S3 Buckets 11. Exploiting Permissive S3 Buckets for Fun and Profit 12. Section 4: AWS Identity Access Management Configuring and Securing
13. Identity Access Management on AWS 14. Privilege Escalation of AWS Accounts Using Stolen Keys, Boto3, and Pacu 15. Using Boto3 and Pacu to Maintain AWS Persistence 16. Section 5: Penetration Testing on Other AWS Services
17. Security and Pentesting of AWS Lambda 18. Pentesting and Securing AWS RDS 19. Targeting Other Services 20. Section 6: Attacking AWS Logging and Security Services
21. Pentesting CloudTrail 22. GuardDuty 23. Section 7: Leveraging AWS Pentesting Tools for Real-World Attacks
24. Using Scout Suite for AWS Security Auditing 25. Using Pacu for AWS Pentesting 26. Putting it All Together - Real - World AWS Pentesting 27. Other Books You May Enjoy

Exploiting a vulnerable Windows VM

Finally, let's go through the results of the Windows Nessus scan. This has more interesting scan results, since we used an EOL OS that receives no updates, as well as an older version of the web application server.

Understanding the Nessus scan for Windows

The Nessus scan for Windows throws up a massive number of issues thanks to the end-of-life OS being used, as well as the outdated server. Let's focus on the most critical findings first:

There are a number of issues dealing with outdated OpenSSL and PHP installations, as well as a couple of findings pointing out that Windows Server 2003 is an unsupported OS. However, the most important issue here is the detection of multiple vulnerabilities in SMBv1. The details of this vulnerability point out the Common Vulnerabilities and Exposures (CVEs) for the associated SMB vulnerabilities and the patches for these:

In addition to vulnerable and outdated services, the scan did pick up a number of web application issues as well:

Since we exploited a network service on the Linux host, we shall focus on exploiting one of the vulnerabilities on the web application to gain access to a shell.

Exploitation on Windows

The vulnerable web application has an SQL injection vulnerability. SQL injection allows an attacker to inject arbitrary SQL queries and execute them on the backend DBMS. This vulnerability is present on the following URL:

http://<ip>/books1.php?title=&author=t

An SQL injection on a web application that is potentially running with admin privileges means that there is a possibility of a complete takeover of the web application. For this purpose, we shall use sqlmap. To attack the URL with sqlmap, the syntax is as follows:

sqlmap --url="http://<IP>/books1.php?title=&author=t"

A sqlmap confirms that the injection vulnerability is present, as seen here:

The next step is to use sqlmap to gain shell access on the remote server. sqlmap comes with a very handy feature, that uploads a stager for uploading further files into the webroot. Then it follows it up by uploading a web shell that executes commands and returns the output of the command, all with a single command. In order to trigger this, execute the following:

sqlmap --url="http://<IP>/books1.php?title=&author=t" --os-shell --tmp-path=C:\\xampp\\htdocs

The --os-shell asks sqlmap to spawn a shell using the method described previously and the --tmp-path value specifies where to upload the PHP files for the purpose of spawning a shell. Once the command is executed, user input would be prompted twice. The first instance is to select the technology, which is PHP in this case. The second instance is to trigger full path disclosures, which can be enabled. If everything goes well, we should be presented with an interactive shell:

As with the Linux exploitation, any commands can be executed through this interactive shell.

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image