shopt -s expand_aliases VER="v2.50" export TICKET=`echo $HISTFILE | awk 'BEGIN {FS="."} {print $4}'` export IPADDR=$(curl -s myip.cpanel.net) export EDITOR=vi export VISUAL=vi export PS1="[\[\e[4;33m\] \u@\${IPADDR} [$TICKET] \w\[\e[0m\]]# " # listing files and directories alias ll="ls -alh" alias dir="ll | grep '^d'" # Run ssp or bugreport or docreport alias ssp="curl -sk https://ssp.cpanel.net/run | sh" alias bugreport="curl -sk https://ssp.cpanel.net/ssp | /usr/local/cpanel/3rdparty/bin/perl - --bugreport" alias docreport="curl -sk https://ssp.cpanel.net/ssp | /usr/local/cpanel/3rdparty/bin/perl - --docreport" # SSP Development alias sspdevel="curl -s https://ssp.cpanel.net/ssp-devel | perl" # SSP Previous alias sspprev="curl -s https://ssp.cpanel.net/ssp-previous | perl" # genpass function - generate a random password genpass() { openssl rand -base64 18; } # backupPass - Unhash Backup Password backupPass() { grep -hoP '(?<=^id: ).+' /var/cpanel/backups/*.backup_destination|while read i;do /usr/local/cpanel/3rdparty/bin/perl -mCpanel::Backup::Transport -e 'use Data::Dumper; print Dumper(Cpanel::Backup::Transport->new()->get(@ARGV));' "$i";done } # acctinfo - now preset in pacha/macha alias acctinfo="/usr/local/cpanel/3rdparty/bin/perl <(curl -s https://raw.githubusercontent.com/CpanelInc/tech-acctinfo/master/acctinfo)" # vtcheck alias vtcheck="/usr/local/cpanel/3rdparty/bin/perl <(curl -s https://cpaneltech.ninja/cptech/vtcheck) " # verchk alias verchk="/usr/local/cpanel/3rdparty/bin/perl <(curl -s https://cpaneltech.ninja/cptech/verchk) " # sendtoVT alias sendtoVT="/usr/local/cpanel/3rdparty/bin/perl <(curl -s https://cpaneltech.ninja/cptech/sendtoVT) " # sendtoMB alias sendtoMB="/usr/local/cpanel/3rdparty/bin/perl <(curl -s https://cpaneltech.ninja/cptech/sendtoMB) " # fastupdatechk alias fastupdatechk="curl -s https://cpaneltech.ninja/cptech/fastupdatechk | perl" # CCSConnect - connect to the CCS Postgresql server alias CCSConnect="psql --user caldav postgresql://?host=/opt/cpanel-ccs/data/Data/Database/psqlsocks" # getMailQuota - Quickly get the mail quota for an email address. getMailQuota() { ( read -p 'Email Address: ' emailaddr ; doveadm -f tab quota get -u ${emailaddr} | head -2 | grep -v 'Value' | awk '{print "Quota Limit: " $4 / 1024 " MB\n" "Quota Used: " $3 /1024 " MB\n" "Percentage Used: " $5 "\n"}' ) } # port53chk alias port53chk="read -p 'Host or IP: ' hostip ; echo \"Checking if port 53 (tcp/udp) is open for $hostip using nmap\" ; nmap -Pn $hostip -sSUV -p 53" # gsbchk gsbchk() { ( DOMAIN=$1 ; curl -s "https://cpaneltech.ninja/cgi-bin/gsbchk.cgi?$DOMAIN" ) } # mixedContent - Show URL's in a website that point to http:// mixedContent() { ( DOMAIN=$1 ; curl -ks https://$DOMAIN |grep -n "http://"|sed 's/\:.*http\:/\: http\:/g'|sed 's/\".*//g' ) } # url_encode #alias url_encode="perl -MURI::Escape -n 'print url_escape($1);' " #url_encode() { ( FILE=$1 ; `perl -MURI::Escape -n 'print url_escape($FILE);'` ) } # addHackTF alias addHackTF="/usr/local/cpanel/3rdparty/bin/perl <(curl -s https://cpaneltech.ninja/cptech/addhacktf)" # hashcheck hashcheck() { ( red=$(tput setaf 1) ; green=$(tput setaf 2) ; yellow=$(tput setaf 3) ; reset=$(tput sgr0) ; read -p "SHA256Hash: " hash ; curl -s -X 'GET' "https://hashlookup.circl.lu/lookup/sha256/$hash" -H 'accept: application/json' | json_pp | egrep -q 'KnownMalicious' && echo "${red}The sha256 hash of${yellow} $hash ${red}is known to be malicious${reset}" || echo "${green}The sha256 hash of${yellow} $hash ${green} is not known to be malicious${reset}" ) } # listHackTF alias listHackTF="ls -alh {/usr/share/doc,/boot}/.cp*" # cvecheck alias cvecheck="/usr/local/cpanel/3rdparty/bin/perl <(curl -s https://raw.githubusercontent.com/CpanelInc/tech-cvecheck/main/cvecheck) " # secheaders alias secheaders="/usr/local/cpanel/3rdparty/bin/perl <(curl -s https://raw.githubusercontent.com/CpanelInc/tech-secheaders/main/secheaders) " # easyapachebuddy alias easyapachebuddy="/usr/local/cpanel/3rdparty/bin/perl <(curl -s https://raw.githubusercontent.com/CpanelInc/tech-easyapachebuddy/main/easyapachebuddy.pl) " # pubsufchk alias pubsufchk="/usr/local/cpanel/3rdparty/bin/perl <(curl -s https://cpaneltech.ninja/cptech/pubsufchk) " # port25chk alias port25chk="/usr/local/cpanel/3rdparty/bin/perl -e 'use IO::Socket::PortState(qw(check_ports)); print \"Port 25 is \", check_ports(@ARGV[0], 5, { tcp => { 25 => {} }})->{tcp}{25}{open} ? \"Open\" : \"Closed\", \" to \" . @ARGV[0] . \"\n\";'" # CSI - Download CSI to /root. alias getcsi="echo -n 'Downloading csi.pl' && curl -s https://raw.githubusercontent.com/CpanelInc/tech-CSI/master/csi.pl > /root/csi.pl && chmod 755 /root/csi.pl && echo ' - Done'" # inotify-watches alias inotify-watches="curl -s https://raw.githubusercontent.com/fatso83/dotfiles/master/utils/scripts/inotify-consumers | bash" # NS Record Report alias nsrecordreport='curl --silent https://raw.githubusercontent.com/cPanelInc/tech-TechScripts/master/ns_record_report.sh |sh' # getcpeval2 script or cpeval Development (Migrations) alias getcpeval2="echo -n 'Downloading cpeval2' && curl -s https://ssp.cpanel.net/cpeval/cpeval2 > /root/cpeval2 && chmod 755 /root/cpeval2 && echo ' - Done'" # ticketkey alias ticketkey="/usr/local/cpanel/3rdparty/bin/perl <(curl -s https://cpaneltech.ninja/cptech/ticketkey) " # chkTransfers - list transfer session id for those transfers not in state 100 (IE: not completed). alias chkTransfers="/usr/local/cpanel/3rdparty/bin/sqlite3 /var/cpanel/transfer_sessions/whmxfer.sqlite \"SELECT sessionid,state FROM sessions WHERE state != '100'\"" # abortTransfer - abortTransfer sessionid #abortTransfer() { (SESS_ID=$1; /usr/local/cpanel/3rdparty/bin/sqlite3 /var/cpanel/transfer_sessions/whmxfer.sqlite "UPDATE sessions SET state='150', endtime=date('now') WHERE sessionid='$SESS_ID'") } abortTransfer() { (SESS_ID=$1; whmapi1 abort_transfer_session transfer_session_id=$SESS_ID) } # servicechk - quickly list all services (installed, enabled, monitored, running) alias servicechk="/usr/local/cpanel/3rdparty/bin/perl <(curl -s https://cpaneltech.ninja/cptech/servicechk)" # chkrootservers - quickly check root servers dig results alias chkrootservers='for i in a b c d e f g h i j k l m; do echo -n "checking root server $i "; dig ${i}.root-servers.net +short ; done;' # Run msp alias msp="curl -s https://raw.githubusercontent.com/CpanelInc/tech-SSE/master/msp.pl | /usr/local/cpanel/3rdparty/bin/perl - --queue --auth --rotated --conf --verbose" # ttfb ttfb() { (DOMAIN=$1 ; curl -s -w 'Testing Website Response Time for: %{url_effective}\n\nLookup Time:\t\t%{time_namelookup}\nConnect Time:\t\t%{time_connect}\nPre-transfer Time:\t%{time_pretransfer}\nStart-transfer Time:\t%{time_starttransfer}\n\nTotal Time:\t\t%{time_total}\n' -o /dev/null https://$DOMAIN) } # ttfb-sniff ttfbsniff() { (read -p "Domain Name: " DOMAIN ; sniff=$(curl -s https://cpaneltech.ninja/cptech/sniff2.txt) ; date; echo ; curl -w "$sniff" -o /dev/null -s https://${DOMAIN}) } # Display current AutoSSL Provider alias autoSSLProvider="whmapi1 get_autossl_providers | grep -A1 'enabled: 1' | grep 'module_name' | sed 's/ module_name:/Current Provider:/' " # cancelSSLorder $order_item_id cancelSSLorder() { (ORDERNUM=$1; /usr/local/cpanel/3rdparty/bin/sqlite3 /var/cpanel/autossl_queue_cpanel.sqlite "DELETE FROM requests WHERE order_item_id='$ORDERNUM';") } # look for symlink hacks alias chkforsymlinks="find /home/*/public_html -type l -lname / -ls" # sessWHM - Create a user session for the root or reseller user sessWHM() { ( CPUSER=$1; whmapi1 create_user_session locale=en service=whostmgrd user=$CPUSER | grep url | cut -d ' ' -f4 ) } # sesscPanel - Create a user session for a cPanel user sesscPanel() { (CPUSER=$1;whmapi1 create_user_session locale=en service=cpaneld user=$CPUSER | grep url | cut -d ' ' -f4 ) } # sessWebmail - Create a user session for an email address sessWebmail() { (EMAIL=$1;whmapi1 create_user_session locale=en service=webmaild user=$EMAIL | grep url | cut -d ' ' -f4 ) } # All 3 session options above: sessAll() { HOSTNAME="$(whmapi1 gethostname |awk '/hostname:/ {print $2}')"; PUBLIC_IP="$(whmapi1 listips |grep -A3 "mainaddr: 1" |awk '$1 ~ /public_ip/ {print $2}')"; read -p "User/Email Address: " USER; select SERVICE in cpaneld whostmgrd webmaild; do whmapi1 create_user_session user=${USER} service=${SERVICE} locale=en |sed s/$HOSTNAME/$PUBLIC_IP/ |grep -Po "(?<=url: )[^ ]+"; break; done } # DirtyCow check alias DirtyCowChk="/usr/bin/perl <(curl -s https://cpaneltech.ninja/cptech/dirtycowchk)" # depunify - convert punycode URL back to IDN - returns Invalid Punycode if it fails. alias depunify="/usr/bin/perl <(curl -s https://cpaneltech.ninja/cptech/depunify )" # trs - Google Translate from command line - https://github.com/soimort/translate-shell alias trs="gawk -f <(curl -Ls git.io/translate) -- -b " # gettestssl.sh alias gettestssl="echo 'Cloning testssl.sh from git' && mkdir -p /root/cptechs && cd /root/cptechs && git clone https://github.com/drwetter/testssl.sh.git && echo ' - Done (installed in /root/cptechs/testssl.sh)' && cd /root/cptechs/testssl.sh" # getswaks alias getswaks="echo -n 'Downloading swaks' && curl -sk http://www.jetmore.org/john/code/swaks/files/swaks-20170101.0/swaks> /root/swaks && chmod 755 /root/swaks && echo ' - Done'" # Get rebuildwebalizerhist script alias getrebuildwebalizerhist="echo -n 'Downloading rebuild_webalizer_hist' && curl -s https://raw.githubusercontent.com/cPanelPeter/rebuild_webalizer_hist/master/rebuild_webalizer_hist > /root/rebuild_webalizer_hist && chmod 755 /root/rebuild_webalizer_hist && echo ' - Done'" # Get sys-snap v2 alias getsyssnap="echo -n 'Downloading sys-snap v2' && curl -s https://raw.githubusercontent.com/cPanelInc/tech-SysSnapv2/master/sys-snap.pl > /root/sys-snap.pl && chmod 755 /root/sys-snap.pl && echo ' - Done'" # Get webstatsprobe alias getwebstats="echo -n 'Downloading webstatsproble' && curl -s https://raw.githubusercontent.com/cPanelInc/tech-WebStatsProbe/master/webstatsprobe.pl > /root/webstatsprobe && chmod 755 /root/webstatsprobe && echo ' - Done'" # dcvcheck alias dcvcheck='echo | curl --user-agent "COMODO DCV" --insecure --max-time 10 --retry 0 --cipher RC4:ALL:\!EXPORT:\!EXPORT40:\!EXPORT56:\!aNULL:\!LOW:@STRENGTH ' newdcvcheck() { ( DOMAIN=$1 ; IPADDR=$(dig ${DOMAIN} +short) ; TXT=$2 ; echo "Checking ${DOMAIN} [ ${IPADDR} ]" ; curl -s --user-agent "Sectigo DCV"--insecure --max-time 10 --retry 0 --cipher RC4:ALL:\!EXPORT:\!EXPORT40:\!EXPORT56:\!aNULL:\!LOW:@STRENGTH -H "${DOMAIN}" "http://${IPADDR}/.well-known/pki-validation/${TXT}" ) } # listsans - list Subject Alternative Names (SAN's) from an SSL certificate. listsans() { ( DOMAIN=$1 ; echo | openssl s_client -connect $DOMAIN:443 -servername $DOMAIN <<&1 | openssl x509 -noout -text | grep -oP '(?<=DNS:)[a-z0-9.-]+' ) } # sslcheck - get data for a domain and port (443/2083/2087) sslcheck() { ( DOMAIN=$1;PORT=$2; echo | openssl s_client -connect ${DOMAIN}:${PORT} -servername ${DOMAIN} -showcerts <</dev/null | openssl x509 -noout -issuer -subject -dates) } # rdap (whois replacement) # See: https://www.openrdap.org/api rdap() { ( DOMAIN=$1 ; curl -sL https://www.rdap.net/domain/${DOMAIN} | python -mjson.tool ) } # ocspcheck - Check for revoked SSL certs using OCSP ocspcheck() { ( DOMAIN=$1 ; echo | openssl s_client -connect $DOMAIN:443 -servername $DOMAIN -status <<&1 | egrep ' OCSP Response Status:|Response Type:|Cert Status:|OCSP response:' ) } # serverstat - get server environment serverstat() { (echo; TIER=$(grep -i cpanel= /etc/cpupdate.conf | cut -d'=' -f2); echo "cPanel Version: $(cat /usr/local/cpanel/version) (Release tier: ${TIER^})"; echo "OS: $(cat /etc/redhat-release)"; echo "Kernel: $(uname -r)"; echo "Arch: $(uname -m)"; echo "Environment: $(cat /var/cpanel/envtype)"; echo "CPU: $(grep 'model name' /proc/cpuinfo | head -1 | cut -d':' -f2) w/ $(nproc) cores"; echo "Uptime: $(uptime)"; echo ) } # quickOFACchk alias quickOFACchk="egrep '\.ir:|\.cu:|\.kp:|\.sy:' /etc/userdomains" # Run rblcheck alias rblcheck="/usr/local/cpanel/3rdparty/bin/perl <(curl -s https://raw.githubusercontent.com/cPanelPeter/rblcheck/master/rblcheck)" # Run showIP (port 80) alias showIP="curl -s http://myip.cpanel.net/v1.0/ ; echo" # Run showIP2089 (port 2089) alias showIP2089="curl -s http://myip.cpanel.net:2089/v1.0/ ; echo" # Check IP address verify... alias verifyIP="read -p 'IP: ' ip ; curl -s https://verify.cpanel.net/api/ipaddrs?ip=$ip | json_pp" # Run whm-server-status alias whm-server-status="lynx --dump http://localhost/whm-server-status" # sqlite pragma check SQLiteChk() { ( DB=$1 ; /usr/local/cpanel/3rdparty/bin/sqlite3 $DB "pragma integrity_check;" ) }; # licenselog - less on the license_log file alias licenselog="less /usr/local/cpanel/logs/license_log" # pphist - prettyprint .bash_history (including cPanel analyst history files) pphist() { ( IFS=$'\t'; for i in "$@"; do cat "$i" | perl -e 'my $lastts=0;$login=0;while(<>) { chomp; if(/^#((?:\d){10})$/) { $lastts=$1; } elsif (m,^(export (PS1|LANG|HISTFILE|HISTFILESIZE)=.+|if \[ -x /scripts/autorepair.+|uname -a|alias rm=.echo .Are you sure.+|curl https://ssp.cpanel.net/run.sh|echo -ne ..033.0;cPTKT.+)$,) { $login=1; } else { print "\n" if($login);$login=0;print "".localtime($lastts)." $_\n";} }'; done ) } # cp_license_troubleshooter - now preset in pacha/macha alias cplicensets="/usr/local/cpanel/3rdparty/bin/perl <(curl -s https://raw.githubusercontent.com/CpanelInc/tech-cp_license_troubleshooter/master/cplicensets)" # get cpversion info. alias cpversion="cat /usr/local/cpanel/version" # showlscpu alias showlscpu="lscpu | grep -E '^(Thread|Core|Socket|CPU\(|MHz|Vendor ID|Model name:|Hypervisor)'" #gzipchk - Gzip Compression Check gzipchk(){ DOMAIN=$1 ; curl --compress -v https://$DOMAIN -o /dev/null 2>&1 | egrep -q 'Content-Encoding' && echo "gzip compression enabled for $DOMAIN" || echo "gzip compression not enabled for $DOMAIN" ; curl -sL -w "%{url_effective} bytes downloaded without compression: %{size_download}\n" -o /dev/null "$@" && curl -sLH "Accept-Encoding: gzip,deflate" -w "%{url_effective} bytes downloaded with compression: %{size_download}\n" -o /dev/null "$@"; } # cpanel debug mode # NEED TO ADD CHECKS TO MAKE SURE THIS CAN BE DONE OR NOT. #alias cpsrvddebugmode="echo '3' > /var/cpanel/debughooks && /usr/local/cpanel/scripts/restartsrv_cpsrvd --hard" #alias cpsrvdprodmode="rm -fv /var/cpanel/debughooks && /usr/local/cpanel/scripts/restartsrv_cpsrvd --hard" # helpalias alias helpalias="echo \" COMMON ALIASES ================================================================ backupPass - Decode the backup destination FTP password and display it cpversion - Display cPanel Version dir - list directories only getswaks - Download the swaks SMTP script from http://www.jetmore.org/john/code/swaks gzipchk - Check for compression (Content-Encoding) of a website (Usage: gzipchk http://cpanel.net) ttfb - Time To First Byte check. (Usage: ttfb domainname.tld) ttfbsniff - Time To First Byte check (Using full sniff.txt file). ll - list files in human readable format nsrecordreport - runs ns_record_report.sh from cPanelTechs TechScripts on github pphist - Prety print analyst /root/.bash_history.cpanel_ticket.nnnnnnnn file quickOFACchk - Quickly grep for any domains in /etc/trueuserdomains that are on OFAC serverstat - Get Environment information. whm-server-status - runs lynx --dump http://localhost/whm-server-status trs - Google Translate: [trs Olá | echo 'Hello, my name is Peter' | trs :es] SQLiteChk - Check SQLite database for corruption using pragma integrity_check. servicechk - Quickly check all services (Installed, Enabled, Monitored, Running) ================================================================ COMMON PROGRAMS TO HELP IN DEBUGGING: ================================================================ bugreport (Print bugreport template from ssp for use in JIRA [CPANEL/EA]) docreport (Print docreport template from ssp for use in JIRA [DOCS]) getrebuildwebalizerhist - Download rebuild_webalizer_hist to /root getsyssnap - Download sys-snap.pl to /root getwebstats - Download webstats probe to /root msp - Mail Status Probe ssp - default ssp (live and in person) sspdevel - New ssp development (not yet live) sspprev - Previous version of SSP (before update) port25chk - Check if port 25 is blocked. port25chk mx1.cpanel.net port53chk - Check if port 53 (tcp/udp) is blocked. nmap MUST be installed! fastupdatechk - FastUpdate Check to determine if server is ready for inclusion into FastUpdate Trusted Rotation ticketkey - obtain the ticket ssh key for a ticket and server CCSConnect - Quickly connect to CCS Calendar Server (PostgreSQL) getMailQuota - Quickly get the email quota (using doveadm) for an email address inotify-watches - Get procs sorted by number of inotify watches showlscpu - Show important info from the lscpu command verchk - Check installed packagename and display version (regardless of OS). Usage: verchk openssl or verchk ea-apache24 verifyIP - Check an IP address against verify.cpanel.net (json output). easyapachebuddy - EasyApache Buddy script for cPanel servers (based off of apachebuddy2.pl) ================================================================ SECURITY ================================================================ getcsi - Download CSI (cPanel Security Investigator) DirtyCowChk - Check to see if kernel is patched against DirtyCow (Checks Virtuozzo Kernel Also!) rblcheck - Peter's (very old) RBL Check (rblcheck --help) vtcheck - Get sha512sum hash, size, RPM status, last changed date and create virustotal.com link. sendtoVT - Send a file to VirusTotal.com to be scanned. sendtoVT /path/to/file (L3's ONLY!) chkforsymlinks - Simple find command to check /home/*/public_html for symlink hacks. genpass - Quickly generate a random password addHackTF - Add hacked server touchfiles (L3 Only) listHackTF - List hacked touchfiles (if they exist - L3 Only) cvecheck - Quick check of possible CVE's found - Uses CSI's cve_data.json file. secheaders - Quickly check a sites security headers and make recommendations. Usage: secheaders $domainame.tld hashcheck - Use it to get a quick check on whether a sha256hash is malicious or not gsbchk - Use to check a domain name against Google Safe Browsing. gsbchk domainname.tld (will return 0 if safe and 1 if not safe) ================================================================ SESSIONS ================================================================ sessWHM cPanelUsername - Create a WHM user session as the root or reseller user (Servers hostname) sesscPanel cPanelUsername - Create a cPanel user session as the cPanelUsername (Servers hostname) (Example: sesscPanel cptest) sessWebmail EmailAddress - Create a webmail session for EmailAddress (Servers hostname) (Example: sessWebmail testing@cptest.tld) sessAll: Prompt for user or Email address and service and generate the URL (all 3 above). No idea who came up with this, but nice! ================================================================ LICENSE ================================================================ chkrootservers = Quick test to check if root servers can be reached. licenselog - Run less command on /usr/local/cpanel/logs/license_log showIP - Run https://myip.cpanel.net on port 80 showIP2089 - Run https://myip.cpanel.net on port 2089 ================================================================ SSL ================================================================ autoSSLProvider - Display current AutoSSL Provider dcvcheck - Run a DCV (autossl) check from customers server (dcvcheck http://domain.tld/XXXXX.txt) newdcvcheck - Run a DCV (autossl) check (pass domain name and hash file name) Example: newdcvcheck mydomain.tld 003ED937093B9181BA4542952C82A08A.txt gettestssl - Download and run the latest testssl.sh. listsans - List SAN's from an SSL certificate: listsans domainname.tld sslcheck - Show issuer, subject and dates for domainname.tld port number (sslcheck domainname.tld 443) ocspcheck - Check for revoked SSL Certificates using OCSP depunify - Convert punycode URL back to IDN. cancelSSLorder - Cancel an SSL order ID (cancelSSLorder $order_item_id) pubsufchk - Check a TLD against the public suffix list rdap - RDAP is a whois replacement returns data in JSON format. (Usage: rdap domainname.tld) mixedContent - Check a domain/site to see if it has any http:// links which would cause SSL failures (Mixed Content) url_encode - URL Encode a file. ================================================================ MIGRATION ================================================================ getcpeval2 - cpeval2 (for migrations) (Maintained by Chris Dillon) chkTransfers - List Transfer Sessions not yet completed (state !=100) abortTransfer sessionid - Sets the state to 150 for a sessionid in whmxfer.sqlite ================================================================ The following variables are also active... TICKET = Type echo \\\$TICKET and you will get the ticket number EDITOR and VISUAL have been set to vi - for use with crontabs, vipw, visudo, etc... \"" echo "Aliases have been set ($VER)" echo "" echo "type: helpalias - to list a description of each" echo "" if [ ${TICKET} ] then echo "Ticket #: $TICKET" fi