CVE-2024-3400: PAN-OS Command Injection Vulnerability in GlobalProtect Gateway. Learn More

CVE-2024-3400: PAN-OS Command Injection Vulnerability in GlobalProtect Gateway. Learn More

Services
Capture
Managed Detection & Response

Eliminate active threats with 24/7 threat detection, investigation, and response.

twi-managed-portal-color
Co-Managed SOC (SIEM)

Maximize your SIEM investment, stop alert fatigue, and enhance your team with hybrid security operations support.

twi-briefcase-color-svg
Advisory & Diagnostics

Advance your cybersecurity program and get expert guidance where you need it most.

tw-laptop-data
Penetration Testing

Test your physical locations and IT infrastructure to shore up weaknesses before exploitation.

twi-database-color-svg
Database Security

Prevent unauthorized access and exceed compliance requirements.

twi-email-color-svg
Email Security

Stop email threats others miss and secure your organization against the #1 ransomware attack vector.

tw-officer
Digital Forensics & Incident Response

Prepare for the inevitable with 24/7 global breach response in-region and available on-site.

tw-network
Firewall & Technology Management

Mitigate risk of a cyberattack with 24/7 incident and health monitoring and the latest threat intelligence.

Solutions
BY TOPIC
Offensive Security
Solutions to maximize your security ROI
Microsoft Exchange Server Attacks
Stay protected against emerging threats
Rapidly Secure New Environments
Security for rapid response situations
Securing the Cloud
Safely navigate and stay protected
Securing the IoT Landscape
Test, monitor and secure network objects
Why Trustwave
About Us
Awards and Accolades
Trustwave SpiderLabs Team
Trustwave Fusion Security Operations Platform
Trustwave Security Colony
Partners
Technology Alliance Partners
Key alliances who align and support our ecosystem of security offerings
Trustwave PartnerOne Program
Join forces with Trustwave to protect against the most advance cybersecurity threats
SpiderLabs Blog

Azure Web App Service For Offensive Operations

In this blog, I will be covering how to use Azure App Services for offensive purposes. What is Azure App Services you may ask? Azure App Services as defined by Microsoft:

“Quickly build, deploy, and scale web apps created with popular frameworks .NET, .NET Core, Node.js, Java, PHP, Ruby, or Python, in containers or running on any operating system. Meet rigorous, enterprise-grade performance, security, and compliance requirements by using the fully managed platform for your operational and monitoring tasks.” — https://azure.microsoft.com/en-us/services/app-service/

What’s great beyond the ability to run many platforms such as .NET, Python, and Node.js, is that when you deploy an app, you receive a custom subdomain on “.azurewebsites.net”. Pretty nice! Deploying websites and applications is also a breeze with the Azure PowerShell modules.

What can we do with Azure Apps regarding offensive operations?

  • Static HTML Pages
  • PHP Phishing Pages
  • C2 Redirection via Flask

Microsoft Examples:

Prerequisites:

Azure PowerShell static HTML deployment

First, log into your Azure service with the command:
az login

For help on all commands available use:
az webapp up help

For a static html deployment, start in your web application’s root folder and simply deploy your app with:
az webapp up --location eastus --resource-group htmlphishtest --name htmlphishtest --html

Note that when your deployment is finished, you’ll have a domain “htmlphishtest.azurewebsites.net”!

In this simple example where I am using a modified version of the “html-docs-hello-world” page which will serve up an executable to the target.

Here is what it looks like when browsed to:

Figure 1: Static Phishing Page with JavaScript Downloader

 

PHP Credential Phishing

Using PHP applications from the zphisher platform, https://github.com/htr-tech/zphisher we can serve up credential harvesting pages via Azure Apps as well. This takes a little more effort and requires that Git be installed.

For the Microsoft docs regarding this deployment, visit https://docs.microsoft.com/en-us/azure/app-service/app-service-web-get-started-php.

First, create your deployment user and password. These credentials will be used to clone and push the Git repository you deploy.

az webapp deployment user set --user-name <username> --password <password>

Next, create a resource group:
az group create --name myResourceGroup --location eastus

Create an Azure App Service plan:
az appservice plan create --name myAppServicePlan --resource-group myResourceGroup --sku FREE

Create your empty web application with either Bash or Powershell.
Using Bash:
az webapp create --resource-group myResourceGroup --plan myAppServicePlan --name <app_name> --runtime "PHP|7.4" --deployment-local-git

Using PowerShell:
az --% webapp create --resource-group myResourceGroup --plan myAppServicePlan --name <app_name> --runtime "PHP|7.4" --deployment-local-git

This command will output the details of your app including the git URL to clone. From a clean folder, clone your empty git repository using the username and password you set for the application. For example: git clone

Copy your PHP phishing application into the empty folder. In this instance, I used the “Microsoft” folder from zphisher.

Add your files with git:
git add *

Commit your changes:
git commit -a -m "Initial Commit"

Push your repo to your application:
git push

Your phishing application should now be hosted at your azurewebsites.net URL

Figure 2: Fake Login Page

Now, to access the logs, open a console via the application’s console page located in your Azure Portal.

Figure 3: Accessing the Console

 

In this instance, cat the usernames.txt file for any captured credentials.

 

Figure 4: Viewing Captured Credentials

 

Flask C2 Redirection

Using a Python Flask app, allows you to also perform redirection to a Command and Control (C2) server. In this example, I am using a “magic header” as described in my previous blog about protecting redirectors. In Cobalt Strike, this magic header may be set under the “client” portion of your profile. Also, be sure to comment out the first HEADER variable and then uncomment second HEADER and HEADER_KEY lines to use magic headers in application.py.

Figure 5: application.py settings

 

From the Python-Flask-Redirector folder execute the following command with your custom variables:
az webapp up --location eastus --resource-group mynewresourcegroup --name mynewsubdomain --SKU FREE

After launching a beacon, the redirector checks that the magic header exists otherwise it will redirect to a site of your choosing. Note the external IP address of this beacon running through Azure Apps. It may be good to whitelist this range.

Figure 6: Deploying the redirector and receiving a Cobalt Strike Beacon

 

If you would like to manage your app via Secure FTP, you may do so by enabling that in the Deployment Center in the settings of your App in Azure. For more information on this visit https://docs.microsoft.com/en-us/azure/app-service/deploy-ftp

Figure 7: FTPS Settings

 

That is all for now! Please visit my GitHub for the code used in this post at https://github.com/rvrsh3ll/Azure-App-Tools. I hope this blog post sheds some light on how legitimate Azure services may be used for offensive purposes.

Latest SpiderLabs Blogs

EDR – The Multi-Tool of Security Defenses

This is Part 8 in my ongoing project to cover 30 cybersecurity topics in 30 weekly blog posts. The full series can be found here.

Read More

The Invisible Battleground: Essentials of EASM

Know your enemy – inside and out. External Attack Surface Management tools are an effective way to understand externally facing threats and help plan cyber defenses accordingly. Let’s discuss what...

Read More

Fake Dialog Boxes to Make Malware More Convincing

Let’s explore how SpiderLabs created and incorporated user prompts, specifically Windows dialog boxes into its malware loader to make it more convincing to phishing targets during a Red Team...

Read More