Skip to content

Instantly share code, notes, and snippets.

@mttjohnson
mttjohnson / resize_disk_on_vm.sh
Last active March 20, 2020 00:10
Resizing/Grow disk partitions on virtual machines
# resize the virtual attached disks
# List block storage devices
lsblk
# List file systems
df -Th
@mttjohnson
mttjohnson / m2_update_varnish_in_env.sh
Last active June 21, 2019 20:45
Updating Magento Varnish Servers in env.php
#!/usr/bin/env bash
set -eu
# Variables
LOG_PATH="/home/www-upload/update_magento_varnish_config.log"
MAGENTO_PATH="/var/www/html/current"
# Get Webscale App Servers
APP_SERVERS=$(webscale-cli apps servers)
@mttjohnson
mttjohnson / archived_revision_of_file_changes.sh
Created June 18, 2019 17:49
Create Archived Revision of File Changes
#!/usr/bin/env bash
set -eu
# ----------------------------------------
# Variables
# ----------------------------------------
INSTALL_DIR="/var/www/html"
SHARED_DIR="/var/www/shared/html"
TIMESTAMP=$(date -u +"%Y%m%dT%H%M%SZ")
@mttjohnson
mttjohnson / cloud_vm_info.sh
Created June 13, 2019 20:24
Cloud VM Instance Type Info (aws/gcp/azue/digitalocean)
# AWS
# https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-instance-metadata.html
curl http://169.254.169.254/latest/dynamic/instance-identity/document
# Azure
curl http://169.254.169.254/metadata/v1/InstanceInfo
# GCP
# https://cloud.google.com/compute/docs/storing-retrieving-metadata#querying
curl -H "Metadata-Flavor: Google" "http://metadata.google.internal/computeMetadata/v1/instance/machine-type"
@mttjohnson
mttjohnson / sitecheck
Last active February 25, 2020 10:03
Magento Version Site Checker
#!/usr/bin/env bash
set -eu
########################################
## Introduction
########################################
HELP_INFO=$(cat <<'CONTENTS_HEREDOC'
sitecheck v0.1
@mttjohnson
mttjohnson / list_symlinks_recursively.sh
Created May 23, 2019 21:56
List all symlinks recursively
@mttjohnson
mttjohnson / python_pip.sh
Created May 9, 2019 21:31
Replacing python pip dependency for development contributions
# Find the installed path for the package
pip show gitman
cd /usr/local/lib/python3.7/site-packages
# install gitman from
pip install git+ssh://[email protected]/mttjohnson/gitman.git@feature/repo-rebuild
# If you've hacked up what is currently installed, you may need to uninstall and reinstall
pip uninstall gitman
@mttjohnson
mttjohnson / cracking_md5crypt_shadow_passwords.txt
Created May 1, 2019 22:05
cracking md5crypt shadow passwords
https://null-byte.wonderhowto.com/how-to/crack-shadow-hashes-after-getting-root-linux-system-0186386/
cat /etc/shadow
root:$1$/avpfBJ1$x0z8w5UF9Iv./DR9E9Lid.:14747:0:99999:7:::
daemon:*:14684:0:99999:7:::
bin:*:14684:0:99999:7:::
sys:$1$fUX6BPOt$Miyc3UpOzQJqz4s5wFD9l0:14742:0:99999:7:::
sync:*:14684:0:99999:7:::
cat hashes.txt
@mttjohnson
mttjohnson / php_security_notes.sh
Last active February 25, 2020 10:03
PHP Security Notes (Scanning/Vulnerability)
# https://github.com/sensiolabs/security-checker
# Uses Security Check Web service (https://security.symfony.com/) and Security Advisories Database (https://github.com/FriendsOfPHP/security-advisories)
curl -o security-checker https://get.sensiolabs.org/security-checker.phar
chmod +x ./security-checker
./security-checker security:check current/composer.lock
# MageReport
# https://www.magereport.com
@mttjohnson
mttjohnson / running_chkrootkit.sh
Created April 18, 2019 20:27
security chkrootkit scanning for system root kits
# http://www.chkrootkit.org/download/
# http://www.chkrootkit.org/README
# Commands to download file, and then upload to server after validating it
wget ftp://ftp.pangeia.com.br/pub/seg/pac/chkrootkit.tar.gz
wget ftp://ftp.pangeia.com.br/pub/seg/pac/chkrootkit.md5
cat chkrootkit.md5
md5sum chkrootkit.tar.gz
scp chkrootkit.tar.gz [email protected]:~/