Skip to content

Instantly share code, notes, and snippets.

View valorin's full-sized avatar

Stephen Rees-Carter valorin

View GitHub Profile
@valorin
valorin / .bash_aliases
Created February 9, 2023 00:25
WSL2 Scripts and helpers
# Dev Services
alias start-all='sudo wslact time-sync && sudo service redis-server start && sudo service mysql start && sudo service php8.2-fpm start && sudo service nginx start && mailcatcher'
alias stop-all='sudo service redis-server stop && sudo service mysql stop && sudo service php8.2-fpm stop && sudo service nginx stop && killall mailcatcher ; sleep 1 && ps ax'
alias restart-all='sudo service redis-server restart && sudo service mysql restart && sudo service php8.2-fpm restart && sudo service nginx restart'
alias use-php7.4='sudo update-alternatives --set php /usr/bin/php7.4'
alias use-php8.0='sudo update-alternatives --set php /usr/bin/php8.0'
alias use-php8.1='sudo update-alternatives --set php /usr/bin/php8.1'
alias use-php8.2='sudo update-alternatives --set php /usr/bin/php8.2'
@valorin
valorin / Middleware-CSP.php
Last active February 5, 2024 18:34
CSP Middleware - the simple CSP middleware I use across all of my projects.
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Support\Facades\Vite;
use Illuminate\Support\Str;
/**
* Simple Content Security Policy middleware.
#!/bin/bash -xe
if [[ $WSL_DISTRO_NAME = Ubuntu* ]]; then
sudo add-apt-repository ppa:ondrej/php -y
if [ $WSL_DISTRO_NAME == "Ubuntu-18.04" ]; then
sudo add-apt-repository ppa:certbot/certbot -y
fi
fi
@valorin
valorin / wordpress-setup-attack.sh
Created August 23, 2019 23:48
Proof of concept WordPress setup script attack - sets up a new WP installation and injects a simple shell into /wp-content/themes/twentynineteen/404.php and /wp-hello.php.
#!/bin/bash
#
# WordPress Setup Attack Script
#
# Created by Stephen Rees-Carter (https://stephenreescarter.net/)
#
# This script injects a remote shell into a fresh copy of WordPress that hasn't been set up yet.
# Once the shells have been set up, it removes the config file with the custom database connection to reset the site back to a fresh install.
#
@valorin
valorin / simple logrotate
Created January 17, 2016 21:24
/etc/logrotate.d/vhost-my.app
/var/www/vhosts/my.app/storage/logs/*.log {
size 100M # Max log file size 100M
weekly # Rotate weekly, if not sooner
missingok # Ignore if missing file
rotate 12 # Keep 12 files
compress # Compress rotated files
notifempty # Ignore empty files
create 755 www-data www-data # Create new log file with perms and owner
}
Verifying that +valorin is my blockchain ID. https://onename.com/valorin
@valorin
valorin / mosh-allow-ufw.yml
Created December 6, 2014 21:31
Ansible tasks to configure Mosh and UFW to play nice
---
- name: Install Mosh PPA
apt_repository: repo='ppa:keithw/mosh'
- name: Install Mosh
apt: >
state=latest
pkg=mosh
update_cache=yes
@valorin
valorin / mosh-allow-ufw.sh
Created December 6, 2014 20:49
Script to open and close Mosh ports in UFW
#!/bin/bash
# Load active ports
PORTS=`lsof -i | grep mosh-serv | cut -f2 -d":"`
STATUS=`sudo ufw status`
# Add Rules for new ports
for PORT in $PORTS; do
echo $STATUS | grep "$PORT/udp" > /dev/null

Keybase proof

I hereby claim:

  • I am valorin on github.
  • I am valorin (https://keybase.io/valorin) on keybase.
  • I have a public key whose fingerprint is 7C1C 5C4A 3017 C21F 9AE5 34DE C1C4 BEBF 0442 284B

To claim this, I am signing this object:

@valorin
valorin / gist:7261952
Last active February 9, 2016 15:44
Git prompt + Byobu
##############
# THIS WORKS #
##############
##
# Git prompt options
##
source ~/.git-prompt.sh
GIT_PS1_SHOWDIRTYSTATE=true
GIT_PS1_SHOWSTASHSTATE=true