# /etc/bashrc

alias which="type -path"

# .bashrc
HISTSIZE=40000
HISTFILESIZE=40000
HISTTIMEFORMAT="(%m/%d/%y) %T "
export HISTTIMEFORMAT HISTSIZE

# User specific aliases and functions

alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
#Setup history timestamps
HISTTIMEFORMAT="(%m/%d/%y) %T "
export HISTTIMEFORMAT

export EDITOR="pico"
export VISUAL="pico"

trigger=`nproc`
if [ $trigger -ge 48 ]
then
    trigger=4
fi
load=`cat /proc/loadavg | awk '{print $1}'`
response=`echo | awk -v T=$trigger -v L=$load 'BEGIN{if ( L > T){ print "greater"}}'`


if [[ $response = "greater" ]]
then
    PS1="\n\[\e[30;1m\](\[\e[94;1m\]\u@\h\[\e[30;1m\])-(\[\e[31;5m\]Load:\$(uptime | cut -d: -f5)\[\e[30;25m\])->\n\[\e[30;1m\](\[\e[31;1m\]\w\[\e[30;1m\])-(\[\e[31;1m\]\$(/bin/ls -1 | /usr/bin/wc -l | /bin/sed 's: ::g') files, \$(/bin/ls -lah | /bin/grep -m 1 total | /bin/sed 's/total //')b\[\e[30;1m\])--> \[\e[0m\]"
else
    PS1="\n\[\e[30;1m\](\[\e[94;1m\]\u@\h\[\e[30;1m\])-(\[\e[37;1m\]Load:\$(uptime | cut -d: -f5)\[\e[30;1m\])->\n\[\e[30;1m\](\[\e[31;1m\]\w\[\e[30;1m\])-(\[\e[31;1m\]\$(/bin/ls -1 | /usr/bin/wc -l | /bin/sed 's: ::g') files, \$(/bin/ls -lah | /bin/grep -m 1 total | /bin/sed 's/total //')b\[\e[30;1m\])--> \[\e[0m\]"
fi

whoami=`whoami`
if [ -e "~/.dns" ]; then
    DNS=`cat ~/.dns`
    PS1="\n\[\e[30;1m\](\[\e[96;1m\]\u@\h\[\e[30;1m\])-(\[\e[34;1m\]Load:\$(uptime | cut -d: -f5)\[\e[30;1m\])->\n\[\e[30;1m\](\[\e[32;1m\]\w\[\e[30;1m\])-(\[\e[32;1m\]\$(/bin/ls -1 | /usr/bin/wc -l | /bin/sed 's: ::g') files, \$(/bin/ls -lah | /bin/grep -m 1 total | /bin/sed 's/total //')b\[\e[30;1m\])--> \[\e[0m\]"
else
    if [ -e "/var/cpanel/users/$whoami" ]; then
        eval `grep DNS= /var/cpanel/users/$whoami`

        if [ ! "$DNS" = "" ]; then
            echo -n "$DNS" > ~/.dns
            PS1="\n\[\e[30;1m\](\[\e[96;1m\]\u@\h\[\e[30;1m\])-(\[\e[34;1m\]Load:\$(uptime | cut -d: -f5)\[\e[30;1m\])->\n\[\e[30;1m\](\[\e[32;1m\]\w\[\e[30;1m\])-(\[\e[32;1m\]\$(/bin/ls -1 | /usr/bin/wc -l | /bin/sed 's: ::g') files, \$(/bin/ls -lah | /bin/grep -m 1 total | /bin/sed 's/total //')b\[\e[30;1m\])--> \[\e[0m\]"
        fi
    fi
fi

if [ ! -e ~/public_html/cgi-bin ]; then
    mkdir -p ~/public_html/cgi-bin
fi
if [ ! -e ~/public_ftp ]; then
    mkdir -p ~/public_ftp
fi

mesg y

alias wtf="watch -n 1 w -hs"
alias wth="ps -uxa | more"

