Skip to content

Instantly share code, notes, and snippets.

View Riebart's full-sized avatar

Mike Riebart

View GitHub Profile
@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 / 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
#
# 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 / 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
@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 / 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 / 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 / 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 / test_ask.cpp
Created September 4, 2022 16:46
A simple test of ASK between two threads using a volatile incrementing global between them
#include <stdio.h>
#include <thread>
#include <random>
#include <stdint.h>
#include <utime.h>
#include <unistd.h>
#include <atomic>
float READ_NOISE_RATIO = 0.0;
int32_t swap_write_count = 0;