Compare commits

..

No commits in common. "next" and "v5.5.22" have entirely different histories.

22 changed files with 434 additions and 522 deletions

View File

@ -2,7 +2,7 @@
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
<https://fsf.org/>
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
@ -304,7 +304,8 @@ the "copyright" line and a pointer to where the full notice is found.
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, see <https://www.gnu.org/licenses/>.
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Also add information on how to contact you by electronic and paper mail.
@ -328,8 +329,8 @@ necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Moe Ghoul>, 1 April 1989
Moe Ghoul, President of Vice
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may

View File

@ -26,17 +26,12 @@
/* which versions? */
# define HAVE_GETOPT_LONG
# define HAVE_GETADDRINFO
# define HAVE_READPASSPHRASE
# define ENABLE_NLS
# ifndef LOCALEDIR
# define LOCALEDIR "/usr/local/share/locale"
# endif
#endif
#if defined OpenBSD
# define HAVE_READPASSPHRASE
#endif
/* needs unistd.h */
#if defined _POSIX_C_SOURCE && _POSIX_C_SOURCE >= 200112L
# define HAVE_GETADDRINFO
@ -46,7 +41,6 @@
#if defined __APPLE__ && defined __MACH__
# define HAVE_GETOPT_LONG
# define HAVE_GETADDRINFO
# define HAVE_READPASSPHRASE
# define HAVE_BSDICRYPT
#endif

21
data.h
View File

@ -1,5 +1,3 @@
/* SPDX-License-Identifier: GPL-2.0-or-later */
/*
* RIPE-like servers.
* All of them do not understand -V2.0Md with the exception of RA and RIPN.
@ -17,23 +15,10 @@ const char *ripe_servers[] = {
"whois.ripn.net",
"whois.register.si",
"whois.nic.ir",
"whois.ra.net",
NULL
};
struct server_referral_handler {
const char *name;
void (*handler)(char **referral_server, const char *buf);
};
const struct server_referral_handler server_referral_handlers[] = {
{ "whois.apnic.net", find_referral_server_apnic },
{ "whois.arin.net", find_referral_server_arin },
{ "whois.iana.org", find_referral_server_iana },
{ "\x04", find_referral_server_verisign },
{ "\x08", find_referral_server_recursive },
{ NULL, NULL }
};
const char *hide_strings[] = {
"The data in Networksolutions.com's WHOIS database", NULL,
/* Some registrars like .wang copied the first paragraph of this
@ -48,7 +33,7 @@ const char *hide_strings[] = {
"Please register your domains at; http://www.", NULL, /* key-systems.net */
"%% NOTICE: Access to this information is provided", NULL, /* bookmyname.com */
"NOTICE: Access to the domain name's information", NULL, /* CORE */
"The data in MarkMonitors WHOIS", NULL, /* MarkMonitor */
"The Data in MarkMonitor.com's", NULL, /* MarkMonitor */
"Corporation Service Company(c) (CSC) The Trusted Partner", "Register your domain name at", /* CSC */
"The data in Networksolutions.com's", NULL, /* Networksolutions */
"# Welcome to the OVH WHOIS Server", "", /* ovh */
@ -87,10 +72,8 @@ const char *hide_strings[] = {
"Access to .IN WHOIS information", NULL, /* in */
"access to .in whois information", NULL, /* in registar */
"% Use of CIRA's WHOIS service is governed by the Terms of Use in its Legal", NULL, /* sx */
"Terms of Use: Access to WHOIS information", NULL, /* vc */
"The Service is provided so that you may look", "We may discontinue",/*vu*/
"NeuStar, Inc., the Registry Administrator for .US", NULL,
"; This data is provided ", NULL, /* whois.1api.net */
NULL, NULL
};

81
debian/changelog vendored
View File

