Skip to content

Instantly share code, notes, and snippets.

View Riebart's full-sized avatar

Mike Riebart

View GitHub Profile
@Riebart
Riebart / contentdump.py
Created November 2, 2021 13:40
Brief mitmdump module for dumping content of responses to a file, and keeping track of what files are which URIs in a map JSON.
"""
Mitmdump extension script that can be used to dump content to disk in a way that can be processed after the fact by arbitrary tools.
"""
import time
import uuid
import json
import os.path
from mitmproxy import http
@Riebart
Riebart / script.ps1
Last active October 22, 2021 20:41
Generate code signing certificate and key using Powershell
# Generate a new certificate with key, marked exportable (the default), suitable for code signing.
# The certificate is stored in the personal certificate store.
New-SelfSignedCertificate -Subject "CN={YOUR NAME}" -KeySpec "Signature" -KeyUsage "DigitalSignature" -KeyUsageProperty "Sign" -Friendlyname "Code Signing" -NotAfter $([datetime]::now.AddYears(5)) -Type "CodeSigningCert" -CertStoreLocation cert:\currentuser\my -KeyAlgorithm RSA -Keylength 4096 -HashAlgorithm "SHA256" -Provider "Microsoft Enhanced RSA and AES Cryptographic Provider"
# To Sign a Powershell script with a certificate
# - Find the key, which you can usually do with the thumbprint and knowing where it was stored
# - This may or may not work for you, depending on whether or not you have access to a functioning timestamp server
# - Regardless of the timestamp, the signature will still work, just won't say when it was signed.
$cert = (ls cert:currentuser\my\0BD717BC985949E736067A15CC7502A1EAE6D031)
@Riebart
Riebart / ffmpeg_multitrack_audio.sh
Created October 19, 2021 17:41
ffmpeg Record multichannel audio from multiple sources to a single file
#!/bin/bash
# get device names from: ffmpeg -list_devices true -f dshow -i dummy
ffmpeg \
-f dshow -ac 1 -i audio="Audio Input Device A" \
-f dshow -ac 1 -i audio="Audio Input Device B" \
-ac 2 -filter_complex "[0:a][1:a]amerge[outA]" -map "[outA]:a" multitrack_out.wav
@Riebart
Riebart / test_ciphers.sh
Created October 2, 2021 00:42
Remote SSL Cipher Test
#!/usr/bin/env bash
# OpenSSL requires the port number.
SERVER=$1
DELAY=1
ciphers=$(openssl ciphers 'ALL:eNULL' | sed -e 's/:/ /g')
echo Obtaining cipher list from $(openssl version).
for cipher in ${ciphers[@]}
@Riebart
Riebart / gs_pdf_squash.sh
Created June 7, 2021 20:48
Squashing a PDF with ghostscript
#!/bin/bash
ghostscript -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/printer -dNOPAUSE -dQUIET -dBATCH -sOutputFile=output.pdf PDFsam_merge.pdf
#
# These variables are device properties. For people who are very
# curious about this, you can download the Windows Driver Kit headers and
# look for pciprop.h. All of these are contained in that file.
#
$devpkey_PciDevice_DeviceType = "{3AB22E31-8264-4b4e-9AF5-A8D2D8E33E62} 1"
$devpkey_PciDevice_RequiresReservedMemoryRegion = "{3AB22E31-8264-4b4e-9AF5-A8D2D8E33E62} 34"
$devpkey_PciDevice_AcsCompatibleUpHierarchy = "{3AB22E31-8264-4b4e-9AF5-A8D2D8E33E62} 31"
$devprop_PciDevice_DeviceType_PciConventional = 0
@Riebart
Riebart / read_process_mem.py
Created January 29, 2021 22:51
Adapted from Stackoverflow, a Python script to dump the memory of a process.
#!/usr/bin/env python
# Source: https://stackoverflow.com/questions/12977179/reading-living-process-memory-without-interrupting-it
#
# Adapted to be python3
import os
import re
import sys
@Riebart
Riebart / reconnect_console.ps1
Created January 5, 2021 18:18
Disconnect the first active session on Windows and reconnect the console session. Useful for disconnecting RDP to use Steam Streaming.
$session=(query session | select-string Active)[0].ToString().split(" ")[0].substring(1)
Start-Process -verb runas tscon -ArgumentList "$session /dest:console"
@Riebart
Riebart / remarkable_find_update_device_id.py
Last active December 15, 2020 15:55 — forked from leezu/remarkable_find_update_device_id.py
Python script to rotate the machine IDs and OEM identifiers to find one that is eligible for a software update.
#!/usr/bin/env python3
import time
import uuid
import random
import re
import sys
import requests
@Riebart
Riebart / syslog_levels.md
Created December 4, 2020 16:24
Documentation on the syslog levels and facilities, and how to use them when building application logging

Syslog logging levels and parameters

All logs

All logs should contain the following information, preferably encoded in JSON so that it is easily machine-parsable as well as human readable. Graylog can parse JSON, so encoding your fields in that way makes it easy to alert and filter on messaged components.

  • Message: The message should be a plaintext description of the event, optionally including an application-unique code.
  • Impact: This field should describe the impact, if any (there is no impact for debug and informational events), on the state, output, and resiliency of the application. It should be short (one sentence), but contain enough information for someone not familiar with the application to triage the event.
  • Correction: This field should describe any corrective action, if any (there is no corrective action required for debug, informational, and notice level events), that could, or should, be taken to resolve the impacts caused by the event. This should be short (at most two sentences) an