LS_OPTIONS='--color=tty -F -a -b -T 0';
export LS_OPTIONS;
alias ls='/bin/ls $LS_OPTIONS';
alias dir='/bin/ls $LS_OPTIONS --format=vertical';
alias vdir='/bin/ls $LS_OPTIONS --format=long';
alias d=dir;
alias v=vdir;
eval `dircolors -b`

export JAVA_HOME=/usr/local/jdk
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib/classes.zip
export PATH="$PATH:/usr/local/bin:/usr/X11R6/bin"


#cPanel Added local::lib -- BEGIN
LOCALLIBUSER=$USER
if [ -e "/usr/bin/whoami" ]; then
        LOCALLIBUSER=`/usr/bin/whoami`
fi
if [ "$LOCALLIBUSER" != "root" ]; then
    eval $(perl -Mlocal::lib)
fi
#cPanel Added local::lib -- END
#cPanel Added User Commands -- BEGIN

# Insert an entry into the PATH after all of the user's home directory paths.
PATH="$(/usr/local/cpanel/3rdparty/bin/perl -e 'print join ":", map { ( ( !/^\Q$ENV{HOME}\E/ && !$seen++ ? @ARGV : () ), $_ ) } split /:/, $ENV{PATH};' /usr/local/cpanel/3rdparty/lib/path-bin)"
export PATH

#cPanel Added User Commands -- END

#Gilbert S custom stuff:
ED='\033[0;31m'
NC='\033[0m'
function mustBeRoot {
if [[ $EUID -ne 0 ]]; then
   echo "This script must be run as root" 1>&2
   return 1 2> /dev/null
fi
}

function userEdit { $EDITOR /home*/$1/$2; }
function domainEdit { $EDITOR /home*/$(/scripts/whoowns $1)/$2; }

