Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

dustyfresh dustyfresh

🎯
Focusing
View GitHub Profile
@dustyfresh
dustyfresh / create_vultr_instance.py
Last active Dec 29, 2020
Simple python script for launching a Vultr instance using the v2 API https://www.vultr.com/api/v2
View create_vultr_instance.py
#!/usr/bin/python
import os
import json
import requests
from time import sleep
def main():
# API configuration
VULTR_SECRET = os.getenv("VULTR_SECRET")
# SSH_KEYS must be a list of SSH key uuids as tracked by Vultr.
@dustyfresh
dustyfresh / dump_ip2asn.py
Last active Dec 11, 2020
quick and dirty script for streaming ip2asn tsv and then saving the data locally as json
View dump_ip2asn.py
#!/usr/bin/env python3
import netaddr
import json
from smart_open import open
def main():
# Use smart_open to stream the compressed data line by line
with open('./ip2asn.json', 'a+') as outfile:
for line in open('https://iptoasn.com/data/ip2asn-v4.tsv.gz', encoding='utf-8'):
range_start,range_end,AS_number,country_code,AS_description = line.split('\t')
@dustyfresh
dustyfresh / inkyphat-crypto-ticker.py
Created Nov 18, 2020
Crypto price ticker with the inkyphat eink display
View inkyphat-crypto-ticker.py
#!/usr/bin/env python3
import cryptocompare
from time import sleep
from inky import InkyPHAT
from random import shuffle
from datetime import datetime
from PIL import Image, ImageDraw, ImageColor, ImageFont
def log(msg):
#print(msg)
@dustyfresh
dustyfresh / mysql_json_table_dump.py
Last active Oct 3, 2020
dump mysql table as jsonl file
View mysql_json_table_dump.py
#!/usr/bin/env python
import json
import pymysql.cursors
def main():
# Connect to the database
connection = pymysql.connect(
host='localhost',
user='changeme',
password='changeme',
@dustyfresh
dustyfresh / hashtables.py
Created Apr 22, 2020
script for quickly generating hash tables from a password list
View hashtables.py
#!/usr/bin/env python
import json
import time
import hashlib
import multiprocessing as mp
class Hashes(object):
def md5(s):
return hashlib.md5(str(s).encode()).hexdigest()
@dustyfresh
dustyfresh / tshark.md
Last active Sep 18, 2020
Systemd service to capture all traffic on ports 53/80/443. tshark will store up to 10MB of data per pcap file, and keep store up to 2GB of captures on disk. Once 2GB disk limit is reached, tshark will rotate older pcaps. Change the filecount in the capture script if you want to store more traffic on disk.
View tshark.md

Continuous capture

Tested on Ubuntu 18.04.

Install tshark

You will want to allow non-root users to capture packets. These users must be part of the wireshark group.

$ sudo apt update
@dustyfresh
dustyfresh / gzip_remote_file.py
Created Mar 30, 2020
read gzipped data from a remote file as a string
View gzip_remote_file.py
import io
import gzip
import requests
data = requests.get('https://url/file.txt.gz', stream=True)
in_ = io.BytesIO()
in_.write(data.content)
in_.seek(0)
gunzipped_bytes_obj = gzip.GzipFile(fileobj=in_, mode='rb').read()
data = gunzipped_bytes_obj.decode()
@dustyfresh
dustyfresh / ssh-dd.sh
Created Mar 28, 2020
dd remote server over SSH
View ssh-dd.sh
#!/bin/bash
ssh root@host "dd if=/dev/sda1" | dd of=host.img
@dustyfresh
dustyfresh / fast_resolv.py
Last active Mar 26, 2020
fast DNS resolution
View fast_resolv.py
#!/usr/bin/env python
import json
import dns.resolver
import multiprocessing as mp
def worker(hostname, results):
resolv = dns.resolver.Resolver()
resolv.nameservers = [
'8.8.8.8', # Google
'8.8.4.4', # Google
@dustyfresh
dustyfresh / default.conf
Last active Jan 27, 2021
Hardened nginx config
View default.conf
# Security enhancements and custom Nginx server header
#
# Requirements:
# $ apt install nginx vim
# $ apt install libnginx-mod-http-headers-more-filter
# $ vim /etc/nginx/sites-enabled/default
#
# Further reading http://docs.hardentheworld.org/Applications/Nginx/
#
server {