Skip to content

Instantly share code, notes, and snippets.

View joshfinley's full-sized avatar
💭
yeet

Josh Finley joshfinley

💭
yeet
View GitHub Profile
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)
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:
@joshfinley
joshfinley / proxy.py
Last active September 28, 2023 19:12
Version 3 is current working version
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()}")
# 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) {
# 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)) {
# Function to flatten the object for CSV output
Function Flatten-AzureArchitecture {
param (
[Parameter(Mandatory=$true)]
$AzureArchitecture
)
$flattenedData = @()
foreach ($sub in $AzureArchitecture) {
# 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
import http.client
import socket
import select
import sys
import base64
import argparse
def main(proxy_host, proxy_port, dest_host, dest_port, auth_file=None):
# Set up authentication
auth = ''
@joshfinley
joshfinley / gist:2938f3f62eaea3a95d9043fedb0eefa7
Created June 26, 2023 14:17
Get-GroupDelegatedGenericAllFromGroupCsv.ps1
Import-Module ActiveDirectory
# Specify the path to the CSV file
$csvPath = "Groups.csv"
# Initialize an empty array to store the results
$results = @()
# Read the CSV file and iterate over each row
$csvData = Import-Csv -Path $csvPath
Import-Module ActiveDirectory
# Specify the path to the CSV file
$csvPath = "input.csv"
# Initialize an empty array to store the results
$results = @()
# Read the CSV file and iterate over each row
$csvData = Import-Csv -Path $csvPath