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 / file-generic-metadata.md
Created February 25, 2020 14:13
Generic file logging data from various sources

Generic Structure for File Events

The purpose of this document is to provide examples of metadata that describe "file events". These events are events that describe analysis of file objects as is currently done in cyber security.

Proposed ECS Event (non-ECS data dropped)

{
    "file": {
        "name": "eicar.com",
        "size": 68,
@dcode
dcode / file-x509-metadata.md
Created February 25, 2020 14:10
Events and data sources that describe x509 information

Structure for x509 File Events

The purpose of this document is to provide examples of metadata that describe "file events" for x509 file objects. These file objects are commonly used in TLS handshakes, digital signatures, file encryption, and entity authentication for directory services.

Proposed ECS Event (non-ECS data dropped)

{
    "@timestamp": "blah",
    "file": {
filter {
cidr {
add_tag => [ "local_source" ]
address => [ "%{[source][ip]}" ]
network => [ "10.0.0.0/8", "172.16.0.0/20", "192.168.0.0/16" ]
}
cidr {
add_tag => [ "local_destination" ]
address => [ "%{[destination][ip]}" ]
network => [ "10.0.0.0/8", "172.16.0.0/20", "192.168.0.0/16" ]
@dcode
dcode / backup_and_load_containers.sh
Created August 12, 2019 19:57
Offline snapshot and import of container images using skopeo
containers=(
docker.io/library/consul:latest
docker.io/library/vault:latest
docker.io/library/redis:alpine
docker.io/library/nginx:alpine
docker.io/library/alpine:latest
)
urlencode() {
# urlencode <string>
---
# Mostly working, but weird cartesian products of groups
scenario:
name: single-node # optional
dependency:
name: galaxy
driver:
name: delegated
options:
managed: True
@dcode
dcode / README.md
Last active April 17, 2025 17:17
How to use CoreDNS w/ etcd backend

Setup CoreDNS w/ etcd backend

Why CoreDNS

[CoreDNS][coredns] was designed from the ground up to provide robust, plugin-based DNS server for use in cloud environments. Namely, it serves as the default primary service discovery mechanism for Kubernetes.

Using CoreDNS allows us to have a lightweight DNS server on RockNSM (11 Mb binary is all that's needed!) to facilitate multi-node service discovery. Alternatively, if another existing DNS service is available, this can be used instead. Aligning with the way the Kubernetes manages service discovery also allows us to build new RockNSM features in parallel with the coming Kubernetes support.

RockNSM Application

@dcode
dcode / _Podman Volume Quotas.md
Last active September 27, 2020 06:32
Discussion on how to create named volumes for Podman and set quotas on them using the native filesystem tools.

Podman has recently added support for named volumes, which is super handy. As of today (2018-01-17), it supports the local driver, which effectively will bind-mount a tracked directory into one or more containers. It's helpful to be able to limit the size of data volumes though so that one container doesn't exhaust the resources of another.

Fortunately, the XFS filesystem let's us handle this natively using "project quotas". XFS allows setting quotas based on username, group, or project. The project quota effectively maps a project ID to a path on a filesystem.

@dcode
dcode / import_dod_certs_mac.sh
Last active May 14, 2025 05:06
Install and trust DoD CA certificates on Mac OS X. Tested on Catalina and Mojave. *NOTE*: This should also enable CAC if you didn't override the system drivers.
#!/bin/bash
set -eu -o pipefail
export CERT_URL='https://dl.dod.cyber.mil/wp-content/uploads/pki-pke/zip/unclass-certificates_pkcs7_DoD.zip'
# Download & Extract DoD root certificates
cd ~/Downloads/ || exit 1
/usr/bin/curl -LOJ "${CERT_URL}"
@dcode
dcode / podman_pod_example.sh
Created November 19, 2018 20:55
I brute forced playing through the options of podman to try to work with pods on a standalone system using podman (i.e. without kubernetes)
# Creates new pod named `test` with `running` status with `infra` container only
sudo podman pod create --name test
# Pauses the named pod and all containers in the pod
sudo podman pod pause test
# Unpauses the named pod and all containers in the pod
sudo podman pod unpause test
# Show all pods and their status
@dcode
dcode / csv2elasticsearch.py
Last active November 21, 2019 13:55
A super simple (i.e. no error handling) script to parse a list of CSVs and write them to Elasticsearch using the bulk API. Requires Python 3 and the Elasticsearch Python client (pip3 install elasticsearch).
#!/usr/bin/env python3
import argparse
from pathlib import Path
import csv
from elasticsearch import Elasticsearch
from elasticsearch.exceptions import TransportError
from elasticsearch.helpers import bulk, streaming_bulk
parser = argparse.ArgumentParser(description='Simple upload of a CSV to Elasticsearch for analysis')
#group = parser.add_mutually_exclusive_group()