Skip to content

Instantly share code, notes, and snippets.

View dcode's full-sized avatar
💭
Hack the 🌎!

Derek Ditch dcode

💭
Hack the 🌎!
View GitHub Profile
@dcode
dcode / get_default_srcIP.sh
Last active September 22, 2018 06:43
Snippet to get local default interface IP using iproute
ip route get $(ip route get 1.1.1.1 | awk '{ print $3 }') | awk 'NR == 1 {print $5}'
@dcode
dcode / certbot.service
Created September 18, 2018 19:17
Run certbot twice daily to ensure we never lose a valid cert.
# /etc/systemd/system/certbot.service
[Unit]
Description=Certbot Renewal
[Service]
ExecStart=/usr/bin/certbot renew --post-hook "systemctl restart httpd"
@dcode
dcode / 0_README.md
Last active February 15, 2018 15:41
Currently working lighttpd config

First, you need to enable the vhost config in lighttpd:

sudo sed -i '/^#.*vhosts\.d\/\*\.conf/ s/^#//' /etc/lighttpd/lighttpd.conf

Finally create the lighttpd docket vhost log dir

sudo mkdir -p /var/log/lighttpd/docket
@dcode
dcode / Dockerfile
Last active January 17, 2018 22:08
Unprivileged lighttpd container with systemd init on centos7
# Dockerfile for lighttpd
FROM centos/systemd
RUN yum install -y epel-release; \
yum update -y; \
yum install -y lighttpd; \
yum clean all; \
rm -rf /var/cache/yum/*; \
systemctl enable lighttpd;
@dcode
dcode / deploy-core-dns.yml
Created December 8, 2017 04:21
Example ansible playbook and group_vars info to deploy range DNS
---
# This playbook uses docker to deploy dnsmasq for each DNS zone required for the
- hosts: core-dns
become: yes
vars:
ansible_user: fedora
tasks:
- name: Download DNS image
docker_image:
name: andyshinn/dnsmasq
@dcode
dcode / clear_kafka.sh
Last active November 7, 2017 20:03
I can never remember how to clear out my kafka brokers. This gets 'er done.
# Enable deletion of topics
echo -n "delete.topic.enable=true" | sudo tee -a /opt/kafka/config/server.properties
# Generate list of topics
./bin/kafka-topics.sh --list --zookeeper 127.0.0.1:2181 | grep -v consumer | tee /tmp/topics
# Delete all topics
for topic in $(cat /tmp/topics); do ./bin/kafka-topics.sh --zookeeper 127.0.0.1:2181 --delete --topic=${topic}; done
# Disable topic deletion
@dcode
dcode / README.md
Last active June 24, 2021 09:27
NetworkManager dispatcher hook to start bro on a VPN interface

BroCtl hook for NetworkManager

I'm going through Offensive Security's "Pentesting With Kali" (PWK) course, and I added this hook to my Kali VM so that Bro would record everything going over the wire. I wanted to do this so I could analyze what my traffic would show up like using various tools.

Of course, you could use this on other systems using NetworkManager. And if you're pentesting, but not going over a VPN, just change the interface name in the script and the instructions. To add this to Kali for the OpenVPN connection, you need to do the following:

apt-get install bro broctl
sed -i 's/eth0/tap0/' /etc/bro/node.cfg
curl 'https://gist.githubusercontent.com/dcode/214fe616b1c98cd5665c99ad34a78893/raw/8d116140bb567c5990e378ab01973399719bb62a/nm-broctl.sh' | tee /etc/NetworkManager/dispatcher.d/broctl.sh
chmod +x /etc/NetworkManager/dispatcher.d/broctl.sh
@dcode
dcode / inverse_cidr.py
Created August 27, 2017 00:18
Generate an inverse list of cidr masks given an input list
#!/usr/bin/env python
IPV4_MIN = 0
IPV4_MAX = 0xFFFFFFFF
def not_network(ipv4_address, ipv4_netmask):
assert IPV4_MIN <= ipv4_address <= IPV4_MAX
assert IPV4_MIN <= ipv4_netmask <= IPV4_MAX
def hostmask_netmask(m):
@dcode
dcode / b64_aes.py
Created August 5, 2017 22:19
Some snippets from PicoCTF. I don't remember the specifics at this point, but maybe it will help ya.
ciphertext = 'V3Vqirostg6qW26sle5mnyrwEYSrteN6oHkilO50e9dFkN+0JhC3yu0LcQNw/hXU'
key = 'r7y1dhmTvjQrcra7A1UQFw=='
from Crypto.Cipher import AES
from base64 import b64decode
ct = b64decode(ciphertext)
k = b64decode(key)
d_suite = AES.new(k, AES.MODE_ECB)

ROCK Sensor Parts List

Below is the hardware I use for development and home use of my ROCK sensor. It’s an extremely powerful system in a small form factor, under $1000. The most important aspects to me were that I wanted IPMI for baremetal remote management, dual Intel NICs, quiet, and relatively low-power. I sit by this thing and work everyday and don’t want to wear hearing protection while I write code.

The prices reflect what I paid for them in March 2016. No doubt the prices will have changed and newer, better stuff is probably available. Things like RAM and SSDs go on sale all the time, so look for that if you’re a bargain shopper.