Skip to content

Instantly share code, notes, and snippets.

View alastairmccormack's full-sized avatar

Alastair McCormack alastairmccormack

View GitHub Profile
@alastairmccormack
alastairmccormack / iframe-probe.py
Last active April 17, 2024 01:35
Shows GOP structure for video file using ffmpeg --show-frames output
#!/usr/bin/env python
#
# Shows GOP structure of video file. Useful for checking suitability for HLS and DASH packaging.
# Example:
#
# $ iframe-probe.py myvideo.mp4
# GOP: IPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP 60 CLOSED
# GOP: IPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP 60 CLOSED
# GOP: IPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP 60 CLOSED
# GOP: IPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP 60 CLOSED
@alastairmccormack
alastairmccormack / x509_sha1_fingerprint.py
Created November 13, 2015 03:40
Gets a SHA1 fingerprint from an x509 certificate using Python and OpenSSL crypto module
from OpenSSL.crypto import load_certificate, FILETYPE_PEM
cert_file_string = open("esx.crt", "rb").read()
cert = load_certificate(FILETYPE_PEM, cert_file_string)
sha1_fingerprint = cert.digest("sha1")
print sha1_fingerprint
@alastairmccormack
alastairmccormack / terraform.tf
Created April 23, 2019 17:41
One-liner Terraform external command to get current branch (No need to create additional script)
# Branch name accessible via: ${data.external.git-branch.result.branch}
data "external" "git-branch" {
program = ["/bin/bash", "-c", "jq -n --arg branch `git rev-parse --abbrev-ref HEAD` '{\"branch\":$branch}'"]
}
@alastairmccormack
alastairmccormack / widevinecdm.proto
Last active February 22, 2021 11:31
An incomplete reverse-engineer of the Widevine EME CDM request protobuf object.
// Used by https://github.com/use-sparingly/pywvpssh to automatically
// strip PSSH from MP4 files
package WidevineCDM;
message WvEmeRequest {
required int32 version = 1; // 1
//start rlen end
message Level1 { //0x02 1467 0x5BD

Keybase proof

I hereby claim:

  • I am alastairmccormack on github.
  • I am amccormack (https://keybase.io/amccormack) on keybase.
  • I have a public key ASC5Len8bl7k_nzDIkwtrI-DzOWPrQqLNu2xXCmbKM_czwo

To claim this, I am signing this object:

@alastairmccormack
alastairmccormack / SCTE35 Decoder
Last active December 27, 2019 23:39
SCTE-35 Parser/Decoder in Python
#!/usr/bin/python
'''
SCTE-35 Decoder
The MIT License (MIT)
Copyright (c) 2014 Al McCormack
@alastairmccormack
alastairmccormack / 123-reg to AWS Route53
Created January 21, 2016 14:39
Migrate 123-reg DNS entries to AWS Route53
import boto.route53
import boto.regioninfo
import requests
import logging
DOMAIN = ""
USERNAME_123REG = ""
PASSWORD_123REG = ""
AWS_ACCESS = ""
@alastairmccormack
alastairmccormack / bitbucket_backup.py
Created July 18, 2019 15:33
Bitbucket Backup - Clones all repos for given username or team
# Requires Python 3.6 (for fstrings)
import requests
from git import Repo
import jmespath
import os.path
# Create an app password. Username can be found using: https://stackoverflow.com/a/44932928/1554386
username = ""
password = ""
@alastairmccormack
alastairmccormack / standard_password_encoder.py
Created July 3, 2019 20:06
A Python implementation of Spring Security StandardPasswordEncoder
import hashlib
import binascii
password_salthash_hex = '916b8cb7de146eab16c83ac3e7cdd33751a4cb19dced8da5aab38d94ebebcff968ca5099cfccf28d'
password_salthash = binascii.a2b_hex(password_salthash_hex)
password_hash = password_salthash[8:]
password_salt = password_salthash[:8]
password = b'11111'
@alastairmccormack
alastairmccormack / rsa_verify_output.py
Last active January 16, 2018 11:55
Pycrypto: Raw RSA verify output
# When using raw RSA key calculations, it sometimes necessary to see the
# verification detail created as a result of a .sign() process (or encryption
# using the private key, which Java let's you do!)
# Pycrypto .verify() method only allows you to check a known value, where as
# openssl let's you see the verification response. I.e
# > openssl rsautl -inkey pub_key.pem -raw -verify -pubin -in mysig.txt
# The following code was found by digging into the Pycrypto innards: