This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Import the required module if not already imported | |
Import-Module AzureAD | |
# Login to Azure AD | |
Connect-AzureAD | |
# Get the 'Application Admin' role | |
$appAdminRole = Get-AzureADDirectoryRole | Where-Object {$_.displayName -eq 'Application Admin'} | |
# If the role hasn't been instantiated, instantiate it |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Install the AzureAD PowerShell module | |
Install-Module AzureAD# Authenticate to the tenant | |
$username = "[email protected]" | |
$password = 'YourVeryStrongPassword' | |
$SecurePassword = ConvertTo-SecureString “$password” -AsPlainText -Force | |
$Credential = New-Object System.Management.Automation.PSCredential($username, $SecurePassword) | |
Connect-AzureAD -Credential $Credential# Build our users and roles object | |
$UserRoles = Get-AzureADDirectoryRole | ForEach-Object { | |
$Role = $_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Authenticate to Azure AD as an Application Administrator user | |
$username = "alice" # Username for authentication | |
$password = "asdf" # Password for authentication | |
# Convert password to a secure string | |
$securePass = ConvertTo-SecureString "$password" -AsPlainText -Force | |
# Create a credential object | |
$cred = New-Object System.Management.Automation.PSCredential($username, $securePass) | |
# Connect to Azure AD with the provided credentials | |
Connect-AzureAd -Credential $cred |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import paramiko | |
import socket | |
def http_connect_proxy(proxy_host, proxy_port, target_host, target_port): | |
""" | |
Establish a socket connection through an HTTP proxy. | |
""" | |
proxy = (proxy_host, proxy_port) | |
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
s.connect(proxy) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import socket | |
import threading | |
import socks # PySocks | |
def handle_client(client_socket): | |
# Establish a tunnel through the corporate proxy using CONNECT | |
remote_socket = socks.socksocket() | |
remote_socket.set_proxy(socks.PROXY_TYPE_HTTP, "corporate_proxy_ip", corporate_proxy_port) | |
try: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import socket | |
import threading | |
import re | |
def establish_tunnel(remote_socket, target_host, target_port): | |
connect_req = f"CONNECT {target_host}:{target_port} HTTP/1.1\r\n\r\n".encode() | |
remote_socket.send(connect_req) | |
# Read the response. In a production setting, you'd want to actually parse the response. | |
response = remote_socket.recv(4096) | |
print(f"Received response from corporate proxy: {response.decode()}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Import the Active Directory module if not already loaded | |
Import-Module ActiveDirectory | |
# Create a script block to process the piped input | |
filter CheckADUser { | |
# Assume $_ is the object passed from the pipeline, attempt to select the Name property | |
$name = $_.Name | |
# If Name property is found, check the AD | |
if ($null -ne $name) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Import the Active Directory module if not already loaded | |
Import-Module ActiveDirectory | |
# Get the path to the text file from the script arguments | |
param ( | |
[string]$groupFile | |
) | |
# If no path is provided, exit the script | |
if ([string]::IsNullOrWhiteSpace($groupFile)) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Function to flatten the object for CSV output | |
Function Flatten-AzureArchitecture { | |
param ( | |
[Parameter(Mandatory=$true)] | |
$AzureArchitecture | |
) | |
$flattenedData = @() | |
foreach ($sub in $AzureArchitecture) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Initialize an empty array to hold firewall information | |
$allFirewalls = @() | |
# Get all subscriptions in the tenant | |
$subscriptions = Get-AzSubscription | |
# Loop through each subscription to gather Azure Firewall information | |
foreach ($subscription in $subscriptions) { | |
# Select the subscription for the Azure context | |
Set-AzContext -Subscription $subscription.Id |