Skip to content

Instantly share code, notes, and snippets.

View mttjohnson's full-sized avatar

Matt Johnson mttjohnson

View GitHub Profile
@mttjohnson
mttjohnson / mysql_drop_all_inside_db_sample.sql
Created April 5, 2017 19:54
mysql sample database for dropping everything inside
/* Create Sample Data for testing removal of tables views triggers routines events */
delimiter //
CREATE PROCEDURE simpleproc (OUT param1 INT)
BEGIN
SELECT COUNT(*) INTO param1 FROM information_schema.tables;
END//
delimiter ;
-- CALL simpleproc(@a);
-- SELECT @a;
@mttjohnson
mttjohnson / ssh_host_key_management.sh
Created April 20, 2017 15:54
SSH host key managment
HOST_NAME='example.com'
# check the known hosts list for any entries for $HOST_NAME
cat ~/.ssh/known_hosts | grep $HOST_NAME
# if the host does not exist in the list append it to the file
[ $(cat ~/.ssh/known_hosts | grep $HOST_NAME | wc -l) -eq 0 ] && ssh-keyscan $HOST_NAME >> ~/.ssh/known_hosts
# remove the key fromt he known hosts list
ssh-keygen -R $HOST_NAME
@mttjohnson
mttjohnson / gist_search.md
Last active June 6, 2017 21:06
Gist User Search
@mttjohnson
mttjohnson / extract_app_configs.sh
Created June 14, 2017 21:37
Extract Application Config Values
ORIGIN_SSH_USER=example_user
ORIGIN_SSH_HOST=example_host
ORIGIN_SITE_ROOT="/example/site/root"
ORIGIN_SHARED_PATH
ORIGIN_MR_COMMAND="mr"
ORIGIN_PHP_COMMAND="php"
export ORIGIN_CONFIG_VALUE=$(
ssh -q ${ORIGIN_SSH_USER}@${ORIGIN_SSH_HOST} "
cd ${ORIGIN_SITE_ROOT};
${ORIGIN_MR_COMMAND} config:get --scope=default --scope-id=0 --format=xml web/unsecure/base_url | \\
@mttjohnson
mttjohnson / most_common_keywords.sql
Created July 8, 2017 06:03
mysql find most common word in column
/* Create procedure for separating strings into a list of keywords */
delimiter $$
DROP PROCEDURE IF EXISTS split_value_into_multiple_rows $$
CREATE PROCEDURE split_value_into_multiple_rows(tablename VARCHAR(50),
id_column VARCHAR(50), value_column VARCHAR(50), delim CHAR(1))
BEGIN
DECLARE id INT DEFAULT 0;
DECLARE value VARCHAR(255);
DECLARE occurrences INT DEFAULT 0;
@mttjohnson
mttjohnson / yum_history.sh
Created August 3, 2017 15:28
Yum History
# To view a history over time of yum activity
yum history summary
# To view the history list of most recent yum activity
# Actions in the list are Erase (E), Install (I), Update (U)
yum history list
# Details on a specific history id
yum history info <ID>
@mttjohnson
mttjohnson / certificate_search.txt
Last active August 18, 2017 18:37
Certificate Search
Certificate Transparancy Search
https://crt.sh/
SSL/TLS Certificates (cert) issued, and logged by various providers
Find all certificates for a domain name including the use of wildcards in the searches. Datetime when certificates were issued.
@mttjohnson
mttjohnson / perl_log_parsing.sh
Created August 25, 2017 22:40
Perl log file parsing
# Input log file
2017-08-22T09:24:24+00:00 DEBUG (7): Start: M2epro Cron index
2017-08-22T09:24:30+00:00 DEBUG (7): Stop: M2epro Cron index
2017-08-22T09:25:24+00:00 DEBUG (7): Start: M2epro Cron index
2017-08-22T09:25:28+00:00 DEBUG (7): Start: M2epro Cron index
2017-08-22T09:25:29+00:00 DEBUG (7): Stop: M2epro Cron index
2017-08-22T09:25:32+00:00 DEBUG (7): Stop: M2epro Cron index
2017-08-22T09:26:24+00:00 DEBUG (7): Start: M2epro Cron index
2017-08-22T09:26:36+00:00 DEBUG (7): Stop: M2epro Cron index
@mttjohnson
mttjohnson / ssl_cipher_checking.sh
Last active September 13, 2017 18:53
SSL Cipher Checking
# enumerate ssl ciphers
nmap --script ssl-enum-ciphers -p 443 <hostname>
# Security/Server Side TLS Recommendation Guide
https://wiki.mozilla.org/Security/Server_Side_TLS
@mttjohnson
mttjohnson / git_references.sh
Created October 17, 2017 14:52
git command reference
# setup a remote as read only so that you do not acidently push to it.
git remote set-url --push upstream read-only