Skip to content

Instantly share code, notes, and snippets.

@colindix
colindix / Converter.sh
Created May 28, 2018 04:46
Domain to IP converter
# Converter.sh by @xdavidhu
# This is a script inspired by the Bug Hunter's Methodology 3 by @Jhaddix
# With this script, you can convert domain lists to resolved IP lists without duplicates.
# Usage: ./converter.sh [domain-list-file] [output-file]
echo -e "[+] Converter.sh by @xdavidhu\n"
if [ -z "$1" ] || [ -z "$2" ]; then
echo "[!] Usage: ./converter.sh [domain-list-file] [output-file]"
exit 1
fi
@colindix
colindix / O365search.ps1
Created July 5, 2018 02:37
Search O365 mailboxes for badness
# Get login credentials
$UserCredential = Get-Credential
$psOption = New-PSSessionOption -ProxyAccessType IEConfig -ProxyAuthentication Negotiate
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.compliance.protection.outlook.com/powershell-liveid -Credential $UserCredential -Authentication Basic -AllowRedirection -SessionOption $psOption
Import-PSSession $Session -AllowClobber -DisableNameChecking
$searchQry = '(Subject:<YOUR SUBJECT HERE) AND (Received:today)' #KQL https://msdn.microsoft.com/library/ee558911(v=office.15).aspx
$compName = "20180514-01-MalwareEmails"
@colindix
colindix / PriorityTGscored.json
Last active May 21, 2019 06:27
Prioritised_TG_Scored
{
"name": "Priority_Threat_Groups_Scoring",
"version": "2.1",
"domain": "mitre-enterprise",
"description": "",
"filters": {
"stages": [
"act"
],
"platforms": [
@colindix
colindix / jupyterwidth.py
Created June 20, 2019 05:17
Jupyter - Pandas Column Width adjustment
pd.set_option('display.max_columns', 500)
pd.set_option('display.width', 2000)
pd.set_option('max_colwidth', 500)
@colindix
colindix / sparkusertokenregex.py
Last active July 8, 2019 08:39
Apache Spark Regex match for User Tokens in Dataframe and SQL syntax
# ### This one works in the dataframe syntax
dfuserrgx1 = r"\\users\\[^\\]+\\"
dfuserrgx2 = r"\\userdata\\[^\\]+\\"
#userrgx3 = r'\bS-1-5-21-\d{8,10}-\d{8,10}-\d{8,10}-\d{5,10}\b'
dfuserrgx3 = r'S-1-5-21-\d{8,10}-\d{8,10}-\d{8,10}-\d{5,10}'
dfusermatch = f"(?i)(?:{dfuserrgx1})|(?:{dfuserrgx2})|(?:{dfuserrgx3})"
################################################################
# ### Works in SQL - can reduce these to 4 x backslashes if raw strings are used
@colindix
colindix / dask_localcluster.py
Created August 25, 2019 06:19
Dask LocalCluster setup
client = Client(n_workers=3, threads_per_worker=1, processes=True, # processes=True for computationally intensive work
memory_limit='16GB', scheduler_port=0,
diagnostics_port=0, silence_logs=False)
# diagnostics_port and scheduler_port with 0 as the param will cause random selection for the client.
@colindix
colindix / tld_list.txt
Created April 2, 2020 04:56
Spamhaus TLD list 20200401
abb
abbott
abc
abogado
abudhabi
ac
academy
accountant
accountants
aco
@colindix
colindix / logparser.ps1
Created May 28, 2020 09:51 — forked from exp0se/logparser.ps1
Logparser log parsing
# Logparser
###############
# Security Log
###############
# Find Event id
& 'C:\Program Files (x86)\Log Parser 2.2\LogParser.exe' -stats:OFF -i:EVT "SELECT * FROM 'Security.evtx' WHERE EventID = '5038'"
@colindix
colindix / siginthandler.py
Created October 19, 2020 07:11
sigint handler
def graceful_cleanup(signum, frame):
"""
signal handler function should perform all clean up tasks and optionall exit.
I here it is just shutting down an executor which will exit the main loop,
i have also used it to set a flag so that processing in other threads will exit on the next test of that flag.
The code below is unlikely to work as i was just using it in a test harness, but the signal module does work well for this
use case.
"""
try:
futurelist_lock.release()
@colindix
colindix / uptime.ps1
Created January 31, 2023 02:43
Powershell get uptime
$cdate = (get-date).ToUniversalTime() ; $bup = ((gcim Win32_OperatingSystem).LastBootupTime).ToUniversalTime(); $ut = (($cdate) - $bup); Write-Output "`nUptime: $($ut.Days)d $($ut.Hours)h $($ut.Minutes)m $($ut.Seconds)s | TotalSeconds: $($ut.TotalSeconds) || Booted: $($bup.ToString('u')) | $(get-date -date $bup -UFormat '%s')`n"