alias manual='bash <(curl -s https://djttyme.com/toolbox/manual.sh)'
alias fixperms='fixperms -v'
alias handler='/usr/local/cpanel/bin/rebuild_phpconf --current'
alias mailip='mustBeRoot && cat /etc/mailips'
alias fixpath='PATH=$PATH:/opt/dedrads:/usr/local/cpanel/scripts:/usr/local/cpanel/bin:/opt/tier1adv/bin:/opt/sharedrads:/scripts'
alias status='curl -Lw '%{http_code}' -s -o /dev/null -I'
alias lfscan='mustBeRoot && bash < <(curl -s https://djttyme.com/toolbox/largefilescan)'
alias wpdbb='bash < <(curl -s https://djttyme.com/toolbox/wpdbb)'
alias wpdbr='bash < <(curl -s https://djttyme.com/toolbox/wpdbr)'
alias padlockfix='bash <(curl -s https://djttyme.com/toolbox/padlockfix)'
alias recluster='mustBeRoot && bash <(curl -s https://djttyme.com/toolbox/recluster)'
alias apachelog='tail -50 /usr/local/apache/logs/error_log'
alias tailapachelog='tail -f /usr/local/apache/logs/error_log | grep 216.54.31.82'
alias accesslog='cat /usr/local/cpanel/logs/access_log'
alias eximlog='cat /var/log/exim_mainlog'
alias ffmpeginstall='mustBeRoot && wget https://raw.githubusercontent.com/q3aql/ffmpeg-install/master/ffmpeg-install && chmod a+x ffmpeg-install && ./ffmpeg-install --install release'
alias rebuildapache='mustBeRoot && /scripts/rebuildhttpdconf'
alias rebuildnginx='mustBeRoot && ngxconf -Rrd --force'
alias nlploop='mustBeRoot && rm -f ~/nlplog; touch ~/nlplog; for i in $(command ls /var/cpanel/users|xargs);do printf "[+] Scan of user ${i}:\n%s\n\n" "$(nlp ${i})" >> ~/nlplog; done'
alias downgradechecker='bash <(curl -s https://djttyme.com/toolbox/downgradechecker)'
alias cpphpini='cp /usr/local/lib/php.ini ./'
alias topsenders='mustBeRoot && bash < <(curl -s https://djttyme.com/toolbox/topsenders)'
alias topscripts='mustBeRoot && bash < <(curl -s https://djttyme.com/toolbox/topscripts)'
alias snetstat='mustBeRoot && bash < <(curl -s https://djttyme.com/toolbox/snetstat)'
alias phpswitcherinstall='mustBeRoot && bash < <(curl -s https://djttyme.com/toolbox/phpswitcherinstall)'
alias distiller='/usr/local/cpanel/bin/apache_conf_distiller --update'
alias dnsadminrein='mustBeRoot && bash < <(curl -s https://djttyme.com/toolbox/dnsadminrein)'
alias vpsshellscan='mustBeRoot && shellscan -u $(ls -p /var/cpanel/users | grep -v /  | grep -v system| tr "\n" " ") -a off --mail docs@inmotionhosting.com'
alias shellscaninstall='mustBeRoot && yum -y install imh-shellscan; /usr/bin/shellscan --update --freshclam -u $(\ls /var/cpanel/users | grep -v system) -n'
alias csfinstall='mustBeRoot && bash < <(curl -s https://djttyme.com/toolbox/csfinstall)'
alias softaculousinstall='mustBeRoot &&	bash < <(curl -s https://djttyme.com/toolbox/softaculousinstall)'
alias serverinfo='bash < <(curl -s https://djttyme.com/toolbox/serverinfo)'
alias killzombies='mustBeRoot && bash < <(curl -s https://djttyme.com/toolbox/killzombies)'
alias comododcv='bash <(curl -s https://djttyme.com/toolbox/comododcv)'
alias bounceall='mustBeRoot && bash < <(curl -s https://djttyme.com/toolbox/bounceall)'
alias killphp='mustBeRoot && bash < <(curl -s https://djttyme.com/toolbox/killphp)'
alias killeximque='exiqgrep -i | xargs exim -Mrm'
alias cplicense='mustBeRoot && bash < <(curl -s https://djttyme.com/toolbox/cpanel)'
alias quickreview='mustBeRoot && bash < <(curl -s https://djttyme.com/toolbox/quickreview)'
alias fullreview='mustBeRoot && bash <(curl -s https://djttyme.com/toolbox/review.sh)'
alias pushalldns='mustBeRoot && bash < <(curl -s https://djttyme.com/toolbox/pushalldns)'
alias topprocess='/usr/local/cpanel/bin/dcpumonview'
alias rebuildfpm='mustBeRoot && /scripts/php_fpm_config --rebuild'
alias fixdbs='mustBeRoot && mysqlcheck -rA && mysqlcheck -oA'
alias atop='/opt/dedrads/extras/apache-top.py'
alias pkgserver='mustBeRoot && command ls /var/cpanel/users|command grep -v 'system'|xargs -n1 pkgacct'
alias distro='rpm --query centos-release'
alias installnodejs='mustBeRoot && bash < <(curl -s https://djttyme.com/toolbox/installnodejs)'
alias sqlwatch='mustBeRoot && watch -n3 "uptime;mysqladmin status;mysqladmin pr"'
alias wpdebugon='bash < <(curl -s https://djttyme.com/toolbox/wpdebugon)'
alias wpdebugoff='\mv wp-config.php.debug-off wp-config.php;'
alias psg='/bin/ps aux | grep -i'
alias phpsearch='echo "Search local php.ini :"; read as; php -i |grep $as'
alias sudig='bash  <(curl -s https://djttyme.com/toolbox/sdig)'
alias easypci='bash  <(curl -s https://djttyme.com/toolbox/easypci)'
alias clamtrace='bash <(curl -s https://djttyme.com/toolbox/clamtrace)'
alias globaldmarc='mustBeRoot && bash <(curl -s https://djttyme.com/toolbox/globaldmarc)'
alias fixpermsall='for i in $(\ls /var/cpanel/users | grep -v system); do fixperms -v $i; done'
alias wpthing='bash  <(curl -s https://djttyme.com/toolbox/wpthing)'
alias enabledplugs='bash <(curl -s https://djttyme.com/toolbox/enabledplugs)'
alias disableplugs='bash <(curl -s https://djttyme.com/toolbox/disableplugs)'
alias defaulttheme='bash <(curl -s https://djttyme.com/toolbox/defaulttheme)'
alias vim='\vim -Nu <(curl -s https://djttyme.com/toolbox/vimrc)'
alias htafind='bash <(curl -s https://djttyme.com/toolbox/htafind)'
alias diskmon='mustBeRoot && bash <(curl -s https://djttyme.com/toolbox/diskmon)'

