Skip to content

Instantly share code, notes, and snippets.

@sussurro
sussurro / cloudshell_backup.sh
Created January 31, 2021 04:30
Backup Cloudshell to s3 bucket
#!/bin/bash
ACCID=`aws sts get-caller-identity --query Account --output text`
BUCKET="ghh-cloudbu-$ACCID"
SECS=`date +%s`
echo "Checking to see if a bucket exists.. if not then making one"
aws s3 ls s3://$BUCKET || aws s3 mb s3://$BUCKET
echo "Creating a tarball of your home"
cd ~/
find . | tar -zcvf /tmp/shell_backup_$SECS.tgz -T - --ignore-failed-read --exclude .cache
@sussurro
sussurro / InstallGuacEC2.sh
Created January 3, 2020 07:40
InstallGuacEC2
#!/bin/bash
# Check if user is root or sudo
if ! [ $(id -u) = 0 ]; then echo "Please run this script as sudo or root"; exit 1 ; fi
# Version number of Guacamole to install
GUACVERSION="1.0.0"
# Colors to use for output
YELLOW='\033[1;33m'
wget -nv https://packages.microsoft.com/config/ubuntu/16.04/packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
sudo apt-get install apt-transport-https
sudo apt install snapd
sudo service snapd start
sudo snap install dotnet-sdk --classic
sudo apt-get install mono-complete
@sussurro
sussurro / gist:399e254da1f5e77980d06e9b07d04285
Created December 1, 2018 18:47
Building a self signed code signing cert
[Windows]
New-SelfSignedCertificate -CertStoreLocation cert:\currentuser\my -Subject "CN=Code Signing" -KeyAlgorithm RSA -KeyLength 2048 -Provider "Microsoft Enhanced RSA and AES Cryptographic Provider" -KeyExportPolicy Exportable -KeyUsage DigitalSignature -Type CodeSigningCert
dir cert:\currentuser\my
$cert = (Get-ChildItem -Path Cert:\CurrentUser\my\<hash>)
Export-Certificate -Cert $cert -Filepath user.p7b -Type p7b
certutil.exe encode .\user.p7b user.txt
<paste to linux box>
base64 -d < b64data > user.p7b
openssl pkcs7 -in user.p7b -inform der -print_certs -outform pem -out user.pem
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
Add-Type -AssemblyName System.IO.Compression.FileSystem
$GhostPack = @{Seatbelt = "https://github.com/GhostPack/Seatbelt/archive/master.zip";
SharpRoast = "https://github.com/GhostPack/SharpRoast/archive/master.zip";
SharpUp = "https://github.com/GhostPack/SharpUp/archive/master.zip";
SharpDPAPI = "https://github.com/GhostPack/SharpDPAPI/archive/master.zip";
SharpDump = "https://github.com/GhostPack/SharpDump/archive/master.zip";
SafetyKatz = "https://github.com/GhostPack/SafetyKatz/archive/master.zip";
require 'pp'
for i in 0..255 do
str += [i].pack('C')
end
pp str
require 'pp'
data = File.open(ARGV[0]).read.force_encoding("ASCII-8BIT")
tree,rest = data.split("\x00",2)
while rest && rest.length > 0 do
head, data = rest.split("\x00",2)
hash = data[0,20]
rest = data[20..-1]
pre = hash.each_byte.map { |b| b.to_s(16).rjust(2,'0') }.join
dir = pre[0,2]
#!/usr/bin/ruby
require 'zlib'
f = File.open(ARGV[0])
d = f.read
print Zlib::Inflate.inflate(d)
@sussurro
sussurro / fromCharCode.rb
Created March 9, 2015 02:31
Generate fromCharCode from a URL
#!/usr/bin/ruby
if ARGV.length < 1
print "Usage: #{$0} <URI>\n\n"
exit
end
str = ARGV[0]
arr = []
str.split("").each do |c|
arr << c.ord.to_i