Skip to content

Instantly share code, notes, and snippets.

@atucom
atucom / ipconvert.py
Created March 19, 2018 15:16
converts 1.1.1.1-1.1.1.4 notation into individual IPs
#!/usr/bin/env python3
#pip3 install iptools
#converts 1.1.1.1-1.1.1.4 notation into individual IPs
#@atucom
import iptools
with open('ips.txt') as f:
lines = f.readlines()
for line in lines:
if '-' in line:
iprange = line.split('-')
@atucom
atucom / gist:1a3b5850c8a63ab74f3d72d8861d80c8
Created March 19, 2018 20:03
Chop off subdomains from an FQDN
#!/usr/bin/env python3
#pip3 install tldextract
#Hostnames listed one/line in supplied file
#@atucom
with open('ips.txt.ssl_and_dns.hostnames') as f:
hostnames = f.readlines()
for hostname in hostanmes:
domain = tldextract.extract(hostname)
print(domain.registered_domain)
#!/usr/bin/env python3
""" LOLDONGS Encoding
This converts data into a series of ASCII dicks.
Because with great power, comes great responsibility.
"""
import argparse
import sys
def encode(inputData):
@atucom
atucom / parsehtml.py
Created August 2, 2018 22:42
Parse HTML for ingredient list, customized for homechef
from lxml import html
import lxml
import os
from collections import defaultdict
def getIngredients(htmlFile):
# Returns the ingredients from an html file
try:
tree = html.fromstring(htmlFile)
except lxml.etree.ParserError:
#!/usr/bin/env python3
# @atucom 2018
# This script, given credentials and a host, will clone all the git repos
# from a bitbucket server into appropriately named project folders locally.
# Just update the username, password, and host, and let it go.
import stashy
import os
import subprocess
@atucom
atucom / outlier.py
Last active October 29, 2018 23:18
This returns the files in the current directory that are statistical outliers in terms of file size
#!/usr/bin/env python3
"""
@atucom
This returns the files in the target directory that are
statistical outliers in terms of file size
This is useful in the quest for finding target data.
"""
from __future__ import division
import argparse
import sys
@atucom
atucom / tmux_logging.sh
Last active October 29, 2018 23:22
tmux logging hack. Works just like GNU screen "logfile"
#!/bin/bash
#place this code in your .bashrc or .profile and have fun :D
if [[ $(uname) = "Darwin" ]]; then #this is for OSX Machines
#This sets up auto logging to $HOME/logs if its a tmux window
if [[ $TERM = "screen" ]] && [[ $(ps $PPID -o comm=) = "tmux" ]] ; then
read -p "Enter Log Prefix: " log_prefix
logname="${log_prefix}_$(date '+%d.%m.%Y-%H:%M:%S').tmux.log"
mkdir $HOME/logs 2> /dev/null
script -t 1 $HOME/logs/${logname} bash -login
exit
@atucom
atucom / ssl_status.py
Created September 19, 2018 21:40
Check if port responds to a SSL handshake
import socket
import ssl
def is_SSL_enabled(ip, port):
"""
Attempts a SSL connection to the specified ip:port
Note: Does not handle STARTTLS yet
returns True if handshake was successful, false if not
"""
context = ssl.create_default_context()
@atucom
atucom / ldapscraper.py
Created August 30, 2018 02:27
Brute force LDAP CN entries and download them locally
#!/usr/bin/env python3
# @atucom 2018
# This tool brutes all cn attributes from ldap recursively.
# Additionally, if a result limit is exceeded, it will drill down farther and keep going
import os
import subprocess
import string
@atucom
atucom / pub2priv.rb
Created January 13, 2017 15:30
Convert an RSA public key into a private key
#!/usr/bin/env ruby
#convert a supplied public key to a private key
#This assumes a reasonably weak key length otherwise the loop will do math longer than you'll want to wait.
#@atucom
#you can test this with:
# openssl genrsa -out rsakey_56bit.priv 56
# openssl rsa -in rsakey_56bit.priv -out rsakey_56bit.pub -outform PEM -pubout
# echo '123456' | openssl rsautl -encrypt -raw -pubin -inkey rsakey_56bit.pub > rsakey_56bit.123456.encrypted
# ruby pub2priv.rb rsakey_56bit.pub | tee pub2priv.generatedpriv
# openssl rsautl -decrypt -in rsakey_56bit.123456.encrypted -keyform PEM -inkey pub2priv.generatedpriv -raw | xxd