Skip to content

Instantly share code, notes, and snippets.

@drewbug
drewbug / gist:4a2fa42790b79e4f3d35
Last active August 29, 2015 14:06
Android SDK Identification
wget http://dl-ssl.google.com/android/repository/android-19_r01.zip
unzip -p android-19_r01.zip android-*/build.prop | grep "ro.build.id" | tail -c+13
# => KRT16L
git clone https://github.com/android/platform_build; cd platform_build
git log --oneline --all --no-abbrev --grep=KRT16L | head -c40 | xargs git describe
# => android-4.4_r0.9
@drewbug
drewbug / secp256k1
Last active August 29, 2015 14:07
ecc notes
require 'openssl'
ec = OpenSSL::PKey::EC.new('secp256k1')
# ec.generate_key
ec.private_key = "85BDCD4EF6319F9996D5499BD011E6094224CD1B9C87599E854F4E4EA408EFA6".to_i(16)
ec.public_key = ec.group.generator.mul(ec.private_key)
@drewbug
drewbug / secdebug
Last active August 29, 2015 14:07
security framework debugging
# trace debug-log macro
sudo dtrace -qn 'security_debug*:::log { printf("[%s] %s\n", copyinstr(arg0), copyinstr(arg1)); }'
# restart securityd
sudo launchctl unload /System/Library/LaunchDaemons/com.apple.securityd.plist &&
sudo launchctl load /System/Library/LaunchDaemons/com.apple.securityd.plist
@drewbug
drewbug / gist:4ed5dd02db4258e21f07
Created October 23, 2014 05:52
securityd notes
In /System/Library/LaunchDaemons/com.apple.securityd.plist, this apparently *won't* keep pcscd alive forever:
<array>
<string>/usr/sbin/securityd</string>
<string>-i</string>
<string>-s</string>
<string>on</string>
</array>
This is despite a comment in pcscmonitor.h that says it should "keep pcscd running at all times"
Oh well.
@drewbug
drewbug / physics-dl.rb
Created November 20, 2014 08:45
youtube-dl hang workaround
require 'timeout'
loop do
pid = fork
if pid.nil?
exec("youtube-dl https://www.youtube.com/playlist?list=PL47F408D36D4CF129")
else
begin
Timeout::timeout(15 * 60) {
@drewbug
drewbug / syslog-ifdreader.sh
Created January 27, 2015 20:24
pcsc ifd-handler logging in yosemite
sudo syslog -w -k Sender com.apple.ifdreader
@drewbug
drewbug / prime256v1.rb
Created January 31, 2015 02:22
ruby prime256v1.rb < secp256k1_private_key.pem > prime256v1_private_key.pem
# ruby prime256v1.rb < secp256k1_private_key.pem > prime256v1_private_key.pem
require 'openssl'
ec = OpenSSL::PKey::EC.new('prime256v1')
ec.private_key = OpenSSL::PKey::EC.new(ARGF.read).private_key
ec.public_key = ec.group.generator.mul(ec.private_key)
print ec.to_pem
#!/usr/bin/env ruby
# create temporary auth key first via gui, then export your whole keyring and modify it
require 'digest'
unpatched = File.read 'temp_auth.key'
unpatched_bytes = unpatched.bytes
wget https://www.gnupg.org/ftp/gcrypt/gnupg/gnupg-2.1.11.tar.bz2
tar xf gnupg-2.1.11.tar.bz2
pushd gnupg-2.1.11

git clone git://git.gnupg.org/libgcrypt.git
pushd libgcrypt

./autogen.sh
./configure --prefix=$PWD --disable-doc

make

#!/usr/bin/env ruby
require 'openssl'
require 'tempfile'
OpenSSL::PKey::EC.send :alias_method, :private?, :private_key?
key = OpenSSL::PKey::EC.new('secp256k1')
key.generate_key