Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env bash
IFS=$'\n'
arr=($(dig @dns.server domain_to_search axfr))
unset IFS
for i in "${arr[@]:6:92}"
do
echo "$i" | awk '{print $5,$1}'
done
@simbalinux
simbalinux / pipe_webpage
Created July 13, 2018 00:22
pipe_webpage
#!/usr/bin/env bash
(echo "Content-Type: text/html"; curl localhost/cgi-bin/report.cgi) | /usr/sbin/sendmail user@domain.com
@simbalinux
simbalinux / create_repo
Created July 13, 2018 00:16
create_repo
#!/usr/bin/env bash
repo_name=$1
test -z $repo_name && echo "Repo name required." 1>&2 && exit 1
curl -u 'username_github' https://api.github.com/user/repos -d "{\"name\":\"$repo_name\"}"
@simbalinux
simbalinux / backup_script
Created July 13, 2018 00:14
backup_script
#!/bin/bash
#set -x
shopt -s nullglob
data=(/nas/csi/*)
key="$HOME"/.ssh/csi
url=user@secureftp.com:/Drop
archive=/nas/data/.data_archive
now=$(date +"%Y%m%d-%T")
sftp_copy () {
@simbalinux
simbalinux / scp_xfers
Created July 13, 2018 00:07
Shell Program to manage scp xfers
#!/bin/bash
#GLOBAL VARS
set -x
DATE=`date +%Y-%m-%d.%H:%M:%S`
RECIPIENTS="user@domain.com"
STAGING=/nas/tbdata/.encrypted_file
EXTRACT=/nas/tbdata2
ARCHIVE=/nas/tbdata/.encrypted_file/md5
MD5="user@obfuscated.domain.com:/erp.tar.gpg.md5"
DATA="user@obfuscated.domain.com:/erp.tar.gpg"
@simbalinux
simbalinux / shell_eval
Last active July 12, 2018 23:59
CGI program written in shell to evaluate filesystem
#!/usr/bin/env bash
shopt -s nullglob
exec > /path/to/logfile
# Variables
sql_path="/path/to/backup"
data_path="/path/to/backup"
days=7
testvalue=1
# Arrays
mapfile -t sql < <(find "$sql_path" -type f -mtime -"$days")
raw=/path/to/dir
files=("$raw"/*)
for each in "${files[@]}"; do
echo "$each"
sleep 3
done
count=${#files[@]}
files_ordered=()
for (( i = 0; i < count; i++ )); do
@simbalinux
simbalinux / grep_replace
Last active July 13, 2018 00:00
find and replace all occurences of " ." IF gt 3 and replace with "+"
[ $(grep -o '\.' file|wc -l) -gt 3 ] && sed -i file -e 's/\./+/g'
@simbalinux
simbalinux / socks5proxy
Created June 25, 2018 17:30
socks 5 proxy
#Create a secure server on your lan e.g. raspi
#invoke the following command from the server you will use as socks5 proxy specify port.
ssh -o ServerAliveInterval=60 -D0.0.0.0:8888 -f -N "host_with_www_connection"
#we have forked a background ssh process creating a socks5 proxy dynamically on ALL interfaces using 8888 on localhost, check with...
netstat -ntlp
#turn on the firewalld service
systemctl status firewalld.service
@simbalinux
simbalinux / check_sites
Created June 25, 2018 16:25
check uptime of sites
#!/bin/bash
SITESFILE=sites.txt #list the sites you want to monitor in this file
#EMAILS="you@email.com,someoneelse@email.com" #list of email addresses to receive alerts (comma separated)
while read site; do
if [ ! -z "${site}" ]; then
CURL=$(curl -s --head $site)