forked from nixcraft/domain-check-2
-
-
Notifications
You must be signed in to change notification settings - Fork 16
/
domain-check-2.sh
1331 lines (1237 loc) · 52.7 KB
/
domain-check-2.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/env bash
#
# Program: Domain Expiration Check <domain-check>
#
# Author: Matty < matty91 at gmail dot com >
# Co-author: Vladyslav V. Prodan <github.com/click0>
#
# Current Version: 2.72
# Last Updated: 20-Oct-2024
#
# Revision History:
#
# Version 2.72
# Fixed support for .md/.ps TLDs. -- Vladyslav V. Prodan <github.com/click0>
#
# Version 2.71
# Fixed support for .kr TLD. -- Vladyslav V. Prodan <github.com/click0>
#
# Version 2.70
# Fixed support for .sg domain -- Vladyslav V. Prodan <github.com/click0>
#
# Version 2.69
# Fixed support for .sk/.bm TLDs. -- Vladyslav V. Prodan <github.com/click0>
#
# Version 2.68
# Fixed support for .md domain -- Vladislav V. Prodan <github.com/click0>
#
# Version 2.67
# Added support for sn/.st/.th/.co.th/.by/.ps TLDs. -- Vladislav V. Prodan <github.com/click0>
#
# Version 2.66
# Added support for .ee/.pk/.biz.ua/.gov.uk/.co.ua/.pp.ua TLDs. -- Vladislav V. Prodan <github.com/click0>
# Code optimization with minor bug fixes.
# Optimization to get rid of long lines in the code.
#
# Version 2.65
# Added support for .co.jp domain -- Vladislav V. Prodan <github.com/click0>
#
# Version 2.64
# Removed whitespace escape for awk.
# Fixed registrar output formatting for some domain zones.
#
# Version 2.63
# Removed the check for the existence of the mail client binary if the script does not use mail notification.
#
# Version 2.62
# Added support for .bm domain -- Vladislav V. Prodan <github.com/click0>
#
# Version 2.61
# The list of requirements has been corrected and added to the project description.
#
# Version 2.60
# Added support for .cf domain -- Vladislav V. Prodan <github.com/click0>
# Simplified checking for .dk/.tr/.xyz/.fi/.fr zones.
# Fixed typos.
#
# Version 2.59
# Fixed support for .md/.kz domains -- Vladislav V. Prodan <github.com/click0>
# Fixed typos.
#
# Version 2.58
# Fixed support for .com.ar/.ar domains -- Axel Vasquez <github.com/axelvf>
#
# Version 2.57
# Fixed partial support for .md domain -- Vladislav V. Prodan <github.com/click0>
# Fixed typos.
#
# Version 2.56
# Added data output in CSV format -- Vladislav V. Prodan <github.com/click0>
#
# Version 2.55
# Fixed support for .md/.id/.kz/.uk domains -- Vladislav V. Prodan <github.com/click0>
# Fixed typos.
#
# Version 2.54
# Fixed checking on the existence of binary files of the necessary programs for the script to work.
#
# Version 2.53
# Added support for .kr/.hk/.pt/.sg domains -- @copenhaus
#
# Version 2.52
# Added work with specific whois servers.
# Fixed display of the registrar name in the .uk domain zone.
# Partially added .gg domain zone, but it does not display the year.
# Fixed typos.
#
# Version 2.51
# Added support for .rs/.am/.xin/ domains -- Vladislav V. Prodan <github.com/click0>
# Fixed typos.
#
# Version 2.50
# Added support for .tg/.co.il/.net.il/.org.il domains -- Vladislav V. Prodan <github.com/click0>
# Added an additional function to change to the desired date format.
# Fixed display of the registrar in the .cn/.edu domains.
#
# Version 2.49
# Added support for .com.br domain -- Vladislav V. Prodan <github.com/click0>
#
# Version 2.48
# Added support for .team/.app/.host/.website domains -- Vladislav V. Prodan <github.com/click0>
# Fixed length of registrar name for .edu domain
# Merged some checks
#
# Version 2.47
# Added support for .do domain -- rk00t <github.com/rk00t>
#
# Version 2.46
# Spaces, tabs and blank lines in the domain list file are now ignored -- Vladislav V. Prodan <github.com/click0>
# Commenting on domains with the # symbol also began to work -- Vladislav V. Prodan <github.com/click0>
#
# Version 2.45
# Added support for .game domain -- Vladislav V. Prodan <github.com/click0>
#
# Version 2.44
# Fixed status when expiration date is wrongly detected (sometimes can be described as not defined) -- https://github.com/hawkeye116477
# Added support for .today domain -- https://github.com/hawkeye116477
#
# Version 2.43
# Added support for .id domain -- Menthol Date <github.com/menthoolll>
#
# Version 2.42
# Fixed support for .jp domain -- Tozapid <github.com/Tozapid>
# Added support for .xxx domain -- Tozapid <github.com/Tozapid>
#
# Version 2.41
# Added support for .stream domain -- https://github.com/hawkeye116477
# Fixed condition with whois -- https://github.com/hawkeye116477
#
# Version 2.40
# Partial syntax fixes in the script -- Vladislav V. Prodan <github.com/click0>
#
# Version 2.39
# Added support for .club domain -- https://github.com/hawkeye116477
#
# Version 2.38
# Added support for .sk domain -- https://github.com/hawkeye116477
# Fixed displaying of some long registrars -- https://github.com/hawkeye116477
# Fixed support for .jp domain -- https://github.com/hawkeye116477
#
# Version 2.37
# Added support for .live domain -- https://github.com/hawkeye116477
#
# Version 2.36
# Added support for .museum domain -- Bryan Clay <github.com/watermark>
#
# Version 2.35
# Added support for .fun domain -- https://github.com/hawkeye116477
#
# Version 2.34
# Added support for .укр domain -- Vladislav V. Prodan <github.com/click0>
#
# Version 2.33
# Added support for .co.pl domain -- https://github.com/hawkeye116477
# Fixed version variable -- https://github.com/hawkeye116477
#
# Version 2.32
# Fixed support for .ca domain -- https://github.com/hawkeye116477
# Added support for .space domain -- https://github.com/hawkeye116477
#
# Version 2.31
# Added support for .expert/.express domains -- https://github.com/hawkeye116477
#
# Version 2.30
# Added option to display the version of the script -- Vladislav V. Prodan <github.com/click0>
# Added option to show debug information when running script -- Vladislav V. Prodan <github.com/click0>
#
# Version 2.29
# Partial syntax fixes in the script -- Vladislav V. Prodan <github.com/click0>
# Partially removed extra disk read operations --Vladislav V. Prodan <github.com/click0>
#
# Version 2.28
# Added support for .systems domain and fixed status when expiration date isn't detected -- https://github.com/hawkeye116477
# Fixed status when expiration date isn't detected -- https://github.com/hawkeye116477
#
# Version 2.27
# Added support for .is/.cloud domains -- https://github.com/hawkeye116477
#
# Version 2.26
# Added support for .icu domain -- https://github.com/hawkeye116477
#
# Version 2.25
# Added support for .bid/.ng/.site domains -- https://github.com/hawkeye116477
#
# Version 2.24
# Added support for .app/.top domains -- Vladislav V. Prodan <github.com/click0>
# Fixed support for .io/.xyz/.me/.pl/.ro domains -- Vladislav V. Prodan <github.com/click0>
#
# Version 2.23
# Added support for .online domain -- https://github.com/hawkeye116477
#
# Version 2.22
# Added support for .kz domains -- Vladislav V. Prodan <github.com/click0>
# Many thanks to the service that provided the API for the .KZ zone - https://www.ps.kz/
#
# Version 2.21
# Fixed support for .pl domain -- https://github.com/hawkeye116477
#
# Version 2.20
# Fixed support for .jp/.aero/.cn/.pl/.md/.tr/.it/.mx domains -- Vladislav V. Prodan <github.com/click0>
#
# Version 2.19
# Added support for .ua/.cn/.io domains -- Vladislav V. Prodan <github.com/click0>
# Fixed support for .pl domain -- Vladislav V. Prodan <github.com/click0>
#
# Version 2.18
# Added support for .pro/.mx/.ro/.aero/.asia/.cc/.college domain -- Vivek Gite <github.com/nixcraft>
# Added support for .it domain -- https://github.com/pelligrag
# Fixed support for .in/.md/.cafe/.fr/.re/.tf/.yt/.pm/.wf/.cat domain -- Vivek Gite <github.com/nixcraft>
#
# Version 2.17
# Fixed suport for .co domain -- Vivek Gite <github.com/nixcraft>
#
# Version 2.16
# Added suport for .tr domain -- https://github.com/eaydin
#
# Version 2.15
# Fixed suport for .jp domain -- Vivek Gite <github.com/nixcraft>
#
# Version 2.14
# Added support for .se/.nu/.dk/.xyz and bug fix by -- https://github.com/happyoccasion
#
# Version 2.13
# Fiexed suport for .biz/.us/.mobi/.tv domains -- Vivek Gite <github.com/nixcraft>
#
# Version 2.12
# Added suport for Czechia (.cz) domains -- Minitram <github.com/Minitram>
#
# Version 2.11
# Added support for .cafe/.blog/.link domain -- <github.com/kode29>
#
# Version 2.10
# Bug fix for .com, net, org, jp, and edu -- Vivek Gite <[email protected]>
#
# Version 2.9
# Bug fix for .ru -- Mikhail Grigorev <[email protected]>
#
# Version 2.8
# Use 'which' to autodetect awk, whois, date and other utils -- Mikhail Grigorev <[email protected]>
#
# Version 2.7
# Bug fix for .md and .co -- Bill Bell <[email protected]>
#
# Version 2.6
# Bug fix for .mobi -- Bill Bell <[email protected]>
#
# Version 2.5
# Bug fix for .me -- Mikhail Grigorev <[email protected]>
#
# Version 2.4
# Bug fix for .com, .net, .us, .org, .in -- Mikhail Grigorev <[email protected]>
#
# Version 2.3
# Bug fix for .info -- Mikhail Grigorev <[email protected]>
#
# Version 2.2
# Bug fix that adds support for .ru and .su domains -- Jim McNamara
#
# Version 2.1
# Bug fix for .mobi and .us -- Jim McNamara
# Added a variable for the location of tr, and made all calls to cut and tr use the variable
# instead of the command without path
#
# Version 2.0
# Bug fix for .org, .biz, info, and .ca -- Cameron and Jim
#
# Version 1.9
# Bug fix and enhancement for .uk and .co.uk -- Vivek Gite <[email protected]>
#
# Version 1.8
# Bug fix added $MAIL -- Vivek Gite <[email protected]>
#
# Version 1.7
# Added support for .jp domain names -- Vivek Gite <[email protected]>
#
# Version 1.6
# Added support for .uk domain names; fixed a bug detecting tldtype -- Vivek Gite <[email protected]>
#
# Version 1.5
# Added support for .org, .in, .biz and .info domain names -- Vivek Gite <[email protected]>
#
# Version 1.4
# Updated the documentation.
#
# Version 1.3
# Gracefully Handle the case where the expiration data is unavailable
#
# Version 1.2
# Added "-s" option to allow arbitrary registrars
#
# Version 1.1
# Fixed issue with 'e' getopt string -- Pedro Alves
#
# Version 1.0
# Initial Release
#
#
# Purpose:
# domain-check checks to see if a domain has expired. domain-check
# can be run in interactive and batch mode, and provides faciltities
# to alarm if a domain is about to expire.
#
# License:
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#
# Notes:
# Since each registrar provides expiration data in a unique format (if
# they provide it at all), domain-check is currently only able to
# processess expiration information for a subset of the available
# registrars.
#
# Requirements:
# Requires whois, curl (for domains in the .kz zone), mail (mailutils)
#
# Installation:
# Copy the shell script to a suitable location
#
# Tested platforms:
# -- Solaris 9 using /bin/bash
# -- Solaris 10 using /bin/bash
# -- OS X 10.4.2 using /bin/sh
# -- OpenBSD using /bin/sh
# -- FreeBSD using /bin/sh
# -- Redhat advanced server 3.0MU3 using /bin/sh
#
# Usage:
# Refer to the usage() sub-routine, or invoke domain-check
# with the "-h" option.
#
# Example:
#
# The first example will print the expiration date and registrar for prefetch.net:
#
# $ domain-check.sh -d prefetch.net
#
# Domain Registrar Status Expires Days Left
# ----------------------------------- ----------------- -------- ----------- ---------
# prefetch.net INTERCOSMOS MEDIA Valid 13-feb-2006 64
#
# The second example prints the expiration date and registrar for the domains
# listed in the file "domains":
#
# $ domain-check.sh -f domains
#
# Domain Registrar Status Expires Days Left
# ----------------------------------- ----------------- -------- ----------- ---------
# sun.com NETWORK SOLUTIONS Valid 20-mar-2010 1560
# google.com EMARKMONITOR INC. Valid 14-sep-2011 2103
# ack.com NETWORK SOLUTIONS Valid 09-may-2008 880
# prefetch.net INTERCOSMOS MEDIA Valid 13-feb-2006 64
# spotch.com GANDI Valid 03-dec-2006 357
#
# The third example will e-mail the address [email protected] with the domains that
# will expire in 60-days or less:
#
# $ domain-check -a -f domains -q -x 60 -e [email protected]
#
PATH=/bin:/usr/bin:/usr/local/bin:/usr/local/ssl/bin:/usr/sfw/bin
export PATH
# Who to page when an expired domain is detected (cmdline: -e)
ADMIN="[email protected]"
# Number of days in the warning threshhold (cmdline: -x)
WARNDAYS=30
# If QUIET is set to TRUE, don't print anything on the console (cmdline: -q)
QUIET="FALSE"
# Don't send emails by default (cmdline: -a)
ALARM="FALSE"
# Output the result in formatted (by default) or CSV format (csv) (cmdline: -o)
OUTPUT_FORMAT="format"
CSV_DELIMITER=","
# Don't show the version of the script by default (cmdline: -V)
VERSIONENABLE="FALSE"
# Don't show debug information by default (cmdline: -vv)
VERBOSE="FALSE"
# Whois server to use (cmdline: -s)
WHOIS_SERVER="whois.iana.org"
# Location of system binaries
for BINARY in whois date curl ; do
if [ ! -x "$(command -v $BINARY)" ]; then
echo "ERROR: The $BINARY binary does not exist in \$$BINARY."
echo " FIX: Please modify the \$$BINARY variable in the program header."
exit 1
fi
done
AWK=$(command -v awk)
WHOIS=$(command -v whois)
DATE=$(command -v date)
CUT=$(command -v cut)
GREP=$(command -v grep)
TR=$(command -v tr)
CURL=$(command -v curl)
ECHO=$(command -v echo)
HEAD=$(command -v head)
SED=$(command -v sed)
TAIL=$(command -v tail)
# Version of the script
VERSION=$(${AWK} -F': ' '/^# Current Version:/ { print $2; exit}' $0)
# User-Agent
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"
# Place to stash temporary files
WHOIS_TMP="/var/tmp/whois.$$"
WHOIS_2_TMP="/var/tmp/whois_2.$$"
#############################################################################
# Purpose: Convert a date from MONTH-DAY-YEAR to Julian format
# Acknowledgements: Code was adapted from examples in the book
# "Shell Scripting Recipes: A Problem-Solution Approach"
# ( ISBN 1590594711 )
# Arguments:
# $1 -> Month (e.g., 06)
# $2 -> Day (e.g., 08)
# $3 -> Year (e.g., 2006)
#############################################################################
date2julian()
{
if [ -n "${1}" ] && [ -n "${2}" ] && [ -n "${3}" ]
then
## Since leap years add aday at the end of February,
## calculations are done from 1 March 0000 (a fictional year)
d2j_tmpmonth=$((12 * ${3} + ${1} - 3))
## If it is not yet March, the year is changed to the previous year
d2j_tmpyear=$(( d2j_tmpmonth / 12))
## The number of days from 1 March 0000 is calculated
## and the number of days from 1 Jan. 4713BC is added
echo $(( (734 * d2j_tmpmonth + 15) / 24 - 2 * d2j_tmpyear + d2j_tmpyear/4 \
- d2j_tmpyear/100 + d2j_tmpyear/400 + ${2} + 1721119 ))
else
echo 0
fi
}
#############################################################################
# Purpose: Convert a string month into an integer representation
# Arguments:
# $1 -> Month name (e.g., Sep)
#############################################################################
getmonth()
{
LOWER=`tolower ${1}`
case ${LOWER} in
jan) echo 1 ;;
feb) echo 2 ;;
mar) echo 3 ;;
apr) echo 4 ;;
may) echo 5 ;;
jun) echo 6 ;;
jul) echo 7 ;;
aug) echo 8 ;;
sep) echo 9 ;;
oct) echo 10 ;;
nov) echo 11 ;;
dec) echo 12 ;;
*) echo 0 ;;
esac
}
#############################################################################
# Purpose: Convert the month number into a short form for writing the month name
# Arguments:
# $1 -> Month number (e.g., 08)
#############################################################################
getmonth_number()
{
case ${1} in
1|01) echo jan ;;
2|02) echo feb ;;
3|03) echo mar ;;
4|04) echo apr ;;
5|05) echo may ;;
6|06) echo jun ;;
7|07) echo jul ;;
8|08) echo aug ;;
9|09) echo sep ;;
10) echo oct ;;
11) echo nov ;;
12) echo dec ;;
*) echo 0 ;;
esac
}
#############################################################################
# Purpose: Calculate the number of seconds between two dates
# Arguments:
# $1 -> Date #1
# $2 -> Date #2
#############################################################################
date_diff()
{
if [ -n "${1}" ] && [ -n "${2}" ]
then
echo $((${2} - ${1}))
else
echo 0
fi
}
##################################################################
# Purpose: Converts a string to lower case
# Arguments:
# $1 -> String to convert to lower case
##################################################################
tolower()
{
LOWER=`echo ${1} | ${AWK} '{print tolower($0);}'`
echo $LOWER
}
##################################################################
# Purpose: Access whois data to grab the registrar and expiration date
# Arguments:
# $1 -> Domain to check
##################################################################
check_domain_status()
{
local REGISTRAR
REGISTRAR=""
# Avoid WHOIS LIMIT EXCEEDED - slowdown our whois client by adding 1 sec
sleep 1
# Save the domain since set will trip up the ordering
local DOMAIN
DOMAIN="${1}"
local TLDTYPE
TLDTYPE=$(echo "${DOMAIN}" | ${AWK} -F. '{print tolower($NF);}')
if [ "x${TLDTYPE}" == "x" ];
then
TLDTYPE=$(echo "${DOMAIN}" | ${AWK} -F. '{print tolower($(NF-1));}')
fi
if [ "${TLDTYPE}" == "ua" ] || [ "${TLDTYPE}" == "pl" ] || [ "${TLDTYPE}" == "br" ] || [ "${TLDTYPE}" == "jp" ] || \
[ "${TLDTYPE}" == "za" ] || \
[ "${TLDTYPE}" == "uk" ];
then
local SUBTLDTYPE
SUBTLDTYPE=$(echo "${DOMAIN}" | ${AWK} -F. '{print tolower($(NF-1)"."$(NF));}')
fi
# Invoke whois to find the domain registrar and expiration date
# ${WHOIS} -h ${WHOIS_SERVER} "=${1}" > ${WHOIS_TMP}
# Let whois select server
local WHS
if [ -n "${WHOIS_SERVER}" ] && [ "${WHOIS_SERVER}" == "whois.iana.org" ]; then
WHS="$(${WHOIS} -h "${WHOIS_SERVER}" "${TLDTYPE}" | ${AWK} '/whois:/ {print $2}')"
else
WHS="${WHOIS_SERVER}"
fi
if [ -n "${WHOIS_SERVER}" ];
then
# section for TLDTYPE
[ "${TLDTYPE}" == "bm" ] && WHS="whois.nic.bm";
[ "${TLDTYPE}" == "ps" ] && WHS="95.217.44.246"; # Look output server here # https://www.pnina.ps/whois/
# section for SUBTLDTYPE
[ "${SUBTLDTYPE}" == "co.pl" ] && WHS="whois.co.pl"; # added by @hawkeye116477 20190514
[ "${SUBTLDTYPE}" == "ac.za" ] || [ "${SUBTLDTYPE}" == "co.za" ] || [ "${SUBTLDTYPE}" == "net.za" ] || \
[ "${SUBTLDTYPE}" == "org.za" ] || [ "${SUBTLDTYPE}" == "web.za" ] && \
WHS="whois.registry.net.za";
[ "${SUBTLDTYPE}" == "gov.za" ] && WHS="whois.gov.za";
[ "${SUBTLDTYPE}" == "gov.uk" ] && WHS="whois.gov.uk";
[ "${SUBTLDTYPE}" == "biz.ua" ] && WHS="whois.biz.ua";
[ "${SUBTLDTYPE}" == "co.ua" ] && WHS="whois.co.ua";
[ "${SUBTLDTYPE}" == "pp.ua" ] && WHS="whois.pp.ua";
fi
${WHOIS} -h ${WHS} "${1}" | env LC_CTYPE=C LC_ALL=C ${TR} -d "\r" > ${WHOIS_TMP}
if [ "${TLDTYPE}" == "kz" ];
then
${CURL} -s -A "$VARUSERAGENT" "https://www.ps.kz/domains/whois/result?q=${1}" \
| env LC_CTYPE=C LC_ALL=C ${TR} -d "\r" >${WHOIS_2_TMP}
fi
# Parse out the expiration date and registrar -- uses the last registrar it finds
REGISTRAR=`${AWK} -F: '/Registrar:/ && $2 != "" { REGISTRAR=substr($2,2,40) } END { print REGISTRAR }' ${WHOIS_TMP}\
| env LC_CTYPE=C LC_ALL=C ${TR} -d "\r" | ${SED} -e 's/[[:space:]\t]*// ;'`
if [ "${TLDTYPE}" == "uk" ] && [ "${SUBTLDTYPE}" != "gov.uk" ]; # for .uk domain
then
REGISTRAR=`${AWK} -F: '/Registrar:/ && $0 != "" { getline; sub(/^[ \t]+/,"",$0); print $0 }' ${WHOIS_TMP} \
| ${AWK} -F'[' '{ print $1 }'`
elif [ "${SUBTLDTYPE}" == "gov.uk" ];
then
REGISTRAR=`${AWK} '/Registered By:/ && $2 != "" { getline; sub(/^[ \t]+/,"",$0); print $0 }' ${WHOIS_TMP} |
${TR} -d "\r"`
elif [ "${TLDTYPE}" == "me" ];
then
REGISTRAR=`${AWK} -F: '/Registrar:/ && $2 != "" { REGISTRAR=substr($2,2,23) } END { print REGISTRAR }' ${WHOIS_TMP}`
elif [ "${TLDTYPE}" == "jp" ] && [ "${SUBTLDTYPE}" != "co.jp" ];
then
REGISTRAR=`${AWK} -F']' '/\[Registrant\]/ && $2 != "" { sub(/^[ \t]+/,"",$2); print $2 }' ${WHOIS_TMP} |
${TR} -d "\r"`
elif [ "${SUBTLDTYPE}" == "co.jp" ];
then
REGISTRAR=`${AWK} -F']' '/\[Organization\]/ && $2 != "" { sub(/^[ \t]+/,"",$2); print $2 }' ${WHOIS_TMP} |
${TR} -d "\r"`
# no longer shows Registrar name, so will use Status #
elif [ "${TLDTYPE}" == "md" ];
then
REGISTRAR=$(${AWK} -F: '/Registrar:/ && $2 != "" { REGISTRAR=substr($2,7,46) } END { print REGISTRAR }' ${WHOIS_TMP})
[ "x${REGISTRAR}" = "x" ] && REGISTRAR="Hidden"
elif [ "${TLDTYPE}" == "info" ];
then
REGISTRAR=`${AWK} -F: '/Registrar:/ && $2 != "" { REGISTRAR=substr($2,2,17) } END { print REGISTRAR }' ${WHOIS_TMP}`
if [ "${REGISTRAR}" = "" ]
then
REGISTRAR=`${AWK} -F: '/Sponsoring Registrar:/ && $2 != "" { REGISTRAR=substr($2,1,17) } END { print REGISTRAR }' ${WHOIS_TMP}`
fi
elif [ "${TLDTYPE}" == "edu" ]; # added by nixCraft 26-aug-2017
then
REGISTRAR=`${AWK} -F: '/Registrant:/ && $0 != "" { getline;REGISTRAR=substr($0,2,30) } END { print REGISTRAR }' ${WHOIS_TMP}`
elif [ "${TLDTYPE}" == "cafe" ]; # added by @kode29 26-aug-2017
then
REGISTRAR=`${AWK} -F: '/Registrar:/ && $0 != "" { REGISTRAR=substr($0,12,17) } END { print REGISTRAR }' ${WHOIS_TMP}`
elif [ "${TLDTYPE}" == "link" ]; # added by @kode29 26-aug-2017
then
REGISTRAR=`${AWK} -F: '/Registrar:/ && $0 != "" { REGISTRAR=substr($0,12,17) } END { print REGISTRAR }' ${WHOIS_TMP}`
elif [ "${TLDTYPE}" == "blog" ]; # added by @kode29 26-aug-2017
then
REGISTRAR=`${AWK} -F: '/Registrar:/ && $0 != "" { REGISTRAR=substr($0,12,17) } END { print REGISTRAR }' ${WHOIS_TMP}`
elif [ "${TLDTYPE}" == "ru" -o "${TLDTYPE}" == "su" ]; # added 20141113
then
REGISTRAR=`${AWK} -F: '/registrar:/ && $2 != "" { REGISTRAR=substr($2,6,17) } END { print REGISTRAR }' ${WHOIS_TMP}`
elif [ "${SUBTLDTYPE}" == "od.ua" ];
then
REGISTRAR=`${AWK} -F: '/registrar:/ && $2 != "" { REGISTRAR=substr($2,11,17) } END { print REGISTRAR }' ${WHOIS_TMP}`
elif [ "${TLDTYPE}" == "ua" ] && [ "${SUBTLDTYPE}" != "biz.ua" ] && [ "${SUBTLDTYPE}" != "co.ua" ] && \
[ "${SUBTLDTYPE}" != "pp.ua" ] && [ "${SUBTLDTYPE}" != "od.ua" ];
then
REGISTRAR=`${AWK} -F: '/registrar:/ && $2 != "" { REGISTRAR=substr($2,9,17) } END { print REGISTRAR }' ${WHOIS_TMP}`
elif [ "${SUBTLDTYPE}" == "biz.ua" ];
then
REGISTRAR=`${AWK} -F: '/[Rr]egistrar:/ && $2 != "" { print $2 }' ${WHOIS_TMP}`
elif [ "${SUBTLDTYPE}" == "co.ua" ];
then
REGISTRAR=`${AWK} -F: '/Billing [Oo]rganization:/ && $2 != "" && $2 !~ "not disclosed" { print $2 }' ${WHOIS_TMP}`
[ "x${REGISTRAR}" = "x" ] && REGISTRAR=`${AWK} -F: '/Billing ID:/ && $2 != "" && $2 !~ "not disclosed" { print $2 }' ${WHOIS_TMP}`
elif [ "${SUBTLDTYPE}" == "pp.ua" ];
then
REGISTRAR=`${AWK} -F: '/Billing [Oo]rganization:/ && $2 != "" && $2 !~ "not disclosed" { print $2 }' ${WHOIS_TMP}`
[ "x${REGISTRAR}" = "x" ] && REGISTRAR=`${AWK} -F: '/Billing ID:/ && $2 != "" && $2 !~ "not disclosed" { print $2 }' ${WHOIS_TMP}`
elif [ "${TLDTYPE}" == "укр" ]; # added by @click0 20190515
then
REGISTRAR=`${AWK} -F: '/Registrar:/ && $2 != "" { REGISTRAR=substr($2,2,65) } END { print REGISTRAR }' ${WHOIS_TMP}`
elif [ "${TLDTYPE}" == "kz" ]; # added by @click0 20190223
then
REGISTRAR=`${AWK} -F": " '/Current Registar:/ && $0 != "" { print $2 }' ${WHOIS_TMP} | ${TR} -d " \r"`
elif [ "${TLDTYPE}" == "cz" ]; # added by Minitram 20170830
then
REGISTRAR=`${AWK} -F: '/registrar:/ && $2 != "" { REGISTRAR=substr($2,5,17) } END { print REGISTRAR }' ${WHOIS_TMP}`
elif [ "${TLDTYPE}" == "pl" ] && [ "${SUBTLDTYPE}" != "co.pl" ];
then
REGISTRAR=`${AWK} -F: '/REGISTRAR:/ && $0 != "" { getline; sub(/^[ \t]+/,"",$0); print $0 }' ${WHOIS_TMP} | ${TR} -d " \r"`
elif [ "${SUBTLDTYPE}" == "co.pl" ] # added by @hawkeye116477 20190514;
then
REGISTRAR=`${GREP} -A1 'Holder data:' ${WHOIS_TMP} | ${AWK} -F': ' '/Name...:/ { print $2 }'`
elif [ "${TLDTYPE}" == "xyz" ];
then
REGISTRAR=`${AWK} -F: '/Registrar:/ && $0 != "" { REGISTRAR=substr($2,2,40) } END { print REGISTRAR }' ${WHOIS_TMP}`
elif [ "${TLDTYPE}" == "se" -o "${TLDTYPE}" == "nu" ];
then
REGISTRAR=`${AWK} -F: '/registrar:/ && $2 != "" { getline; REGISTRAR=substr($2,9,20) } END { print REGISTRAR }' ${WHOIS_TMP}`
elif [ "${TLDTYPE}" == "fi" ];
then
REGISTRAR=`${AWK} -F: '/registrar......../ && $2 != "" { REGISTRAR=substr($2,2,20) } END { print REGISTRAR }' ${WHOIS_TMP}`
elif [ "${TLDTYPE}" == "fr" -o "${TLDTYPE}" == "re" -o "${TLDTYPE}" == "tf" -o "${TLDTYPE}" == "yt" -o \
"${TLDTYPE}" == "pm" -o "${TLDTYPE}" == "wf" ];
then
REGISTRAR=`${AWK} -F: '/registrar:/ && $2 != "" { REGISTRAR=substr($2,22,40) } END { print REGISTRAR }' ${WHOIS_TMP}`
elif [ "${TLDTYPE}" == "dk" ];
then
REGISTRAR=`${AWK} -F: '/Registrar:/ && $2 != "" { REGISTRAR=substr($2,13,40) } END { print REGISTRAR }' ${WHOIS_TMP}`
elif [ "${TLDTYPE}" == "tr" ];
then
REGISTRAR=`${AWK} -F': ' '/Organization Name/ { REGISTRAR=substr($2,0,47);print REGISTRAR }' ${WHOIS_TMP}`
elif [ "${TLDTYPE}" == "it" ];
then
REGISTRAR=`${AWK} -F':' '/Registrar/ && $0 != "" { getline;REGISTRAR=substr($0,21,40) } END { print REGISTRAR }' ${WHOIS_TMP}`
elif [ "${TLDTYPE}" == "cn" ];
then
REGISTRAR=$(${AWK} -F': ' '/Registrant ID:|Registrant:/ && $0 != "" { print $2 }' ${WHOIS_TMP})
elif [ "${TLDTYPE}" == "io" ];
then
REGISTRAR=$(${AWK} -F: '/Registrar:/ && $0 != "" { print $2 }' ${WHOIS_TMP} | ${TR} -d " \r")
elif [ "${TLDTYPE}" == "mx" ];
then
REGISTRAR=$(${AWK} '/Registrar:/ && $0 != "" { print $2 }' ${WHOIS_TMP})
elif [ "${TLDTYPE}" == "is" ]; # added by @hawkeye116477 20190408
then
REGISTRAR=$(${AWK} '/registrant:/ && $0 != "" { print $2 }' ${WHOIS_TMP})
elif [ "${TLDTYPE}" == "sk" ]; # added by @hawkeye116477 20190603
then
REGISTRAR=$(${AWK} -F: '/^Registrar:/ && $0 != "" { getline; getline; sub(/^[ \t]+/,"",$2); print $2 }' ${WHOIS_TMP})
elif [ "${SUBTLDTYPE}" == "com.br" ];
then
REGISTRAR=$(${AWK} -F':' '/owner:/ && $0 != "" { print $2 }' ${WHOIS_TMP} | ${SED} -e 's/[[:space:]\t]*// ;')
elif [ "${TLDTYPE}" == "il" ];
then
REGISTRAR=$(${AWK} -F': ' '/registrar name:/ && $0 != "" { print $2 }' ${WHOIS_TMP})
elif [ "${TLDTYPE}" == "id" ];
then
REGISTRAR=$(${AWK} -F: '/Registrar Organization:/ && $2 != "" { sub(/^[ \t]+/,"",$2); print $2 }' ${WHOIS_TMP})
elif [ "${TLDTYPE}" == "tg" ];
then
REGISTRAR=`${ECHO} ${REGISTRAR} | ${TR} -d "."`
elif [ "${TLDTYPE}" == "hr" ];
then
REGISTRAR=$(${AWK} -F': ' '/Registrant Name:/ && $2 != "" { print $2 }' ${WHOIS_TMP})
elif [ "${TLDTYPE}" == "gg" ];
then
REGISTRAR=`${AWK} -F'(' '/Registrar:/ && $0 != "" { getline; sub(/^[ \t]+/,"",$0); print $1 }' ${WHOIS_TMP}`
elif [ "${TLDTYPE}" == "kr" ];
then
REGISTRAR=$(${AWK} -F: '/Registrant / && $2 != "" { sub(/^[ \t]+/,"",$2); print $2 }' ${WHOIS_TMP})
elif [ "${TLDTYPE}" == "hk" ];
then
REGISTRAR=`${AWK} -F: '/Registrar Name:/ && $2 != "" { REGISTRAR=substr($2,2,38) } END { print REGISTRAR }' ${WHOIS_TMP}`
elif [ "${TLDTYPE}" == "pt" ];
then
REGISTRAR=`${AWK} -F: '/Admin Name:/ && $2 != "" { REGISTRAR=substr($2,2,30) } END { print REGISTRAR }' ${WHOIS_TMP}`
elif [ "${TLDTYPE}" == "ar" ] && [ "${SUBTLDTYPE}" != "com.ar" ];
then
REGISTRAR=`${AWK} -F: '/name:/ && $2 != "" { REGISTRAR=substr($2,3,30) } END { print REGISTRAR }' ${WHOIS_TMP}`
elif [ "${TLDTYPE}" == "cf" ];
then
REGISTRAR=`${AWK} -F: '/Owner contact:/ { getline; getline; REGISTRAR=substr($2,10,40) } END { print REGISTRAR }' ${WHOIS_TMP}`
elif [ "${TLDTYPE}" == "bm" ];
then
REGISTRAR="$(${AWK} -F': ' '/Admin Organization:/ && $2 != "" { print $2 }' ${WHOIS_TMP})"
elif [ "${TLDTYPE}" == "ee" ];
then
REGISTRAR=`${AWK} -F: '/Registrant:/ && $0 != "" { getline; sub(/^[ \t]+/,"",$2); print $2 }' ${WHOIS_TMP}`
elif [ "${TLDTYPE}" == "pk" ];
then
REGISTRAR=$(${AWK} '/Domain:/ && $0 != "" { print $2 }' ${WHOIS_TMP})
elif [ "${TLDTYPE}" == "kg" ];
then
REGISTRAR="$(${AWK} -F: '/Billing Contact:/ { getline; getline; sub(/^[ \t]+/,"",$2); print $2 }' ${WHOIS_TMP})"
fi
# If the Registrar is NULL, then we didn't get any data
if [ "x${REGISTRAR}" = "x" ]
then
prints "${DOMAIN}" "Unknown" "Unknown" "Unknown" "Unknown"
return
fi
# The whois Expiration data should resemble the following: "Expiration Date: 09-may-2008"
if [ "${TLDTYPE}" == "com" -o "${TLDTYPE}" == "net" -o "${TLDTYPE}" == "org" -o "${TLDTYPE}" == "link" -o \
"${TLDTYPE}" == "blog" -o "${TLDTYPE}" == "cafe" -o "${TLDTYPE}" == "biz" -o "${TLDTYPE}" == "us" -o \
"${TLDTYPE}" == "mobi" -o "${TLDTYPE}" == "tv" -o "${TLDTYPE}" == "co" -o "${TLDTYPE}" == "pro" -o \
"${TLDTYPE}" == "cafe" -o "${TLDTYPE}" == "in" -o "${TLDTYPE}" == "cat" -o "${TLDTYPE}" == "asia" -o \
"${TLDTYPE}" == "cc" -o "${TLDTYPE}" == "college" -o "${TLDTYPE}" == "aero" -o "${TLDTYPE}" == "online" -o \
"${TLDTYPE}" == "app" -o "${TLDTYPE}" == "io" -o "${TLDTYPE}" == "me" -o "${TLDTYPE}" == "xyz" -o \
"${TLDTYPE}" == "top" -o "${TLDTYPE}" == "bid" -o "${TLDTYPE}" == "ng" -o "${TLDTYPE}" == "site" -o \
"${TLDTYPE}" == "icu" -o "${TLDTYPE}" == "cloud" -o "${TLDTYPE}" == "systems" -o \
"${TLDTYPE}" == "expert" -o "${TLDTYPE}" == "express" -o "${TLDTYPE}" == "ca" -o "${TLDTYPE}" == "space" -o \
"${TLDTYPE}" == "fun" -o "${TLDTYPE}" == "museum" -o "${TLDTYPE}" == "live" -o "${TLDTYPE}" == "club" -o \
"${TLDTYPE}" == "stream" -o "${TLDTYPE}" == "today" -o "${TLDTYPE}" == "website" -o "${TLDTYPE}" == "host" -o \
"${TLDTYPE}" == "team" -o "${TLDTYPE}" == "info" -o "${TLDTYPE}" == "xxx" -o \
"${TLDTYPE}" == "se" -o "${TLDTYPE}" == "nu" -o "${TLDTYPE}" == "dk" -o "${TLDTYPE}" == "it" -o \
"${TLDTYPE}" == "do" -o "${TLDTYPE}" == "ro" -o "${TLDTYPE}" == "game" -o "${TLDTYPE}" == "pk" -o \
"${TLDTYPE}" == "ee" -o "${TLDTYPE}" == "st" -o "${TLDTYPE}" == "sg" ];
then
# From date format 2023-12-11 convert to ${tday}-${tmonth}-${tyear} (11-dec-2023)
tdomdate=`${AWK} '/Registrar Registration Expiration [Dd]ate:|Registry Expiry Date:|Expiration [Dd]ate:|\
Renewal date:|Expir[ey] [Dd]ate:|Expires [Oo]n:|Expires [Oo]n:|[Ee]xpires?:/ \
{ print $NF }' ${WHOIS_TMP} | ${AWK} -FT '{ print $1 }' | ${HEAD} -1`
tyear=`echo ${tdomdate} | ${CUT} -d'-' -f1`
tmon=`echo ${tdomdate} | ${CUT} -d'-' -f2`
tmonth=$(getmonth_number ${tmon})
tday=`echo ${tdomdate} | ${CUT} -d'-' -f3 | ${CUT} -d'T' -f1`
DOMAINDATE=`echo "${tday}-${tmonth}-${tyear}"`
elif [ "${TLDTYPE}" == "uk" ] && [ "${SUBTLDTYPE}" != "gov.uk" ]; # for .uk domain (excluding .gov.uk subdomains)
then
DOMAINDATE=`${AWK} '/Renewal date:|Expiry date:/ { print tolower($3) }' ${WHOIS_TMP}`
elif [ "${SUBTLDTYPE}" == "gov.uk" ];
then
tdomdate=`${AWK} '/Renewal date:/ && $2 != "" \
{ getline; sub(/^[ \t]+/,"",$0); sub(/th/,"",$2);print $2"-"tolower($3)"-"$4 }' ${WHOIS_TMP}`
DOMAINDATE=${tdomdate}
elif [ "${TLDTYPE}" == "jp" ] && [ "${SUBTLDTYPE}" != "co.jp" ];
then
tdomdate=`${AWK} -F] '/\[有効期限\]|\[Expires on\]/ { print $2 }' ${WHOIS_TMP} | ${TR} -d " \r"`
tyear=`echo ${tdomdate} | ${CUT} -d'/' -f1`
tmon=`echo ${tdomdate} | ${CUT} -d'/' -f2`
tmonth=$(getmonth_number ${tmon})
tday=`echo ${tdomdate} | ${CUT} -d'/' -f3`
DOMAINDATE=`echo $tday-$tmonth-$tyear`
elif [ "${SUBTLDTYPE}" == "co.jp" ];
then
tdomdate=`${AWK} '/\[状態\]/ { print $NF }' ${WHOIS_TMP} | ${TR} -d "() \r"`
tyear=`echo ${tdomdate} | ${CUT} -d'/' -f1`
tmon=`echo ${tdomdate} | ${CUT} -d'/' -f2`
tmonth=$(getmonth_number ${tmon})
tday=`echo ${tdomdate} | ${CUT} -d'/' -f3`
DOMAINDATE=`echo $tday-$tmonth-$tyear`
elif [ "${TLDTYPE}" == "ru" -o "${TLDTYPE}" == "su" ]; # for .ru and .su 2014/11/13
then
tdomdate=`${AWK} '/paid-till:/ { print $2 }' ${WHOIS_TMP}`
tyear=`echo ${tdomdate} | ${CUT} -d'-' -f1`
tmon=`echo ${tdomdate} |${CUT} -d'-' -f2`
tmonth=$(getmonth_number ${tmon})
tday=`echo ${tdomdate} | ${CUT} -d'-' -f3 | ${CUT} -d'T' -f1`
DOMAINDATE=`echo "${tday}-${tmonth}-${tyear}"`
elif [ "${TLDTYPE}" == "ua" ] && [ "${SUBTLDTYPE}" != "biz.ua" ] && [ "${SUBTLDTYPE}" != "co.ua" ] && \
[ "${SUBTLDTYPE}" != "pp.ua" ];
then
tdomdate=`${AWK} '/expires:/ { print $2 }' ${WHOIS_TMP}`
tyear=`echo ${tdomdate} | ${CUT} -d'-' -f1`
tmon=`echo ${tdomdate} | ${CUT} -d'-' -f2`
tmonth=$(getmonth_number ${tmon})
tday=`echo ${tdomdate} | ${CUT} -d'-' -f3 | ${CUT} -d'T' -f1`
DOMAINDATE=`echo "${tday}-${tmonth}-${tyear}"`
elif [ "${SUBTLDTYPE}" == "biz.ua" ];
then
tdomdate=`${AWK} '/Expiration Date:/ { print $2 }' ${WHOIS_TMP} | ${AWK} -F: '{ print tolower($2) }'`
DOMAINDATE=${tdomdate}
elif [ "${SUBTLDTYPE}" == "co.ua" ];
then
tdomdate=`${AWK} '/Expiration Date:/ { print $2 }' ${WHOIS_TMP} | ${AWK} -F: '{ print tolower($2) }'`
DOMAINDATE=${tdomdate}
elif [ "${SUBTLDTYPE}" == "pp.ua" ];
then
tdomdate=`${AWK} '/Expiration Date:/ { print $2 }' ${WHOIS_TMP} | ${AWK} -F: '{ print tolower($2) }'`
DOMAINDATE=${tdomdate}
elif [ "${TLDTYPE}" == "укр" ]; # for .укр @click0 2019/05/15
then
tdomdate=`${AWK} '/Expiration Date:/ { print $3 }' ${WHOIS_TMP}`
tyear=`echo ${tdomdate} | ${CUT} -d'-' -f3`
tmon=`echo ${tdomdate} | ${CUT} -d'-' -f2`
tmonth=$(getmonth ${tmon})
tmonth=$(getmonth_number ${tmonth})
tday=`echo ${tdomdate} | ${CUT} -d'-' -f1`
DOMAINDATE=`echo "${tday}-${tmonth}-${tyear}"`
elif [ "${TLDTYPE}" == "is" ]; # for .is @hawkeye116477 2019/04/08
then
tdomdate=`${AWK} '/expires:/ { print $2 " " $3 " " $4}' ${WHOIS_TMP}`
tyear=`echo ${tdomdate} | ${CUT} -d' ' -f3`
tmon=`echo ${tdomdate} | ${CUT} -d' ' -f1`
case ${tmon} in
January) tmonth=jan ;;
February) tmonth=feb ;;
March) tmonth=mar ;;
April) tmonth=apr ;;
May) tmonth=may ;;
June) tmonth=jun ;;
July) tmonth=jul ;;
August) tmonth=aug ;;
September) tmonth=sep ;;
October) tmonth=oct ;;
November) tmonth=nov ;;
December) tmonth=dec ;;
*) tmonth=0 ;;
esac
tday=`echo ${tdomdate} | ${CUT} -d' ' -f2`
DOMAINDATE=`echo "${tday}-${tmonth}-${tyear}"`
elif [ "${TLDTYPE}" == "kz" ]; # for .kz @click0 2019/02/23
then
tdomdate=$(${GREP} -A 2 'Дата окончания:' ${WHOIS_2_TMP} | ${TAIL} -n 1 | ${AWK} '{print $1;}' | ${AWK} -FT '{print $1}')
tyear=`echo ${tdomdate} | ${CUT} -d'-' -f1`
tmon=`echo ${tdomdate} | ${CUT} -d'-' -f2`
tmonth=$(getmonth_number ${tmon})
tday=$(echo ${tdomdate} | ${CUT} -d'-' -f3)
DOMAINDATE=`echo "${tday}-${tmonth}-${tyear}"`
elif [ "${TLDTYPE}" == "edu" ] # added on 26-aug-2017 by nixCraft
then
tdomdate=`${AWK} '/Domain expires:/ { print $NF }' ${WHOIS_TMP}`
tyear=`echo ${tdomdate} | ${CUT} -d'-' -f3`
tmon=`echo ${tdomdate} |${CUT} -d'-' -f2`
tmonth=$(getmonth_number ${tmon})
tday=`echo ${tdomdate} | ${CUT} -d'-' -f1`
DOMAINDATE=`echo "${tday}-${tmon}-${tyear}"`
elif [ "${TLDTYPE}" == "cz" ] # added on 20170830 by Minitram
then
tdomdate=`${AWK} '/expire:/ { print $NF }' ${WHOIS_TMP}`
tyear=`echo ${tdomdate} | ${CUT} -d'.' -f3`
tmon=`echo ${tdomdate} |${CUT} -d'.' -f2`
tmonth=$(getmonth_number ${tmon})
tday=`echo ${tdomdate} | ${CUT} -d'.' -f1`
DOMAINDATE=`echo "${tday}-${tmonth}-${tyear}"`
elif [ "${TLDTYPE}" == "pl" ] && [ "${SUBTLDTYPE}" != "co.pl" ] # NASK
then
tdomdate=`${AWK} -F: '/^expiration date:/ || /renewal date:/ { print $2; }' ${WHOIS_TMP} | ${AWK} -F" " '{ print $1; }'`
tyear=`echo ${tdomdate} | ${CUT} -d'.' -f1`
tmon=`echo ${tdomdate} | ${CUT} -d'.' -f2`
tmonth=$(getmonth_number ${tmon})
tday=`echo ${tdomdate} | ${CUT} -d'.' -f3`
DOMAINDATE=`echo "${tday}-${tmonth}-${tyear}"`
elif [ "${SUBTLDTYPE}" == "co.pl" ]; # for .co.pl @hawkeye116477 2019/05/14
then
tdomdate=`${AWK} '/Expires:/ { print $2 }' ${WHOIS_TMP}`
tyear=`echo ${tdomdate} | ${CUT} -d'.' -f1`
tmon=`echo ${tdomdate} | ${CUT} -d'.' -f2`
tmonth=$(getmonth_number ${tmon})
tday=`echo ${tdomdate} | ${CUT} -d'.' -f3`
DOMAINDATE=`echo "${tday}-${tmonth}-${tyear}"`
elif [ "${TLDTYPE}" == "fi" ];
then
tdomdate=`${AWK} '/expires/ { print $2 }' ${WHOIS_TMP}`
tyear=`echo ${tdomdate} | ${CUT} -d'.' -f3`
tmon=`echo ${tdomdate} | ${CUT} -d'.' -f2`
tmonth=$(getmonth_number ${tmon})
tday=`echo ${tdomdate} | ${CUT} -d'.' -f1`
DOMAINDATE=`echo "${tday}-${tmonth}-${tyear}"`
elif [ "${TLDTYPE}" == "fr" -o "${TLDTYPE}" == "re" -o "${TLDTYPE}" == "tf" -o "${TLDTYPE}" == "yt" -o \
"${TLDTYPE}" == "pm" -o "${TLDTYPE}" == "wf" -o "${TLDTYPE}" == "mx" -o "${TLDTYPE}" == "sk" ];
then
tdomdate=`${AWK} '/Expiry Date:|Expiration Date:|Valid Until:/ { print $3 }' ${WHOIS_TMP}`
tyear=`echo ${tdomdate} | ${CUT} -d'-' -f1`
tmon=`echo ${tdomdate} | ${CUT} -d'-' -f2`
tmonth=$(getmonth_number ${tmon})
tday=`echo ${tdomdate} | ${CUT} -d'-' -f3 | ${CUT} -d'T' -f1`
DOMAINDATE=`echo "${tday}-${tmonth}-${tyear}"`
elif [ "${TLDTYPE}" == "tr" ];
then
tdomdate=`${AWK} '/Expires/ { print substr($3, 1, length($3)-1) }' ${WHOIS_TMP}`
tyear=`echo ${tdomdate} | ${CUT} -d'-' -f1`
tmon=`echo ${tdomdate} | ${CUT} -d'-' -f2`
tday=`echo ${tdomdate} | ${CUT} -d'-' -f3`
DOMAINDATE=`echo "${tday}-${tmon}-${tyear}"`
elif [ "${TLDTYPE}" == "cn" ]; # for .cn @click0 2019/02/12
then
tdomdate=`${AWK} -F':' '/Expiration Time:/ { print $2 }' ${WHOIS_TMP} | ${AWK} '{ print $1; }'`
tyear=`echo ${tdomdate} | ${CUT} -d'-' -f1`
tmon=`echo ${tdomdate} | ${CUT} -d'-' -f2`
tmonth=$(getmonth_number ${tmon})
tday=`echo ${tdomdate} | ${CUT} -d'-' -f3`
DOMAINDATE=`echo "${tday}-${tmonth}-${tyear}"`
elif [ "${TLDTYPE}" == "id" ]; # for .id @Minitram 2019/07/01
then
tdomdate=`${AWK} '/Expiration Date:/ { print $3 }' ${WHOIS_TMP}`
tyear=`echo ${tdomdate} | ${CUT} -d'-' -f3`
tmon=`echo ${tdomdate} | ${CUT} -d'-' -f2`
tmonth=$(tolower ${tmon})
tday=`echo ${tdomdate} | ${CUT} -d'-' -f1`
DOMAINDATE=`echo "${tday}-${tmonth}-${tyear}"`
elif [ "${SUBTLDTYPE}" == "com.br" ];
then
tdomdate=`${AWK} '/expires:/ { print $2 }' ${WHOIS_TMP}`
tyear=`echo ${tdomdate} | ${CUT} -c 1-4`
tmon=`echo ${tdomdate} | ${CUT} -c 5-6`
tmonth=$(getmonth_number ${tmon})
tday=`echo ${tdomdate} | ${CUT} -c 7-8`
DOMAINDATE=`echo "${tday}-${tmonth}-${tyear}"`
elif [ "${TLDTYPE}" == "il" ]
then
tdomdate=`${AWK} '/validity:/ { print $NF }' ${WHOIS_TMP}`
tyear=`echo ${tdomdate} | ${CUT} -d'-' -f3`
tmon=`echo ${tdomdate} | ${CUT} -d'-' -f2`
tmonth=$(getmonth_number ${tmon})
tday=`echo ${tdomdate} | ${CUT} -d'-' -f1`
DOMAINDATE=`echo "${tday}-${tmonth}-${tyear}"`
elif [ "${TLDTYPE}" == "tg" ]
then