Skip to content

Instantly share code, notes, and snippets.

@kimboslice99
kimboslice99 / Invoke-FileDownload.psm1
Last active April 30, 2024 17:30
A powershell module to keep a remote file up to date with a local copy via etag; e.g. IP lists
function Invoke-FileDownload {
param(
[Parameter(Mandatory=$true)]
[string]$Uri,
[Parameter(Mandatory=$true)]
[string]$OutFile,
[Parameter(Mandatory=$false)]
[hashtable]$Headers
)
@kimboslice99
kimboslice99 / dbip-update.ps1
Created February 23, 2024 07:26
Update dbip database
$download_file = "dbip-country-lite-$((Get-Date).ToString('yyyy'))-$((Get-Date).ToString('MM')).mmdb"
$download_url = "https://download.db-ip.com/free/$download_file.gz"
# download latest GeoIP database
Invoke-WebRequest -Uri $download_url -OutFile "$PSScriptRoot\dbip-country-lite.mmdb.gz" -UseBasicParsing
Add-Type -AssemblyName System.IO.Compression.FileSystem
$sourceFileStream = [System.IO.File]::OpenRead("$PSScriptRoot\dbip-country-lite.mmdb.gz")
$destinationFileStream = [System.IO.File]::Create("$PSScriptRoot\dbip-country-lite.mmdb")
$gzipStream = New-Object System.IO.Compression.GzipStream $sourceFileStream, ([System.IO.Compression.CompressionMode]::Decompress)
@kimboslice99
kimboslice99 / tlsa_checkup.ps1
Last active August 25, 2024 01:45
A powershell script to verify tlsa records and fire off an email with the result - OS agnostic
#A powershell script to verify tlsa records and fire off an email with the result - OS agnostic
# choco install -y bind-toolsonly - why wouldnt they keep building dig tools for windows? boo >:(
# also runs on linux provided you have dig and openssl available
# your root domain, we will look up the mx record within this script
$domainToCheck = "domain.tld"
$portsToCheck = @{
25 = 'tcp'
587 = 'tcp'
}
# notify settings
@kimboslice99
kimboslice99 / bulk_dns_query.php
Created February 7, 2024 06:48
Bulk DNS queries at blazing fast speed! (A/AAAA)
<?php
// enter domain names in a file, newline delimited
$filename = 'domain_names.txt';
// read the file
$fp = @fopen($filename, 'r');
!$fp?die('File not found!'):'';
$domains = explode(PHP_EOL, fread($fp, filesize($filename)));
fclose($fp);
@kimboslice99
kimboslice99 / Cloudflare_ListandUpdate.ps1
Last active February 2, 2024 09:13
A script to list all A/AAAA records in a zone and update their IP if it has changed
$type = "A" # type A/AAAA
$email = "<CF_EMAIL_ADDRESS>"
$apikey = "<CF_API_KEY>"
$ZoneID = "<CF_ZONE_ID>"
$iplink = "https://ipv4.seeip.org"
$date = get-date -format yyyy-MM-ddTHH-mm-ss-ff
#list all records of $type
$response = Invoke-RestMethod -UseBasicParsing -Uri "https://api.cloudflare.com/client/v4/zones/$ZoneID/dns_records?type=$type" -Method GET -Headers @{'Accept'='application/json';'X-Auth-Email'="$email";'X-Auth-Key'="$apikey"} -ContentType "application/json"
#get ip address
@kimboslice99
kimboslice99 / QBT_Controller.ps1
Last active February 4, 2024 04:51
Set QBT to alternative speeds while a stream is active in Jellyfin or Emby
# Read configuration from JSON file, run once to generate config.json
$configFile = "$PSScriptRoot/config.json"
if (-not (Test-Path $configFile)) {
$configlayout = @{
"jfAddress"="http://127.0.0.1:8096";
"jfKey"="abcdefg12345";
"qbtAddress"="http://127.0.0.1:8080";
"QBusername"="username";
"QBpassword"="password";
}
@kimboslice99
kimboslice99 / Clean_old_ip_records.ps1
Created March 12, 2023 21:04
Delete Cloudflare IP access rules older than X days
$email="CF_EMAIL"
$apikey="CF_API_KEY"
$deleted = 0
$records = 0
$page = 1
$pages = 1
while($page -le $pages){
Write-Host "########## $page ###########"
@kimboslice99
kimboslice99 / index.php
Created February 20, 2023 02:19
A simple single file website using PHP, HTML, CSS, and JS
<?php
if (isset($_POST['name']) && isset($_POST['message']) && isset($_POST['email'])) {
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: from@yourdomain.tld';
$message = 'Email from: '.filter_input(INPUT_POST, 'name').' '.filter_input(INPUT_POST, 'email', FILTER_SANITIZE_EMAIL).'<br>';
$message .= filter_input(INPUT_POST, 'message');
$message .= '<br><br>';
$message .= 'Remote address '.$_SERVER['REMOTE_ADDR'];
if(mail('to@yourdomain.tld', 'Contact Form', $message, $headers)){
@kimboslice99
kimboslice99 / PHP-IIS_Setup.ps1
Last active December 22, 2022 05:55
A script to set up PHP easily
# Drop this script in your PHP folder with the ini & php-cgi.exe
$path = "$PSScriptRoot\php-cgi.exe"
$ini = "$PSScriptRoot\php.ini"
# Get Version
$Version = "$(./php -r 'echo PHP_VERSION;')"
# Create Handler
New-WebHandler -Name "PHP $Version" -Path "*.php" -Verb "*" -Modules FastCgiModule -ScriptProcessor "$path" -ResourceType "Either"
# FastCGI Settings
Add-WebConfigurationProperty -pspath 'MACHINE/WEBROOT/APPHOST' -filter "system.webServer/fastCgi" -name "." -value @{fullPath="$path";monitorChangesTo="$ini";stderrMode='ReturnGeneric500';maxInstances=8;idleTimeout=600;activityTimeout=604800;requestTimeout=7200;instanceMaxRequests=10000;protocol='NamedPipe';rapidFailsPerMinute=105}
# Environment Variables
@kimboslice99
kimboslice99 / DKIM_Updtae.ps1
Last active December 20, 2022 02:40
dkim cloudflare update script
$email = 'CLOUDFLARE_EMAIL'
$apikey = 'API_KEY'
$ZoneID = 'ZONE_ID'
$type = 'TXT'
$Record = 's1._domainkey.domain.com'
openssl genrsa -out $PSScriptroot\dkim.private.pem 2048
$key = openssl rsa -in $PSScriptroot\dkim.private.pem -pubout | Select -Skip 1 | Select -SkipLast 1 | Join-String
$key | Out-File $PSScriptroot\dkim.public.pem
# Get the record ID
Try { $result = Invoke-RestMethod -Uri "https://api.cloudflare.com/client/v4/zones/$ZoneID/dns_records?type=$type&name=$Record&page=1&per_page=100&order=type&direction=desc&match=all" -Method 'GET' -ContentType "application/json" -Headers @{'Accept'='application/json';'X-Auth-Email'="$email";'X-Auth-Key'="$apikey"} |