Skip to content

Instantly share code, notes, and snippets.

@ssstonebraker
ssstonebraker / python_log_parsing_functions.md
Created November 11, 2024 14:24
Python_Log_parsing_functions
import re
from datetime import datetime
from typing import List, Dict, Optional

# Function to read logs from a file
def read_log_file(file_path: str) -> List[str]:
    """Reads a log file and returns each line as an entry in a list."""
    with open(file_path, 'r') as file:
        return file.readlines()
@ssstonebraker
ssstonebraker / Python_notes.md
Last active January 22, 2025 19:59
Python Notes

Data Structures

Type

Figure out what type of object something is

type(object)

Example:
from collections import Counter
#!/usr/bin/env python
# prints all the records in all the zones in colums separated by ','.
# It uses raw mode to handle pagination to iterate over zones and records
import CloudFlare
separator=","
cf = CloudFlare.CloudFlare(token='REPLACE_WITH_YOUR_OWN_CF_TOKEN', raw=True)
per_page = 10
#!/bin/sh
# for testing EDR
VERSION="ng"
ADVISORY="This script should be used for authorized penetration testing and/or educational purposes only. Any misuse of this software will not be the responsibility of the author or of any other collaborator. Use it at your own computers and/or with the computer owner's permission."
###########################################
#-------) Checks pre-everything (---------#
###########################################
if ([ -f /usr/bin/id ] && [ "$(/usr/bin/id -u)" -eq "0" ]) || [ "`whoami 2>/dev/null`" = "root" ]; then
IAMROOT="1"
@ssstonebraker
ssstonebraker / write_temp_file_and_execute.sh
Last active March 15, 2022 22:18
write_temp_file_and_execute.sh
#!/bin/bash
echo "[*] - Now writing file /tmp/check_ip.sh"
cat <<'EOF' > /tmp/check_ip.sh
#!/bin/bash
# Purpose: Return current external IP
CURRENTIP=$(curl --silent icanhazip.com)
echo "[*] - Current IP - ${CURRENTIP}"
@ssstonebraker
ssstonebraker / tcpdump_tcpreplay.org
Created November 2, 2021 18:33 — forked from niranjan-nagaraju/tcpdump_tcpreplay.org
TCPReplay/TCPRewrite/TCPPrep/TCPDump Cheatsheet

TCPReplay/TCPRewrite/TCPPrep/TCPDump Cheatsheet

tcprewrite

Rewrite IP/Mac addresses, -C optionally to fix checksums

  1. tcpprep, first:C2S, Second S2C, Generate cache file
        
@ssstonebraker
ssstonebraker / pentestws.json
Created January 28, 2021 23:15
pentest.ws export
{
"username": "brakertech",
"export_time": "2021-01-28T23:14:25.004Z",
"export_type": "Account Items",
"service_command_library": [
{
"service": "http",
"sort_order": null,
"name": "davtest",
"command": "davtest -url http://$ip:$port",
@ssstonebraker
ssstonebraker / hue.sh_crontab.txt
Created November 16, 2020 19:43
hue.sh crontab
* * * * * . $HOME/.bash_profile; cd $HOME/Library/cron/philips-hue-experiments && $HOME/Library/cron/philips-hue-experiments/hue.sh 2>&1 >> $HOME/Library/cron/philips-hue-experiments/log/hue.log
@daily /bin/echo "" > $HOME/Library/cron/philips-hue-experiments/log/hue.log
@ssstonebraker
ssstonebraker / hue.sh
Last active February 15, 2021 05:12
hue.sh
#!/bin/bash
# Author: Steve Stonebraker
# Date: 11/16/2020
# brakertech.com
WHOAMI=$(whoami)
path_phe=/Users/"$WHOAMI"/Library/cron/philips-hue-experiments
path_log="$PWD"/log/hue.log
path_npm=$(which npm)