Skip to content

Instantly share code, notes, and snippets.

@dcode
dcode / GitHub Flavored Asciidoc (GFA).adoc
Last active April 20, 2024 13:55
Demo of some useful tips for using Asciidoc on GitHub

GitHub Flavored Asciidoc (GFA)

@dcode
dcode / group_cpuinfo_by_socket-core-ids.sh
Last active September 27, 2016 21:07
Get top-level physical processor numbers grouped by socket and core id's
egrep -e "processor" -e "core id" -e ^physical /proc/cpuinfo | \
xargs -l3 echo | \
awk -vOFS='\t' '{ print "{\"socket\": "$7", \"core\": " $11 ", \"proc\":" $3 "}" }' | \
jq -sc '
[.[] | {sock_core:"\(.socket)-\(.core)", proc, core, socket } ]
| group_by(.sock_core) | .[] | .[0] ' | \
sort -V
@dcode
dcode / stenographer.service
Last active June 30, 2023 03:00
This is a hack that I put together to pull PCAP from multiple instances of stenographer, each with a different configuration file. It adds `mergecap` as a dependency, which is used to produce the final PCAP, which is then filtered through `tcpdump` as before.
# Copyright 2014 Google Inc. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,

README

This is a CentOS-themed /etc/issue w/ hooks to update IP address and OS release upon ifup/ifdown. My motivation was that I was tired of logging into an otherwise headless box just to find the IP of the system so I can SSH to it.

Note
The issue.in file actually contains control characters to do the color in the text. The easiest way to preserve that is to clone this gist and run the install.sh script w/ sudo, which will copy the file and set the SELinux
@dcode
dcode / elasticsearch@.service
Last active September 7, 2016 16:27
Example template service file for multiple instances. Set `node.name` in `elasticsearch.yml` to ${NODENAME}.
[Unit]
Description=Elasticsearch
Documentation=http://www.elastic.co
Wants=network-online.target
After=network-online.target
[Service]
Environment=ES_HOME=/usr/share/elasticsearch
Environment=CONF_DIR=/etc/elasticsearch
Environment=DATA_DIR=/var/lib/elasticsearch
@dcode
dcode / json2csv.jq
Created August 30, 2016 16:58
Useful for mapping JSON to CSV when each of the records have the same structure. You can put this into a script and `chmod +x` it.
#!/usr/local/bin/jq -s -r -f
( map(keys) | add | unique ) as $cols |
map(. as $row | $cols | map($row[.])) as $rows |
$cols, $rows[] | @csv
@et0x
et0x / Get-DownloadedPEHashes.ps1
Created August 8, 2016 17:32
Get the hashes of all exe / dll files downloaded from the internet. Checks for the Zone.Identifier ADS and ensures the value is 3.
function Get-DownloadedPEHashes
{
[CmdletBinding()]
Param(
[Parameter(Mandatory=$true, Position=0)]
[String]$Path,
[Switch]$Recursive = $true
)
if (!$Path.EndsWith('\'))
@dcode
dcode / http_gauss_browse.py
Last active June 1, 2016 14:07
Takes in a list of CSV ordered by (rank,domain) (from Alexa, for instance) and browses the highest ranking more often.
#!/usr/bin/env python2
from multiprocessing import Pool
from time import sleep
from random import randint, gauss
import os, sys
import requests
## TODO
# . recursively download linked resources:
# . images
@rhwood
rhwood / rpi3-wireless-drivers.sh
Last active August 2, 2017 12:39
CentOS 7 Raspberry Pi 3 Wireless Drivers
#!/bin/bash
curl --location https://github.com/raspberrypi/firmware/raw/master/boot/bcm2710-rpi-3-b.dtb > /boot/bcm2710-rpi-3-b.dtb
curl --location https://github.com/RPi-Distro/firmware-nonfree/raw/54bab3d6a6d43239c71d26464e6e10e5067ffea7/brcm80211/brcm/brcmfmac43430-sdio.bin > /usr/lib/firmware/brcm/brcmfmac43430-sdio.bin
curl --location https://github.com/RPi-Distro/firmware-nonfree/raw/54bab3d6a6d43239c71d26464e6e10e5067ffea7/brcm80211/brcm/brcmfmac43430-sdio.txt > /usr/lib/firmware/brcm/brcmfmac43430-sdio.txt
echo "Reboot to ensure the dtb is initialized and kernel knows about the hardware in place."
echo
@dcode
dcode / snort_unified2_output.sh
Created January 19, 2016 21:10
Configure Snort w/ the RPM for unified2 output
sudo sed -i'' 's/^# output unified2/output unified2/' /etc/snort/snort.conf
sudo sed -i'' 's/ALERTMODE/#ALERTMODE/' /etc/sysconfig/snort