├── .github └── FUNDING.yml ├── LICENSE.txt ├── README.md ├── domain-check-2.sh └── domain-list.txt /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: click0 2 | custom: "https://www.buymeacoffee.com/click0" 3 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | This program is distributed in the hope that it will be useful, 2 | but WITHOUT ANY WARRANTY; without even the implied warranty of 3 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 4 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Domain Expiration Check Shell Script 2 | ==================================== 3 | A simple shell script to display or notify the user via email about domain status and expiry date. 4 | 5 | Installation: 6 | ------------- 7 | Use the curl or wget command to grab script as follows: 8 | 9 | ``` 10 | $ wget https://raw.githubusercontent.com/click0/domain-check-2/master/domain-check-2.sh 11 | ## [ sample domain list for testing purpose ] ## 12 | $ wget https://raw.githubusercontent.com/click0/domain-check-2/master/domain-list.txt 13 | ## [ install it in /usr/local/bin dir ] ## 14 | $ sudo cp -vf domain-check-2.sh /usr/local/bin/domain-check-2 15 | $ sudo chmod +x /usr/local/bin/domain-check-2 16 | ``` 17 | Requirements: 18 | - 19 | Requires `whois`, `curl` (for domains in the .kz zone), `mail` (mailutils). 20 | 21 | Usage: 22 | ------ 23 | Run it as follows: 24 | ``` 25 | $ domain-check-2 -d google.com 26 | $ domain-check-2 -f domain-list.txt 27 | $ domain-check-2 -f domain-list.txt -a -e admin@my-cool-domain.com 28 | ``` 29 | Sample outputs: 30 | ``` 31 | Domain Registrar Status Expires Days Left 32 | ----------------------------------- ---------------------------------------------- -------- ----------- --------- 33 | nixcraft.com NameCheap, Inc. Valid 10-may-2024 756 34 | google.org MarkMonitor Inc. Valid 20-oct-2022 188 35 | google.net MarkMonitor Inc. Valid 15-mar-2023 334 36 | google.info MarkMonitor Inc. Valid 31-jul-2022 107 37 | cyberciti.biz NameCheap, Inc. Valid 30-jun-2025 1172 38 | google.in MarkMonitor Inc. Valid 14-feb-2023 305 39 | google.co.in MarkMonitor Inc. Valid 23-jun-2022 69 40 | google.us MarkMonitor, Inc. Valid 18-apr-2023 368 41 | google.uk Markmonitor Inc. Valid 11-Jun-2022 57 42 | google.co.uk Markmonitor Inc. Valid 14-Feb-2023 305 43 | google.jp Google LLC Valid 31-may-2022 46 44 | google.cz REG-MARKMONITOR Valid 22-jul-2022 98 45 | google.pl Markmonitor,Inc. Valid 18-sep-2022 156 46 | google.co MarkMonitor, Inc. Valid 24-feb-2023 315 47 | google.ru RU-CENTER-RU Valid 04-mar-2023 323 48 | google.blog MarkMonitor, Inc Valid 19-aug-2022 126 49 | linux.cafe Porkbun LLC Valid 14-nov-2022 213 50 | google.co MarkMonitor, Inc. Valid 24-feb-2023 315 51 | dotmobi.mobi CSC Corporate Domains, Inc. Expiring 11-may-2022 26 52 | google.me MarkMonitor Inc. Valid 13-jun-2022 59 53 | google.us MarkMonitor, Inc. Valid 18-apr-2023 368 54 | google.su RUCENTER-SU Valid 15-oct-2022 183 55 | youtube.tv MarkMonitor Inc. Valid 14-aug-2022 121 56 | abc.xyz MarkMonitor, Inc (TLDs) Valid 20-mar-2025 1070 57 | google.se MarkMonitor Inc Valid 20-oct-2022 188 58 | google.dk DK Hostmaster A/S Valid 31-mar-2023 350 59 | ``` 60 | [Setup Unix/Linux cron job](https://www.cyberciti.biz/faq/how-do-i-add-jobs-to-cron-under-linux-or-unix-oses/) as follows to get email notification to send expiration notices: 61 | 62 | ``` 63 | @daily /path/to/domain-check-2.sh -f /path/to/your-domains.txt -a -e you@example.com 64 | ``` 65 | Getting help 66 | ------------ 67 | ``` 68 | $ domain-check-2.sh -h 69 | Usage: domain-check-2.sh [ -e email ] [ -x expir_days ] [ -q ] [ -a ] [ -h ] [ -v ] [ -V ] 70 | [ -s whois_server ] {[ -d domain_name ]} || { -f domainfile} 71 | 72 | -a : Send a warning message through email 73 | -d domain : Domain to analyze (interactive mode) 74 | -e email address : Email address to send expiration notices 75 | -f domain file : File with a list of domains 76 | -h : Print this screen 77 | -s whois server : Whois sever to query for information 78 | -q : Don't print anything on the console 79 | -x days : Domain expiration interval (eg. if domain_date < days) 80 | -v : Show debug information when running script 81 | -V : Print version of the script 82 | ``` 83 | 84 | Authors: 85 | -------- 86 | * Origianl Author: Matty < matty91 at gmail dot com > https://github.com/Matty9191 87 | * Forked by nixCraft https://www.cyberciti.biz/tips/domain-check-script.html 88 | * Forked and maintained by Vladislav V. Prodan 89 | 90 | ## 🤝 Contributing 91 | 92 | Contributions, issues and feature requests are welcome!
Feel free to check [issues page](https://github.com/click0/domain-check-2/issues). 93 | 94 | ## Show your support 95 | 96 | Give a ⭐ if this project helped you! 97 | 98 | Buy Me A Coffee 99 | -------------------------------------------------------------------------------- /domain-check-2.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # 4 | # Program: Domain Expiration Check 5 | # 6 | # Author: Matty < matty91 at gmail dot com > 7 | # Co-author: Vladyslav V. Prodan 8 | # 9 | # Current Version: 2.73 10 | # Last Updated: 11-Feb-2025 11 | # 12 | # Revision History: 13 | # Version 2.73 14 | # Fixed support for .dk TLD without registrar info -- Lasse Glerup 15 | # 16 | # Version 2.72 17 | # Fixed support for .md/.ps TLDs. -- Vladyslav V. Prodan 18 | # 19 | # Version 2.71 20 | # Fixed support for .kr TLD. -- Vladyslav V. Prodan 21 | # 22 | # Version 2.70 23 | # Fixed support for .sg domain -- Vladyslav V. Prodan 24 | # 25 | # Version 2.69 26 | # Fixed support for .sk/.bm TLDs. -- Vladyslav V. Prodan 27 | # 28 | # Version 2.68 29 | # Fixed support for .md domain -- Vladislav V. Prodan 30 | # 31 | # Version 2.67 32 | # Added support for sn/.st/.th/.co.th/.by/.ps TLDs. -- Vladislav V. Prodan 33 | # 34 | # Version 2.66 35 | # Added support for .ee/.pk/.biz.ua/.gov.uk/.co.ua/.pp.ua TLDs. -- Vladislav V. Prodan 36 | # Code optimization with minor bug fixes. 37 | # Optimization to get rid of long lines in the code. 38 | # 39 | # Version 2.65 40 | # Added support for .co.jp domain -- Vladislav V. Prodan 41 | # 42 | # Version 2.64 43 | # Removed whitespace escape for awk. 44 | # Fixed registrar output formatting for some domain zones. 45 | # 46 | # Version 2.63 47 | # Removed the check for the existence of the mail client binary if the script does not use mail notification. 48 | # 49 | # Version 2.62 50 | # Added support for .bm domain -- Vladislav V. Prodan 51 | # 52 | # Version 2.61 53 | # The list of requirements has been corrected and added to the project description. 54 | # 55 | # Version 2.60 56 | # Added support for .cf domain -- Vladislav V. Prodan 57 | # Simplified checking for .dk/.tr/.xyz/.fi/.fr zones. 58 | # Fixed typos. 59 | # 60 | # Version 2.59 61 | # Fixed support for .md/.kz domains -- Vladislav V. Prodan 62 | # Fixed typos. 63 | # 64 | # Version 2.58 65 | # Fixed support for .com.ar/.ar domains -- Axel Vasquez 66 | # 67 | # Version 2.57 68 | # Fixed partial support for .md domain -- Vladislav V. Prodan 69 | # Fixed typos. 70 | # 71 | # Version 2.56 72 | # Added data output in CSV format -- Vladislav V. Prodan 73 | # 74 | # Version 2.55 75 | # Fixed support for .md/.id/.kz/.uk domains -- Vladislav V. Prodan 76 | # Fixed typos. 77 | # 78 | # Version 2.54 79 | # Fixed checking on the existence of binary files of the necessary programs for the script to work. 80 | # 81 | # Version 2.53 82 | # Added support for .kr/.hk/.pt/.sg domains -- @copenhaus 83 | # 84 | # Version 2.52 85 | # Added work with specific whois servers. 86 | # Fixed display of the registrar name in the .uk domain zone. 87 | # Partially added .gg domain zone, but it does not display the year. 88 | # Fixed typos. 89 | # 90 | # Version 2.51 91 | # Added support for .rs/.am/.xin/ domains -- Vladislav V. Prodan 92 | # Fixed typos. 93 | # 94 | # Version 2.50 95 | # Added support for .tg/.co.il/.net.il/.org.il domains -- Vladislav V. Prodan 96 | # Added an additional function to change to the desired date format. 97 | # Fixed display of the registrar in the .cn/.edu domains. 98 | # 99 | # Version 2.49 100 | # Added support for .com.br domain -- Vladislav V. Prodan 101 | # 102 | # Version 2.48 103 | # Added support for .team/.app/.host/.website domains -- Vladislav V. Prodan 104 | # Fixed length of registrar name for .edu domain 105 | # Merged some checks 106 | # 107 | # Version 2.47 108 | # Added support for .do domain -- rk00t 109 | # 110 | # Version 2.46 111 | # Spaces, tabs and blank lines in the domain list file are now ignored -- Vladislav V. Prodan 112 | # Commenting on domains with the # symbol also began to work -- Vladislav V. Prodan 113 | # 114 | # Version 2.45 115 | # Added support for .game domain -- Vladislav V. Prodan 116 | # 117 | # Version 2.44 118 | # Fixed status when expiration date is wrongly detected (sometimes can be described as not defined) -- https://github.com/hawkeye116477 119 | # Added support for .today domain -- https://github.com/hawkeye116477 120 | # 121 | # Version 2.43 122 | # Added support for .id domain -- Menthol Date 123 | # 124 | # Version 2.42 125 | # Fixed support for .jp domain -- Tozapid 126 | # Added support for .xxx domain -- Tozapid 127 | # 128 | # Version 2.41 129 | # Added support for .stream domain -- https://github.com/hawkeye116477 130 | # Fixed condition with whois -- https://github.com/hawkeye116477 131 | # 132 | # Version 2.40 133 | # Partial syntax fixes in the script -- Vladislav V. Prodan 134 | # 135 | # Version 2.39 136 | # Added support for .club domain -- https://github.com/hawkeye116477 137 | # 138 | # Version 2.38 139 | # Added support for .sk domain -- https://github.com/hawkeye116477 140 | # Fixed displaying of some long registrars -- https://github.com/hawkeye116477 141 | # Fixed support for .jp domain -- https://github.com/hawkeye116477 142 | # 143 | # Version 2.37 144 | # Added support for .live domain -- https://github.com/hawkeye116477 145 | # 146 | # Version 2.36 147 | # Added support for .museum domain -- Bryan Clay 148 | # 149 | # Version 2.35 150 | # Added support for .fun domain -- https://github.com/hawkeye116477 151 | # 152 | # Version 2.34 153 | # Added support for .укр domain -- Vladislav V. Prodan 154 | # 155 | # Version 2.33 156 | # Added support for .co.pl domain -- https://github.com/hawkeye116477 157 | # Fixed version variable -- https://github.com/hawkeye116477 158 | # 159 | # Version 2.32 160 | # Fixed support for .ca domain -- https://github.com/hawkeye116477 161 | # Added support for .space domain -- https://github.com/hawkeye116477 162 | # 163 | # Version 2.31 164 | # Added support for .expert/.express domains -- https://github.com/hawkeye116477 165 | # 166 | # Version 2.30 167 | # Added option to display the version of the script -- Vladislav V. Prodan 168 | # Added option to show debug information when running script -- Vladislav V. Prodan 169 | # 170 | # Version 2.29 171 | # Partial syntax fixes in the script -- Vladislav V. Prodan 172 | # Partially removed extra disk read operations --Vladislav V. Prodan 173 | # 174 | # Version 2.28 175 | # Added support for .systems domain and fixed status when expiration date isn't detected -- https://github.com/hawkeye116477 176 | # Fixed status when expiration date isn't detected -- https://github.com/hawkeye116477 177 | # 178 | # Version 2.27 179 | # Added support for .is/.cloud domains -- https://github.com/hawkeye116477 180 | # 181 | # Version 2.26 182 | # Added support for .icu domain -- https://github.com/hawkeye116477 183 | # 184 | # Version 2.25 185 | # Added support for .bid/.ng/.site domains -- https://github.com/hawkeye116477 186 | # 187 | # Version 2.24 188 | # Added support for .app/.top domains -- Vladislav V. Prodan 189 | # Fixed support for .io/.xyz/.me/.pl/.ro domains -- Vladislav V. Prodan 190 | # 191 | # Version 2.23 192 | # Added support for .online domain -- https://github.com/hawkeye116477 193 | # 194 | # Version 2.22 195 | # Added support for .kz domains -- Vladislav V. Prodan 196 | # Many thanks to the service that provided the API for the .KZ zone - https://www.ps.kz/ 197 | # 198 | # Version 2.21 199 | # Fixed support for .pl domain -- https://github.com/hawkeye116477 200 | # 201 | # Version 2.20 202 | # Fixed support for .jp/.aero/.cn/.pl/.md/.tr/.it/.mx domains -- Vladislav V. Prodan 203 | # 204 | # Version 2.19 205 | # Added support for .ua/.cn/.io domains -- Vladislav V. Prodan 206 | # Fixed support for .pl domain -- Vladislav V. Prodan 207 | # 208 | # Version 2.18 209 | # Added support for .pro/.mx/.ro/.aero/.asia/.cc/.college domain -- Vivek Gite 210 | # Added support for .it domain -- https://github.com/pelligrag 211 | # Fixed support for .in/.md/.cafe/.fr/.re/.tf/.yt/.pm/.wf/.cat domain -- Vivek Gite 212 | # 213 | # Version 2.17 214 | # Fixed suport for .co domain -- Vivek Gite 215 | # 216 | # Version 2.16 217 | # Added suport for .tr domain -- https://github.com/eaydin 218 | # 219 | # Version 2.15 220 | # Fixed suport for .jp domain -- Vivek Gite 221 | # 222 | # Version 2.14 223 | # Added support for .se/.nu/.dk/.xyz and bug fix by -- https://github.com/happyoccasion 224 | # 225 | # Version 2.13 226 | # Fiexed suport for .biz/.us/.mobi/.tv domains -- Vivek Gite 227 | # 228 | # Version 2.12 229 | # Added suport for Czechia (.cz) domains -- Minitram 230 | # 231 | # Version 2.11 232 | # Added support for .cafe/.blog/.link domain -- 233 | # 234 | # Version 2.10 235 | # Bug fix for .com, net, org, jp, and edu -- Vivek Gite 236 | # 237 | # Version 2.9 238 | # Bug fix for .ru -- Mikhail Grigorev 239 | # 240 | # Version 2.8 241 | # Use 'which' to autodetect awk, whois, date and other utils -- Mikhail Grigorev 242 | # 243 | # Version 2.7 244 | # Bug fix for .md and .co -- Bill Bell 245 | # 246 | # Version 2.6 247 | # Bug fix for .mobi -- Bill Bell 248 | # 249 | # Version 2.5 250 | # Bug fix for .me -- Mikhail Grigorev 251 | # 252 | # Version 2.4 253 | # Bug fix for .com, .net, .us, .org, .in -- Mikhail Grigorev 254 | # 255 | # Version 2.3 256 | # Bug fix for .info -- Mikhail Grigorev 257 | # 258 | # Version 2.2 259 | # Bug fix that adds support for .ru and .su domains -- Jim McNamara 260 | # 261 | # Version 2.1 262 | # Bug fix for .mobi and .us -- Jim McNamara 263 | # Added a variable for the location of tr, and made all calls to cut and tr use the variable 264 | # instead of the command without path 265 | # 266 | # Version 2.0 267 | # Bug fix for .org, .biz, info, and .ca -- Cameron and Jim 268 | # 269 | # Version 1.9 270 | # Bug fix and enhancement for .uk and .co.uk -- Vivek Gite 271 | # 272 | # Version 1.8 273 | # Bug fix added $MAIL -- Vivek Gite 274 | # 275 | # Version 1.7 276 | # Added support for .jp domain names -- Vivek Gite 277 | # 278 | # Version 1.6 279 | # Added support for .uk domain names; fixed a bug detecting tldtype -- Vivek Gite 280 | # 281 | # Version 1.5 282 | # Added support for .org, .in, .biz and .info domain names -- Vivek Gite 283 | # 284 | # Version 1.4 285 | # Updated the documentation. 286 | # 287 | # Version 1.3 288 | # Gracefully Handle the case where the expiration data is unavailable 289 | # 290 | # Version 1.2 291 | # Added "-s" option to allow arbitrary registrars 292 | # 293 | # Version 1.1 294 | # Fixed issue with 'e' getopt string -- Pedro Alves 295 | # 296 | # Version 1.0 297 | # Initial Release 298 | # 299 | # 300 | # Purpose: 301 | # domain-check checks to see if a domain has expired. domain-check 302 | # can be run in interactive and batch mode, and provides faciltities 303 | # to alarm if a domain is about to expire. 304 | # 305 | # License: 306 | # This program is distributed in the hope that it will be useful, 307 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 308 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 309 | # 310 | # Notes: 311 | # Since each registrar provides expiration data in a unique format (if 312 | # they provide it at all), domain-check is currently only able to 313 | # processess expiration information for a subset of the available 314 | # registrars. 315 | # 316 | # Requirements: 317 | # Requires whois, curl (for domains in the .kz zone), mail (mailutils) 318 | # 319 | # Installation: 320 | # Copy the shell script to a suitable location 321 | # 322 | # Tested platforms: 323 | # -- Solaris 9 using /bin/bash 324 | # -- Solaris 10 using /bin/bash 325 | # -- OS X 10.4.2 using /bin/sh 326 | # -- OpenBSD using /bin/sh 327 | # -- FreeBSD using /bin/sh 328 | # -- Redhat advanced server 3.0MU3 using /bin/sh 329 | # 330 | # Usage: 331 | # Refer to the usage() sub-routine, or invoke domain-check 332 | # with the "-h" option. 333 | # 334 | # Example: 335 | # 336 | # The first example will print the expiration date and registrar for prefetch.net: 337 | # 338 | # $ domain-check.sh -d prefetch.net 339 | # 340 | # Domain Registrar Status Expires Days Left 341 | # ----------------------------------- ----------------- -------- ----------- --------- 342 | # prefetch.net INTERCOSMOS MEDIA Valid 13-feb-2006 64 343 | # 344 | # The second example prints the expiration date and registrar for the domains 345 | # listed in the file "domains": 346 | # 347 | # $ domain-check.sh -f domains 348 | # 349 | # Domain Registrar Status Expires Days Left 350 | # ----------------------------------- ----------------- -------- ----------- --------- 351 | # sun.com NETWORK SOLUTIONS Valid 20-mar-2010 1560 352 | # google.com EMARKMONITOR INC. Valid 14-sep-2011 2103 353 | # ack.com NETWORK SOLUTIONS Valid 09-may-2008 880 354 | # prefetch.net INTERCOSMOS MEDIA Valid 13-feb-2006 64 355 | # spotch.com GANDI Valid 03-dec-2006 357 356 | # 357 | # The third example will e-mail the address admin@prefetch.net with the domains that 358 | # will expire in 60-days or less: 359 | # 360 | # $ domain-check -a -f domains -q -x 60 -e admin@prefetch.net 361 | # 362 | 363 | PATH=/bin:/usr/bin:/usr/local/bin:/usr/local/ssl/bin:/usr/sfw/bin 364 | export PATH 365 | 366 | # Who to page when an expired domain is detected (cmdline: -e) 367 | ADMIN="sysadmin@mydomain.com" 368 | 369 | # Number of days in the warning threshhold (cmdline: -x) 370 | WARNDAYS=30 371 | 372 | # If QUIET is set to TRUE, don't print anything on the console (cmdline: -q) 373 | QUIET="FALSE" 374 | 375 | # Don't send emails by default (cmdline: -a) 376 | ALARM="FALSE" 377 | 378 | # Output the result in formatted (by default) or CSV format (csv) (cmdline: -o) 379 | OUTPUT_FORMAT="format" 380 | CSV_DELIMITER="," 381 | 382 | # Don't show the version of the script by default (cmdline: -V) 383 | VERSIONENABLE="FALSE" 384 | 385 | # Don't show debug information by default (cmdline: -vv) 386 | VERBOSE="FALSE" 387 | 388 | # Whois server to use (cmdline: -s) 389 | WHOIS_SERVER="whois.iana.org" 390 | 391 | # Location of system binaries 392 | for BINARY in whois date curl ; do 393 | if [ ! -x "$(command -v $BINARY)" ]; then 394 | echo "ERROR: The $BINARY binary does not exist in \$$BINARY." 395 | echo " FIX: Please modify the \$$BINARY variable in the program header." 396 | exit 1 397 | fi 398 | done 399 | 400 | AWK=$(command -v awk) 401 | WHOIS=$(command -v whois) 402 | DATE=$(command -v date) 403 | CUT=$(command -v cut) 404 | GREP=$(command -v grep) 405 | TR=$(command -v tr) 406 | CURL=$(command -v curl) 407 | ECHO=$(command -v echo) 408 | HEAD=$(command -v head) 409 | SED=$(command -v sed) 410 | TAIL=$(command -v tail) 411 | 412 | # Version of the script 413 | VERSION=$(${AWK} -F': ' '/^# Current Version:/ { print $2; exit}' $0) 414 | 415 | # User-Agent 416 | VARUSERAGENT="Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36" 417 | 418 | # Place to stash temporary files 419 | WHOIS_TMP="/var/tmp/whois.$$" 420 | WHOIS_2_TMP="/var/tmp/whois_2.$$" 421 | 422 | ############################################################################# 423 | # Purpose: Convert a date from MONTH-DAY-YEAR to Julian format 424 | # Acknowledgements: Code was adapted from examples in the book 425 | # "Shell Scripting Recipes: A Problem-Solution Approach" 426 | # ( ISBN 1590594711 ) 427 | # Arguments: 428 | # $1 -> Month (e.g., 06) 429 | # $2 -> Day (e.g., 08) 430 | # $3 -> Year (e.g., 2006) 431 | ############################################################################# 432 | date2julian() 433 | { 434 | if [ -n "${1}" ] && [ -n "${2}" ] && [ -n "${3}" ] 435 | then 436 | ## Since leap years add aday at the end of February, 437 | ## calculations are done from 1 March 0000 (a fictional year) 438 | d2j_tmpmonth=$((12 * ${3} + ${1} - 3)) 439 | 440 | ## If it is not yet March, the year is changed to the previous year 441 | d2j_tmpyear=$(( d2j_tmpmonth / 12)) 442 | 443 | ## The number of days from 1 March 0000 is calculated 444 | ## and the number of days from 1 Jan. 4713BC is added 445 | echo $(( (734 * d2j_tmpmonth + 15) / 24 - 2 * d2j_tmpyear + d2j_tmpyear/4 \ 446 | - d2j_tmpyear/100 + d2j_tmpyear/400 + ${2} + 1721119 )) 447 | else 448 | echo 0 449 | fi 450 | } 451 | 452 | ############################################################################# 453 | # Purpose: Convert a string month into an integer representation 454 | # Arguments: 455 | # $1 -> Month name (e.g., Sep) 456 | ############################################################################# 457 | getmonth() 458 | { 459 | LOWER=`tolower ${1}` 460 | 461 | case ${LOWER} in 462 | jan) echo 1 ;; 463 | feb) echo 2 ;; 464 | mar) echo 3 ;; 465 | apr) echo 4 ;; 466 | may) echo 5 ;; 467 | jun) echo 6 ;; 468 | jul) echo 7 ;; 469 | aug) echo 8 ;; 470 | sep) echo 9 ;; 471 | oct) echo 10 ;; 472 | nov) echo 11 ;; 473 | dec) echo 12 ;; 474 | *) echo 0 ;; 475 | esac 476 | } 477 | 478 | ############################################################################# 479 | # Purpose: Convert the month number into a short form for writing the month name 480 | # Arguments: 481 | # $1 -> Month number (e.g., 08) 482 | ############################################################################# 483 | getmonth_number() 484 | { 485 | case ${1} in 486 | 1|01) echo jan ;; 487 | 2|02) echo feb ;; 488 | 3|03) echo mar ;; 489 | 4|04) echo apr ;; 490 | 5|05) echo may ;; 491 | 6|06) echo jun ;; 492 | 7|07) echo jul ;; 493 | 8|08) echo aug ;; 494 | 9|09) echo sep ;; 495 | 10) echo oct ;; 496 | 11) echo nov ;; 497 | 12) echo dec ;; 498 | *) echo 0 ;; 499 | esac 500 | } 501 | 502 | ############################################################################# 503 | # Purpose: Calculate the number of seconds between two dates 504 | # Arguments: 505 | # $1 -> Date #1 506 | # $2 -> Date #2 507 | ############################################################################# 508 | date_diff() 509 | { 510 | if [ -n "${1}" ] && [ -n "${2}" ] 511 | then 512 | echo $((${2} - ${1})) 513 | else 514 | echo 0 515 | fi 516 | } 517 | 518 | ################################################################## 519 | # Purpose: Converts a string to lower case 520 | # Arguments: 521 | # $1 -> String to convert to lower case 522 | ################################################################## 523 | tolower() 524 | { 525 | LOWER=`echo ${1} | ${AWK} '{print tolower($0);}'` 526 | echo $LOWER 527 | } 528 | 529 | ################################################################## 530 | # Purpose: Access whois data to grab the registrar and expiration date 531 | # Arguments: 532 | # $1 -> Domain to check 533 | ################################################################## 534 | check_domain_status() 535 | { 536 | local REGISTRAR 537 | REGISTRAR="" 538 | # Avoid WHOIS LIMIT EXCEEDED - slowdown our whois client by adding 1 sec 539 | sleep 1 540 | # Save the domain since set will trip up the ordering 541 | local DOMAIN 542 | DOMAIN="${1}" 543 | local TLDTYPE 544 | TLDTYPE=$(echo "${DOMAIN}" | ${AWK} -F. '{print tolower($NF);}') 545 | if [ "x${TLDTYPE}" == "x" ]; 546 | then 547 | TLDTYPE=$(echo "${DOMAIN}" | ${AWK} -F. '{print tolower($(NF-1));}') 548 | fi 549 | if [ "${TLDTYPE}" == "ua" ] || [ "${TLDTYPE}" == "pl" ] || [ "${TLDTYPE}" == "br" ] || [ "${TLDTYPE}" == "jp" ] || \ 550 | [ "${TLDTYPE}" == "za" ] || \ 551 | [ "${TLDTYPE}" == "uk" ]; 552 | then 553 | local SUBTLDTYPE 554 | SUBTLDTYPE=$(echo "${DOMAIN}" | ${AWK} -F. '{print tolower($(NF-1)"."$(NF));}') 555 | fi 556 | 557 | # Invoke whois to find the domain registrar and expiration date 558 | # ${WHOIS} -h ${WHOIS_SERVER} "=${1}" > ${WHOIS_TMP} 559 | # Let whois select server 560 | 561 | local WHS 562 | if [ -n "${WHOIS_SERVER}" ] && [ "${WHOIS_SERVER}" == "whois.iana.org" ]; then 563 | WHS="$(${WHOIS} -h "${WHOIS_SERVER}" "${TLDTYPE}" | ${AWK} '/whois:/ {print $2}')" 564 | else 565 | WHS="${WHOIS_SERVER}" 566 | fi 567 | 568 | if [ -n "${WHOIS_SERVER}" ]; 569 | then 570 | # section for TLDTYPE 571 | [ "${TLDTYPE}" == "bm" ] && WHS="whois.nic.bm"; 572 | [ "${TLDTYPE}" == "ps" ] && WHS="95.217.44.246"; # Look output server here # https://www.pnina.ps/whois/ 573 | 574 | # section for SUBTLDTYPE 575 | [ "${SUBTLDTYPE}" == "co.pl" ] && WHS="whois.co.pl"; # added by @hawkeye116477 20190514 576 | [ "${SUBTLDTYPE}" == "ac.za" ] || [ "${SUBTLDTYPE}" == "co.za" ] || [ "${SUBTLDTYPE}" == "net.za" ] || \ 577 | [ "${SUBTLDTYPE}" == "org.za" ] || [ "${SUBTLDTYPE}" == "web.za" ] && \ 578 | WHS="whois.registry.net.za"; 579 | [ "${SUBTLDTYPE}" == "gov.za" ] && WHS="whois.gov.za"; 580 | [ "${SUBTLDTYPE}" == "gov.uk" ] && WHS="whois.gov.uk"; 581 | [ "${SUBTLDTYPE}" == "biz.ua" ] && WHS="whois.biz.ua"; 582 | [ "${SUBTLDTYPE}" == "co.ua" ] && WHS="whois.co.ua"; 583 | [ "${SUBTLDTYPE}" == "pp.ua" ] && WHS="whois.pp.ua"; 584 | fi 585 | 586 | ${WHOIS} -h ${WHS} "${1}" | env LC_CTYPE=C LC_ALL=C ${TR} -d "\r" > ${WHOIS_TMP} 587 | 588 | if [ "${TLDTYPE}" == "kz" ]; 589 | then 590 | ${CURL} -s -A "$VARUSERAGENT" "https://www.ps.kz/domains/whois/result?q=${1}" \ 591 | | env LC_CTYPE=C LC_ALL=C ${TR} -d "\r" >${WHOIS_2_TMP} 592 | fi 593 | 594 | # Parse out the expiration date and registrar -- uses the last registrar it finds 595 | REGISTRAR=`${AWK} -F: '/Registrar:/ && $2 != "" { REGISTRAR=substr($2,2,40) } END { print REGISTRAR }' ${WHOIS_TMP}\ 596 | | env LC_CTYPE=C LC_ALL=C ${TR} -d "\r" | ${SED} -e 's/[[:space:]\t]*// ;'` 597 | 598 | if [ "${TLDTYPE}" == "uk" ] && [ "${SUBTLDTYPE}" != "gov.uk" ]; # for .uk domain 599 | then 600 | REGISTRAR=`${AWK} -F: '/Registrar:/ && $0 != "" { getline; sub(/^[ \t]+/,"",$0); print $0 }' ${WHOIS_TMP} \ 601 | | ${AWK} -F'[' '{ print $1 }'` 602 | elif [ "${SUBTLDTYPE}" == "gov.uk" ]; 603 | then 604 | REGISTRAR=`${AWK} '/Registered By:/ && $2 != "" { getline; sub(/^[ \t]+/,"",$0); print $0 }' ${WHOIS_TMP} | 605 | ${TR} -d "\r"` 606 | elif [ "${TLDTYPE}" == "me" ]; 607 | then 608 | REGISTRAR=`${AWK} -F: '/Registrar:/ && $2 != "" { REGISTRAR=substr($2,2,23) } END { print REGISTRAR }' ${WHOIS_TMP}` 609 | elif [ "${TLDTYPE}" == "jp" ] && [ "${SUBTLDTYPE}" != "co.jp" ]; 610 | then 611 | REGISTRAR=`${AWK} -F']' '/\[Registrant\]/ && $2 != "" { sub(/^[ \t]+/,"",$2); print $2 }' ${WHOIS_TMP} | 612 | ${TR} -d "\r"` 613 | elif [ "${SUBTLDTYPE}" == "co.jp" ]; 614 | then 615 | REGISTRAR=`${AWK} -F']' '/\[Organization\]/ && $2 != "" { sub(/^[ \t]+/,"",$2); print $2 }' ${WHOIS_TMP} | 616 | ${TR} -d "\r"` 617 | # no longer shows Registrar name, so will use Status # 618 | elif [ "${TLDTYPE}" == "md" ]; 619 | then 620 | REGISTRAR=$(${AWK} -F: '/Registrar:/ && $2 != "" { REGISTRAR=substr($2,7,46) } END { print REGISTRAR }' ${WHOIS_TMP}) 621 | [ "x${REGISTRAR}" = "x" ] && REGISTRAR="Hidden" 622 | elif [ "${TLDTYPE}" == "info" ]; 623 | then 624 | REGISTRAR=`${AWK} -F: '/Registrar:/ && $2 != "" { REGISTRAR=substr($2,2,17) } END { print REGISTRAR }' ${WHOIS_TMP}` 625 | if [ "${REGISTRAR}" = "" ] 626 | then 627 | REGISTRAR=`${AWK} -F: '/Sponsoring Registrar:/ && $2 != "" { REGISTRAR=substr($2,1,17) } END { print REGISTRAR }' ${WHOIS_TMP}` 628 | fi 629 | elif [ "${TLDTYPE}" == "edu" ]; # added by nixCraft 26-aug-2017 630 | then 631 | REGISTRAR=`${AWK} -F: '/Registrant:/ && $0 != "" { getline;REGISTRAR=substr($0,2,30) } END { print REGISTRAR }' ${WHOIS_TMP}` 632 | elif [ "${TLDTYPE}" == "cafe" ]; # added by @kode29 26-aug-2017 633 | then 634 | REGISTRAR=`${AWK} -F: '/Registrar:/ && $0 != "" { REGISTRAR=substr($0,12,17) } END { print REGISTRAR }' ${WHOIS_TMP}` 635 | elif [ "${TLDTYPE}" == "link" ]; # added by @kode29 26-aug-2017 636 | then 637 | REGISTRAR=`${AWK} -F: '/Registrar:/ && $0 != "" { REGISTRAR=substr($0,12,17) } END { print REGISTRAR }' ${WHOIS_TMP}` 638 | elif [ "${TLDTYPE}" == "blog" ]; # added by @kode29 26-aug-2017 639 | then 640 | REGISTRAR=`${AWK} -F: '/Registrar:/ && $0 != "" { REGISTRAR=substr($0,12,17) } END { print REGISTRAR }' ${WHOIS_TMP}` 641 | elif [ "${TLDTYPE}" == "ru" -o "${TLDTYPE}" == "su" ]; # added 20141113 642 | then 643 | REGISTRAR=`${AWK} -F: '/registrar:/ && $2 != "" { REGISTRAR=substr($2,6,17) } END { print REGISTRAR }' ${WHOIS_TMP}` 644 | elif [ "${SUBTLDTYPE}" == "od.ua" ]; 645 | then 646 | REGISTRAR=`${AWK} -F: '/registrar:/ && $2 != "" { REGISTRAR=substr($2,11,17) } END { print REGISTRAR }' ${WHOIS_TMP}` 647 | elif [ "${TLDTYPE}" == "ua" ] && [ "${SUBTLDTYPE}" != "biz.ua" ] && [ "${SUBTLDTYPE}" != "co.ua" ] && \ 648 | [ "${SUBTLDTYPE}" != "pp.ua" ] && [ "${SUBTLDTYPE}" != "od.ua" ]; 649 | then 650 | REGISTRAR=`${AWK} -F: '/registrar:/ && $2 != "" { REGISTRAR=substr($2,9,17) } END { print REGISTRAR }' ${WHOIS_TMP}` 651 | elif [ "${SUBTLDTYPE}" == "biz.ua" ]; 652 | then 653 | REGISTRAR=`${AWK} -F: '/[Rr]egistrar:/ && $2 != "" { print $2 }' ${WHOIS_TMP}` 654 | elif [ "${SUBTLDTYPE}" == "co.ua" ]; 655 | then 656 | REGISTRAR=`${AWK} -F: '/Billing [Oo]rganization:/ && $2 != "" && $2 !~ "not disclosed" { print $2 }' ${WHOIS_TMP}` 657 | [ "x${REGISTRAR}" = "x" ] && REGISTRAR=`${AWK} -F: '/Billing ID:/ && $2 != "" && $2 !~ "not disclosed" { print $2 }' ${WHOIS_TMP}` 658 | elif [ "${SUBTLDTYPE}" == "pp.ua" ]; 659 | then 660 | REGISTRAR=`${AWK} -F: '/Billing [Oo]rganization:/ && $2 != "" && $2 !~ "not disclosed" { print $2 }' ${WHOIS_TMP}` 661 | [ "x${REGISTRAR}" = "x" ] && REGISTRAR=`${AWK} -F: '/Billing ID:/ && $2 != "" && $2 !~ "not disclosed" { print $2 }' ${WHOIS_TMP}` 662 | elif [ "${TLDTYPE}" == "укр" ]; # added by @click0 20190515 663 | then 664 | REGISTRAR=`${AWK} -F: '/Registrar:/ && $2 != "" { REGISTRAR=substr($2,2,65) } END { print REGISTRAR }' ${WHOIS_TMP}` 665 | elif [ "${TLDTYPE}" == "kz" ]; # added by @click0 20190223 666 | then 667 | REGISTRAR=`${AWK} -F": " '/Current Registar:/ && $0 != "" { print $2 }' ${WHOIS_TMP} | ${TR} -d " \r"` 668 | elif [ "${TLDTYPE}" == "cz" ]; # added by Minitram 20170830 669 | then 670 | REGISTRAR=`${AWK} -F: '/registrar:/ && $2 != "" { REGISTRAR=substr($2,5,17) } END { print REGISTRAR }' ${WHOIS_TMP}` 671 | elif [ "${TLDTYPE}" == "pl" ] && [ "${SUBTLDTYPE}" != "co.pl" ]; 672 | then 673 | REGISTRAR=`${AWK} -F: '/REGISTRAR:/ && $0 != "" { getline; sub(/^[ \t]+/,"",$0); print $0 }' ${WHOIS_TMP} | ${TR} -d " \r"` 674 | elif [ "${SUBTLDTYPE}" == "co.pl" ] # added by @hawkeye116477 20190514; 675 | then 676 | REGISTRAR=`${GREP} -A1 'Holder data:' ${WHOIS_TMP} | ${AWK} -F': ' '/Name...:/ { print $2 }'` 677 | elif [ "${TLDTYPE}" == "xyz" ]; 678 | then 679 | REGISTRAR=`${AWK} -F: '/Registrar:/ && $0 != "" { REGISTRAR=substr($2,2,40) } END { print REGISTRAR }' ${WHOIS_TMP}` 680 | elif [ "${TLDTYPE}" == "se" -o "${TLDTYPE}" == "nu" ]; 681 | then 682 | REGISTRAR=`${AWK} -F: '/registrar:/ && $2 != "" { getline; REGISTRAR=substr($2,9,20) } END { print REGISTRAR }' ${WHOIS_TMP}` 683 | elif [ "${TLDTYPE}" == "fi" ]; 684 | then 685 | REGISTRAR=`${AWK} -F: '/registrar......../ && $2 != "" { REGISTRAR=substr($2,2,20) } END { print REGISTRAR }' ${WHOIS_TMP}` 686 | elif [ "${TLDTYPE}" == "fr" -o "${TLDTYPE}" == "re" -o "${TLDTYPE}" == "tf" -o "${TLDTYPE}" == "yt" -o \ 687 | "${TLDTYPE}" == "pm" -o "${TLDTYPE}" == "wf" ]; 688 | then 689 | REGISTRAR=`${AWK} -F: '/registrar:/ && $2 != "" { REGISTRAR=substr($2,22,40) } END { print REGISTRAR }' ${WHOIS_TMP}` 690 | elif [ "${TLDTYPE}" == "dk" ]; 691 | then 692 | REGISTRAR=`${AWK} -F: '/Registrar:/ && $2 != "" { REGISTRAR=substr($2,13,40) } END { print REGISTRAR ? REGISTRAR : "N/A" }' ${WHOIS_TMP}` 693 | elif [ "${TLDTYPE}" == "tr" ]; 694 | then 695 | REGISTRAR=`${AWK} -F': ' '/Organization Name/ { REGISTRAR=substr($2,0,47);print REGISTRAR }' ${WHOIS_TMP}` 696 | elif [ "${TLDTYPE}" == "it" ]; 697 | then 698 | REGISTRAR=`${AWK} -F':' '/Registrar/ && $0 != "" { getline;REGISTRAR=substr($0,21,40) } END { print REGISTRAR }' ${WHOIS_TMP}` 699 | elif [ "${TLDTYPE}" == "cn" ]; 700 | then 701 | REGISTRAR=$(${AWK} -F': ' '/Registrant ID:|Registrant:/ && $0 != "" { print $2 }' ${WHOIS_TMP}) 702 | elif [ "${TLDTYPE}" == "io" ]; 703 | then 704 | REGISTRAR=$(${AWK} -F: '/Registrar:/ && $0 != "" { print $2 }' ${WHOIS_TMP} | ${TR} -d " \r") 705 | elif [ "${TLDTYPE}" == "mx" ]; 706 | then 707 | REGISTRAR=$(${AWK} '/Registrar:/ && $0 != "" { print $2 }' ${WHOIS_TMP}) 708 | elif [ "${TLDTYPE}" == "is" ]; # added by @hawkeye116477 20190408 709 | then 710 | REGISTRAR=$(${AWK} '/registrant:/ && $0 != "" { print $2 }' ${WHOIS_TMP}) 711 | elif [ "${TLDTYPE}" == "sk" ]; # added by @hawkeye116477 20190603 712 | then 713 | REGISTRAR=$(${AWK} -F: '/^Registrar:/ && $0 != "" { getline; getline; sub(/^[ \t]+/,"",$2); print $2 }' ${WHOIS_TMP}) 714 | elif [ "${SUBTLDTYPE}" == "com.br" ]; 715 | then 716 | REGISTRAR=$(${AWK} -F':' '/owner:/ && $0 != "" { print $2 }' ${WHOIS_TMP} | ${SED} -e 's/[[:space:]\t]*// ;') 717 | elif [ "${TLDTYPE}" == "il" ]; 718 | then 719 | REGISTRAR=$(${AWK} -F': ' '/registrar name:/ && $0 != "" { print $2 }' ${WHOIS_TMP}) 720 | elif [ "${TLDTYPE}" == "id" ]; 721 | then 722 | REGISTRAR=$(${AWK} -F: '/Registrar Organization:/ && $2 != "" { sub(/^[ \t]+/,"",$2); print $2 }' ${WHOIS_TMP}) 723 | elif [ "${TLDTYPE}" == "tg" ]; 724 | then 725 | REGISTRAR=`${ECHO} ${REGISTRAR} | ${TR} -d "."` 726 | elif [ "${TLDTYPE}" == "hr" ]; 727 | then 728 | REGISTRAR=$(${AWK} -F': ' '/Registrant Name:/ && $2 != "" { print $2 }' ${WHOIS_TMP}) 729 | elif [ "${TLDTYPE}" == "gg" ]; 730 | then 731 | REGISTRAR=`${AWK} -F'(' '/Registrar:/ && $0 != "" { getline; sub(/^[ \t]+/,"",$0); print $1 }' ${WHOIS_TMP}` 732 | elif [ "${TLDTYPE}" == "kr" ]; 733 | then 734 | REGISTRAR=$(${AWK} -F: '/Registrant / && $2 != "" { sub(/^[ \t]+/,"",$2); print $2 }' ${WHOIS_TMP}) 735 | 736 | elif [ "${TLDTYPE}" == "hk" ]; 737 | then 738 | REGISTRAR=`${AWK} -F: '/Registrar Name:/ && $2 != "" { REGISTRAR=substr($2,2,38) } END { print REGISTRAR }' ${WHOIS_TMP}` 739 | 740 | elif [ "${TLDTYPE}" == "pt" ]; 741 | then 742 | REGISTRAR=`${AWK} -F: '/Admin Name:/ && $2 != "" { REGISTRAR=substr($2,2,30) } END { print REGISTRAR }' ${WHOIS_TMP}` 743 | 744 | elif [ "${TLDTYPE}" == "ar" ] && [ "${SUBTLDTYPE}" != "com.ar" ]; 745 | then 746 | REGISTRAR=`${AWK} -F: '/name:/ && $2 != "" { REGISTRAR=substr($2,3,30) } END { print REGISTRAR }' ${WHOIS_TMP}` 747 | elif [ "${TLDTYPE}" == "cf" ]; 748 | then 749 | REGISTRAR=`${AWK} -F: '/Owner contact:/ { getline; getline; REGISTRAR=substr($2,10,40) } END { print REGISTRAR }' ${WHOIS_TMP}` 750 | elif [ "${TLDTYPE}" == "bm" ]; 751 | then 752 | REGISTRAR="$(${AWK} -F': ' '/Admin Organization:/ && $2 != "" { print $2 }' ${WHOIS_TMP})" 753 | elif [ "${TLDTYPE}" == "ee" ]; 754 | then 755 | REGISTRAR=`${AWK} -F: '/Registrant:/ && $0 != "" { getline; sub(/^[ \t]+/,"",$2); print $2 }' ${WHOIS_TMP}` 756 | elif [ "${TLDTYPE}" == "pk" ]; 757 | then 758 | REGISTRAR=$(${AWK} '/Domain:/ && $0 != "" { print $2 }' ${WHOIS_TMP}) 759 | elif [ "${TLDTYPE}" == "kg" ]; 760 | then 761 | REGISTRAR="$(${AWK} -F: '/Billing Contact:/ { getline; getline; sub(/^[ \t]+/,"",$2); print $2 }' ${WHOIS_TMP})" 762 | fi 763 | # If the Registrar is NULL, then we didn't get any data 764 | if [ "x${REGISTRAR}" = "x" ] 765 | then 766 | prints "${DOMAIN}" "Unknown" "Unknown" "Unknown" "Unknown" 767 | return 768 | fi 769 | 770 | # The whois Expiration data should resemble the following: "Expiration Date: 09-may-2008" 771 | 772 | if [ "${TLDTYPE}" == "com" -o "${TLDTYPE}" == "net" -o "${TLDTYPE}" == "org" -o "${TLDTYPE}" == "link" -o \ 773 | "${TLDTYPE}" == "blog" -o "${TLDTYPE}" == "cafe" -o "${TLDTYPE}" == "biz" -o "${TLDTYPE}" == "us" -o \ 774 | "${TLDTYPE}" == "mobi" -o "${TLDTYPE}" == "tv" -o "${TLDTYPE}" == "co" -o "${TLDTYPE}" == "pro" -o \ 775 | "${TLDTYPE}" == "cafe" -o "${TLDTYPE}" == "in" -o "${TLDTYPE}" == "cat" -o "${TLDTYPE}" == "asia" -o \ 776 | "${TLDTYPE}" == "cc" -o "${TLDTYPE}" == "college" -o "${TLDTYPE}" == "aero" -o "${TLDTYPE}" == "online" -o \ 777 | "${TLDTYPE}" == "app" -o "${TLDTYPE}" == "io" -o "${TLDTYPE}" == "me" -o "${TLDTYPE}" == "xyz" -o \ 778 | "${TLDTYPE}" == "top" -o "${TLDTYPE}" == "bid" -o "${TLDTYPE}" == "ng" -o "${TLDTYPE}" == "site" -o \ 779 | "${TLDTYPE}" == "icu" -o "${TLDTYPE}" == "cloud" -o "${TLDTYPE}" == "systems" -o \ 780 | "${TLDTYPE}" == "expert" -o "${TLDTYPE}" == "express" -o "${TLDTYPE}" == "ca" -o "${TLDTYPE}" == "space" -o \ 781 | "${TLDTYPE}" == "fun" -o "${TLDTYPE}" == "museum" -o "${TLDTYPE}" == "live" -o "${TLDTYPE}" == "club" -o \ 782 | "${TLDTYPE}" == "stream" -o "${TLDTYPE}" == "today" -o "${TLDTYPE}" == "website" -o "${TLDTYPE}" == "host" -o \ 783 | "${TLDTYPE}" == "team" -o "${TLDTYPE}" == "info" -o "${TLDTYPE}" == "xxx" -o \ 784 | "${TLDTYPE}" == "se" -o "${TLDTYPE}" == "nu" -o "${TLDTYPE}" == "dk" -o "${TLDTYPE}" == "it" -o \ 785 | "${TLDTYPE}" == "do" -o "${TLDTYPE}" == "ro" -o "${TLDTYPE}" == "game" -o "${TLDTYPE}" == "pk" -o \ 786 | "${TLDTYPE}" == "ee" -o "${TLDTYPE}" == "st" -o "${TLDTYPE}" == "sg" ]; 787 | then 788 | # From date format 2023-12-11 convert to ${tday}-${tmonth}-${tyear} (11-dec-2023) 789 | tdomdate=`${AWK} '/Registrar Registration Expiration [Dd]ate:|Registry Expiry Date:|Expiration [Dd]ate:|\ 790 | Renewal date:|Expir[ey] [Dd]ate:|Expires [Oo]n:|Expires [Oo]n:|[Ee]xpires?:/ \ 791 | { print $NF }' ${WHOIS_TMP} | ${AWK} -FT '{ print $1 }' | ${HEAD} -1` 792 | tyear=`echo ${tdomdate} | ${CUT} -d'-' -f1` 793 | tmon=`echo ${tdomdate} | ${CUT} -d'-' -f2` 794 | tmonth=$(getmonth_number ${tmon}) 795 | tday=`echo ${tdomdate} | ${CUT} -d'-' -f3 | ${CUT} -d'T' -f1` 796 | DOMAINDATE=`echo "${tday}-${tmonth}-${tyear}"` 797 | 798 | elif [ "${TLDTYPE}" == "uk" ] && [ "${SUBTLDTYPE}" != "gov.uk" ]; # for .uk domain (excluding .gov.uk subdomains) 799 | then 800 | DOMAINDATE=`${AWK} '/Renewal date:|Expiry date:/ { print tolower($3) }' ${WHOIS_TMP}` 801 | 802 | elif [ "${SUBTLDTYPE}" == "gov.uk" ]; 803 | then 804 | tdomdate=`${AWK} '/Renewal date:/ && $2 != "" \ 805 | { getline; sub(/^[ \t]+/,"",$0); sub(/th/,"",$2);print $2"-"tolower($3)"-"$4 }' ${WHOIS_TMP}` 806 | DOMAINDATE=${tdomdate} 807 | 808 | elif [ "${TLDTYPE}" == "jp" ] && [ "${SUBTLDTYPE}" != "co.jp" ]; 809 | then 810 | tdomdate=`${AWK} -F] '/\[有効期限\]|\[Expires on\]/ { print $2 }' ${WHOIS_TMP} | ${TR} -d " \r"` 811 | tyear=`echo ${tdomdate} | ${CUT} -d'/' -f1` 812 | tmon=`echo ${tdomdate} | ${CUT} -d'/' -f2` 813 | tmonth=$(getmonth_number ${tmon}) 814 | tday=`echo ${tdomdate} | ${CUT} -d'/' -f3` 815 | DOMAINDATE=`echo $tday-$tmonth-$tyear` 816 | 817 | elif [ "${SUBTLDTYPE}" == "co.jp" ]; 818 | then 819 | tdomdate=`${AWK} '/\[状態\]/ { print $NF }' ${WHOIS_TMP} | ${TR} -d "() \r"` 820 | tyear=`echo ${tdomdate} | ${CUT} -d'/' -f1` 821 | tmon=`echo ${tdomdate} | ${CUT} -d'/' -f2` 822 | tmonth=$(getmonth_number ${tmon}) 823 | tday=`echo ${tdomdate} | ${CUT} -d'/' -f3` 824 | DOMAINDATE=`echo $tday-$tmonth-$tyear` 825 | 826 | elif [ "${TLDTYPE}" == "ru" -o "${TLDTYPE}" == "su" ]; # for .ru and .su 2014/11/13 827 | then 828 | tdomdate=`${AWK} '/paid-till:/ { print $2 }' ${WHOIS_TMP}` 829 | tyear=`echo ${tdomdate} | ${CUT} -d'-' -f1` 830 | tmon=`echo ${tdomdate} |${CUT} -d'-' -f2` 831 | tmonth=$(getmonth_number ${tmon}) 832 | tday=`echo ${tdomdate} | ${CUT} -d'-' -f3 | ${CUT} -d'T' -f1` 833 | DOMAINDATE=`echo "${tday}-${tmonth}-${tyear}"` 834 | 835 | elif [ "${TLDTYPE}" == "ua" ] && [ "${SUBTLDTYPE}" != "biz.ua" ] && [ "${SUBTLDTYPE}" != "co.ua" ] && \ 836 | [ "${SUBTLDTYPE}" != "pp.ua" ]; 837 | then 838 | tdomdate=`${AWK} '/expires:/ { print $2 }' ${WHOIS_TMP}` 839 | tyear=`echo ${tdomdate} | ${CUT} -d'-' -f1` 840 | tmon=`echo ${tdomdate} | ${CUT} -d'-' -f2` 841 | tmonth=$(getmonth_number ${tmon}) 842 | tday=`echo ${tdomdate} | ${CUT} -d'-' -f3 | ${CUT} -d'T' -f1` 843 | DOMAINDATE=`echo "${tday}-${tmonth}-${tyear}"` 844 | 845 | elif [ "${SUBTLDTYPE}" == "biz.ua" ]; 846 | then 847 | tdomdate=`${AWK} '/Expiration Date:/ { print $2 }' ${WHOIS_TMP} | ${AWK} -F: '{ print tolower($2) }'` 848 | DOMAINDATE=${tdomdate} 849 | 850 | elif [ "${SUBTLDTYPE}" == "co.ua" ]; 851 | then 852 | tdomdate=`${AWK} '/Expiration Date:/ { print $2 }' ${WHOIS_TMP} | ${AWK} -F: '{ print tolower($2) }'` 853 | DOMAINDATE=${tdomdate} 854 | 855 | elif [ "${SUBTLDTYPE}" == "pp.ua" ]; 856 | then 857 | tdomdate=`${AWK} '/Expiration Date:/ { print $2 }' ${WHOIS_TMP} | ${AWK} -F: '{ print tolower($2) }'` 858 | DOMAINDATE=${tdomdate} 859 | 860 | elif [ "${TLDTYPE}" == "укр" ]; # for .укр @click0 2019/05/15 861 | then 862 | tdomdate=`${AWK} '/Expiration Date:/ { print $3 }' ${WHOIS_TMP}` 863 | tyear=`echo ${tdomdate} | ${CUT} -d'-' -f3` 864 | tmon=`echo ${tdomdate} | ${CUT} -d'-' -f2` 865 | tmonth=$(getmonth ${tmon}) 866 | tmonth=$(getmonth_number ${tmonth}) 867 | tday=`echo ${tdomdate} | ${CUT} -d'-' -f1` 868 | DOMAINDATE=`echo "${tday}-${tmonth}-${tyear}"` 869 | 870 | elif [ "${TLDTYPE}" == "is" ]; # for .is @hawkeye116477 2019/04/08 871 | then 872 | tdomdate=`${AWK} '/expires:/ { print $2 " " $3 " " $4}' ${WHOIS_TMP}` 873 | tyear=`echo ${tdomdate} | ${CUT} -d' ' -f3` 874 | tmon=`echo ${tdomdate} | ${CUT} -d' ' -f1` 875 | case ${tmon} in 876 | January) tmonth=jan ;; 877 | February) tmonth=feb ;; 878 | March) tmonth=mar ;; 879 | April) tmonth=apr ;; 880 | May) tmonth=may ;; 881 | June) tmonth=jun ;; 882 | July) tmonth=jul ;; 883 | August) tmonth=aug ;; 884 | September) tmonth=sep ;; 885 | October) tmonth=oct ;; 886 | November) tmonth=nov ;; 887 | December) tmonth=dec ;; 888 | *) tmonth=0 ;; 889 | esac 890 | tday=`echo ${tdomdate} | ${CUT} -d' ' -f2` 891 | DOMAINDATE=`echo "${tday}-${tmonth}-${tyear}"` 892 | 893 | elif [ "${TLDTYPE}" == "kz" ]; # for .kz @click0 2019/02/23 894 | then 895 | tdomdate=$(${GREP} -A 2 'Дата окончания:' ${WHOIS_2_TMP} | ${TAIL} -n 1 | ${AWK} '{print $1;}' | ${AWK} -FT '{print $1}') 896 | tyear=`echo ${tdomdate} | ${CUT} -d'-' -f1` 897 | tmon=`echo ${tdomdate} | ${CUT} -d'-' -f2` 898 | tmonth=$(getmonth_number ${tmon}) 899 | tday=$(echo ${tdomdate} | ${CUT} -d'-' -f3) 900 | DOMAINDATE=`echo "${tday}-${tmonth}-${tyear}"` 901 | 902 | elif [ "${TLDTYPE}" == "edu" ] # added on 26-aug-2017 by nixCraft 903 | then 904 | tdomdate=`${AWK} '/Domain expires:/ { print $NF }' ${WHOIS_TMP}` 905 | tyear=`echo ${tdomdate} | ${CUT} -d'-' -f3` 906 | tmon=`echo ${tdomdate} |${CUT} -d'-' -f2` 907 | tmonth=$(getmonth_number ${tmon}) 908 | tday=`echo ${tdomdate} | ${CUT} -d'-' -f1` 909 | DOMAINDATE=`echo "${tday}-${tmon}-${tyear}"` 910 | 911 | elif [ "${TLDTYPE}" == "cz" ] # added on 20170830 by Minitram 912 | then 913 | tdomdate=`${AWK} '/expire:/ { print $NF }' ${WHOIS_TMP}` 914 | tyear=`echo ${tdomdate} | ${CUT} -d'.' -f3` 915 | tmon=`echo ${tdomdate} |${CUT} -d'.' -f2` 916 | tmonth=$(getmonth_number ${tmon}) 917 | tday=`echo ${tdomdate} | ${CUT} -d'.' -f1` 918 | DOMAINDATE=`echo "${tday}-${tmonth}-${tyear}"` 919 | 920 | elif [ "${TLDTYPE}" == "pl" ] && [ "${SUBTLDTYPE}" != "co.pl" ] # NASK 921 | then 922 | tdomdate=`${AWK} -F: '/^expiration date:/ || /renewal date:/ { print $2; }' ${WHOIS_TMP} | ${AWK} -F" " '{ print $1; }'` 923 | tyear=`echo ${tdomdate} | ${CUT} -d'.' -f1` 924 | tmon=`echo ${tdomdate} | ${CUT} -d'.' -f2` 925 | tmonth=$(getmonth_number ${tmon}) 926 | tday=`echo ${tdomdate} | ${CUT} -d'.' -f3` 927 | DOMAINDATE=`echo "${tday}-${tmonth}-${tyear}"` 928 | 929 | elif [ "${SUBTLDTYPE}" == "co.pl" ]; # for .co.pl @hawkeye116477 2019/05/14 930 | then 931 | tdomdate=`${AWK} '/Expires:/ { print $2 }' ${WHOIS_TMP}` 932 | tyear=`echo ${tdomdate} | ${CUT} -d'.' -f1` 933 | tmon=`echo ${tdomdate} | ${CUT} -d'.' -f2` 934 | tmonth=$(getmonth_number ${tmon}) 935 | tday=`echo ${tdomdate} | ${CUT} -d'.' -f3` 936 | DOMAINDATE=`echo "${tday}-${tmonth}-${tyear}"` 937 | 938 | elif [ "${TLDTYPE}" == "fi" ]; 939 | then 940 | tdomdate=`${AWK} '/expires/ { print $2 }' ${WHOIS_TMP}` 941 | tyear=`echo ${tdomdate} | ${CUT} -d'.' -f3` 942 | tmon=`echo ${tdomdate} | ${CUT} -d'.' -f2` 943 | tmonth=$(getmonth_number ${tmon}) 944 | tday=`echo ${tdomdate} | ${CUT} -d'.' -f1` 945 | DOMAINDATE=`echo "${tday}-${tmonth}-${tyear}"` 946 | 947 | elif [ "${TLDTYPE}" == "fr" -o "${TLDTYPE}" == "re" -o "${TLDTYPE}" == "tf" -o "${TLDTYPE}" == "yt" -o \ 948 | "${TLDTYPE}" == "pm" -o "${TLDTYPE}" == "wf" -o "${TLDTYPE}" == "mx" -o "${TLDTYPE}" == "sk" ]; 949 | then 950 | tdomdate=`${AWK} '/Expiry Date:|Expiration Date:|Valid Until:/ { print $3 }' ${WHOIS_TMP}` 951 | tyear=`echo ${tdomdate} | ${CUT} -d'-' -f1` 952 | tmon=`echo ${tdomdate} | ${CUT} -d'-' -f2` 953 | tmonth=$(getmonth_number ${tmon}) 954 | tday=`echo ${tdomdate} | ${CUT} -d'-' -f3 | ${CUT} -d'T' -f1` 955 | DOMAINDATE=`echo "${tday}-${tmonth}-${tyear}"` 956 | 957 | elif [ "${TLDTYPE}" == "tr" ]; 958 | then 959 | tdomdate=`${AWK} '/Expires/ { print substr($3, 1, length($3)-1) }' ${WHOIS_TMP}` 960 | tyear=`echo ${tdomdate} | ${CUT} -d'-' -f1` 961 | tmon=`echo ${tdomdate} | ${CUT} -d'-' -f2` 962 | tday=`echo ${tdomdate} | ${CUT} -d'-' -f3` 963 | DOMAINDATE=`echo "${tday}-${tmon}-${tyear}"` 964 | 965 | elif [ "${TLDTYPE}" == "cn" ]; # for .cn @click0 2019/02/12 966 | then 967 | tdomdate=`${AWK} -F':' '/Expiration Time:/ { print $2 }' ${WHOIS_TMP} | ${AWK} '{ print $1; }'` 968 | tyear=`echo ${tdomdate} | ${CUT} -d'-' -f1` 969 | tmon=`echo ${tdomdate} | ${CUT} -d'-' -f2` 970 | tmonth=$(getmonth_number ${tmon}) 971 | tday=`echo ${tdomdate} | ${CUT} -d'-' -f3` 972 | DOMAINDATE=`echo "${tday}-${tmonth}-${tyear}"` 973 | 974 | elif [ "${TLDTYPE}" == "id" ]; # for .id @Minitram 2019/07/01 975 | then 976 | tdomdate=`${AWK} '/Expiration Date:/ { print $3 }' ${WHOIS_TMP}` 977 | tyear=`echo ${tdomdate} | ${CUT} -d'-' -f3` 978 | tmon=`echo ${tdomdate} | ${CUT} -d'-' -f2` 979 | tmonth=$(tolower ${tmon}) 980 | tday=`echo ${tdomdate} | ${CUT} -d'-' -f1` 981 | DOMAINDATE=`echo "${tday}-${tmonth}-${tyear}"` 982 | 983 | elif [ "${SUBTLDTYPE}" == "com.br" ]; 984 | then 985 | tdomdate=`${AWK} '/expires:/ { print $2 }' ${WHOIS_TMP}` 986 | tyear=`echo ${tdomdate} | ${CUT} -c 1-4` 987 | tmon=`echo ${tdomdate} | ${CUT} -c 5-6` 988 | tmonth=$(getmonth_number ${tmon}) 989 | tday=`echo ${tdomdate} | ${CUT} -c 7-8` 990 | DOMAINDATE=`echo "${tday}-${tmonth}-${tyear}"` 991 | 992 | elif [ "${TLDTYPE}" == "il" ] 993 | then 994 | tdomdate=`${AWK} '/validity:/ { print $NF }' ${WHOIS_TMP}` 995 | tyear=`echo ${tdomdate} | ${CUT} -d'-' -f3` 996 | tmon=`echo ${tdomdate} | ${CUT} -d'-' -f2` 997 | tmonth=$(getmonth_number ${tmon}) 998 | tday=`echo ${tdomdate} | ${CUT} -d'-' -f1` 999 | DOMAINDATE=`echo "${tday}-${tmonth}-${tyear}"` 1000 | 1001 | elif [ "${TLDTYPE}" == "tg" ] 1002 | then 1003 | tdomdate=`${AWK} -F: '/Expiration:/ { print $2 }' ${WHOIS_TMP} | ${HEAD} -1 | ${TR} -d "."` 1004 | tyear=`echo ${tdomdate} | ${CUT} -d'-' -f1` 1005 | tmon=`echo ${tdomdate} | ${CUT} -d'-' -f2` 1006 | tmonth=$(getmonth_number ${tmon}) 1007 | tday=`echo ${tdomdate} | ${CUT} -d '-' -f3` 1008 | DOMAINDATE=`echo "${tday}-${tmonth}-${tyear}"` 1009 | 1010 | elif [ "${TLDTYPE}" == "rs" ] 1011 | then 1012 | tdomdate=`${AWK} '/Expiration date:/ { print $3 }' ${WHOIS_TMP} ` 1013 | tyear=`echo ${tdomdate} | ${CUT} -d'.' -f3` 1014 | tmon=`echo ${tdomdate} | ${CUT} -d'.' -f2` 1015 | tmonth=$(getmonth_number ${tmon}) 1016 | tday=`echo ${tdomdate} | ${CUT} -d'.' -f1` 1017 | DOMAINDATE=`echo "${tday}-${tmonth}-${tyear}"` 1018 | 1019 | elif [ "${TLDTYPE}" == "gg" ] 1020 | then 1021 | tdomdate=`${AWK} -F' ' '/Registry fee due on/ && $0 != "" { print $5" "$6 }' ${WHOIS_TMP}` 1022 | tyear=$(( ${YEAR} + 1 )) 1023 | tmon=`echo ${tdomdate} | ${CUT} -d' ' -f2` 1024 | case ${tmon} in 1025 | January) tmonth=jan ;; 1026 | February) tmonth=feb ;; 1027 | March) tmonth=mar ;; 1028 | April) tmonth=apr ;; 1029 | May) tmonth=may ;; 1030 | June) tmonth=jun ;; 1031 | July) tmonth=jul ;; 1032 | August) tmonth=aug ;; 1033 | September) tmonth=sep ;; 1034 | October) tmonth=oct ;; 1035 | November) tmonth=nov ;; 1036 | December) tmonth=dec ;; 1037 | *) tmonth=0 ;; 1038 | esac 1039 | tday=`echo ${tdomdate} | ${AWK} -F'th|st' '{ print $1 }'` 1040 | DOMAINDATE=`echo "${tday}-${tmonth}-${tyear}"` 1041 | 1042 | elif [ "${TLDTYPE}" == "kr" ]; # for .kr added @copenhaus 2021/02/18 1043 | then 1044 | tdomdate=`${AWK} -F\: '/Expiration/ { print $2 }' ${WHOIS_TMP} | ${TR} -d " \r"` 1045 | tyear=`echo ${tdomdate} | ${CUT} -d'.' -f1` 1046 | tmon=`echo ${tdomdate} | ${CUT} -d'.' -f2` 1047 | tmonth=$(getmonth_number ${tmon}) 1048 | tday=`echo ${tdomdate} | ${CUT} -d'.' -f3` 1049 | DOMAINDATE=`echo $tday-$tmonth-$tyear` 1050 | 1051 | elif [ "${TLDTYPE}" == "hk" ]; # for .hk added @copenhaus 2021/02/18 1052 | then 1053 | tdomdate=`${AWK} '/Expiry Date:/ { print $3 }' ${WHOIS_TMP} | ${TR} -d " \r"` 1054 | tyear=$(echo $tdomdate| ${CUT} -c7-10) 1055 | tmonth=$(echo $tdomdate| ${CUT} -c4-5) 1056 | tmonth=$(getmonth_number ${tmonth}) 1057 | tday=$(echo $tdomdate| ${CUT} -c-2) 1058 | DOMAINDATE=`echo $tday-$tmonth-$tyear` 1059 | 1060 | elif [ "${TLDTYPE}" == "pt" ]; # for .pt added @copenhaus 2021/03/02 1061 | then 1062 | tdomdate=`${AWK} '/Expiration Date:/ { print $3 }' ${WHOIS_TMP} | ${TR} -d " \r"` 1063 | tyear=$(echo $tdomdate| ${CUT} -c7-10) 1064 | tmonth=$(echo $tdomdate| ${CUT} -c4-5) 1065 | tmonth=$(getmonth_number ${tmonth}) 1066 | tday=$(echo $tdomdate| ${CUT} -c-2) 1067 | DOMAINDATE=`echo $tday-$tmonth-$tyear` 1068 | 1069 | elif [ "${TLDTYPE}" == "ar" ] && [ "${SUBTLDTYPE}" != "com.ar" ] # for .ar added @axelvf 2022/07/21 1070 | then 1071 | tdomdate=`${AWK} '/expire:/ { print $2 }' ${WHOIS_TMP} | ${TR} -d " \r"` 1072 | tyear=`echo ${tdomdate} | ${CUT} -d'.' -f1` 1073 | tmon=`echo ${tdomdate} | ${CUT} -d'.' -f2` 1074 | tmonth=$(getmonth_number ${tmon}) 1075 | tday=`echo ${tdomdate} | ${CUT} -d'.' -f3` 1076 | DOMAINDATE=`echo "${tday}-${tmonth}-${tyear}"` 1077 | 1078 | elif [ "${TLDTYPE}" == "cf" ]; # for .cf added @click0 2021/07/24 1079 | then 1080 | tdomdate=`${AWK} -F: '/Record will expire on:/ { print $2 }' ${WHOIS_TMP} | ${TR} -d " \r"` 1081 | tyear=$(echo ${tdomdate} | ${CUT} -d'/' -f3) 1082 | tmonth=$(echo ${tdomdate} | ${CUT} -d'/' -f1) 1083 | tday=$(echo ${tdomdate} | ${CUT} -d'/' -f2) 1084 | DOMAINDATE=`echo ${tday}-${tmonth}-${tyear}` 1085 | 1086 | elif [ "${TLDTYPE}" == "sn" ]; 1087 | then 1088 | tdomdate=`${AWK} -F: '/expiration:/ { sub(/^[ \t]+/,"",$2); sub(/T[0-9]+/,"",$2); print $2 }' ${WHOIS_TMP} | ${TR} -d " \r"` 1089 | tyear=$(echo ${tdomdate} | ${CUT} -d'-' -f1) 1090 | tmon=$(echo ${tdomdate} | ${CUT} -d'-' -f2) 1091 | tmonth=$(getmonth_number ${tmon}) 1092 | tday=$(echo ${tdomdate} | ${CUT} -d'-' -f3) 1093 | DOMAINDATE=`echo ${tday}-${tmonth}-${tyear}` 1094 | 1095 | elif [ "${TLDTYPE}" == "th" ]; 1096 | then 1097 | tdomdate=`${AWK} -F: '/Exp date:/ { sub(/^[ \t]+/,"",$2); gsub(/ /,"-",$2); print $2 }' ${WHOIS_TMP} | ${TR} -d " \r"` 1098 | DOMAINDATE=${tdomdate} 1099 | 1100 | elif [ "${TLDTYPE}" == "by" ]; 1101 | then 1102 | tdomdate=`${AWK} -F": " '/Expiration Date:/ { print $2 }' ${WHOIS_TMP} | ${TR} -d " \r"` 1103 | tyear=$(echo ${tdomdate} | ${CUT} -d'-' -f1) 1104 | tmon=$(echo ${tdomdate} | ${CUT} -d'-' -f2) 1105 | tmonth=$(getmonth_number ${tmon}) 1106 | tday=$(echo ${tdomdate} | ${CUT} -d'-' -f3) 1107 | DOMAINDATE=`echo ${tday}-${tmonth}-${tyear}` 1108 | 1109 | elif [ "${TLDTYPE}" == "kg" ]; then 1110 | tdomdate=$(${AWK} -F: '/Record expires on:/ { sub(/^[ \t]+/,"",$2); print $2" "$4 }' ${WHOIS_TMP}) 1111 | tyear=$(echo ${tdomdate} | ${CUT} -d' ' -f6) 1112 | tmonth=$(echo ${tdomdate} | ${CUT} -d' ' -f2) 1113 | tday=$(echo ${tdomdate} | ${CUT} -d' ' -f3) 1114 | DOMAINDATE=$(echo ${tday}-${tmonth}-${tyear}) 1115 | 1116 | elif [ "${TLDTYPE}" == "md" ]; 1117 | then 1118 | tdomdate=$(${AWK} '/Expires on/ { print $3 }' ${WHOIS_TMP}) 1119 | tyear=$(echo ${tdomdate} | ${CUT} -d- -f1) 1120 | tmonth=$(echo ${tdomdate} | ${CUT} -d- -f2) 1121 | tmonth=$(getmonth_number ${tmonth}) 1122 | tday=$(echo ${tdomdate} | ${CUT} -d- -f3) 1123 | DOMAINDATE=$(echo ${tday}-${tmonth}-${tyear}) 1124 | 1125 | # may work with others ??? ;) 1126 | else 1127 | DOMAINDATE=`${AWK} '/Expiration:|[Ee]xpires:|Registry Expiry Date:|Registrar Registration Expiration Date:/ \ 1128 | { print $NF }' ${WHOIS_TMP} | ${AWK} -FT '{ print $1 }' | ${HEAD} -1` 1129 | fi 1130 | 1131 | #echo $DOMAINDATE # debug 1132 | # Whois data should be in the following format: "13-feb-2006" 1133 | IFS="-" 1134 | set -- ${DOMAINDATE} 1135 | MONTH=$(getmonth ${2}) 1136 | # We change the date format here as we need ("13-feb-2006") 1137 | if [ "$MONTH" == "0" ]; then 1138 | MONTH=${2#0} 1139 | MONTH_IN_WORDS=$(getmonth_number ${2#0}) 1140 | DOMAINDATE=${3}-${MONTH_IN_WORDS}-${1} 1141 | set -- ${DOMAINDATE} 1142 | fi 1143 | IFS="" 1144 | 1145 | # Convert the date to seconds, and get the diff between NOW and the expiration date 1146 | DOMAINJULIAN=$(date2julian ${MONTH} ${1#0} ${3#0}) 1147 | DOMAINDIFF=$(date_diff ${NOWJULIAN} ${DOMAINJULIAN}) 1148 | 1149 | if [ ${DOMAINDIFF} -lt 0 ] && [ ${DOMAINJULIAN} -gt 0 ] && \ 1150 | [ ${MONTH} -gt 0 ] && [ ${DAY} -gt 0 ] && [ ${YEAR} -gt 0 ] 1151 | then 1152 | if [ "${ALARM}" == "TRUE" ] 1153 | then 1154 | echo "The domain ${DOMAIN} has expired!" \ 1155 | | ${MAIL} -s "Domain ${DOMAIN} has expired!" ${ADMIN} 1156 | fi 1157 | prints "${DOMAIN}" "Expired" "${DOMAINDATE}" "${DOMAINDIFF}" "${REGISTRAR}" 1158 | 1159 | elif [ ${DOMAINDIFF} -lt ${WARNDAYS} ] && [ ${DOMAINJULIAN} -gt 0 ] && \ 1160 | [ ${MONTH} -gt 0 ] && [ ${DAY} -gt 0 ] && [ ${YEAR} -gt 0 ] 1161 | then 1162 | if [ "${ALARM}" == "TRUE" ] 1163 | then 1164 | echo "The domain ${DOMAIN} will expire on ${DOMAINDATE}" \ 1165 | | ${MAIL} -s "Domain ${DOMAIN} will expire in ${WARNDAYS}-days or less" ${ADMIN} 1166 | fi 1167 | prints "${DOMAIN}" "Expiring" "${DOMAINDATE}" "${DOMAINDIFF}" "${REGISTRAR}" 1168 | elif [ ${DOMAINJULIAN} -eq 0 ] || [ ${MONTH} -le 0 ] || [ ${DAY} -le 0 ] || \ 1169 | [ ${YEAR} -le 0 ] 1170 | then 1171 | prints "${DOMAIN}" "Unknown" "Unknown" "Unknown" "${REGISTRAR}" 1172 | else 1173 | prints "${DOMAIN}" "Valid" "${DOMAINDATE}" "${DOMAINDIFF}" "${REGISTRAR}" 1174 | fi 1175 | } 1176 | 1177 | #################################################### 1178 | # Purpose: Print a heading with the relevant columns 1179 | # Arguments: 1180 | # None 1181 | #################################################### 1182 | print_heading() 1183 | { 1184 | if [ "${QUIET}" != "TRUE" ] 1185 | then 1186 | if [ "${OUTPUT_FORMAT}" == "format" ]; then 1187 | printf "\n%-35s %-46s %-8s %-11s %-5s\n" "Domain" "Registrar" "Status" "Expires" "Days Left" 1188 | echo "----------------------------------- ---------------------------------------------- -------- ----------- ---------" 1189 | fi 1190 | if [ "${OUTPUT_FORMAT}" == "csv" ]; then 1191 | printf "%s${CSV_DELIMITER}" "Domain" "Registrar" "Status" "Expires" "\"Days Left\"" | ${SED} "s/${CSV_DELIMITER}$//" 1192 | printf '\n' 1193 | fi 1194 | fi 1195 | } 1196 | 1197 | ##################################################################### 1198 | # Purpose: Print a line with the expiraton interval 1199 | # Arguments: 1200 | # $1 -> Domain 1201 | # $2 -> Status of domain (e.g., expired or valid) 1202 | # $3 -> Date when domain will expire 1203 | # $4 -> Days left until the domain will expire 1204 | # $5 -> Domain registrar 1205 | ##################################################################### 1206 | prints() 1207 | { 1208 | if [ "${QUIET}" != "TRUE" ] 1209 | then 1210 | local MIN_DATE 1211 | MIN_DATE=$(${ECHO} $3 | ${AWK} '{ print $1, $2, $4 }' | ${TR} -d " " ) 1212 | if [ "${OUTPUT_FORMAT}" == "format" ]; then 1213 | printf "%-35s %-46s %-8s %-11s %-5s\n" "$1" "$5" "$2" "${MIN_DATE}" "$4" 1214 | fi 1215 | if [ "${OUTPUT_FORMAT}" == "csv" ]; then 1216 | printf "%s${CSV_DELIMITER}" "$1" "\"$5\"" "$2" "${MIN_DATE}" "$4" | ${SED} "s/${CSV_DELIMITER}$//" 1217 | printf '\n' 1218 | fi 1219 | 1220 | fi 1221 | } 1222 | 1223 | ########################################## 1224 | # Purpose: Describe how the script works 1225 | # Arguments: 1226 | # None 1227 | ########################################## 1228 | usage() 1229 | { 1230 | echo "Usage: $0 [ -e email ] [ -x expir_days ] [ -s whois server ] [ -o output format ] [ -q ] [ -a ] [ -h ] [ -v ] [ -V ]" 1231 | echo " [ -s whois_server ] {[ -d domain_name ]} || {[ -f domain_file ]}" 1232 | echo "" 1233 | echo " -a : Send a warning message through email" 1234 | echo " -d domain_name : Domain to analyze (interactive mode)" 1235 | echo " -e email address : Email address to send expiration notices" 1236 | echo " -f domain_file : File with a list of domains" 1237 | echo " -h : Print this screen" 1238 | echo " -s whois server : Whois server to query for information" 1239 | echo " -o output format : Output the result in formatted (format) [by default] or CSV format (csv)" 1240 | echo " -q : Don't print anything on the console" 1241 | echo " -x days : Domain expiration interval (eg. if domain_date < days)" 1242 | echo " -v : Show debug information when running script" 1243 | echo " -V : Print version of the script" 1244 | echo "" 1245 | } 1246 | 1247 | ### Evaluate the options passed on the command line 1248 | while getopts ad:e:f:hs:o:qx:vV option 1249 | do 1250 | case "${option}" 1251 | in 1252 | a) ALARM="TRUE";; 1253 | d) DOMAIN=${OPTARG};; 1254 | e) ADMIN=${OPTARG};; 1255 | f) SERVERFILE=$OPTARG;; 1256 | s) WHOIS_SERVER=$OPTARG;; 1257 | o) OUTPUT_FORMAT=$OPTARG;; 1258 | q) QUIET="TRUE";; 1259 | x) WARNDAYS=$OPTARG;; 1260 | v) VERBOSE="TRUE";; 1261 | V) VERSIONENABLE="TRUE";; 1262 | \?|h) usage 1263 | exit 1;; 1264 | esac 1265 | done 1266 | 1267 | ### Checking for the existence of a mail client 1268 | if [ "${ALARM}" == "TRUE" ] 1269 | then 1270 | for BINARY in mail ; do 1271 | if [ ! -x "$(command -v $BINARY)" ]; then 1272 | echo "ERROR: The $BINARY binary does not exist in \$$BINARY." 1273 | echo " FIX: Please modify the \$$BINARY variable in the program header." 1274 | exit 1 1275 | fi 1276 | done 1277 | MAIL=$(command -v mail) 1278 | fi 1279 | 1280 | 1281 | ### Show debug information when running script 1282 | if [ "${VERBOSE}" == "TRUE" ] 1283 | then 1284 | set -x 1285 | fi 1286 | 1287 | ### Print version of the script 1288 | if [ "${VERSIONENABLE}" == "TRUE" ] 1289 | then 1290 | printf "%-15s %-10s\n" "Script version: " "${VERSION}" 1291 | exit 1 1292 | fi 1293 | 1294 | ### Baseline the dates so we have something to compare to 1295 | MONTH=$(${DATE} "+%m") 1296 | DAY=$(${DATE} "+%d") 1297 | YEAR=$(${DATE} "+%Y") 1298 | NOWJULIAN=$(date2julian ${MONTH#0} ${DAY#0} ${YEAR}) 1299 | 1300 | ### Touch the files prior to using them 1301 | touch ${WHOIS_TMP} 1302 | 1303 | ### If a HOST and PORT were passed on the cmdline, use those values 1304 | if [ "${DOMAIN}" != "" ] 1305 | then 1306 | print_heading 1307 | check_domain_status "${DOMAIN}" 1308 | ### If a file and a "-a" are passed on the command line, check all 1309 | ### of the domains in the file to see if they are about to expire 1310 | elif [ -f "${SERVERFILE}" ] 1311 | then 1312 | print_heading 1313 | ${SED} -e 's/[[:space:]]*#.*// ; /^[[:space:]]*$/d' ${SERVERFILE} | tr -d '[:blank:]' | \ 1314 | while read DOMAIN 1315 | do 1316 | check_domain_status "${DOMAIN}" 1317 | done 1318 | 1319 | ### There was an error, so print a detailed usage message and exit 1320 | else 1321 | usage 1322 | exit 1 1323 | fi 1324 | 1325 | # Add an extra newline 1326 | echo 1327 | 1328 | ### Remove the temporary files 1329 | [ -f "${WHOIS_TMP}" ] && rm -f ${WHOIS_TMP}; 1330 | [ -f "${WHOIS_2_TMP}" ] && rm -f ${WHOIS_2_TMP}; 1331 | 1332 | ### Exit with a success indicator 1333 | exit 0 1334 | -------------------------------------------------------------------------------- /domain-list.txt: -------------------------------------------------------------------------------- 1 | nixcraft.com 2 | google.org 3 | google.net 4 | google.info 5 | cyberciti.biz 6 | google.in 7 | google.co.in 8 | google.us 9 | google.uk 10 | google.co.uk 11 | google.jp 12 | google.cz 13 | google.pl 14 | google.co 15 | google.ru 16 | google.blog 17 | linux.cafe 18 | google.md 19 | google.co 20 | google.mobi 21 | google.wf 22 | google.me 23 | google.us 24 | google.su 25 | youtube.tv 26 | abc.xyz 27 | google.se 28 | google.dk 29 | google.com.tr 30 | google.mx 31 | google.pro 32 | google.fr 33 | google.re 34 | google.tf 35 | google.yt 36 | google.pm 37 | google.it 38 | google.ro 39 | information.aero 40 | google.asia 41 | google.cc 42 | google.college 43 | google.cn 44 | google.io 45 | google.ua 46 | google.kz 47 | google.xyz 48 | google.app 49 | google.top 50 | google.is 51 | google.cloud 52 | nic.systems 53 | nic.expert 54 | google.express 55 | google.space 56 | google.ca 57 | google.co.pl 58 | zaproszenia.co.pl 59 | гугл.укр 60 | google.fun 61 | about.museum 62 | nic.live 63 | google.sk 64 | nic.club 65 | nic.stream 66 | google.xxx 67 | google.id 68 | nic.today 69 | mail.game 70 | dream.team 71 | google.app 72 | google.host 73 | google.website 74 | google.co.il 75 | isoc.org.il 76 | hot.net.il 77 | ali.xin 78 | google.am 79 | visa.go.kr 80 | dominos.co.kr 81 | google.kr 82 | coronavirus.gov.hk 83 | hkdnr.net.hk 84 | mtr.com.hk 85 | dns.pt 86 | ana.pt 87 | amazon.sg 88 | sps.gov.sg 89 | shell.com.sg 90 | jcu.edu.sg 91 | donuts.media 92 | google.click 93 | google.business 94 | google.photo 95 | google.com.ar 96 | amazon.bm 97 | google.co.jp 98 | google.icu 99 | google.ee 100 | google.pk 101 | hse.gov.uk 102 | news.biz.ua 103 | google.co.ua 104 | google.pp.ua 105 | google.sn 106 | google.st 107 | google.th 108 | google.co.th 109 | google.by 110 | google.ps 111 | google.kg 112 | nic.network 113 | nic.run 114 | nic.rocks 115 | google.win 116 | google.tel 117 | google.rs 118 | --------------------------------------------------------------------------------