@ -1,84 +1,3 @@
whois (5.6.6) unstable; urgency=medium
* Added the .mc TLD server.
* Updated the .ps TLD server.
* Removed the .info, .mobi, .travel and .فلسطين (.xn--ygbi2ammx,
Palestinian Territory) TLD servers.
* Removed 3 new gTLDs which are no longer active.
* mkpasswd: added support the Chinese SM3-based hashing algorithms.
-- Marco d'Itri <md@linux.it> Mon, 16 Feb 2026 02:46:51 +0100
whois (5.6.5) unstable; urgency=medium
* Updated the .co TLD server.
* Added some large KRNIC networks.
* Updated the second level .uk TLD servers.
* Removed the .pro TLD server.
* Removed 1 new gTLD which is no longer active.
-- Marco d'Itri <md@linux.it> Mon, 13 Oct 2025 03:37:20 +0200
whois (5.6.4) unstable; urgency=medium
* Updated the .cm and .to TLD servers.
-- Marco d'Itri <md@linux.it> Sat, 02 Aug 2025 01:13:07 +0200
whois (5.6.3) unstable; urgency=medium
* Added the .sr and .мон (.xn--l1acc, Mongolia) TLD servers.
* Use readpassphrase(3) on OpenBSD and FreeBSD.
-- Marco d'Itri <md@linux.it> Thu, 17 Jul 2025 05:15:53 +0200
whois (5.6.2) unstable; urgency=medium
* Updated the .post and .in (and related IDN TLDs) TLD servers.
* Removed 1 new gTLDs which is no longer active.
* Build-Depend on libcrypt-dev. (Closes: #1106977)
-- Marco d'Itri <md@linux.it> Fri, 06 Jun 2025 18:22:04 +0200
whois (5.6.1) unstable; urgency=medium
* Added the .pg TLD server.
* Updated the .gov, .mu, .中国 (.xn--fiqs8s) and .中國 (.xn--fiqz9s)
TLD servers.
* Removed the .jobs TLD server.
* Added the encodings for whois.afrinic.net and whois.apnic.net.
* Enabled the UTF-8 encoding for whois.ripe.net.
* Use the last ReferralServer returned by the ARIN server instead of
the first, because we want to follow the referral for the most
specific record returned.
* Make sure to avoid trivial referral loops.
-- Marco d'Itri <md@linux.it> Sat, 17 May 2025 01:30:06 +0200
whois (5.6.0) unstable; urgency=medium
* Fixed the mangling of RADB queries with commands.
* Implemented the parsing of more variants of ARIN's ReferralServer
field.
* Implemented following the APNIC pseudo-referrals.
* Added the .ad and .za TLD servers.
* Updated the .ao, .bz, .gi, .gq, .gr, .gw, .lc, .md, .pn, .pr, .uy, .vc,
.info, .mobi, .ελ (.xn--qxam, Greece) and .გე (.xn--node, Georgia) TLD
servers.
* Added 2410::/12.
* Removed 7 new gTLDs which are no longer active.
* Cleaned up the markup of the man pages, courtesy of Bjarni Ingi
Gislason. (Closes: #1036826, #1094208)
-- Marco d'Itri <md@linux.it> Mon, 05 May 2025 02:57:37 +0200
whois (5.5.23) unstable; urgency=medium
* Updated the .sc, .新加坡 (.xn--yfro4i67o, Singapore) and .சிங்கப்பூர்
(.xn--clchc0ea0b2g2a9gcd, Singapore) TLD servers.
-- Marco d'Itri <md@linux.it> Sat, 04 May 2024 03:13:22 +0200
whois (5.5.22) unstable; urgency=medium
* Fixed a segmentation fault with --no-recursion.

9
debian/control vendored
View File

@ -2,14 +2,13 @@ Source: whois
Section: net
Priority: standard
Maintainer: Marco d'Itri <md@linux.it>
Standards-Version: 4.7.2.0
Standards-Version: 4.6.2.0
Rules-Requires-Root: no
Build-Depends: debhelper-compat (= 13), gettext, pkgconf,
bash-completion,
libcrypt-dev,
libidn2-dev,
Vcs-Git: https://salsa.debian.org/md/whois.git
Vcs-Browser: https://salsa.debian.org/md/whois
libidn2-dev (>= 2.0.3),
Vcs-Git: https://github.com/rfc1036/whois.git
Vcs-Browser: https://github.com/rfc1036/whois
Package: whois
Architecture: any

6
debian/salsa-ci.yml vendored
View File

@ -1,6 +0,0 @@
---
include:
- https://salsa.debian.org/salsa-ci-team/pipeline/raw/master/recipes/debian.yml
variables:
SALSA_CI_IGNORED_BRANCHES: '^next$'

View File

@ -35,12 +35,13 @@
2003:0000::/18 ripe
2400:0000::/20 whois.nic.or.kr
2400:0000::/11 apnic
2400:0000::/12 apnic
2600:0000::/12 arin
2610:0000::/23 arin
2620:0000::/23 arin
2630:0000::/12 arin
2800:0000::/12 lacnic
2A00:0000::/11 ripe
2A00:0000::/12 ripe
2A10:0000::/12 ripe
2C00:0000::/12 afrinic

View File

@ -10,20 +10,16 @@
1.0.0.0/8 apnic
2.0.0.0/8 ripe
5.0.0.0/8 ripe
14.64.0.0/11 whois.nic.or.kr
14.0.0.0/8 apnic
24.132.0.0/14 ripe
27.176.0.0/13 whois.nic.or.kr
27.0.0.0/8 apnic
31.0.0.0/8 ripe
36.0.0.0/8 apnic
37.0.0.0/8 ripe
39.0.0.0/8 apnic
41.0.0.0/8 afrinic
42.32.0.0/12 whois.nic.or.kr
42.0.0.0/7 apnic
46.0.0.0/8 ripe
49.8.0.0/14 whois.nic.or.kr
49.0.0.0/8 apnic
51.0.0.0/8 ripe
# whois -r -K -h whois.apnic.net -i admin-c IM76-AP

View File

@ -18,7 +18,7 @@ while (<>) {
$b = "\\x03" if $b eq 'NONE';
$b =~ s/^RECURSIVE\s+/\\x08" "/;
$b = "\\x08$b" if $b eq 'whois.flexireg.net';
$b = "\\x08$b" if $b eq 'whois.nixiregistry.in';
$b = "\\x08$b" if $b eq 'whois.registry.in';
$b = "\\x0C" if $b eq 'ARPA';
$b = "\\x0D" if $b eq 'IP6';
print qq| "$a",\t"$b",\n|;

View File

@ -14,17 +14,12 @@ close($fh);
my ($ver) = $line =~ /^whois \s+ \( ( [^\)]+ ) \) \s+ \S+/x;
die "Version number not found in $changelog!\n" if not $ver;
$ver =~ s/ (
build\d+
| ubuntu\d+
| ~\S+
| \+\S+
) $//x;
$ver =~ s/ ( ~bpo\d+\+\d+ | \+b\d+ | ~deb\d+.* | ubuntu\d+ | build\d+ | \+dyson\d+ ) $//x;
# The version number must not deviate from this format or the -V option
# to RIPE-like servers will break. If needed, update the previous regexp.
# This may not be true anymore in 2019.
die "Invalid version number in $changelog: '$ver'!\n"
die "Invalid version number in $changelog!\n"
unless $ver =~ /^ \d+\.\d+ ( \.\d+ )? $/x;
# This is the version number used in the help messages.

View File

@ -12,28 +12,28 @@ encrypts the given password with the
libc function, using the given salt.
.SH OPTIONS
.TP
.BR \-S " STRING\fR, \fP" \-\-salt= \fISTRING\fP
.BR \-S ", "\c
.BI \-\-salt= STRING
Use the
.I STRING
as salt.
If it begins with
as salt. If it begins with
.I $
then it will be passed straight to
.BR crypt (3)
without any checks.
.TP
.BR \-R " NUMBER\fR, \fP" \-\-rounds= \fINUMBER\fP
.BR \-R ", "\c
.BI \-\-rounds= NUMBER
Use
.I NUMBER
rounds.
This argument is ignored if the method chosen
does not support variable rounds.
For the OpenBSD Blowfish method this is
rounds. This argument is ignored if the method chosen
does not support variable rounds. For the OpenBSD Blowfish method this is
the logarithm of the number of rounds.
The behavior is undefined if this option is used without
.IR \-\-method .
.TP
.BR \-m " TYPE\fR, \fP" \-\-method= \fITYPE\fP
.BR \-m ", "\c
.BI \-\-method= TYPE
Compute the password using the
.I TYPE
method.
@ -47,18 +47,20 @@ If
begins and end with
.I $
characters then the string is passed to
.BR crypt_gensalt (3)
.IR crypt_gensalt (3)
as-is.
.TP
.B \-5
.B -5
Like
.IR \-\-method=md5crypt .
.TP
.BI \-P " NUM\fR, \fP" \-\-password-fd= NUM
.B \-P \c
.IR NUM ", "\c
.BI \-\-password-fd= NUM
Read the password from file descriptor
.I NUM
instead of using
.BR getpass (3).
.IR getpass (3).
If the file descriptor is not connected to a tty then no other text
than the hashed password is printed on stdout.
.TP
@ -77,16 +79,16 @@ characters may not be read correctly.
.P
This program suffers of a bad case of featuritis.
.SH "SEE ALSO"
.BR passwd (1),
.BR passwd (5),
.BR crypt (3),
.BR crypt (5),
.BR crypt_gensalt (3),
.BR getpass (3).
.IR passwd (1),
.IR passwd (5),
.IR crypt (3),
.IR crypt (5),
.IR crypt_gensalt (3),
.IR getpass (3).
.SH AUTHOR
.B mkpasswd
and this man page were written by Marco d'Itri
.RI < md@linux.it >
and are licensed under the terms of the GNU General Public License,
version 2 or later.
.\" SPDX-License-Identifier: GPL-2.0-or-later
\" SPDX-License-Identifier: GPL-2.0-or-later

View File

@ -12,7 +12,8 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, see <https://www.gnu.org/licenses/>.
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
@ -46,9 +47,6 @@
#ifdef HAVE_GETTIMEOFDAY
#include <sys/time.h>
#endif
#ifdef HAVE_READPASSPHRASE
#include <readpassphrase.h>
#endif
/* Application-specific */
#include "version.h"
@ -102,6 +100,9 @@ static const struct crypt_method methods[] = {
{ "md5", "$1$", 8, 8, 0, NULL },
#if defined XCRYPT_VERSION_NUM
{ "yescrypt", "$y$", 0, 0, 1, "Yescrypt" },
#if XCRYPT_VERSION_NUM >= ((4 << 16) | 4)
{ "gost-yescrypt", "$gy$", 0, 0, 1, "GOST Yescrypt" },
#endif
{ "scrypt", "$7$", 0, 0, 1, "scrypt" },
#endif
#ifdef HAVE_BCRYPT_OBSOLETE
@ -110,7 +111,7 @@ static const struct crypt_method methods[] = {
#endif
#ifdef HAVE_BCRYPT
{ "bcrypt", "$2b$", 22, 22, 2, "bcrypt" },
{ "bcrypt_a", "$2a$", 22, 22, 2, "bcrypt (obsolete $2a$ version)" },
{ "bcrypt-a", "$2a$", 22, 22, 2, "bcrypt (obsolete $2a$ version)" },
#endif
#if defined HAVE_SHA_CRYPT
/* http://people.redhat.com/drepper/SHA-crypt.txt */
@ -137,13 +138,6 @@ static const struct crypt_method methods[] = {
#endif
{ "descrypt", "", 2, 2, 0,
N_("standard 56 bit DES-based crypt(3)") },
#if XCRYPT_VERSION_NUM >= ((4 << 16) | 5)
{ "sm3crypt", "$sm3$", 0, 0, 1, "ShangMi 3" },
{ "sm3_yescrypt", "$sm3y$", 0, 0, 1, "ShangMi 3 Yescrypt" },
#endif
#if XCRYPT_VERSION_NUM >= ((4 << 16) | 4)
{ "gost_yescrypt", "$gy$", 0, 0, 1, "GOST Yescrypt" },
#endif
#if defined FreeBSD || defined XCRYPT_VERSION_NUM
{ "nt", "$3$", 0, 0, 0, "NT-Hash" },
#endif
@ -393,21 +387,11 @@ int main(int argc, char *argv[])
exit(2);
}
} else {
#ifdef HAVE_READPASSPHRASE
const size_t size = 128;
password = NOFAIL(malloc(size));
if (!readpassphrase(_("Password: "), password, size, 0)) {
perror("readpassphrase");
exit(2);
}
#else
password = getpass(_("Password: "));
if (!password) {
perror("getpass");
exit(2);
}
#endif
}
{

View File

@ -99,6 +99,7 @@ bcn
beats
beauty
beer
bentley
berlin
best
bestbuy
@ -239,6 +240,7 @@ cruises
cuisinella
cymru
cyou
dabur
dad
dance
data
@ -282,6 +284,7 @@ download
drive
dtv
dubai
dunlop
dupont
durban
dvag
@ -398,6 +401,7 @@ godaddy
gold
goldpoint
golf
goo
goodyear
goog
google
@ -503,6 +507,7 @@ juniper
kaufen
kddi
kerryhotels
kerrylogistics
kerryproperties
kfh
kia
@ -523,6 +528,7 @@ kyoto
lacaixa
lamborghini
lamer
lancaster
land
landrover
lanxess
@ -551,6 +557,7 @@ limited
limo
lincoln
link
lipsy
live
living
llc
@ -626,6 +633,7 @@ mtr
music
nab
nagoya
natura
navy
nba
nec
@ -716,6 +724,7 @@ pohl
poker
politie
porn
pramerica
praxi
press
prime
@ -742,6 +751,7 @@ realtor
realty
recipes
red
redstone
redumbrella
rehab
reise
@ -817,6 +827,7 @@ sexy
sfr
shangrila
sharp
shaw
shell
shia
shiksha
@ -990,6 +1001,7 @@ windows
wine
winners
wme
wolterskluwer
woodside
work
works

90
ripe-mail Normal file
View File

@ -0,0 +1,90 @@
From ripe-dbm@ripe.net Mon Jan 27 10:09:59 2003
Return-Path: <ripe-dbm@ripe.net>
Delivered-To: md@wonderland.linux.it
Received: from attila.bofh.it (localhost [127.0.0.1])
by wonderland.linux.it (Postfix/Md) with ESMTP id 582BA33CD5
for <md@wonderland.linux.it>; Mon, 27 Jan 2003 10:09:59 +0100 (CET)
Received: from picard.linux.it (picard.linux.it [::ffff:62.177.1.107])
by attila.bofh.it (Postfix) with ESMTP id 46AE15F966
for <md@wonderland.linux.it>; Mon, 27 Jan 2003 09:03:25 +0100 (CET)
Received: from birch.ripe.net (birch.ripe.net [::ffff:193.0.1.96])
by picard.linux.it (Postfix) with ESMTP id 4A76942B2
for <md@Linux.IT>; Mon, 27 Jan 2003 09:05:01 +0100 (CET)
Received: from x24.ripe.net (x24.ripe.net [193.0.1.24])
by birch.ripe.net (8.12.5/8.11.6) with ESMTP id h0R83NAq030231;
Mon, 27 Jan 2003 09:03:23 +0100
Received: (from ripe-dbm@localhost)
by x24.ripe.net (8.12.4/8.12.6) id h0R83M5k002263;
Mon, 27 Jan 2003 09:03:22 +0100
Message-Id: <200301270803.h0R83M5k002263@x24.ripe.net>
From: RIPE Database Administration <ripe-dbm@ripe.net>
Cc: Can Bican <can@ripe.net>
To: md@Linux.IT
FCC: cur
Subject: Re: NCC#2003013332 Re: [db-wg] IPv6 Whois update
Reply-To: ripe-dbm@ripe.net
X-Organization: RIPE Network Coordination Centre
X-Phone: +31 20 535 4444
X-Fax: +31 20 535 4341
X-Mailer: BaT/0.67
Sender: RIPE Database Manager <ripe-dbm@ripe.net>
Date: Mon, 27 Jan 2003 09:03:21 +0100
MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
X-Spam-Status: No, hits=0.6 required=5.0
tests=DEAR_SOMEBODY,QUOTED_EMAIL_TEXT,SIGNATURE_SHORT_DENSE,
SPAM_PHRASE_05_08
version=2.43
X-Spam-Level:
Status: RO
Content-Length: 1239
Lines: 46
Dear Marco d'Itri,
For the month October, 2002:
We had 55 milion queries, 4.3 milion done with your client.
This number is probably not the best indicator as some IPs do a lot of
queries so here are also the statistics for different IP addresses using
your client:
31364 (of 853385) different IP addresses used your client.
If you have any more questions, please contact <ripe-dbm@ripe.net>.
Regards,
Tiago Antao
____________________________
RIPE Database Administration.
Original message follows:
------------------------
On Thursday 23 January 2003 18:52, Marco d'Itri wrote:
> On Jan 23, Can Bican <can@ripe.net> wrote:
> >This is a feature we supported, and we'll keep supporting it. It's a
> > mistake on our side that we'll change promptly, so please don't change
> > the behaviour. We'll make the proxy accept -V switches of these types.
>
> Thank you for your prompt reply.
> BTW, is any statistics about -V arguments available? I wonder how many
> queries are made with my client (i.e. the -V argument matches /^Md/).
I have forwarded your request to ripe-dbm@ripe.net. You can contact that
address if you'd like more/less specific requirements about the counts.
Regards,
--
Can Bican
DB Group
RIPE NCC

View File

@ -1,6 +1,4 @@
# server name encoding optional parameters
whois.afrinic.net utf-8
whois.apnic.net iso-8859-1
# server name charset optional parameters
whois.cat utf-8 -C UTF-8
whois.conac.cn utf-8
whois.corenic.net utf-8 -C UTF-8
@ -8,7 +6,7 @@ whois.online.rs.corenic.net utf-8 -C UTF-8
whois.site.rs.corenic.net utf-8 -C UTF-8
whois.lacnic.net utf-8
whois.museum utf-8 -C UTF-8
whois.ripe.net utf-8 --charset UTF-8
whois.ripe.net iso-8859-1
whois.nic.llyw.cymru utf-8
whois.nic.gov.scot utf-8
@ -22,6 +20,7 @@ whois.cira.ca utf-8
whois.nic.ch utf-8
whois.nic.cl utf-8
whois.cnnic.cn utf-8
cwhois.cnnic.cn utf-8
whois.nic.cz utf-8
whois.denic.de utf-8
whois.enum.denic.de utf-8

View File

@ -15,9 +15,8 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, see <https://www.gnu.org/licenses/>.
*
* SPDX-License-Identifier: GPL-2.0-or-later
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include <stdlib.h>

View File

@ -1,4 +1,3 @@
/* SPDX-License-Identifier: GPL-2.0-or-later */
#ifndef SIMPLE_RECODE_H
#define SIMPLE_RECODE_H

View File

@ -45,7 +45,7 @@
.gov.wales whois.nic.gov.wales
.edu whois.educause.edu
.gov whois.nic.gov
.gov whois.dotgov.gov
.int whois.iana.org
.mil NONE
@ -59,26 +59,26 @@
.biz whois.nic.biz
.cat whois.nic.cat
.coop whois.nic.coop
.info NONE
.jobs NONE
.mobi NONE
.info whois.afilias.net
.jobs whois.nic.jobs
.mobi whois.afilias.net
.museum whois.nic.museum
.name whois.nic.name
.post whois.nic.post
.pro NONE
.post whois.dotpostregistry.net
.pro whois.nic.pro
.tel whois.nic.tel
.travel NONE
.travel whois.nic.travel
.xxx whois.nic.xxx
.ac whois.nic.ac
.ad whois.nic.ad
.ad NONE # www.nic.ad
.ae whois.aeda.net.ae
.af whois.nic.af
.ag whois.nic.ag
.ai whois.nic.ai
.al NONE # www.akep.al
.am whois.amnic.net
.ao WEB https://www.dns.ao/ao/whois/ # www.dns.ao
.ao WEB https://www.dns.ao/ao/gca/index.php?id=19 # www.dns.ao
.aq NONE # 2day.com
.ar whois.nic.ar
.as whois.nic.as
@ -109,7 +109,7 @@
.bv NONE # http://www.norid.no/domenenavnbaser/bv-sj.html
.by whois.cctld.by
.bw whois.nic.net.bw
.bz RECURSIVE whois.identitydigital.services
.bz RECURSIVE whois.afilias-grs.info
.co.ca whois.co.ca
.ca whois.cira.ca
.cc VERISIGN ccwhois.verisign-grs.com
@ -120,11 +120,11 @@
.ci whois.nic.ci
.ck NONE
.cl whois.nic.cl
.cm whois.nic.cm
.cm whois.netcom.cm
.edu.cn whois.edu.cn
.cn whois.cnnic.cn
.uk.co whois.uk.co
.co whois.registry.co
.co whois.nic.co
.cr whois.nic.cr
.cu WEB https://www.nic.cu/
.cv whois.nic.cv
@ -159,17 +159,17 @@
.gf whois.mediaserv.net
.gg whois.gg
.gh whois.nic.gh
.gi whois.identitydigital.services
.gi whois2.afilias-grs.net
.gl whois.nic.gl
.gm WEB http://www.nic.gm/htmlpages/whois.htm
.gn whois.ande.gov.gn
.gp whois.nic.gp
.gq WEB http://www.dominio.gq/en/whois.html
.gr WEB https://grweb.ics.forth.gr/public/whois?lang=en
.gq whois.dominio.gq
.gr WEB https://grweb.ics.forth.gr/public/whois
.gs whois.nic.gs
.gt WEB https://www.gt/sitio/?lang=en
.gu NONE
.gw WEB https://registar.nic.gw/en/whois/
.gw WEB https://nic.gw/en/whois/
.gy whois.registry.gy
.hk whois.hkirc.hk
.hm whois.registry.hm
@ -181,7 +181,7 @@
.ie whois.weare.ie
.il whois.isoc.org.il
.im whois.nic.im
.in whois.nixiregistry.in
.in whois.registry.in
.io whois.nic.io
.iq whois.cmc.iq # http://www.cmc.iq/en/iq.html
.ir whois.nic.ir
@ -204,7 +204,7 @@
.kz whois.nic.kz
.la whois.nic.la
.lb whois.lbdr.org.lb
.lc RECURSIVE whois.identitydigital.services
.lc whois2.afilias-grs.net
.li whois.nic.li
.lk whois.nic.lk
.lr NONE # http://www.psg.com/dns/lr/
@ -214,9 +214,9 @@
.lv whois.nic.lv
.ly whois.nic.ly
.ma whois.registre.ma
.mc whois.nic.mc
.mc NONE # www.nic.mc
.md whois.nic.md
.me RECURSIVE whois.nic.me # whois.identitydigital.services
.me whois.nic.me # afilias
#.mf
.mg whois.nic.mg
.mh NONE # www.nic.net.mh
@ -230,7 +230,7 @@
.mr whois.nic.mr
.ms whois.nic.ms
.mt whois.nic.org.mt
.mu whois.tld.mu
.mu whois.nic.mu
.mv NONE # NIC? www.dhiraagu.com.mv
.mw whois.nic.mw
.mx whois.mx
@ -252,17 +252,17 @@
.pa WEB http://www.nic.pa/en
.pe kero.yachay.pe
.pf whois.registry.pf
.pg whois.nic.pg # https://www.unitech.ac.pg/icts-dns/
.edu.ph WEB https://services.ph.net/dnshosting/dnshostingquery.pl
.pg NONE # http://www.unitech.ac.pg/
.edu.ph WEB https://services.ph.net/dns/query.pl
.gov.ph NONE # http://dns.gov.ph/
.ph WEB https://whois.dot.ph/
.pk whois.pknic.net.pk
.co.pl whois.co.pl # "unofficial" SLD
.pl whois.dns.pl
.pm whois.nic.pm
.pn WEB https://www.nic.pn/
.pr RECURSIVE whois.nic.pr # whois.identitydigital.services
.ps WEB https://www.pnina.ps/
.pn WEB http://www.pitcairn.pn/PnRegistry/whois.html
.pr whois.afilias-srs.net
.ps whois.pnina.ps
.pt whois.dns.pt
.pw whois.nic.pw
.py WEB https://www.nic.py/consultdompy.php
@ -283,7 +283,7 @@
.rw whois.ricta.org.rw # http://www.ricta.org.rw/
.sa whois.nic.net.sa
.sb whois.nic.net.sb
.sc whois.nic.sc
.sc whois2.afilias-grs.net # www.nic.sc
.sd whois.nic.sd
.se whois.iis.se
.sg whois.sgnic.sg
@ -295,7 +295,7 @@
.sm whois.nic.sm
.sn whois.nic.sn
.so whois.nic.so
.sr whois.sr # https://isp.datasur.sr/
.sr NONE # www.register.sr
.ss whois.nic.ss
.st whois.nic.st
.msk.su whois.flexireg.net
@ -316,7 +316,7 @@
.tl whois.nic.tl
.tm whois.nic.tm
.tn whois.ati.tn
.to whois.tonicregistry.to
.to whois.tonic.to
.tr whois.trabis.gov.tr
.tt WEB https://www.nic.tt/cgi-bin/search.pl
.tv RECURSIVE whois.nic.tv
@ -328,22 +328,29 @@
.ua whois.ua
.ug whois.co.ug
.ac.uk whois.nic.ac.uk
.bl.uk NONE
.british-library.uk NONE
.gov.uk whois.gov.uk
.mil.uk NONE
.icnet.uk NONE
.jet.uk NONE
.mod.uk NONE
.nhs.uk NONE
.nls.uk NONE
.parliament.uk NONE
.police.uk NONE
.uk whois.nic.uk
#.um
.fed.us whois.nic.gov
.us whois.nic.us
.com.uy WEB https://nic.com.uy/consulta-whois
.edu.uy WEB https://www.nic.uy/
.gub.uy WEB https://www.dominios.gub.uy/
.mil.uy WEB https://www.dominios.gub.uy/
.uy WEB https://www.nic.uy/
.net.uy WEB https://www.nic.uy/
.org.uy WEB https://www.nic.uy/
.uy WEB https://nic.com.uy/v2/consulta-whois
.uz whois.cctld.uz
.va NONE
.vc RECURSIVE whois.identitydigital.services
.vc whois2.afilias-grs.net
.ve whois.nic.ve
.vg whois.nic.vg
.vi whois.nic.vi
@ -361,39 +368,39 @@
.net.za net-whois.registry.net.za
.org.za org-whois.registry.net.za
.web.za web-whois.registry.net.za
.za whois.nic.za
.za NONE # https://www.nic.za/za-domains/
.zm whois.zicta.zm
.zw NONE # http://www.zispa.co.zw/
# AW means that I had to guess the whois server name, but I was not able
# to find any registered subdomains to verify it.
.xn--2scrj9c whois.nixiregistry.in # India
.xn--2scrj9c whois.registry.in # India
.xn--3e0b707e whois.kr # Korea, Republic of
.xn--3hcrj9c whois.nixiregistry.in # India
.xn--45br5cyl whois.nixiregistry.in # India
.xn--45brj9c whois.nixiregistry.in # India, Bengali
.xn--3hcrj9c whois.registry.in # India
.xn--45br5cyl whois.registry.in # India
.xn--45brj9c whois.registry.in # India, Bengali
.xn--4dbrk0ce whois.isoc.org.il # Israel
.xn--54b7fta0cc WEB https://bdia.btcl.com.bd/ # Bangladesh
.xn--80ao21a whois.nic.kz # Kazakhstan
.xn--90a3ac whois.rnids.rs # Serbia
.xn--90ae whois.imena.bg # Bulgaria
.xn--90ais whois.cctld.by # Belarus
.xn--clchc0ea0b2g2a9gcd whois.ta.sgnic.sg # Singapore, Tamil
.xn--clchc0ea0b2g2a9gcd whois.sgnic.sg # Singapore, Tamil
.xn--d1alf whois.marnet.mk # Macedonia
.xn--e1a4c whois.eu # European Union, Cyrillic
.xn--fiqs8s whois.cnnic.cn # China, Simplified Chinese
.xn--fiqz9s whois.cnnic.cn # China, Traditional Chinese
.xn--fpcrj9c3d whois.nixiregistry.in # India, Telugu
.xn--fiqs8s cwhois.cnnic.cn # China, Simplified Chinese
.xn--fiqz9s cwhois.cnnic.cn # China, Traditional Chinese
.xn--fpcrj9c3d whois.registry.in # India, Telugu
.xn--fzc2c9e2c whois.nic.lk # Sri Lanka, Sinhala
.xn--gecrj9c whois.nixiregistry.in # India, Gujarati
.xn--h2breg3eve whois.nixiregistry.in # India
.xn--h2brj9c8c whois.nixiregistry.in # India
.xn--h2brj9c whois.nixiregistry.in # India, Hindi
.xn--gecrj9c whois.registry.in # India, Gujarati
.xn--h2breg3eve whois.registry.in # India
.xn--h2brj9c8c whois.registry.in # India
.xn--h2brj9c whois.registry.in # India, Hindi
.xn--j1amh whois.dotukr.com # Ukraine
.xn--j6w193g whois.hkirc.hk # Hong Kong
.xn--kprw13d whois.twnic.net.tw # Taiwan, Simplified Chinese
.xn--kpry57d whois.twnic.net.tw # Taiwan, Traditional Chinese
.xn--l1acc whois.mn # Mongolia
.xn--l1acc NONE # Mongolia
.xn--lgbbat1ad8j whois.nic.dz # Algeria
.xn--mgb9awbf whois.registry.om # Oman
.xn--mgba3a4f16a whois.nic.ir # Iran
@ -401,30 +408,30 @@
.xn--mgbah1a3hjkrd whois.nic.mr # Mauritania
.xn--mgbai9azgqp6j NONE # Pakistan
.xn--mgbayh7gpa WEB https://www.domain.jo/FirstPageen.aspx # Jordan
.xn--mgbbh1a71e whois.nixiregistry.in # India, Urdu
.xn--mgbbh1a whois.nixiregistry.in # India
.xn--mgbbh1a71e whois.registry.in # India, Urdu
.xn--mgbbh1a whois.registry.in # India
.xn--mgbc0a9azcg NONE # Morocco
.xn--mgbcpq6gpa1a NONE # Bahrain
.xn--mgberp4a5d4ar whois.nic.net.sa # Saudi Arabia
.xn--mgbgu82a whois.nixiregistry.in # India
.xn--mgbgu82a whois.registry.in # India
.xn--mgbpl2fh NONE # Sudan
.xn--mgbtx2b whois.cmc.iq # Iraq
.xn--mgbx4cd0ab whois.mynic.my # Malaysia AW
.xn--mix891f WEB https://www.monic.mo/monic/faces/whois # Macao
.xn--node WEB http://რეგისტრაცია.გე/ # Georgia
.xn--node whois.itdc.ge # Georgia
.xn--o3cw4h whois.thnic.co.th # Thailand
.xn--ogbpf8fl whois.tld.sy # Syria
.xn--p1ai whois.tcinet.ru # Russian Federation
.xn--pgbs0dh whois.ati.tn # Tunisia
.xn--q7ce6a whois.nic.la # Lao
.xn--qxa6a whois.eu # European Union, Greek
.xn--qxam WEB https://grweb.ics.forth.gr/public/whois?lang=en # Greece
.xn--rvc1e0am3e whois.nixiregistry.in # India
.xn--s9brj9c whois.nixiregistry.in # India, Punjabi
.xn--qxam WEB https://grweb.ics.forth.gr/public/whois # Greece
.xn--rvc1e0am3e whois.registry.in # India
.xn--s9brj9c whois.registry.in # India, Punjabi
.xn--wgbh1c whois.dotmasr.eg # Egypt
.xn--wgbl6a whois.registry.qa # Qatar
.xn--xkc2al3hye2a whois.nic.lk # Sri Lanka, Tamil
.xn--xkc2dl3a5ee0h whois.nixiregistry.in # India, Tamil
.xn--xkc2dl3a5ee0h whois.registry.in # India, Tamil
.xn--y9a3aq whois.amnic.net # Armenia
.xn--yfro4i67o whois.zh.sgnic.sg # Singapore, Chinese
.xn--ygbi2ammx NONE # Palestinian Territory
.xn--yfro4i67o whois.sgnic.sg # Singapore, Chinese
.xn--ygbi2ammx whois.pnina.ps # Palestinian Territory

View File

@ -16,9 +16,8 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, see <https://www.gnu.org/licenses/>.
*
* SPDX-License-Identifier: GPL-2.0-or-later
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
/* for strdup */

68
whois.1
View File

@ -9,16 +9,18 @@ whois \- client for the whois directory service
] [
.RB {\~ \-p \~|\~ \-\-port \~}
.I PORT
]
.RB [\~ \-abBcdGHIKlLmMrRx
]
.RB [\~ \-g \fI\~SOURCE:FIRST\-LAST\fR
]
.RB [\~ \-i
] [\~\c
.B \-abBcdGHIKlLmMrRx
] [\~\c
.BI \-g \~SOURCE:FIRST\-LAST
] [\~\c
.BR \-i \~
.IR ATTR [, ATTR ]...\~]
.RB [\~ \-s
[\~\c
.BR \-s \~
.IR SOURCE [, SOURCE ]...\~]
.RB [\~ \-T
[\~\c
.BR \-T \~
.IR TYPE [, TYPE ]...\~]
.RB [\~ \-\-verbose \~]
.RB [\~ \-\-no\-recursion \~]
@ -47,15 +49,14 @@ searches for an object in a
database.
.P
This version of the whois client tries to guess the right server to
ask for the specified object.
If no guess can be made it will connect to
ask for the specified object. If no guess can be made it will connect to
.I whois.networksolutions.com
for NIC handles or
.I whois.arin.net
for IPv4 addresses and network names.
.SH OPTIONS
.TP 8
.B \-h
.B \-h \c
.IR HOST ,
.BI \-\-host= HOST
Connect to
@ -64,7 +65,7 @@ Connect to
.B \-H
Do not display the legal disclaimers that some registries like to show you.
.TP 8
.B \-p
.B \-p \c
.IR PORT ,
.BI \-\-port= PORT
Connect to
@ -74,8 +75,7 @@ Connect to
First query
.I whois.iana.org
and then follow its referral to the
whois server authoritative for that request.
This works for IP addresses,
whois server authoritative for that request. This works for IP addresses,
AS numbers and domains.
.BR BEWARE :
this implies that the IANA server will receive your complete query.
@ -113,7 +113,7 @@ Return the smallest IP address range with a reference to an irt object.
.B \-d
Return the reverse DNS delegation object too.
.TP 8
.B \-g
.B \-g \c
.I SOURCE:FIRST\-LAST
Search updates from
.I SOURCE
@ -121,13 +121,12 @@ database between
.I FIRST
and
.I LAST
update serial number.
It is useful to obtain Near Real Time Mirroring stream.
update serial number. It is useful to obtain Near Real Time Mirroring stream.
.TP 8
.B \-G
Disable grouping of associated objects.
.TP 8
.B \-i
.B \-i \c
.IR ATTR [, ATTR ]...
Inverse-search objects having associated attributes.
.I ATTR
@ -136,13 +135,11 @@ is the attribute name, while the positional
argument is the attribute value.
.TP 8
.B \-K
Return primary key attributes only.
An exception is the
Return primary key attributes only. An exception is the
.I members
attribute of
.I set
objects, which is always returned.
Another exception are all
objects, which is always returned. Another exception are all
attributes of the objects
.IR organisation ,
.I person
@ -162,7 +159,7 @@ Return all one level more specific objects.
.B \-M
Return all levels of more specific objects.
.TP 8
.B \-q
.B \-q \c
.I KEYWORD
Return information about the server.
.I KEYWORD
@ -181,7 +178,7 @@ Disable recursive lookups for contact information.
Disable following referrals and force showing the object from the local copy
in the server.
.TP 8
.B \-s
.B \-s \c
.IR SOURCE [, SOURCE ]...
Request the server to search for objects mirrored from
.IR SOURCE .
@ -190,18 +187,18 @@ Use the
.I \-q sources
parameter to obtain a list of valid sources.
.TP 8
.B \-t
.B \-t \c
.I TYPE
Return the template for a object of
.IR TYPE .
.TP 8
.B \-T
.B \-T \c
.IR TYPE [, TYPE ]...
Restrict the search to objects of
.IR TYPE .
Multiple types are separated by a comma.
.TP 8
.B \-v
.B \-v \c
.I TYPE
Return the verbose template for a object of
.IR TYPE .
@ -209,9 +206,7 @@ Return the verbose template for a object of
.B \-x
Search for only exact match on network address prefix.
.SH NOTES
When querying the Verisign gTLDs
(e.g.\& \&.com, \&.net...\&)
thin registry servers
When querying the Verisign gTLDs (e.g.\& \&.com, \&.net...\&) thin registry servers
for a domain, the program will automatically prepend the
.I domain
keyword to only show domain records. The
@ -244,8 +239,7 @@ flags have been specified, the program will automatically add the flag
.IR "\-\-show\-handles" .
.P
RIPE-specific command line options are ignored when querying non-RIPE
servers.
This may or may not be the behaviour intended by the user.
servers. This may or may not be the behaviour intended by the user.
When using non-standard query parameters then the command line options
which are not to be interpreted by the client must follow the
.I \-\-
@ -254,8 +248,7 @@ separator (which marks the beginning of the query string).
If the
.I /etc/whois.conf
configuration file exists, it will be consulted
to find a server before applying the normal rules.
Each line of the
to find a server before applying the normal rules. Each line of the
file should contain a regular expression to be matched against the query
text and the whois server to use, separated by white space.
IDN domains must use the ACE format.
@ -286,8 +279,7 @@ A list of options which will be evaluated before the ones specified on the
command line.
.IP "WHOIS_SERVER"
This server will be queried if the program cannot guess where some kind
of objects are located.
If the variable does not exist then
of objects are located. If the variable does not exist then
.I whois.arin.net
will be queried.
.SH "SEE ALSO"
@ -297,7 +289,7 @@ will be queried.
WHOIS Protocol Specification.
.P
.IR "RIPE Database Query Reference Manual" :
.RI < https://www.ripe.net/\:data\-tools/\:support/\:documentation/\:ripe\-database\-query\-reference\-manual >
.RI < https://www.ripe.net/data\-tools/support/documentation/ripe\-database\-query\-reference\-manual >
.SH BUGS
The program may have buffer overflows in the command line parser:
be sure to not pass untrusted data to it.
@ -312,4 +304,4 @@ and this man page were written by Marco d'Itri
.RI < md@linux.it >
and are licensed under the terms of the GNU General Public License,
version 2 or later.
.\" SPDX-License-Identifier: GPL-2.0-or-later
\" SPDX-License-Identifier: GPL-2.0-or-later

416
whois.c
View File

@ -6,14 +6,6 @@
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* 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. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, see <https://www.gnu.org/licenses/>.
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
@ -48,13 +40,6 @@
#include <idna.h>
#endif
/* prototypes referenced in data.h */
static void find_referral_server_apnic(char **, const char *);
static void find_referral_server_arin(char **, const char *);
static void find_referral_server_iana(char **, const char *);
static void find_referral_server_recursive(char **, const char *);
static void find_referral_server_verisign(char **, const char *);
/* Application-specific */
#include "version.h"
#include "data.h"
@ -326,7 +311,7 @@ int handle_query(const char *hserver, const char *hport,
const char *query, const char *flags)
{
char *server = NULL, *port = NULL;
char *p, *query_string, *old_server, *new_server;
char *p, *query_string;
if (hport) {
server = strdup(hserver);
@ -359,18 +344,18 @@ int handle_query(const char *hserver, const char *hport,
case 4:
if (verb)
printf(_("Using server %s.\n"), server + 1);
old_server = server;
server = query_verisign(server, NULL, query);
free(old_server);
sockfd = openconn(server + 1, NULL);
free(server);
server = query_crsnic(sockfd, query);
if (no_recursion && server)
server[0] = '\0';
break;
case 8:
if (verb)
printf(_("Using server %s.\n"), server + 1);
old_server = server;
server = query_server(server, NULL, query);
free(old_server);
sockfd = openconn(server + 1, NULL);
free(server);
server = query_afilias(sockfd, query);
if (no_recursion && server)
server[0] = '\0';
break;
@ -403,8 +388,9 @@ int handle_query(const char *hserver, const char *hport,
case 0x0E:
if (verb)
printf(_("Using server %s.\n"), "whois.iana.org");
sockfd = openconn("whois.iana.org", NULL);
free(server);
server = query_server("whois.iana.org", NULL, query);
server = query_iana(sockfd, query);
break;
default:
break;
@ -422,17 +408,15 @@ int handle_query(const char *hserver, const char *hport,
printf(_("Query string: \"%s\"\n\n"), query_string);
}
new_server = query_server(server, port, query_string);
sockfd = openconn(server, port);
free(server);
if (port)
free(port);
server = do_query(sockfd, query_string);
free(query_string);
/* recursion is fun */
if (!no_recursion && new_server && !strchr(query, ' ')) {
printf(_("\n\nFound a referral to %s.\n\n"), new_server);
handle_query(new_server, NULL, query, flags);
free(new_server);
if (!no_recursion && server && !strchr(query, ' ')) {
printf(_("\n\nFound a referral to %s.\n\n"), server);
handle_query(server, NULL, query, flags);
}
return 0;
@ -804,218 +788,55 @@ int hide_line(int *hiding, const char *const line)
return 0;
}
static void find_referral_server_apnic(char **referral_server, const char *buf)
{
/* Possible states of this FSM:
* 0: searching for the descr or mnt-by attribute
* 1: searching for the mnt-by attribute (descr found)
* 2: searching for the descr attribute (mnt-by found)
* 3: searching for the end of the object (an empty line)
* 4: done: stop searching
*
* Since the descr attribute is user-provided, consider it only if it
* is in an object actually maintained by APNIC.
*
* If multiple records are returned then it users the referral in the
* first valid object found.
*/
static int state = 0;
static char *rir_name = NULL;
char *p;
if (state == 4)
return;
if (state <= 2) {
if (strneq(buf, "descr:", 6)) {
p = (char *)buf + 6; /* skip until the colon */
for (; *p == ' ' || *p == '\t'; p++); /* skip white space */
if (strneq(p, "Transferred to the ", 19)) {
rir_name = strdup(p + 19);
if ((p = strpbrk(rir_name, " ")))
*p = '\0';
if (state == 0)
state = 1; /* still needs mnt-by */
else
state = 3;
}
} else if (strneq(buf, "mnt-by:", 7)) {
p = (char *)buf + 7; /* skip until the colon */
for (; *p == ' ' || *p == '\t'; p++); /* skip white space */
if (streq(p, "APNIC-STUB")) {
if (state == 0)
state = 2; /* still needs descr */
else
state = 3;
}
} else if (streq(buf, "")) {
if (state == 1)
free(rir_name);
state = 0; /* start again with a new object */
}
return;
}
if (state == 3 && streq(buf, "")) {
int i;
const char *rir_servers[] = {
"AFRINIC", "whois.afrinic.net",
"ARIN", "whois.arin.net",
"LACNIC", "whois.lacnic.net",
"RIPE", "whois.ripe.net",
NULL, NULL,
};
state = 4;
for (i = 0; rir_servers[i]; i += 2)
if (streq(rir_name, rir_servers[i]))
*referral_server = strdup(rir_servers[i + 1]);
free(rir_name);
}
}
static void find_referral_server_arin(char **referral_server, const char *buf)
{
char *p;
/* ARIN referrals:
* ReferralServer: rwhois://rwhois.fuse.net:4321/
* ReferralServer: whois://whois.ripe.net
* ReferralServer: whois.ripe.net
*/
if (!strneq(buf, "ReferralServer:", 15))
return;
/* When whois.arin.net returns multiple NetRange records, they will
* appear from the less specific one to the most specific one.
* Since the range we care about is the most specific one then we
* need to use the last ReferralServer field found.
*/
if (*referral_server) {
free(*referral_server);
*referral_server = NULL;
}
if ((p = strstr(buf, "rwhois://")))
*referral_server = strdup(p + 9);
else if ((p = strstr(buf, "whois://")))
*referral_server = strdup(p + 8);
else
*referral_server = strdup(buf + 17);
if (*referral_server && (p = strpbrk(*referral_server, "/")))
*p = '\0';
}
static void find_referral_server_iana(char **referral_server, const char *buf)
{
const char *p;
if (*referral_server)
return;
/* IANA referrals:
* refer: whois.apnic.net
*/
if (!strneq(buf, "refer:", 6))
return;
p = buf + 6; /* skip until the colon */
for (; *p == ' ' || *p == '\t'; p++); /* skip white space */
*referral_server = strdup(p);
}
static void find_referral_server_recursive(char **referral_server, const char *buf)
{
static int state = 0;
const char *p;
if (*referral_server)
return;
if (state == 0 && strneq(buf, "Domain Name:", 12))
state = 1;
else if (state == 1 && strneq(buf, "Domain Name:", 12))
state = 2;
else if (state == 1 && strneq(buf, "Registrar WHOIS Server:", 23)) {
p = buf + 23; /* skip until the colon */
for (; *p && *p == ' '; p++); /* skip the spaces */
*referral_server = strdup(p);
state = 2;
}
}
static void find_referral_server_verisign(char **referral_server, const char *buf)
{
static int state = 0;
const char *p;
if (*referral_server)
return;
/* If there are multiple matches only the server of the first record
* is queried */
if (state == 0 && strneq(buf, " Domain Name:", 15)) {
state = 1;
} else if (state == 0 && strneq(buf, " Server Name:", 15)) {
*referral_server = strdup("");
state = 2;
} else if (state == 1 && strneq(buf, " Registrar WHOIS Server:", 26)) {
p = buf + 26; /* skip until the colon */
for (; *p && *p == ' '; p++); /* skip the spaces */
*referral_server = strdup(p);
state = 2;
}
}
/* returns a string which should be freed by the caller, or NULL */
char *query_server(const char *server, const char *port, const char *query)
char *do_query(const int sock, const char *query)
{
char *temp, *p, buf[2000];
FILE *fi;
int hide = hide_discl;
int sock, i;
char *referral_server = NULL;
void (*referral_handler)(char **referral_server, const char *buf) = NULL;
temp = malloc(strlen(query) + 2 + 1);
strcpy(temp, query);
strcat(temp, "\r\n");
for (i = 0; server_referral_handlers[i].name; i++) {
/* If the first character is not printable then it represents
* a general category of servers in the list.
*/
if (server[0] < ' ' &&
strneq(server_referral_handlers[i].name, server, 1)) {
server++;
referral_handler = server_referral_handlers[i].handler;
break;
} else if (streq(server_referral_handlers[i].name, server)) {
referral_handler = server_referral_handlers[i].handler;
break;
}
}
sock = openconn(server, port);
fi = fdopen(sock, "r");
if (!fi)
err_sys("fdopen");
if (write(sock, temp, strlen(temp)) < 0)
err_sys("write");
free(temp);
while (fgets(buf, sizeof(buf), fi)) {
alarm(20); /* reset the timeout */
if ((p = strpbrk(buf, "\r\n"))) /* remove the trailing CR/LF */
*p = '\0';
/* 6bone-style referral:
* % referto: whois -h whois.arin.net -p 43 as 1
*/
if (!referral_server && strneq(buf, "% referto:", 10)) {
char nh[256], np[16], nq[1024];
if (referral_handler)
referral_handler(&referral_server, buf);
if (sscanf(buf, REFERTO_FORMAT, nh, np, nq) == 3) {
/* XXX we are ignoring the new query string */
referral_server = malloc(strlen(nh) + 1 + strlen(np) + 1);
sprintf(referral_server, "%s:%s", nh, np);
}
}
/* ARIN referrals:
* ReferralServer: rwhois://rwhois.fuse.net:4321/
* ReferralServer: whois://whois.ripe.net
*/
if (!referral_server && strneq(buf, "ReferralServer:", 15)) {
if ((p = strstr(buf, "rwhois://")))
referral_server = strdup(p + 9);
else if ((p = strstr(buf, "whois://")))
referral_server = strdup(p + 8);
if (referral_server && (p = strpbrk(referral_server, "/\r\n")))
*p = '\0';
}
if (hide_line(&hide, buf))
continue;
if ((p = strpbrk(buf, "\r\n")))
*p = '\0';
recode_fputs(buf, stdout);
fputc('\n', stdout);
}
@ -1028,20 +849,16 @@ char *query_server(const char *server, const char *port, const char *query)
err_quit(_("Catastrophic error: disclaimer text has been changed.\n"
"Please upgrade this program.\n"));
/* defensive programming: make sure to avoid trivial referral loops */
if (referral_server && streq(server, referral_server)) {
free(referral_server);
referral_server = NULL;
}
return referral_server;
}
char *query_verisign(const char *server, const char *port, const char *query)
char *query_crsnic(const int sock, const char *query)
{
char *temp, *p;
int sock;
char *temp, *p, buf[2000];
FILE *fi;
int hide = hide_discl;
char *referral_server = NULL;
int state = 0;
int dotscount = 0;
temp = malloc(strlen("domain ") + strlen(query) + 2 + 1);
@ -1055,9 +872,140 @@ char *query_verisign(const char *server, const char *port, const char *query)
if (dotscount == 1 && !strpbrk(query, "=~ "))
strcpy(temp, "domain ");
strcat(temp, query);
strcat(temp, "\r\n");
referral_server = query_server(server, port, temp);
fi = fdopen(sock, "r");
if (write(sock, temp, strlen(temp)) < 0)
err_sys("write");
free(temp);
while (fgets(buf, sizeof(buf), fi)) {
/* If there are multiple matches only the server of the first record
is queried */
if (state == 0 && strneq(buf, " Domain Name:", 15))
state = 1;
if (state == 0 && strneq(buf, " Server Name:", 15)) {
referral_server = strdup("");
state = 2;
}
if (state == 1 && strneq(buf, " Registrar WHOIS Server:", 26)) {
for (p = buf; *p != ':'; p++); /* skip until the colon */
for (p++; *p == ' '; p++); /* skip the spaces */
referral_server = strdup(p);
if ((p = strpbrk(referral_server, "\r\n ")))
*p = '\0';
state = 2;
}
/* the output must not be hidden or no data will be shown for
host records and not-existing domains */
if (hide_line(&hide, buf))
continue;
if ((p = strpbrk(buf, "\r\n")))
*p = '\0';
recode_fputs(buf, stdout);
fputc('\n', stdout);
}
if (ferror(fi))
err_sys("fgets");
fclose(fi);
return referral_server;
}
char *query_afilias(const int sock, const char *query)
{
char *temp, *p, buf[2000];
FILE *fi;
int hide = hide_discl;
char *referral_server = NULL;
int state = 0;
temp = malloc(strlen(query) + 2 + 1);
strcpy(temp, query);
strcat(temp, "\r\n");
fi = fdopen(sock, "r");
if (write(sock, temp, strlen(temp)) < 0)
err_sys("write");
free(temp);
while (fgets(buf, sizeof(buf), fi)) {
/* If multiple attributes are returned then use the first result.
This is not supposed to happen. */
if (state == 0 && strneq(buf, "Domain Name:", 12))
state = 1;
if (state == 1 && strneq(buf, "Registrar WHOIS Server:", 23)) {
for (p = buf; *p != ':'; p++); /* skip until colon */
for (p++; *p == ' '; p++); /* skip colon and spaces */
referral_server = strdup(p);
if ((p = strpbrk(referral_server, "\r\n ")))
*p = '\0';
state = 2;
}
/* the output must not be hidden or no data will be shown for
host records and not-existing domains */
if (hide_line(&hide, buf))
continue;
if ((p = strpbrk(buf, "\r\n")))
*p = '\0';
recode_fputs(buf, stdout);
fputc('\n', stdout);
}
if (ferror(fi))
err_sys("fgets");
fclose(fi);
if (hide > HIDE_NOT_STARTED && hide != HIDE_TO_THE_END)
err_quit(_("Catastrophic error: disclaimer text has been changed.\n"
"Please upgrade this program.\n"));
return referral_server;
}
char *query_iana(const int sock, const char *query)
{
char *temp, *p, buf[2000];
FILE *fi;
char *referral_server = NULL;
int state = 0;
temp = malloc(strlen(query) + 2 + 1);
strcpy(temp, query);
strcat(temp, "\r\n");
fi = fdopen(sock, "r");
if (write(sock, temp, strlen(temp)) < 0)
err_sys("write");
free(temp);
while (fgets(buf, sizeof(buf), fi)) {
/* If multiple attributes are returned then use the first result.
This is not supposed to happen. */
if (state == 0 && strneq(buf, "refer:", 6)) {
for (p = buf; *p != ':'; p++); /* skip until colon */
for (p++; *p == ' '; p++); /* skip colon and spaces */
referral_server = strdup(p);
if ((p = strpbrk(referral_server, "\r\n ")))
*p = '\0';
state = 2;
}
if ((p = strpbrk(buf, "\r\n")))
*p = '\0';
recode_fputs(buf, stdout);
fputc('\n', stdout);
}
if (ferror(fi))
err_sys("fgets");
fclose(fi);
return referral_server;
}
@ -1081,7 +1029,7 @@ int openconn(const char *server, const char *port)
if (AFL_MODE)
return dup(0);
alarm(20);
alarm(60);
#ifdef HAVE_GETADDRINFO
memset(&hints, 0, sizeof(struct addrinfo));
@ -1309,12 +1257,6 @@ char *normalize_domain(const char *dom)
}
#if defined HAVE_LIBIDN || defined HAVE_LIBIDN2
/* A leading ! means that this probably is a RADB query, so skip IDN
* processing because it would lower-case the command characters.
*/
if (*ret == '!')
return ret;
/* find the start of the last word if there are spaces in the query */
for (p = ret; *p; p++)
if (*p == ' ')

View File

@ -1,6 +1,9 @@
/* SPDX-License-Identifier: GPL-2.0-or-later */
#include "utils.h"
/* 6bone referto: extension */
#define REFERTO_FORMAT "%% referto: whois -h %255s -p %15s %1021[^\n\r]"
#define HIDE_TO_THE_END -3
#define HIDE_DISABLED -2
#define HIDE_NOT_STARTED -1
@ -12,8 +15,10 @@ const char *match_config_file(const char *);
const char *whereas(const unsigned long);
char *queryformat(const char *, const char *, const char *);
int hide_line(int *hiding, const char *const line);
char *query_server(const char *, const char *, const char *);
char *query_verisign(const char *, const char *, const char *);
char *do_query(const int, const char *);
char *query_crsnic(const int, const char *);
char *query_afilias(const int, const char *);
char *query_iana(const int, const char *);
int openconn(const char *, const char *);
int connect_with_timeout(int, const struct sockaddr *, socklen_t, int);
void NORETURN usage(int error);