Skip to content

Instantly share code, notes, and snippets.

@bmaupin
bmaupin / gist:1b59abbf30406ed1eb82
Last active April 2, 2021 15:13
Parse installed packages from /var/log/apt/history.log
import re
history_snippet = '''Start-Date: 2014-08-25 12:52:37
Commandline: apt-get install -y openjdk-6-jdk openjdk-7-jdk icedtea-7-plugin
Install: openjdk-6-jre-lib:amd64 (6b32-1.13.4-4ubuntu0.14.04.1, automatic), icedtea-netx-common:amd64 (1.5-1ubuntu1, automatic), openjdk-6-jdk:amd64 (6b32-1.13.4-4ubuntu0.14.04.1), libxcb1-dev:amd64 (1.10-2ubuntu1, automatic), ttf-dejavu-extra:amd64 (2.34-1ubuntu1, automatic), icedtea-6-jre-cacao:amd64 (6b32-1.13.4-4ubuntu0.14.04.1, automatic), icedtea-7-plugin:amd64 (1.5-1ubuntu1), libxau-dev:amd64 (1.0.8-1, automatic), openjdk-6-jre-headless:amd64 (6b32-1.13.4-4ubuntu0.14.04.1, automatic), x11proto-core-dev:amd64 (7.0.24-1, automatic), libxt-dev:amd64 (1.1.4-1, automatic), openjdk-7-jdk:amd64 (7u65-2.5.1-4ubuntu1~0.14.04.1), libx11-dev:amd64 (1.6.2-1ubuntu2, automatic), x11proto-kb-dev:amd64 (1.0.6-2, automatic), openjdk-6-jre:amd64 (6b32-1.13.4-4ubuntu0.14.04.1, automatic), xtrans-dev:amd64 (1.3.2-1, automatic), libxdmcp-dev:amd64 (1.1.1-1, automatic), icedtea-netx:a
@bmaupin
bmaupin / build-libimobiledevice.sh
Last active August 29, 2015 14:13
Build libimobiledevice on Ubuntu 14.04 for iOS 8 compatibility
# Edit necessary permissions
sudo chmod 777 /var/lib/lockdown
# Install dependencies
sudo apt-get -y install build-essential git libplist-dev libssl-dev libusbmuxd-dev libxml2-dev pkg-config python-dev usbmuxd
# Build libplist dependency
git clone https://github.com/libimobiledevice/libplist.git
cd libplist
./autogen.sh
@bmaupin
bmaupin / build-remmina-stable.sh
Last active August 29, 2015 14:13
Build Remmina master/stable branch on Ubuntu 14.04
# The preferred way to install a newer version of Remmina is this PPA:
# sudo apt-add-repository -y ppa:remmina-ppa-team/remmina-next
# sudo apt-get update
# sudo apt-get install -y libfreerdp-plugins-standard remmina
# Kill any running instances of Remmina
killall remmina
# Remove old Remmina packages
sudo apt-get --purge remove freerdp-x11 \
@bmaupin
bmaupin / ms-filetime.go
Created January 20, 2015 17:38
Convert MS Filetime
package main
import "fmt"
import "time"
func main() {
var filetime int64 = 129472648056962786
fmt.Println(time.Unix(convertFiletimeToUnix(filetime), 0))
}
@bmaupin
bmaupin / build-footnote.sh
Last active August 29, 2015 14:15
Build footnote on Ubuntu 14.04 64-bit
#!/bin/bash
# Install libgranite-dev 0.2 and prerequisites
wget https://launchpad.net/~elementary-os/+archive/ubuntu/stable/+files/gir1.2-granite-1.0_0.2.3.1~r662-0%2Bpkg55~ubuntu12.04.1_amd64.deb
wget https://launchpad.net/~elementary-os/+archive/ubuntu/stable/+files/libgranite-common_0.2.3.1~r662-0%2Bpkg55~ubuntu12.04.1_all.deb
wget https://launchpad.net/~elementary-os/+archive/ubuntu/stable/+files/libgranite-dev_0.2.3.1~r662-0%2Bpkg55~ubuntu12.04.1_amd64.deb
wget https://launchpad.net/~elementary-os/+archive/ubuntu/stable/+files/libgranite1_0.2.3.1~r662-0%2Bpkg55~ubuntu12.04.1_amd64.deb
sudo dpkg -i gir1.2-granite-1.0_0.2.3.1~r662-0+pkg55~ubuntu12.04.1_amd64.deb libgranite-common_0.2.3.1~r662-0+pkg55~ubuntu12.04.1_all.deb libgranite-dev_0.2.3.1~r662-0+pkg55~ubuntu12.04.1_amd64.deb libgranite1_0.2.3.1~r662-0+pkg55~ubuntu12.04.1_amd64.deb
rm gir1.2-granite-1.0_0.2.3.1~r662-0+pkg55~ubuntu12.04.1_amd64.deb libgranite-common_0.2.3.1~r662-0+pkg55~ubuntu12.04.1_all.deb libgranite-dev_0.2.3.1~r662-0+pkg55~ubuntu1
@bmaupin
bmaupin / UnlimitedJCEPolicyJDK7-RHEL.sh
Last active April 24, 2017 20:39
Install UnlimitedJCEPolicyJDK7.zip on RHEL/CentOS
# See here for JDK 8: https://gist.github.com/bmaupin/87631863d55e2accc05ca7759247f887
# See here for test to make sure this works: https://gist.github.com/evaryont/6786915
if grep -q -i "release 6" /etc/*release; then
jce_primary_link_dir=/usr/lib/jvm/jre-1.7.0-oracle.x86_64/lib/security
elif grep -q -i "release 7" /etc/*release; then
jce_primary_link_dir=/usr/lib/jvm/jce-1.7.0-oracle
fi
wget \
@bmaupin
bmaupin / install-go.sh
Last active January 9, 2018 18:14
Install or upgrade Go on Ubuntu
# Get latest version from https://golang.org/dl/
go_version=1.9.2
sudo -v
# Clean up old versions
sudo apt-get remove golang-go
sudo rm -rf /usr/local/go
wget https://storage.googleapis.com/golang/go$go_version.linux-amd64.tar.gz
sudo tar -C /usr/local -xvf go$go_version.linux-amd64.tar.gz
@bmaupin
bmaupin / create-blank-ext4-image.sh
Created May 25, 2015 13:28
Create a blank ext4 disk image for testing (2.4 MB)
dd if=/dev/zero of=system_new.img bs=4k count=600
mkfs.ext4 -F system_new.img
@bmaupin
bmaupin / get-ext4-start-offset.py
Created May 25, 2015 16:53
Get the start offset of an ext4 partition in a raw image file
search_bytes = b'\x53\xef'
with open('system.raw.img.tmp', 'rb') as f:
i = 0
while True:
byte = f.read(1)
if not byte:
break
elif byte == search_bytes[i:i+1]:
i += 1
elif byte == search_bytes[0:1]:
@bmaupin
bmaupin / get-ext4-start-offset.sh
Last active August 29, 2015 14:21
Get the start offset of an ext4 partition in a raw image file
LANG=C grep -aobP -m1 '\x53\xEF' system.raw.img.tmp | head -1 | awk '{print $1 - 1080}'