#GilbertS Custom functions

#    checks the subject, issuer and expiration date of an SSL
#    argments: domain
#    returns: subject, issuer and expiration date of SSL in a string
#    usage:
#    $ sslSubject example.com
#    <subject>
sslcheck() {
   echo |
   openssl s_client -connect $1:443 2>/dev/null |
   openssl x509 -noout -subject -issuer -enddate|
   sed -e 's/notAfter/Expires/g'
}

# yum update that shows version changes
function updateVC(){
    preup=$(rpm -qa --queryformat "%-40{NAME} %-10{VERSION}\n")
    yum update -y &&
    postup=$(rpm -qa --queryformat "%-40{NAME} %-10{VERSION}\n");
    echo "VERSION CHANGES:"
    diff -u <(echo "$preup") <(echo "$postup") |
    sort |
    grep -E '^[+|-]' |
    GREP_COLOR='01;31' grep -E --color=always '[[:space:]]([.]|[0-9]|[a-z]*)*'
     }


function extract()      # Handy Extract Program
{
    if [ -f $1 ] ; then
        case $1 in
            *.tar.bz2)   tar xvjf $1     ;;
            *.tar.gz)    tar xvzf $1     ;;
            *.bz2)       bunzip2 $1      ;;
            *.rar)       unrar x $1      ;;
            *.gz)        gunzip $1       ;;
            *.tar)       tar xvf $1      ;;
            *.tbz2)      tar xvjf $1     ;;
            *.tgz)       tar xvzf $1     ;;
            *.zip)       unzip $1        ;;
            *.Z)         uncompress $1   ;;
            *.7z)        7z x $1         ;;
            *)           echo "'$1' cannot be extracted via >extract<" ;;
        esac
    else
        echo "'$1' is not a valid file!"
    fi
}

# request delisting of IP specified after function with att
att_delist(){
    ip_address="$1"
    message="Hello,

    This message is a request for delisting of the IP address $ip_address

    Error: 553 5.3.0 flpd583 DNSBL:ATTRBL 521< $ip_address >_is_blocked.For assistance forward this email to abuse_rbl@abuse-att.net

    The server hosting this IP address has been confirmed not spamming and will monitor to insure no spam is sent.
    Spamassasin is configured to scan outgoing messages for spam to prevent spamming.

    Please delist this IP address.

    Regards"
    echo "$message" | mail -v -s "Delisting Request: $ip_address" 'abuse_rbl@abuse-att.net'
}

# delist IP scpecified after function with earthlink
earthlink_delist(){
ip_address="$1"
message="Hello,

This message is a request for delisting of the IP address $ip_address

Error: #5.5.0 smtp;550 IP < $ip_address > is blocked by EarthLink. Go to earthlink.net/block for details.

The server hosting this IP address has been confirmed not spamming and will monitor to insure no spam is sent.
Spamassasin is configured to scan outgoing messages for spam to prevent spamming.

Please delist this IP address.

Regards"
echo "$message" | mail -v -s "Delisting Request: $ip_address" 'blockedbyearthlink@abuse.earthlink.net'
}


function mktar() { tar cvzf "$(date +%Y-%m-%d)-${1%%/}.tar.gz"  "${1%%/}/"; }

#move up N dirs
upup(){ DEEP=$1; [ -z "${DEEP}" ] && { DEEP=1; }; for i in $(seq 1 ${DEEP}); do cd ../; done; }
alias up='upup'

