Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
# ./normal_user_ips.sh
# desc: display IPs of all normal users on your Debian system
# by: Sahal Ansari http://sahal.info/
accepted="Accepted"
# to display Accepted or Failed IPs from auth.log uncomment:
#accepted="Accepted|Failed"
# directory where you keep auth.log
#!/bin/bash
# ./auto_verify_dns.sh
# _very_ dumb way to verify that a list of dns servers work...
# by sahal
#
# use: ./auto_verify_dns.sh /full/path/to/dns/servers > ~/output
# requires timeout3 (set $W_TOUT) by Dimitry V Golovashkin (see Google)
# path to timeout3 - written by Dmitry V Golovashkin - via google
W_TOUT=/home/sahal/scripts/others/timeout3
@sahal
sahal / dch-generate.sh
Created May 18, 2014 09:35
dch-generate.sh - quick and dirty (emphasis on dirty) debian changelog generator for SoftEtherVPN
#!/bin/bash
# use: ./debian/dch-generate.sh > ./debian/changelog
# desc: quick and dirty (emphasis on dirty) debian changelog generator for SoftEtherVPN
#
# Copyright (c) 2014 Sahal Ansari (github@sahal.info)
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# version 2 as published by the Free Software Foundation.
@sahal
sahal / ipc.sh
Created August 10, 2014 12:20
Convert hex encoded ip from mibbit or cgi:irc to dot-decimal format. Useful script from my ircop days.
#! /bin/bash
# ./ipc.sh $1
# by: Sahal Ansari github.com/sahal
#
# desc: takes input ($1) in form of hex encoded ip from mibbit or cgi:irc
# returns ip in dot-decimal format
#
# use in irssi: /exec (-o) ~/ipc hexip
#ready the input
@sahal
sahal / gen-server-stats.sh
Last active August 29, 2015 14:05
Generate very simple server stats using this bash script. Who needs phpSysInfo?
#!/bin/bash
# ./gen-server-stats.sh
# by Sahal Ansari - github.com/sahal
# desc: generates a list of stats on the box you're on. Not as impressive as phpSysInfo.
#
# run it every hour via cron, if you'd like:
# 0 * * * * /home/user/gen-server-stats.sh > /home/user/public_html/stats
# generate "html":
#echo "<pre>"
@sahal
sahal / proxy.pac
Last active August 20, 2024 00:03
Proxy Auto Configuration - SOCKS5 Sample
// see: http://blog.sahal.info/post/58278726443/chromebook-socks-proxies-and-ssh-tunnels
function FindProxyForURL(url, host)
{
// On my Chromebook, I've found that "Secure Shell" or Chrome itself doesn't close ports after a session timesout
// so I have to switch the local proxy listen address to 8081. Now, I don't have to use two proxy.pac files.
// See Simple PAC Load Balancing on proxypacfiles.com
// http://www.proxypacfiles.com/proxypac/index.php?option=com_content&view=article&id=63&Itemid=104
// https://web.archive.org/web/20131011081101/http://www.proxypacfiles.com/proxypac/index.php?option=com_content&view=article&id=63&Itemid=104
return "SOCKS5 localhost:8080; SOCKS5 localhost:8081";
}
@sahal
sahal / putty-reset.reg
Created September 9, 2014 02:25
Remove all of PuTTY's saved registry information (e.g. saved SSH keys)
Windows Registry Editor Version 5.00
[
-HKEY_CURRENT_USER\Software\SimonTatham
]
@sahal
sahal / misfits.sh
Last active August 29, 2015 14:09
Quick Bash script to geolocate IPs causing lines in your apache error logs
#!/bin/bash
# desc: find out where misfits (those causing apache errors) are located
# by: Sahal Ansari (github@sahal.info)
# use: ./misfits.sh [stats|top10]
# requires: geoip-bin package in Debian (and derivatives?)
DIR="$( cd "$( dirname "$0" )" && pwd )"
misfitlist="$DIR/list"
apache_error_log_location="/var/log/apache2/error.log"
#local copy of error.log exists
@sahal
sahal / l2tp-install.sh
Last active August 29, 2015 14:10
IPSec/L2TP VPN on Debian Wheezy, CentOS/RHEL - no compilation, no need to configure users (outside OS)
#!/bin/bash
# Installing an L2TP/IPSec VPN on Debian Wheezy, CentOS, RHEL
# see: http://blog.sahal.info/post/103242887966/ipsec-l2tp-vpn-on-debian
#
# adapted from: https://gist.github.com/hwdsl2/9030462 # need to compile libreswan :(
# adapted from: https://raymii.org/s/tutorials/IPSEC_L2TP_vpn_with_Ubuntu_14.04.html # installs Openswan (unmaintained) :(
#
# Copyright (c) 2014 Sahal Ansari - github@sahal.info
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
@sahal
sahal / gen-passwords.sh
Created November 23, 2014 19:48
Generate a list of passwords using /dev/urandom or /dev/random and bash
#!/bin/sh -e
# by Sahal Ansari - github@sahal.info
# based on this blog post by Kevin Goodman
# http://blog.colovirt.com/2009/01/07/linux-generating-strong-passwords-using-randomurandom/
# NOTE: install haveged for faster/'better' results!
length=24
count=10
random_source="/dev/urandom"