Skip to content

Instantly share code, notes, and snippets.

Sean O'Donnell sodonnell

View GitHub Profile
@sodonnell
sodonnell / putObject.php
Last active Mar 7, 2019
Using the AWS PHP SDK to upload files to S3 bucket using EC2 Instance Profile (IAM Role) Credentials
View putObject.php
<?php
require_once 'vendor/autoload.php';
use Aws\Credentials\CredentialProvider;
use Aws\S3\S3Client;
$provider = CredentialProvider::instanceProfile();
$mprovider = CredentialProvider::memoize($provider);
$s3 = new S3Client([
@sodonnell
sodonnell / multi-address.nic.sh
Last active Dec 4, 2018
Configuring Multiple IP Addresses on a single Network Interface
View multi-address.nic.sh
#!/usr/bin/env bash
#
# There are many custom use cases that require
# assigning multiple 'virtual' IP addresses to
# a single network interface.
#
# One case in particular, is for developing web applications
# locally on a workstation, to support a project that has multiple
# sub-domains. In such a case, you would create virtual IP addresses
# to support virtul hosts in apache/nginx. You would then associate the
@sodonnell
sodonnell / ab.sh
Last active Nov 15, 2018
apache benchmark testing
View ab.sh
ab -n 1000 -c 100 -k -H "Accept-Encoding: gzip, deflate" http://some.site.com/
@sodonnell
sodonnell / bash.batch.rename.sh
Created Oct 23, 2018
Batch-renaming Files in Bash
View bash.batch.rename.sh
#!/usr/bin/env bash
for i in rc_*; do mv $i ${i/rc_/rc2_}; done
@sodonnell
sodonnell / siege.sh
Created Oct 12, 2018
Stress Testing HTTP Services...
View siege.sh
siege -A "SiegeStressTest/1.0 (pwnd;)" -c 100 -r 100 -v https://someshittysite.com/
@sodonnell
sodonnell / rds.hosts.sync.sh
Last active Oct 12, 2018
I really hate dealing with legacy systems. This feels so wrong, and should not exist, but here we are.
View rds.hosts.sync.sh
#!/usr/bin/env bash
#
# This script is a complete hack to work-around a crappy
# old Amazon EC2 instance running a custom CentOS AMI that
# was NOT provisioned by Amazon AWS engineers.
#
# This particular (bain of my existence) server uses
# Google's DNS servers in the /etc/resolv.conf file, but
# wreaks havoc on the PHP web application when trying to
# call mysqli_connect, and often times-out or takes far
@sodonnell
sodonnell / ntpdate.sh
Created Oct 2, 2018
ntpdate - centos/rhel
View ntpdate.sh
#!/usr/bin/env bash
# install ntp service and sync w/ the pool
# why wasn't this done on these old servers. smh
yum -y install ntp;
chkconfig ntpd on;
service ntpd start;
date -R; ntpq -p; date -R;
ntpdate -q 0.ro.pool.ntp.org 1.ro.pool.ntp.org
@sodonnell
sodonnell / nmap.sh
Last active Sep 14, 2018
basic nmap scanning argument iterations and logging
View nmap.sh
#!/usr/bin/env bash
#
# Run various nmap scans on a hostname and log all scans to a single file.
#
# Alternatively, nmap does support log-output arguments on it's own, but the problem is
# grouping various scans that often conflict during the same process, thus requiring
# a series of multiple scans and would create multiple logs.
#
# usage examples:
# default scan:
@sodonnell
sodonnell / aws.rds.restore.snapshot.sh
Created Sep 6, 2018
Restore/Re-Deploy an Amazon RDS (MySQL) Database Instance from a specified snapshot.
View aws.rds.restore.snapshot.sh
#!/usr/bin/env bash
#
# Restore/Re-Deploy an Amazon RDS (MySQL) Database Instance from a specified snapshot.
#
# This script is intended to be run on an AWS EC2 instance
# within an isolated VPC infrastructure, to restore or re-deploy a
# test/staging database instance from a the latest
# 'production database' snapshot.
#
# This script requires the latest aws-cli program.
@sodonnell
sodonnell / myisam2innodb.sh
Created Sep 6, 2018
convert LIVE mysql tables from MyISAM to InnoDB via mysql cli
View myisam2innodb.sh
#!/usr/bin/env bash
#
# This was commented on the following page:
# https://dev.mysql.com/doc/refman/8.0/en/converting-tables-to-innodb.html
#
# This script/command was tested and found to be harmless/non-destructive, surprisingly. ;-P
#
DBNAME="exampledb";
DBHOST="localhost";
DBUSER="someguy";
You can’t perform that action at this time.