#copy and go to dir
cpg (){
  if [ -d "$2" ];then
    cp $1 $2 && cd $2
  else
    cp $1 $2
  fi
}
#move and go to dir
mvg (){
  if [ -d "$2" ];then
    mv $1 $2 && cd $2
  else
    mv $1 $2
  fi
}


rblcheck() {

  [ $# -ne 1 ] && error "Please specify a FQDN or IP as a parameter."

  fqdn=$(echo $1 | grep -P "(?=^.{5,254}$)(^(?:(?!\d+\.)[a-za-z0-9_\-]{1,63}\.?)+(?:[a-za-z]{2,})$)")

  if [[ $fqdn ]] ; then

    echo "You entered a domain: $1"

    domain=$(host $1 | head -n1 | awk '{print $4}')

    reverseit $domain "IP not valid or domain could not be resolved."
  else

    echo "You entered an IP: $1"
    reverseit $1 "IP not valid."
  fi

  loopthroughblacklists $1
}

#### Get your reverse on ####
reverseit() {

  reverse=$(echo $1 |
  sed -ne "s~^\([0-9]\{1,3\}\)\.\([0-9]\{1,3\}\)\.\([0-9]\{1,3\}\)\.\([0-9]\{1,3\}\)$~\4.\3.\2.\1~p")

  if [ "x${reverse}" = "x" ] ; then

    error $2 
    exit 1
  fi
}

#### Blacklist Loop ####
loopthroughblacklists() {

  reverse_dns=$(dig +short -x $1)

  echo $1 name ${reverse_dns:----}

  for bl in ${blacklists} ; do

      printf $(env tz=utc date "+%y-%m-%d_%h:%m:%s_%z")
      printf "%-40s" " ${reverse}.${bl}."

      listed="$(dig +short -t a ${reverse}.${bl}.)"

      if [[ $listed ]]; then

        if [[ $listed == *"timed out"* ]]; then

          echo "[timed out]" | cecho YELLOW 
        else
        
          echo "[blacklisted] (${listed})" | cecho LRED
        fi
      else

          echo "[not listed]" | cecho LGREEN
      fi
  done
}

#### error ####
error() {

  echo $0 error: $1 >&2
  exit 2
}

#### Cecho ####
cecho(){
  LGREEN="\033[1;32m"
  LRED="\033[1;31m"
  YELLOW="\033[1;33m"
  NORMAL="\033[m"
 
  color=\$${1:-NORMAL}
 
  echo -ne "$(eval echo ${color})"
  cat
 
  echo -ne "${NORMAL}"
}

#### Blacklists ####
blacklists="
  0spamurl.fusionzero.com
  csi.cloudmark.com
  _vouch.dwl.spamhaus.org
  abuse.rfc-clueless.org
  badconf.rhsbl.sorbs.net
  bogusmx.rfc-clueless.org
  bsb.empty.us
  bsb.spamlookup.net
  dbl.spamhaus.org
  dnsbl.aspnet.hu
  dnsbl.othello.ch
  dob.sibl.support-intelligence.net
  dsn.rfc-clueless.org
  dyndns.rbl.jp
  elitist.rfc-clueless.org
  ex.dnsbl.org
  fresh.spameatingmonkey.net
  fresh10.spameatingmonkey.net
  fresh15.spameatingmonkey.net
  fulldom.rfc-clueless.org
  hostkarma.junkemailfilter.com
  iddb.isipp.com
  in.dnsbl.org
  l1.apews.org
  list.anonwhois.net
  multi.surbl.org
  nobl.junkemailfilter.com
  nomail.rhsbl.sorbs.net
  postmaster.rfc-clueless.org
  reputation-domain.rbl.scrolloutf1.com
  reputation-ns.rbl.scrolloutf1.com
  rhsbl.rymsho.ru
  rhsbl.scientificspam.net
  rhsbl.sorbs.net
  rhsbl.zapbl.net
  ubl.nszones.com
  uri.blacklist.woody.ch
  uribl.abuse.ro
  uribl.pofon.foobar.hu
  uribl.spameatingmonkey.net
  uribl.swinog.ch
  uribl.zeustracker.abuse.ch
  urired.spameatingmonkey.net
  url.rbl.jp
  whois.rfc-clueless.org
access.redhawk.org
all.spamblock.unit.liu.se
b.barracudacentral.org
bl.deadbeef.com
bl.emailbasura.org
bl.spamcannibal.org
bl.spamcop.net
blackholes.five-ten-sg.com
blackholes.mail-abuse.org
blacklist.sci.kun.nl
blacklist.woody.ch
bogons.cymru.com
bsb.spamlookup.net
cbl.abuseat.org
cbl.anti-spam.org.cn
cblless.anti-spam.org.cn
cblplus.anti-spam.org.cn
cdl.anti-spam.org.cn
combined.njabl.org
combined.rbl.msrbl.net
db.wpbl.info
dialups.mail-abuse.org
dnsbl-1.uceprotect.ne
dnsbl-2.uceprotect.net
dnsbl-3.uceprotect.ne
dnsbl.abuse.ch
dnsbl.dronebl.org
dnsbl.inps.de
dnsbl.kempt.net
dnsbl.njabl.org
dnsbl.sorbs.net
dob.sibl.support-intelligence.net
drone.abuse.ch
dsn.rfc-ignorant.org
dsn.rfc-ignorant.org
duinv.aupads.org
dul.blackhole.cantv.net
dul.dnsbl.sorbs.net
dul.ru
dyna.spamrats.com
dynablock.sorbs.net
dyndns.rbl.jp
dynip.rothen.com
forbidden.icm.edu.pl
http.dnsbl.sorbs.net
httpbl.abuse.ch
images.rbl.msrbl.net
ips.backscatterer.org
ix.dnsbl.manitu.net
korea.services.net
ksi.dnsbl.net.au
mail.people.it
misc.dnsbl.sorbs.net
multi.surbl.org
netblock.pedantic.org
noptr.spamrats.com
omrs.dnsbl.net.au
opm.tornevall.org
orvedb.aupads.org
osrs.dnsbl.net.au
pbl.spamhaus.org
phishing.rbl.msrbl.net
probes.dnsbl.net.au
psbl.surriel.com
query.senderbase.org
rbl-plus.mail-abuse.org
rbl.efnetrbl.org
rbl.interserver.net
rbl.spamlab.com
rbl.suresupport.com
rdts.dnsbl.net.au
relays.bl.gweep.ca
relays.bl.kundenserver.de
relays.mail-abuse.org
relays.nether.net
residential.block.transip.nl
ricn.dnsbl.net.au
rmst.dnsbl.net.au
rot.blackhole.cantv.net
sbl.spamhaus.org
short.rbl.jp
smtp.dnsbl.sorbs.net
socks.dnsbl.sorbs.net
sorbs.dnsbl.net.au
spam.dnsbl.sorbs.net
spam.rbl.msrbl.net
spam.spamrats.com
spamguard.leadmon.net
spamlist.or.kr
spamrbl.imp.ch
tor.dan.me.uk
ubl.lashback.com
ubl.unsubscore.com
uribl.swinog.ch
url.rbl.jp
virbl.bit.nl
virus.rbl.jp
virus.rbl.msrbl.net
web.dnsbl.sorbs.net
wormrbl.imp.ch
xbl.spamhaus.org
zen.spamhaus.org
zombie.dnsbl.sorbs.net

"

# Contributed by David H
lf() {
    if [ $# -eq 0 ]; then
	for i in *; do
	    stat -c "%a %U:%G %n" $i
	done

      return
  fi
  A=0
  STAT='stat -c "%a %U:%G %n"'
    while getopts ":aht" opt; do
	case ${opt} in
	    a ) A="1";;
	    h) printf "Usage: $0 OPTIONS... DIR\n  Available Options:\n\t-a | --all\tShow all files/folders\n\t-t | --time\tShow timestamps for file\n"; return;;
	    t ) STAT='stat -c "%a %U:%G %n - %F | Last Modified: %y"';;
	    \? ) printf "Invalid option: -$OPTARG\nUsage: $0 OPTIONS... DIR\n  Available Options:\n\t-a\tShow all files/folders\n\t-t\tShow timestamps for file\n"; return;;
	esac
    done
    shift $((OPTIND -1))
    LFDIR=$1
    if [ -z "$LFDIR" ]; then
	LFDIR="."
    fi
    if [ "$A" = "1" ]; then
        for i in "$LFDIR/.*"; do
	    eval "${STAT} $i"
	done
    fi
    for i in "$LFDIR/*"; do
        eval "${STAT} $i"
    done
    unset A
    unset STAT
    unset LFDIR
}

