Skip to content

Instantly share code, notes, and snippets.

View twirrim's full-sized avatar

Twirrim twirrim

View GitHub Profile
@twirrim
twirrim / random_data.md
Created November 15, 2024 20:27
Making Random Data really Fast

I stumbled across this trick elsewhere several years ago, but I don't remember where. I needed to generate 10TiB of hard-to-compress data, and /dev/urandom is somewhat slow (400-ish MB/s)

Most major CPUs over the past several years have acceleration for AES-256 ciphers. So one way to produce lots of random-ish, hard to compress data is to leverage openssl.

For OpenSSL 1.1 onwards, using current epoch as the seed:

$ openssl enc -aes-256-ctr -pbkdf2 -pass pass:"$(date '+%s')" < /dev/zero

Note you could replace that call out to date with a straight password instead, but you'll always get the same data each time out the other side:

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import sys
flipdict = {
'a': 'ɐ',
'b': 'q',
'c': 'ɔ',
'C': 'Ɔ',
'd': 'p',
@twirrim
twirrim / compression.py
Created February 6, 2019 21:21
Check compression in use
#!/usr/bin/env python
from multiprocessing.dummy import Pool
from collections import defaultdict
import requests
import logging
def uses_compression(domain):
logging.info(domain)
try:
@twirrim
twirrim / sslcheck.py
Created August 29, 2018 22:10
ssl check
import socket
import ssl
import datetime
from multiprocessing.dummy import Pool as ThreadPool
# Tuples containing host and port
CERTS_TO_CHECK = [("host_one", 443),
("host_two", 25)]
@twirrim
twirrim / throttle.py
Created August 10, 2018 05:54
Quick attempt to emit Raspberry Pi throttling state metrics through telegraf
#!/usr/bin/env python3
import re
import socket
from subprocess import check_output
def eval_position(position, status):
try:
if status[position] == 1:
return 1
#!/usr/bin/env python
import socket
import ssl
import datetime
import smtplib
import argparse
import sys
import logging