Skip to content

Instantly share code, notes, and snippets.

function FindProxyForURL(url, host) {
if (shExpMatch(url, "*.slack.com")) {
return "PROXY 127.0.0.1:666";
}
}
@caveatlector
caveatlector / gist:d744af4e186d9b5646bdedee744eb8cb
Last active June 28, 2019 08:30
Azure: join an Ubuntu 16.04 LTS VM to AD DS for key-based login with SSH
# Packages:
apt update && apt upgrade
apt install -y realmd sssd sssd-tools libnss-sss libpam-sss krb5-user adcli samba-common-bin
# Add the following to /etc/krb5.conf under [libdefaults] (following default_realm):
dns_lookup_kdc = true
dns_lookup_realm = true
@caveatlector
caveatlector / gist:eca31bb464c19e9bb70bbbc7f6fe1ad2
Last active March 9, 2021 22:02
Azure: provision an IaaS AD DS domain controller
#!/usr/bin/env bash
# Create a Windows Server 2016 VM with a private IP in a specific subnet.
# Requires: az-cli
NSG= # Existing NSG (by name)
PRIVATE_IP= # Available private IP address, e.g. 10.0.0.10
RG_VM= # Existing resource group (by name) for deployment
RG_VNET= # Existing resource group (by name) containing existing VNet resource
SUBSCRIPTION= # Azure subscription ID
@caveatlector
caveatlector / gist:1f081a3f82c7057baa35f5650cf3cbb5
Created June 17, 2019 14:04
PowerShell: add user to local group
Add-LocalGroupMember -Group ${GROUP} -Member ${USER}
@caveatlector
caveatlector / gist:0aca83cfd97948266ae920051c13286b
Created June 12, 2019 09:16
Robocopy: copy directory recursively
robocopy \${SOURCE} \${TARGET} /E
https://docs.microsoft.com/en-us/azure/virtual-machines/windows/attach-managed-disk-portal
@caveatlector
caveatlector / sqlcmd_test_getdate.bash
Created June 7, 2019 14:03
sqlcmd: test connection via getdate()
#!/usr/bin/env bash
# Requires: sqlcmd
IP=
sqlcmd -S tcp:${IP},1433 -Q "select getdate()"
@caveatlector
caveatlector / azure_create_windows_vm.bash
Last active June 7, 2019 10:57
Azure: create Windows VM (from existing disks)
#!/usr/bin/env bash
# Requires: az-cli
DATA_DISK= # Existing data disk (by name)
NSG= # Existing NSG (by name)
OS_DISK # Existing OS disk (by name)
PRIVATE_IP= # Available private IP address, e.g. 10.0.0.10
PUBLIC_IP= # Existing public IP address (by name)
RG_TARGET= # Existing resource group (by name) for deployment
@caveatlector
caveatlector / azure_copy_storage-account_container.bash
Last active June 7, 2019 14:04
Azure: copy Storage Accounts container
#!/usr/bin/env bash
# Requires: az-cli, azcopy, jp
SOURCE= # Source Storage Account name
TARGET= # Target Storage Account name
SOURCE_KEY= # Source Storage Account key
TARGET_KEY= # Target Storage Account key
for CONTAINER in $(az storage container list --account-name ${SOURCE} | jp [].name)
@caveatlector
caveatlector / nmap_scan_array.bash
Last active June 7, 2019 10:56
nmap: TCP/UDP port scan array of IPs
#!/usr/bin/env bash
# Requires: nmap
TIMESTAMP=$(date +"%Y%m%d%M")
TARGETS=( ) # E.g. TARGETS=( 1.0.0.1 1.1.1.1 )
for TARGET in "${TARGETS[@]}"
do
echo "Begin scan: ${TARGET}" | tee -a nmap_${TIMESTAMP}.log