Skip to content

Instantly share code, notes, and snippets.

@jrwarwick
jrwarwick / captive_portal_escape.py
Last active September 7, 2022 16:34
Wi-Fi Captive Portal (Automatable) Escape
#!/usr/bin/env ptython
import re
import requests
from bs4 import BeautifulSoup
from urllib.parse import urljoin
##optional
import textwrap
from datetime import datetime
"""captive_portal_escape.py: Schedulable automatic-ish escape from a wi-fi "captive portal".
@jrwarwick
jrwarwick / trendy_title_generator.ps1
Last active August 5, 2022 19:58
Trendy Job Title Generator
function pick($hat) {
$a = $hat -split ","
$a[(get-random -min 0 -max $a.count)]
}
$altitudeModifier = "chief,head,senior,lead,principal,lord,earl of,vice,total,regional,legendary,imaginary,administrator of,minister of,professor of,master,associate,assistant,supreme,ultimate,proto,star,best,high,uber,arch,bestest,director of,manager of,commissioner of"
$subjectModifier = "interpersonal,extrapersonal,blackbelt,intra-,meta-,omni-,hyper-,tele-,eco-,trans-,para-,re-,turbo-,cyber,brand,catalytic,integrated,dynamic,intersectional,initiative,AI,machine learning,agile,communal,pro,team,quantitative,imaginary,holistic,core,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,," #this is a trick to reduce frequency of the term appearing at all; lots of blanks will be selected
$subject = "data,knowledge,science,administration,infrastructure,sales,impression,ceremony,induction,persuasion,performance,propaganda,collection,cooperation,discovery,distribution,influence,referral,growth,profit,business,solutioning,disaster
@jrwarwick
jrwarwick / generic_ldap_access_setup.sh
Last active October 4, 2023 18:24
Simple generic LDAP access (to ActiveDirectory) from Linux CLI
#When modern AD is your LDAP, and Linux (RHEL-ish) is your server, but not joined to domain, per se.
#yum install yum install openldap-clients
cp -p /etc/openldap/ldap.conf /etc/openldap/ldap.conf.$(date +%Y%m%d)
cat <<_EOF_>/etc/openldap/ldap.conf
BASE OU=Sites,DC=INT,DC=FOO,DC=COM
URI ldaps://int.foo.com:3269
TLS_REQCERT ALLOW
_EOF_
read -p "LDAP lookups Simple Bind password:" ; echo -n $REPLY > $HOME/.config/ldap_password
@jrwarwick
jrwarwick / jks_to_pfx_conversion.sh
Created July 27, 2022 22:09
Code Signing Certificate Conversion: from Java Keystore+(issued)Cert to PFX (combined)
#We're starting with a Java Keystore (in adkeystore.dat), and we want to end up with a combined PFX
#first jks out to PFX, but just the key
keytool -importkeystore -srckeystore adkeystore.dat -destkeystore CodeSigning_keyonly.pfx -deststoretype pkcs12 -deststorepass KEEPASS -destkeypass KEEPASS
#then "refine it" to a plain PEM (still key only)
openssl pkcs12 -in CodeSigning_keyonly.pfx -nocerts -out isolated_key.pem -nodes
#then combine isolated key with issued (public) cert
openssl pkcs12 -export -out CodeSigning_combined.pfx -inkey isolated_key.pem -in CodeSigning_$(date '+%Y')*.crt
#Optional review:
openssl pkcs12 -info -in CodeSigning_combined.pfx | egrep 'issuer|subject|--*BEGIN'
@jrwarwick
jrwarwick / get_scp_retrieval_command_bash_alias.sh
Created July 27, 2022 21:13
Convenience command to generate a command to "pull via scp (elsewhere)" a file in local FS
function getcmd () { echo $1; find `pwd` -name "*$1*" | sed "s/^/scp $USER@$HOSTNAME:/"; }
@jrwarwick
jrwarwick / MSSQL_All_Tables_with_Columns.sql
Created June 3, 2022 21:44
MSSQL Tables and Columns survey - inspection of all tables with column names via a temporary table
SET NOCOUNT ON
DECLARE @AllTables table (db_name nvarchar(128),schema_name nvarchar(128),table_name nvarchar(128), table_type_desc nvarchar(60), table_modify_date datetime, column_id int,column_name nvarchar(128),data_type nvarchar(128),max_length smallint,precision tinyint, is_nullable bit)
DECLARE @SQL nvarchar(4000)
SET @SQL='select ''?'' as db_name,
schema_name(tab.schema_id) as schema_name,
tab.name as table_name, tab.type_desc as table_type_desc, tab.modify_date as table_modify_date,
col.column_id, col.name as column_name,
t.name as data_type, col.max_length, col.precision, col.is_nullable
from [?].sys.tables as tab
inner join [?].sys.columns as col
@jrwarwick
jrwarwick / powershell_coding_conventions.ps1
Created May 19, 2022 14:45
PowerShell Coding Conventions Guidance
## bry PowerShell Corporate Coding Conventions ##
"Largely, respecting: https://docs.microsoft.com/en-us/powershell/scripting/developer/cmdlet/strongly-encouraged-development-guidelines?view=powershell-7.2"
"Perhaps a few extensions and modifications."
"Also try to include this: https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_comment_based_help?view=powershell-7.2#comment-based-help-for-a-script"
## Major Sections Double-Crunch, Capitalized, and Doublespaced ##
"For clarity, uniformity, ease of navigation, and grepability/searchability."
@jrwarwick
jrwarwick / .bash_profile__nslookup_emulation
Last active February 23, 2022 20:52
Emulate nslookup with dig
##Simple, partial, more-or-less emulation of nslookup when all you have is dig
##tested on RHEL 8 and Ubuntu 20. Sometimes local dns cache is reported as SERVER.
nslookup () { dig $([[ $1 =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]] && echo "-x" || echo " ") $1 | egrep 'SERVER|^[^;]' | sed -e 's/\.\s*[0-9]*\s*IN\s*/\t/' -e 's/^;; /\tvia DNS /' -e 's/#[0-9]\+(.*//' | cat -s; }
## slightly fancier version, that will definitely be linux only, and one with nmcli on it, but will prevent internal DNS server cache answers.
# nslookup () { dig @$(nmcli | grep servers | cut -d' ' -f 2) $([[ $1 =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]] && echo "-x" || echo " ") $1 | egrep 'SERVER|^[^;]' | sed -e 's/\.\s*[0-9]*\s*IN\s*/\t/' -e 's/^;; /\tvia DNS /' -e 's/#[0-9]\+(.*//' | cat -s; }
## and here is a solaris edition which works around various limitations on tab characters
# nslookup () { dig $([[ $1 =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]] && echo "-x" || echo " ") $1 | egrep 'SERVER|
@jrwarwick
jrwarwick / gpg_keyset_gen.sh
Last active October 22, 2021 15:27
GPG (PGP) Supplemental Tools: keyset generator SOP script and SecretServer secret template for PGP Keys
#!/usr/bin/bash
DOMAIN="abc.tld"
GPG_USER_ID=${1:-$USER}
echo "RSA, RSA, 4096-bit $(date +%Y.%m.%d)"
echo "Building a keypair for User ID: ${GPG_USER_ID}"
echo "Supply Legal incorporated chartered corporation/company name OR personal legal name, "
echo "with department name in Comment or blank (for personal legal names)."
gpg --gen-key
gpg --list-keys
@jrwarwick
jrwarwick / standard_audit_pk_apex_BIU_table_trigger.sql
Created September 15, 2021 20:25
Oracle RDBMS Audit column trigger formula - with APEX support and serial UID surrogate PK
-- Prefer Oracle APEX user identity, but gracefully "descend" to lower contexts. Also works pretty well over DB links (avoiding static proxy user identity)!
-- Note the regex call might have some performance implications for very high transaction rates.
create or replace TRIGGER "SCHEMA"."TABLENAME_BIU"
BEFORE INSERT or UPDATE on TABLENAME FOR EACH ROW
DECLARE
BEGIN
if :new.ENTITY_UID is null then
:new.ENTITY_UID := TABLENAME_ENTITY_UID_SEQ.nextval;
end if;
:new.AUTH_ID := UPPER(:new.AUTH_ID);