Skip to content

Instantly share code, notes, and snippets.

View RickyCook's full-sized avatar
🏳️‍🌈

Ricky Cook RickyCook

🏳️‍🌈
View GitHub Profile
def i_to_w(indexes, wordlist):
"""
Examples:
>>> wl = ['a', 'b', 'c', 'd', 'e', 'f', 'g']
>>> i_to_w([0, 0, 0], wl)
['a', 'b', 'c']
>>> i_to_w([1, 1, 1], wl)
['b', 'c', 'd']
@RickyCook
RickyCook / id_rsa.pub
Created March 7, 2016 01:27
temp ssh pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC8KMhmqWn0Aeq0OVos1ka7b5zM44kDCxh7AJIMtBQQ8gQ1RNgGca/dGamkj55ogBWuKfDe03Qn/jGpW1wF4nm8khzEkPc5ygoz9B7iYod1VheUwGiO+RYu8VeZlO/BMrvYkmIAl15z4olVS6YsHOftDs+sJhI0QD/0xizw9jAihkXt5mu7y8LAMYwzpABAu8ccCcQhk67znDP2iZ++z83h1JMmSW8PcoZicvANKaYNs+t55/YA6ChhHJBZMH6tlhUpVo3thP++P/5PuWxNc9m5po1UBRAdKjuT/9mx4olQysPJgtbwY50NmtTnZeG3/diSYsAjhv4vjum+WDO2j9Yh [email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

What.....?

TL;DR tunnels a socket from multiple hosts to a single host, creating sockets on the remote end automatically and encrypting all traffic over the network.

Creates a server that listens on 4433. All traffic is encrypted with OpenSSL using both client and server keys. When a client connects, a new random UNIX socket is created on the host and waits for connection. When an application connects to the socket on the server, it can talk to the socket on the client as if it were a local socket.

In this case, we're using a Docker socket, but this is easy to change.

On the server

$ ./server.sh server
@RickyCook
RickyCook / Command.md
Last active November 7, 2023 06:55
Using socat to forward new ports via STDIO in a running Docker container

What?... Why?

Imagine you're messing around in a container, and you install some stuff, add some config, and now it's time to load up your client and check it out! Oh wait, you forgot to forward ports when you created the container! Fear not, all is not lost, for in the world of pipes, and streams, there is always a way to do something disgusting.

The Dockerfile

Example Dockerfile included will install Nginx, and socat in a container, and make Nginx run in foreground mode. To build, and run:

@RickyCook
RickyCook / cloud-config
Last active August 29, 2015 14:21
cloud-config
#cloud-config
coreos:
units:
- name: 00-eth0.network
runtime: true
content: |
[Match]
Name=eth0
[Network]
@RickyCook
RickyCook / README.md
Last active August 29, 2015 14:19
LastPass to 1password cleanup

LastPass adds category fields for everything; even things without categories! It will add a "grouping: (none)" for these passwords. This script takes a data.1pif export file (File -> Export -> All Items in 1password) and strip out this useless extra data. When done, import the data-out.1pif, and the fields will be removed. Data is updated in-place in 1password, so there will be no duplicates or anything nasty like that (thanks 1password!)

@RickyCook
RickyCook / bookmarklet.js
Last active August 29, 2015 14:16
Fill AWS tags based on a JSON hash, obtained from user prompt
(function($, c) {
var rootObject = $('table:visible:contains("Create Tag")').first(),
createButton = $('button:contains("Create Tag")', rootObject).first(),
inputsKey = $('input[name="key"]', rootObject),
inputsValue = $('input[name="value"]', rootObject),
tags = $.parseJSON(prompt('JSON tag values')),
tagsKeys = Object.keys(tags);
if (tagsKeys.length > inputsKey.length) {
for (var i = 0; i < tagsKeys.length - inputsKey.length; i++) {
@RickyCook
RickyCook / git_sync.sh
Last active August 29, 2015 14:13
Rsync a git repo to its remote. For when you want to sync, but not commit
#!/bin/bash
remote_name="$1"
: ${remote_name:="origin"}
git_root="$(cd "$(git rev-parse --show-toplevel)"; pwd)/"
rsync_dest=$(git remote -v | grep "^$remote_name\s.*\(push\)" | awk '{print $2}')
echo "Remote name: $remote_name"
echo "Repo root: $git_root"
echo "Repo dest: $rsync_dest"
@RickyCook
RickyCook / file_match.py
Last active August 29, 2015 14:08
Pytho one line file match in directory
# Find files in the current directory that do not contain a '.'
(item for sublist in ((os.path.join(r,f) for f in fs if '.' not in f) for r, _, fs in os.walk('.')) for item in sublist if os.path.isfile(item))
# Add '.log' to the end of any file that has no extension. Probably easier with `rename` command :|
[shutil.move(src, '%s.log' % src) for src in (item for sublist in ((os.path.join(r,f) for f in fs if '.' not in f) for r, _, fs in os.walk('.')) for item in sublist if os.path.isfile(item))]