Skip to content

Instantly share code, notes, and snippets.

View blasterpal's full-sized avatar

Hank Beaver blasterpal

View GitHub Profile
@blasterpal
blasterpal / gh_audit_parsing_report.rb
Created April 24, 2018 17:10
Ruby script to parse GH audit download
require 'json'
require 'pry'
require 'active_support'
require 'date'
require 'csv'
class GHAudit
def initialize
@file = File.open('./gh_audit.json','r')
@blasterpal
blasterpal / shellshock_metasploit_example.sh
Last active February 17, 2018 19:36
shellshock metasploit example use
# setup metasploit from master on github: https://github.com/rapid7/metasploit-framework/wiki/Setting-Up-a-Metasploit-Development-Environment
# good help on console and metasploit: http://www.offensive-security.com/metasploit-unleashed/Msfconsole
#start msfconsole
use auxiliary/scanner/http/apache_mod_cgi_bash_env
set VHOST app.local
set TARGETURI "/all"
set RPORT 3000
@blasterpal
blasterpal / simple-init-script.sh
Created November 24, 2012 18:15
simple-init-script.sh
#!/bin/bash
# from http://ubuntuserverguide.com/2012/06/how-to-installing-nginx-with-php5-and-mysql-support-on-ubuntu-server-12-04-lts.html
PHP_SCRIPT=/usr/sbin/php-fastcgi
FASTCGI_USER=www-data
FASTCGI_GROUP=www-data
PID_DIR=/var/run/php-fastcgi
PID_FILE=/var/run/php-fastcgi/php-fastcgi.pid
RET_VAL=0
case "$1" in
@blasterpal
blasterpal / calc_mysql_db_size.txt
Created June 21, 2012 15:39
Calculate MySQL Database Size
SELECT table_schema "Data Base Name", SUM( data_length + index_length) / 1024 / 1024
"Data Base Size in MB" FROM information_schema.TABLES GROUP BY table_schema ;
@blasterpal
blasterpal / mysql_grant.sql
Created September 5, 2012 17:49
Create mysql user with specific permissions
CREATE USER 'joe'@'%' IDENTIFIED BY 'xxxxxx';
# ALL PRIVILEGES is everything except grant
GRANT ALL PRIVILEGES ON APP_production_temp.* TO 'joe'@'%';
GRANT SELECT ON APP_production.* TO 'joe'@'%';
GRANT SELECT ON stats_production.* TO 'joe'@'%';
@blasterpal
blasterpal / ssl-ssh-cheatsheet.txt
Created December 11, 2012 14:36
SSH - SSL Cheatsheet
1. Convert PEM into pub SSH key file:
ssh-keygen -e -f amazon-ec2-key.pem >> amazon-ec2-key.pem.pub
2. Generate a PEM from a SSH key:
openssl rsa -in my_tunneler -outform pem > my_tunneler.pem
@blasterpal
blasterpal / add_read_only_pg_user.rb
Created August 28, 2013 12:57
Add read only user to PG 9 on DB, cookbook snippet.
# Create a user with Login
sql = [%(CREATE ROLE jsmith WITH PASSWORD 'foobar' LOGIN)]
# # Allow to connect
sql << %(GRANT CONNECT ON DATABASE reports TO jsmith)
# # Allow to use schema
sql << %(GRANT USAGE ON SCHEMA public TO jsmith)
# # grant on current objects
sql << %(GRANT SELECT ON ALL TABLES IN SCHEMA public TO jsmith)
# # grant on future objects
sql << %(ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO jsmith)
@blasterpal
blasterpal / check_slave_status.rb
Created January 23, 2013 21:11
Check MySQL Slave status from Shell using Ruby
#!/usr/bin/env ruby
@slave_status = Hash[%x(mysql -uroot -e 'SHOW SLAVE STATUS \\\G').split(/\s*\n\s*/).map { |e| spl = e.split(/\:\s*/); spl.size == 2 ? [spl.first, spl.last] : nil }.compact]
def slave_healthy?
@slave_status['Slave_IO_Running'] == 'Yes' &&
@slave_status['Slave_SQL_Running'] == 'Yes' &&
@slave_status['Seconds_Behind_Master'] != 'NULL' &&
@slave_status['Seconds_Behind_Master'].to_i < 1800
end
@blasterpal
blasterpal / com.hankbeaver.dockerformacloopback.plist
Created May 11, 2017 20:09
Docker For Mac Loopback adapter MacOS LaunchAgent script
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.hankbeaver.DockerForMacLoopBack</string>
<key>ProgramArguments</key>
<array>
<string>/System/Library/CoreServices/Spotlight.app/Contents/MacOS/Spotlight</string>
</array>
@blasterpal
blasterpal / bigquery_semantic_gh_metadata.rb
Last active April 30, 2017 19:18
Script to merge results from BigQuery Github Dataset with GitHub meta data
#Gemfile contents
source "https://rubygems.org"
gem 'octokit'
gem "pry"
# END Gemfile
require 'rubygems'
require 'bundler/setup'
require 'octokit'
require 'csv'