Skip to content

Instantly share code, notes, and snippets.

View ScrambledBits's full-sized avatar

Emilio Castro ScrambledBits

View GitHub Profile
@ScrambledBits
ScrambledBits / server_backup.sh
Created December 11, 2012 03:09
Server Backup
#!/bin/bash
tar -cvpzf /backup/backup$(date +%d-%m-%Y).tar.gz --exclude=backup --exclude=bin --exclude=boot --exclude=dev --exclude=lib --exclude=lost+found --exclude=media --exclude=mnt --exclude=opt --exclude=proc --exclude=sbin --exclude=selinux --exclude=srv --exclude=sys --exclude=tmp --exclude=usr --exclude=var/backup --exclude=var/backups --exclude=var/cache --exclude=var/crash --exclude=var/lib --exclude=var/local --exclude=var/lock --exclude=var/log --exclude=var/mail --exclude=var/opt --exclude=var/run --exclude=var/spool --exclude=var/tmp --exclude=var/vmail /
mysqldump -u root -p --all-databases | gzip > /backup/backup-database_$(date '+%m-%d-%Y').sql.gz
cd /backup/
for i in $(ls backup*); do dropbox_upload.sh upload $i /backup/*; done
@ScrambledBits
ScrambledBits / iptables_block.sh
Created December 11, 2012 03:29
SSH Dictionary Attack Prevention with iptables
#!/bin/bash
iptables -N SSH_CHECK
iptables -A INPUT -p tcp --dport 22 -m state --state NEW -j SSH_CHECK
iptables -A SSH_CHECK -m recent --set --name SSH
iptables -A SSH_CHECK -m recent --update --seconds 60 --hitcount 4 --name SSH -j DROP
<?php
// Code snippet to extract the icon from an exe file on a Linux system -- tested on Debian Wheezy
// Install icoutils on your system e.g. sudo apt-get install icoutils
// Web process must have write privileges to /tmp
///** Config **///
$input_file = '/path/to/program.exe';
#!/bin/sh
# Just copy and paste the lines below (all at once, it won't work line by line!)
# MAKE SURE YOU ARE HAPPY WITH WHAT IT DOES FIRST! THERE IS NO WARRANTY!
function abort {
echo "$1"
exit 1
}
set -e
<?php
function array_keys_multi(array $array)
{
$keys = array();
foreach ($array as $key => $value) {
$keys[] = $key;
if (is_array($array[$key])) {
$keys = array_merge($keys, array_keys_multi($array[$key]));
#!/usr/bin/env bash
# Simple move this file into your Rails `script` folder. Also make sure you `chmod +x puma.sh`.
# Please modify the CONSTANT variables to fit your configurations.
# The script will start with config set by $PUMA_CONFIG_FILE by default
PUMA_CONFIG_FILE=config/puma.rb
PUMA_PID_FILE=tmp/pids/puma.pid
PUMA_SOCKET=tmp/sockets/puma.sock
@ScrambledBits
ScrambledBits / ColorizedLogs.sh
Last active February 1, 2016 19:39
This snippet finds all log files under /var/log and displays them in realtime with color highlight. CCZE must be installed.
#!/bin/bash
find /var/log -type f -iregex '.*[^\.][^0-9]+$' -not -iregex '.*gz$' 2> /dev/null | xargs tail -n0 -f | ccze -A