Skip to content

Instantly share code, notes, and snippets.

@dnet
dnet / ssh-yubisign.py
Created March 13, 2021 22:46
Quick and dirty OpenSSH agent to OpenPGPpy bridge
#!/usr/bin/env python3
import base64
import getpass
import os
import socket
import struct
import sys
import OpenPGPpy # requires https://github.com/dnet/OpenPGPpy/commit/d97a2184a1c1e40599ad1db30b06d33bb7178e59
@dnet
dnet / youtube.erl
Last active February 22, 2018 15:16
YouTube title plugin for Erlang IRCbot
% depends: https://github.com/talentdeficit/jsx
-module(youtube).
-export([ircmain/1, ircproc/1, reload/2]).
-define(API_KEY, "GetYourOwnApiKeyFromGoogle").
query_gdata_feed(VID) ->
URL = "https://www.googleapis.com/youtube/v3/videos?part=snippet&"
"fields=items/snippet(channelTitle,title)&key=" ?API_KEY "&id=" ++ VID,
@dnet
dnet / extract.py
Created August 31, 2016 09:23
Extracting main icon from 64-bit PE (Windows EXE) files in Python 2.x using 7z (p7zip)
#!/usr/bin/env python
import subprocess, tempfile, struct, shutil, os
HDR_FMT = '<hhh'
HDR_LEN = struct.calcsize(HDR_FMT)
def extract_64bit_ico(exefn, icofn):
d = tempfile.mkdtemp()
gis = os.path.join(d, '.rsrc', 'GROUP_ICON')
@dnet
dnet / Decode ARM64 CFString.py
Created February 1, 2016 21:30
ARM64 CFString decoder script for Hopper
import struct, re
doc = Document.getCurrentDocument()
sg = doc.getCurrentSegment()
addr = doc.getCurrentAddress()
i1 = sg.getInstructionAtAddress(addr)
if i1.getInstructionString() == 'adrp':
@dnet
dnet / gist:8568440
Created January 22, 2014 22:10
Test module created on an Erlang workshop for HSBXL https://hackerspace.be/Erlang-workshop
-module(test).
-export([foo/1, proc/0, price/1]).
-export([init_queue/0, queue_server/1, srv_enqueue/2, srv_dequeue/1]).
%% A function that returns a function, demonstrating that functions are
%% first-class citizens in the Erlang world.
%%
%% Example:
%% > SixMultiplier = test:foo(6).
%% #Fun<test.0.23908741>
@dnet
dnet / searx.erl
Created October 23, 2013 17:14
Searx module for dnet's fork of jimm-erlang-bot
-module(searx).
-export([ircmain/1, ircproc/1, reload/2]).
ircmain(Contact) ->
Pid = spawn(?MODULE, ircproc, [Contact]),
Contact ! {subscribe, Pid},
ssl:start(),
Pid.
reload(Contact, Pid) ->
@dnet
dnet / tickets.erl
Created September 22, 2013 14:11
Ticket number reporter for dnet's fork of jimm-erlang-bot
-module(tickets).
-export([ircmain/1, ircproc/1, reload/2]).
-define(TICKETS_DIR, "path/to/campzer0").
tickets() ->
NumTickets = filelib:fold_files(?TICKETS_DIR,
"\\.json$", false, fun (_, A) -> A + 1 end, 0),
integer_to_list(NumTickets).
@dnet
dnet / mails.sh
Created August 9, 2013 13:18
PGP keysigning e-mail address verification generator
#!/bin/sh
# reads e-mail addresses (one per row) from `mails.txt` and writes
# e-mail bodies into files inside the `mails` directory, putting the
# e-mail address in the filename, with a `.txt` extension -- these
# can be changed below
# author: András Veres-Szentkirályi <vsza@vsza.hu>
# source code is licensed under MIT, textual content under CC-BY-SA
@dnet
dnet / tweet.erl
Last active December 19, 2015 18:49
Twitter module for Erlang IRC bot
% depends: https://github.com/dnet/erlang-oauth
% depends: https://github.com/talentdeficit/jsx
-module(tweet).
-export([ircmain/1, ircproc/1, reload/2]).
-define(CONSUMER_KEY, "...").
-define(CONSUMER_SECRET, "...").
-define(ACCESS_TOKEN, "...").
-define(TOKEN_SECRET, "...").
@dnet
dnet / share.sh
Created February 12, 2013 18:08
Simple web file sharing script using SHA-256 hash as file name to avoid brute force attacks
#!/bin/sh
if [ $# -lt 1 ]; then
echo "Usage: $0 <filename>" >&2
exit 1
fi
HASH=$(sha256sum $1 | cut -c -64)
EXT=$(echo "$1" | sed 's/^.*\.//')
scp "$1" remote_host:directory_available_from_web/$HASH.$EXT