Skip to content

Instantly share code, notes, and snippets.

View joswr1ght's full-sized avatar

Joshua Wright joswr1ght

View GitHub Profile
@joswr1ght
joswr1ght / wifiscan.cmd
Created July 11, 2019 11:32
Wi-Fi Scanning at the Windows Command Prompt, FOR loop style
FOR /L %N IN () DO @netsh wlan show networks mode=bssid | findstr "^SSID Signal" && ping -n 16 127.0.0.1 >NUL && cls
@joswr1ght
joswr1ght / debugrequests.py
Created January 4, 2023 13:58
Add this code to Python scripts to debug HTTP requests activity and see request/response data
import logging
import requests
import http.client
http.client.HTTPConnection.debuglevel = 1
logging.basicConfig()
logging.getLogger().setLevel(logging.DEBUG)
requests_log = logging.getLogger("requests.packages.urllib3")
requests_log.setLevel(logging.DEBUG)
requests_log.propagate = True
@joswr1ght
joswr1ght / countips.py
Last active February 9, 2024 18:23
Read a file of network + CIDR masks, one per line; count the number of IP addresses it represents
#!/usr/bin/env python
import sys
def countips(netblock):
cidr = int(netblock.split('/')[1])
return 2**(32 - cidr)
if (len(sys.argv) != 2):
print(f"Usage: {sys.argv[0]} <file with CIDR masks>")
sys.exit(0)
@joswr1ght
joswr1ght / accesslog2csv.py
Created December 16, 2019 11:45
Convert Apache/Nginx Unified Log Format to CSV
# accesslog2csv: Convert default, unified access log from Apache, Nginx
# servers to CSV format.
#
# Original source by Maja Kraljic, July 18, 2017
# Modified by Joshua Wright to parse all elements in the HTTP request as
# different columns, December 16, 2019
import csv
import re
@joswr1ght
joswr1ght / ctsummarize.sh
Created November 10, 2021 14:08
ctsummarize: Create Multiple Output Files From CloudTrail Activity for Analysis
#!/bin/bash
REQUIREDUTILS="jq zcat mktemp sort uniq rm"
# Run program and test exit status to ensure success
function runtst {
"$@"
local status=$?
if (( status != 0 )); then
echo "error running command" >&2
@joswr1ght
joswr1ght / disabledep.txt
Created October 25, 2015 11:35
Disable DEP/NX on Linux in Grub
Boot and interrupt the GRUB menu
Edit the boot configuration, changing the "linux" line by adding these two parameters to the end of the line:
noexec=off noexec32=off
Then boot by pressing Ctrl+x.
After booting, you can check to see if DEP/NX is turned off by running:
dmesg | grep NX
When DEP/NX is turned off you should see something similar to this output:
@joswr1ght
joswr1ght / nmap-top-tcpport-commadsep-list.sh
Created July 24, 2022 12:23
Create a list of top Nmap TCP ports, converted to comma-separated format
grep -v '^#' /usr/local/Cellar/nmap/7.92/share/nmap/nmap-services | grep '/tcp' | sort -r -k3 | awk '{print $2}' | sed 's,/tcp,,' | head -40 | sort -n | gsed -z 's/\n/,/g;s/,$/\n/'
@joswr1ght
joswr1ght / winfwdisable.cmd
Created July 26, 2016 14:36
Disable Windows Firewall via netsh
netsh advfirewall set allprofiles state off
@joswr1ght
joswr1ght / searchpackage.py
Created August 2, 2023 11:24
Search Ranges.io Package for Keyword, Display Matching Group and Short Title
#!/usr/bin/env python3
import json
import sys
if (len(sys.argv) != 3):
sys.stderr.write('Search RIO Package for string, identify matching group'
' and short title\n')
sys.stderr.write(f'Usage: {sys.argv[0]} package_export.json "keyword"\n')
sys.exit(0)
@joswr1ght
joswr1ght / cleanup-turnkey.sh
Created January 25, 2018 18:39
Turnkey Linux Cleanup
apt-get remove tklbam confconsole shellinabox postfix mysql\* monit webmin vim-tiny
rm /etc/init.d/confconsole
apt-get install vim