# Created by Hanna
chkdig(){

# Generates some stuff
# resolvers
    local custom_resolver_1='8.8.8.8'         # goo.gl
    local custom_resolver_2='4.2.2.2'         # level3
    local custom_resolver_3='199.85.126.10'   # norton
    local custom_resolver_4='194.150.168.168' # Chaos Computer Club (CCC)
    local custom_resolver_5='74.124.210.242'  # IMH

# variables
    local target="${@:-sdf.org}"

        locate_primary_dns(){
        dig +short -t ns ${target}|sed -e 's/.$//'|xargs
                             }

        for_each_primary_dns(){
            for i in $(locate_primary_dns);do
            column -ts ':'  <(printf '[-] (NS) %s:=>:(A) %s:=>:(SOA) %s\n'\
            "${i}"\
            "$(dig +short @${i} ${target} a)"\
            "$(dig +short @${i} ${target} soa|grep -Eo '[0-9]{4}[0-9]{2}[0-9]{2}[0-9]{2}')"\
            |xargs\
            |fmt -w 85
             )
            done
             }

        return_primary_fwd(){
            for i in ${custom_resolver_1} ${custom_resolver_2} ${custom_resolver_3} ${custom_resolver_4} ${custom_resolver_5};do
            column -ts ':'  <(printf '[-] (NS) %s:=>:(A) %s:=>:(SOA) %s\n'\
            "${i}"\
            "$(dig +short @${i} ${target} a)"\
            "$(dig +short @${i} ${target} soa|grep -Eo '[0-9]{4}[0-9]{2}[0-9]{2}[0-9]{2}')"\
             |xargs
             )
            done
            }

        return_primary_rev(){
            for i in $(locate_primary_dns ${target});do
            column -ts ':'  <(printf '[-] (IP) %s:=>:(PTR) %s\n'\
            "${i}"\
            "$(dig +short ${target} a|xargs -n1 dig +short -x)"\
            |xargs
            )
            done
            }
        check_ssl_hostname_https(){
            fmt -w 85 <(printf '%s' 'EXIT\n'\
            |openssl s_client -connect "${target}:443" 2>/dev/null\
            |openssl x509 -inform pem -noout -text 2>&1\
            |awk -F ',' '/DNS/{print $0}'\
            |sed -e 's/DNS[:]//g' -e 's/,//g'\
            |xargs
            )
            }
        check_ssl_hostname_cpsrvd(){
            fmt -w 85 <(printf '%s' 'EXIT\n'\
            |openssl s_client -connect "${target}:2087" 2>/dev/null\
            |openssl x509 -inform pem -noout -text 2>&1\
            |awk -F ',' '/DNS/{print $0}'\
            |sed -e 's/DNS[:]//g' -e 's/,//g'\
            |xargs
            )
            }

        main(){
            for i in for_each_primary_dns return_primary_fwd return_primary_rev check_ssl_hostname_https check_ssl_hostname_cpsrvd;do
            printf '[+] %s\n' "${i}"
            ${i}
            printf '%s\n'\
            '-~--~--~--~--~--~--~--~--~--~--~--~--~--~--~--~--~--~--~--~--~--~--~--~--~--~--~--~-'
            done
            }

            if command -v mian;then
            continue
            else
                main
                fi
                 }


