Skip to content

Instantly share code, notes, and snippets.

@jahil
jahil / mysql_backup.sh
Last active August 29, 2015 14:08
MySQL Backup Script
#!/bin/bash
DB_USER=root
DB_PASS=""
HOST=localhost
DBS_LIST=$(mysql -u $DB_USER $DB_PASS -Bse 'show databases')
BASE_BAK_FLDR=/www/backups/dump
RM_FLDR_DAYS="+7"
index=0
PING=$(mysqladmin ping --host $HOST -u $DB_USER $DB_PASS 2>/dev/null)
@jahil
jahil / rds_backup.sh
Last active October 15, 2022 19:45
RDS Backup Script
#!/bin/bash
# Database credentials
DB_USER=root
DB_PASS="-pvchangeme"
RDS_HOST=warp.cc7vd70wnd3ed.us-east-1.rds.amazonaws.com
# Get list of Database
DBS_LIST=$(mysql -u $DB_USER $DB_PASS -h $RDS_HOST -Bse 'show databases')
# Log file
BAKUP_LOG=/var/log/rds_backup.log
# Backup Base directory
@jahil
jahil / ebs_backup
Last active August 29, 2015 14:08
EBS Backup and Rotation Script
#!/bin/bash
export EC2_PRIVATE_KEY=~/.ec2/pk.pem
export EC2_CERT=~/.ec2/cert.pem
ec2-create-snapshot vol-ab0921c0 -d "Intellinar Server ROOT - $(date +'%d-%m-%Y')"
ec2-create-snapshot vol-110d257a -d "Intellinar Data - $(date +'%d-%m-%Y')"
ec2-create-snapshot vol-8bbb93e0 -d "Database Server aka RDS - $(date +'%d-%m-%Y')"
Purge EBS Snapshots
-------------------
export EC2_PRIVATE_KEY=~/.ec2/pk.pem
@jahil
jahil / trends.py
Created November 4, 2014 12:03
Twitter Trends - Major Cities of Pakistan
@jahil
jahil / usbreset.c
Created November 4, 2014 12:04
usbreset -- send a USB port reset to a USB device
/* usbreset -- send a USB port reset to a USB device */
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <sys/ioctl.h>
#include <linux/usbdevice_fs.h>
@jahil
jahil / aws.py
Created November 4, 2014 12:25
AWS Report Tool
__author__ = 'mohsin'
import boto.ec2
import optparse
from termcolor import colored
parser = optparse.OptionParser()
parser.add_option("-r", action="count", dest="regions", help='list all regions')
parser.add_option("-i", action="count", dest="instances", help='list all instances in region')
parser.add_option("-a", action="count", dest="all_instances", help='list all instances in all region')
@jahil
jahil / decoder.py
Created November 4, 2014 12:42
Remmina Password Decoder
__author__ = 'mohsin'
import base64
from Crypto.Cipher import DES3
secret = base64.decodestring('nMfNBx9y1T7Xe+DvWmsFwTeGUevEw3WLQlD5pl74qvo=')
password = base64.decodestring('temWEHt1x/0=')
print DES3.new(secret[:24], DES3.MODE_CBC, secret[24:]).decrypt(password)
import requests
url = 'http://kitaabghar.com/bookbase/idara/KrishanChandKeBehtareenAfsanay.html'
def download_file(url,path,filename=''):
try:
if filename=='':
@jahil
jahil / npass.sh
Last active August 29, 2015 14:08
GRC's Perfect Passwords Generator
#!/bin/bash
# GRC's Perfect Passwords Generator
WGET="/usr/bin/wget"
FILE=`tempfile`
$WGET -q --tries=10 --timeout=5 http://www.google.com -O $FILE &> /dev/null
[ -z "$1" ] && echo -e "\E[31mGRC's\E[37m Ultra High Security Password Generator v0.1\r\033[0m" && echo -e '--------------------------------------------------\n' &&
echo -e '\E[37mUsage: ppassword [\E[31m-an alphanumeric\E[37m ] [\E[32m-as ascii\E[37m ] [ -hex hexadecimal ]' && exit 100
Patch for OpenSSH Portable to log passwords
Tested on:
OpenSSH 5.3p1 - OpenSSH 6.6p1
May apply to older versions.
To apply:
patch --dry-run < sshlog.patch