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
<?php | |
class IPUtilities { | |
static function IsInIPv4Range($ipaddress, $range){ | |
// convert the ip to long respresentation | |
$long = ip2long($ipaddress); | |
// split the range/cidr | |
$parts = explode('/', $range); | |
// convert the range to long representation | |
$rangeAddr = ip2long($parts[0]); | |
// binary mask |
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
<?php | |
function IsValidMailbox($address){ | |
if(preg_match('/@([^\s]+)/i', $address, $matches)){ | |
if(dns_get_mx($matches[1], $out)){ | |
$timeout = 10; // Timeout for connection | |
$mailServer = $out[0]; | |
// Open a plaintext connection to the mail server. Assuming port 25 outbound isnt blocked here | |
$connection = stream_socket_client( | |
"$mailServer:25", |
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 Invoke-FileDownload { | |
param( | |
[Parameter(Mandatory=$true)] | |
[string]$Uri, | |
[Parameter(Mandatory=$true)] | |
[string]$OutFile, | |
[Parameter(Mandatory=$false)] | |
[hashtable]$Headers | |
) |
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
$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) |
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
#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 |
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
<?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); |
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
$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 |
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
# 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"; | |
} |
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
$email="CF_EMAIL" | |
$apikey="CF_API_KEY" | |
$deleted = 0 | |
$records = 0 | |
$page = 1 | |
$pages = 1 | |
while($page -le $pages){ | |
Write-Host "########## $page ###########" |
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
<?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: [email protected]'; | |
$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('[email protected]', 'Contact Form', $message, $headers)){ |
NewerOlder