Skip to content

Instantly share code, notes, and snippets.

@IAmStoxe
IAmStoxe / permutation.go
Created August 12, 2020 22:03
The package calculates asynchronously combinations and permutations of a collection of values.
package main
import (
"fmt"
"strings"
"klaidliadon.dev/next"
)
func main() {
@IAmStoxe
IAmStoxe / change-from-static-to-dhcp-unifi.sh
Created July 29, 2020 16:49
Change a unifi switch/firewall/ap from static IP to DHCP
sed -i -E 's/netconf.1.ip=.+/netconf.1.ip=0.0.0.0/g' /tmp/system.cfg
sed -i -E 's/netconf.1.netmask=.+//g' /tmp/system.cfg
sed -i -E 's/route.1.gateway=.+//g' /tmp/system.cfg
sed -i 's/route.1.status=enabled//g' /tmp/system.cfg
sed -i 's/route.1.devname=eth0//g' /tmp/system.cfg
sed -i 's/route.1.ip=0.0.0.0//g' /tmp/system.cfg
sed -i -E 's/route.1.gateway=.+//g' /tmp/system.cfg
@IAmStoxe
IAmStoxe / change-from-static-to-dhcp-unifi.sh
Last active July 29, 2020 16:52
Change a unifi switch/firewall/ap from static IP to DHCP
# Backup config
cp /tmp/system.cfg" "/tmp/system.cfg.bak
sed -i -E 's/netconf.1.ip=.+/netconf.1.ip=0.0.0.0/g' /tmp/system.cfg
sed -i -E 's/netconf.1.netmask=.+//g' /tmp/system.cfg
sed -i -E 's/route.1.gateway=.+//g' /tmp/system.cfg
sed -i 's/route.1.status=enabled//g' /tmp/system.cfg
sed -i 's/route.1.devname=eth0//g' /tmp/system.cfg
(Get-ADDomainController -Filter *).Name |
ForEach-Object {
repadmin /syncall $_ (Get-ADDomain).DistinguishedName /e /A | Out-Null
};
Start-Sleep 10;
Get-ADReplicationPartnerMetadata -Target "$env:userdnsdomain" -Scope Domain |
Select-Object Server, LastReplicationSuccess
@IAmStoxe
IAmStoxe / query_crt.sh
Created July 25, 2020 00:16
query_crt.sh
curl -s "https://crt.sh/?q=%25.DOMAIN_NAME_HERE&output=json" |
jq -r '.[].name_value' |
sed 's/\*\.//g' |
sort -u
@IAmStoxe
IAmStoxe / get-aws-ips.sh
Last active July 23, 2020 03:55
Replace EC2 with the target service (i.e. S3, CLOUDFRONT, etc. - case sensitive)
curl -s 'https://ip-ranges.amazonaws.com/ip-ranges.json' |
jq -r '.prefixes[] | select(.service | contains("EC2")) | .ip_prefix' |
sort -u
@IAmStoxe
IAmStoxe / get-gcp-ips.sh
Last active July 23, 2020 02:49
How to query the current IP ranges of google cloud platform
#!/bin/bash
{
nslookup -q=TXT _cloud-netblocks1.googleusercontent.com 8.8.8.8
nslookup -q=TXT _cloud-netblocks2.googleusercontent.com 8.8.8.8
nslookup -q=TXT _cloud-netblocks3.googleusercontent.com 8.8.8.8
nslookup -q=TXT _cloud-netblocks4.googleusercontent.com 8.8.8.8
nslookup -q=TXT _cloud-netblocks5.googleusercontent.com 8.8.8.8
} | grep -o '[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\/[0-9]\{1,\}' | sort -u
curl -s 'https://crt.sh/?q=%25.DOMAIN_NAME_HERE.com&output=json' \
| jq -r '.[].name_value' \
| sed 's/\*\.//g' \
| sort -u \
| xargs -L1 -I % sh -c './main --ignore-ssl --json="./tmp/%.json" --url="%"'
@IAmStoxe
IAmStoxe / lazycrt.sh
Created July 7, 2020 22:54
Quickly query a certificate transparancy log to get known subdomains for a given domain.
#!/bin/bash
# Usage: ./lazycrt.sh MyDomain.com
curl -s "https://crt.sh/?q=%25.$1&output=json" | jq -r '.[].name_value' | sed 's/\*\.//g' | sort -u
@IAmStoxe
IAmStoxe / Check-PublicIPChange.ps1
Last active July 8, 2020 06:57
Check constantly ever 10 seconds for a public IP change.
$ipCheckUrl = "http://ipinfo.io/ip"
$ip1 = (Invoke-WebRequest $ipCheckUrl).Content
while ($true) {
Start-Sleep 10
$ip2 = (Invoke-WebRequest $ipCheckUrl).Content
if ($ip1 -ne $ip2) {
$date = Get-Date
"IP CHANGED @ $date" | Out-Host
"IP CHANGED FROM $ip1 to $ip2!" | Out-Host