Skip to content

Instantly share code, notes, and snippets.

@MorbosVermin
MorbosVermin / VaultConfigurationManager.cs
Created May 24, 2018 21:42
.Net C# Class for getting configuration information from Vault (vaultproject.io)
using log4net;
using System;
using System.Collections.Generic;
using System.Security;
using VaultSharp;
using VaultSharp.Backends.Authentication.Models;
using VaultSharp.Backends.Authentication.Models.Token;
using VaultSharp.Backends.Authentication.Models.UsernamePassword;
namespace MyApp
@MorbosVermin
MorbosVermin / TestClass.java
Created February 16, 2018 15:20
Validation using an Enum type.
import java.text.ParseException;
public class TestClass {
static class Parameter {
private String name;
private Object value;
public Parameter(String name, Object value) {
@MorbosVermin
MorbosVermin / StringSec.cs
Last active December 6, 2017 15:19
General Utils
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Security;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
namespace Com.WaitWha.Utils
#!/bin/bash
# grab the public keys on a PIV/CAC and generate ssh-rsa which can be appended to the .ssh/authorized_keys(2) file for pubkeyauth.
# your PKCS#11 driver may vary (we also used cackey).
#LIB=/usr/lib/libcackey.so
LIB=/usr/lib/pkcs11/libcoolkeypkcs11.so
ssh-keygen -D ${LIB}
import os, sys, base64
from M2Crypto import X509
'''
Load the certificate from a file.
'''
cert = X509.load_cert(filename, X509.FORMAT_DER)
'''
Lets first save the certiticate as PEM.
#!/bin/bash
rootpwd=$(cat /dev/urandom|tr -dc "a-zA-Z0-9-_\$\?"|fold -w 30|head -n 1)
passwd "root" <<EOF
$rootpwd
$rootpwd
EOF
logger -t root_scramble "Scrambled the eggs doOd!"
exit $?
/**
* Converts the given RSAPublicKey obejct to RSA-SSH format byte array. This
* byte[] returned DOES NOT include the prefixed <i>ssh-rsa</i> nor any appended
* text (i.e. the username or email address) for a comment.
*
* @param pubkey java.security.interfaces.RSAPublicKey to convert.
* @return byte[]
* @throws IOException
*/
public static final byte[] publicKeyToRsaSsh(RSAPublicKey pubkey)
#!/bin/bash
NAME=$1
[[ -z "${NAME}" ]] && echo "Syntax: $0 <package>" && exit 1;
sudo ls > /dev/null
echo -n ">> Setting up environment; please wait..."
sudo mount -t proc /proc ${NAME}/proc
sudo mount --bind /dev ${NAME}/dev
sudo mount --bind /sys ${NAME}/sys
#!/bin/bash
[[ -e $HOME/colors.conf ]] && . $HOME/colors.conf
CWD=`pwd`
NAME=$1
#DIALOG="${DIALOG=dialog} --clear"
tempfile=/tmp/sel-$$
[[ -z "${NAME}" ]] && echo "Syntax: $0 <name> [<path to stage3 tarball>] [<path to portage tarball>]" && exit 1;
sudo ls > /dev/null
#!/bin/bash
#
# Provides useful information for a GIT repo. Place somewhere in your PATH
# and you should be able to simply execute 'git info' or 'git-info' to
# execute.
#
# Check for git binary.
git=`which git`
[ -z "${git}" ] && echo "Error: git is required to be installed." && exit 1;