Skip to content

Instantly share code, notes, and snippets.

@craig-m
craig-m / readme.md
Last active October 28, 2021 02:45
Lazy automation with Invoke, Ansible and Ansible-runner

Lazy automation

A solution to automate regular, routine, somewhat boring tasks.

Disclaimer: I am not much of a Python programmer by any means, but I have used Ansible for a number of years and using Invoke, and now runner too, has made my ansible workflow better. These are some jumbled notes to share some ideas :)

Tools

The programs I am using:

@chrisdlangton
chrisdlangton / syscall2seccomp.py
Last active August 31, 2022 23:51
Automatically generate seccomp profile json by learning from container activity using sysdig
#!/usr/bin/env python3
import fileinput
import json
import argparse
SECCOMP_PROFILE = ('{"defaultAction": "SCMP_ACT_ERRNO",'
'"architectures": ['
'"SCMP_ARCH_X86_64",'
'"SCMP_ARCH_X86",'
@chrisdlangton
chrisdlangton / test_pfs.py
Last active December 2, 2019 22:56
Enforcing Perfect Forward Secrecy for AWS Query Request HTTP API
"""
Based on https://docs.aws.amazon.com/general/latest/gr/sigv4-signed-request-examples.html
"""
from requests.packages.urllib3.util.ssl_ import create_urllib3_context
from requests.adapters import HTTPAdapter
import hmac
import hashlib
import datetime
import base64
import os
@chrisdlangton
chrisdlangton / waybacksploit.sh
Last active July 8, 2022 21:18
The real dark web - find and exploit forgotten files on servers
#!/usr/bin/env bash
if [ -z $(which retire) ]; then
echo "retire not found. try npm install -g retire"
exit 1
fi
if [ -z $(which parallel) ]; then
echo "parallel not found. try 'apt install -y parallel'"
exit 1
fi
@chrisdlangton
chrisdlangton / awsrole.py
Last active May 7, 2020 23:17
AWS Assume Role interactive utility - stores temporary session tokens and manages local credentials profile
#!/usr/bin/env python3
import boto3
import argparse
import configparser
from os.path import expanduser
from botocore.exceptions import ClientError
def chose_profile()->str:
session = boto3.Session()
@chrisdlangton
chrisdlangton / rotate-credentials.sh
Last active May 17, 2020 04:16
Use the temporary AWS security credentials created by STS assume-role rotated hourly
#!/usr/bin/env sh
if [ -z "$(which aws)" ]; then
echo "aws command not callable"
exit 1
fi
if [ -z "$(which python)" ]; then
echo "python command not found"
exit 1
@rverton
rverton / cowroot.c
Created October 21, 2016 14:06
CVE-2016-5195 (DirtyCow) Local Root PoC
/*
* (un)comment correct payload first (x86 or x64)!
*
* $ gcc cowroot.c -o cowroot -pthread
* $ ./cowroot
* DirtyCow root privilege escalation
* Backing up /usr/bin/passwd.. to /tmp/bak
* Size of binary: 57048
* Racing, this may take a while..
* /usr/bin/passwd overwritten
@bmhatfield
bmhatfield / .profile
Last active January 29, 2025 11:11
Automatic Git commit signing with GPG on OSX
# In order for gpg to find gpg-agent, gpg-agent must be running, and there must be an env
# variable pointing GPG to the gpg-agent socket. This little script, which must be sourced
# in your shell's init script (ie, .bash_profile, .zshrc, whatever), will either start
# gpg-agent or set up the GPG_AGENT_INFO variable if it's already running.
# Add the following to your shell init to set up gpg-agent automatically for every shell
if [ -f ~/.gnupg/.gpg-agent-info ] && [ -n "$(pgrep gpg-agent)" ]; then
source ~/.gnupg/.gpg-agent-info
export GPG_AGENT_INFO
else
@koelling
koelling / gist:ef9b2b9d0be6d6dbab63
Last active December 30, 2024 15:55
CVE-2015-0235 (GHOST) test code
#include <netdb.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#define CANARY "in_the_coal_mine"
struct {
char buffer[1024];
@chokepoint
chokepoint / dht_sniff.py
Created September 5, 2014 15:13
Distributed Hash Table Sniffer (BitTorrent)
#!/usr/bin/env python
"""
Sniff a specific port for Bit Torrent DHT traffic and print
requests/responses in human readable form.
Reference: http://www.bittorrent.org/beps/bep_0005.html
"""
from pcapy import open_live
from bencode import bdecode