Skip to content

Instantly share code, notes, and snippets.

View kkirsche's full-sized avatar

Kevin Kirsche kkirsche

View GitHub Profile
@kkirsche
kkirsche / aes256-gcm.go
Last active November 12, 2024 02:47
AES-256 GCM Encryption Example in Golang
package example_test
import (
"crypto/aes"
"crypto/cipher"
"hex"
"io"
)
// AES-GCM should be used because the operation is an authenticated encryption
@kkirsche
kkirsche / add_auth_key.sh
Last active November 12, 2021 21:07
Add Local SSH Keys to Remote Machine
cat ~/.ssh/id_rsa.pub | ssh <username>@<ip_address> "mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys && chmod 700 ~/.ssh && chmod 600 ~/.ssh/authorized_keys"
@kkirsche
kkirsche / Brewfile
Last active April 1, 2016 00:36
Mac Brewfile
# Brewfile
# Relies on: brew tap Homebrew/bundle
# https://github.com/Homebrew/homebrew-bundle
cask_args appdir: '/Applications'
# Taps
tap "caskroom/cask"
# Brews
brew "ansible"
brew "ansible-cmdb"
brew "cask"
@kkirsche
kkirsche / Solarized iTerm3 Profile
Created February 22, 2016 18:22
iTerm3 Profile
{
"Badge Text" : "",
"Working Directory" : "\/Users\/<username>",
"Prompt Before Closing 2" : 0,
"Selected Text Color" : {
"Green Component" : 0.8900123,
"Blue Component" : 0.7978109,
"Red Component" : 0.9161106
},
"Rows" : 25,
@kkirsche
kkirsche / inetAton-inet6Aton.go
Last active October 25, 2022 15:18
inet_aton and inet6_aton in Golang
package nessusProcessor
import (
"encoding/hex"
"math/big"
"net"
)
// Inet_Aton converts an IPv4 net.IP object to a 64 bit integer.
func Inet_Aton(ip net.IP) int64 {
@kkirsche
kkirsche / tracer.go
Created May 26, 2016 17:40
Golang URL Tracer
package main
import (
"log"
"net/http"
"time"
)
// TransportWrapper wraps the http.Transport structure to allow us to record the
// URLs which we are redirected through
@kkirsche
kkirsche / fileserver.py
Created July 18, 2016 15:49 — forked from vgel/fileserver.py
A very basic HTTP file server in 13 lines of python. Assumes all requests are GETs, and it vulnerable to directory traversal (Run it in ~ and localhost:8080/../../ will ls root), so don't use it online. Will correctly list files in directories.
import sys, os, socket
s = socket.socket()
s.bind((sys.argv[1], int(sys.argv[2])))
s.listen(5)
try:
while True:
conn, addr = s.accept()
path = os.path.join(os.getcwd(), "./"+conn.recv(4096).split("\n")[0].split(" ")[1])
conn.send((open(path).read() if os.path.isfile(path) else reduce(lambda x,s:x+"\n"+s+("/" if os.path.isdir(s) else ""),sorted(os.listdir(path)),"Directory "+path+" ls")) if os.path.exists(path) else '404: '+path)
conn.close()
@kkirsche
kkirsche / int_to_rgba.go
Created July 21, 2016 01:07
Integer to RGBA in Golang — Similar to C/C++
package main
import "fmt"
func main() {
red := int(0xFF0000FF)
green := int(0x00FF00FF)
blue := int(0x0000FFFF)
redHex, greenHex, blueHex, alphaHex := calcColor(red)
@kkirsche
kkirsche / ssl_puma.sh
Created July 22, 2016 12:46 — forked from tadast/ssl_puma.sh
localhost SSL with puma
# 1) Create your private key (any password will do, we remove it below)
$ cd ~/.ssh
$ openssl genrsa -des3 -out server.orig.key 2048
# 2) Remove the password
$ openssl rsa -in server.orig.key -out server.key
@kkirsche
kkirsche / ftp.py
Created August 7, 2016 12:00
Python Port Checker — Detect a port opening
import socket;
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
openPort = False
while openPort == False:
result = sock.connect_ex(('10.10.10.136', 20))
if result == 0:
openPort = True