1

http://www.anta.net/misc/telnet-troubleshooting/whois.shtml shows that we can get whois server using telnet

However, webclient uses get and http protocol.

So how to get whois via vb.net then?

Some software like domainpunch can get tons of domain info. However, they can't possibly just query whois server because most of which are rate limited.

Maybe they query tons of whois server.

Or how?

user4951
  • 32,206
  • 53
  • 172
  • 282

1 Answers1

1

A simple TcpClient will do. WhoIs is a very simple protocol: you just connect and send the query followed by \r\n.

Example:

Private Sub Main()
    Dim data = System.Text.Encoding.ASCII.GetBytes("stackoverflow.com" & Microsoft.VisualBasic.vbCr & Microsoft.VisualBasic.vbLf)
    Using client = New TcpClient("whois.name.com", 43),
        stream = client.GetStream()
        stream.Write(data, 0, data.Length)

        data = New Byte(255) {}
        Dim responseData = String.Empty
        Dim read = stream.Read(data, 0, data.Length)
        While read > 0
            responseData = System.Text.Encoding.ASCII.GetString(data, 0, read)
            Console.Write(responseData)
            read = stream.Read(data, 0, data.Length)
        End While
    End Using
End Sub

Output:

__   _                             ____                
| \ | | __ _ _ __ ___   ___       / ___|___  _ __ ___  
|  \| |/ _` | '_ ` _ \ / _ \     | |   / _ \| '_ ` _ \ 
| |\  | (_| | | | | | |  __/  _  | |__| (_) | | | | | |
|_| \_|\__,_|_| |_| |_|\___| (_)  \____\___/|_| |_| |_|
On a first name basis with the rest of the world.


Get your <a href="http://www.name.com">domains</a> at Name.com.


Domain Name:     stackoverflow.com
Registrar:       Name.com LLC

Expiration Date: 2015-12-26 19:18:07
Creation Date:   2003-12-26 19:18:07

Name Servers:
  ns1.serverfault.com
  ns2.serverfault.com

REGISTRANT CONTACT INFO
Stack Exchange, Inc.
Sysadmin Team
1 Exchange Plaza
Floor 26
New York
NY
10006
US
Phone:         +1.2122328280
Email Address: sysadmin-team@stackoverflow.com

ADMINISTRATIVE CONTACT INFO
Stack Exchange, Inc.
Sysadmin Team
1 Exchange Plaza
Floor 26
New York
NY
10006
US
Phone:         +1.2122328280
Email Address: sysadmin-team@stackoverflow.com

TECHNICAL CONTACT INFO
Stack Exchange, Inc.
Sysadmin Team
1 Exchange Plaza
Floor 26
New York
NY
10006
US
Phone:         +1.2122328280
Email Address: sysadmin-team@stackoverflow.com

BILLING CONTACT INFO
Stack Exchange, Inc.
Sysadmin Team
1 Exchange Plaza
Floor 26
New York
NY
10006
US
Phone:         +1.2122328280
Email Address: sysadmin-team@stackoverflow.com

Timestamp: 1383039360.9081

The Data in the Name.com LLC WHOIS database is provided by Name.com LLC for information purposes, and to assist persons in obtaining information about or related to a domain name registration record.  Name.com LLC does not guarantee its accuracy.  By submitting a WHOIS query, you agree that you will use this Data only for lawful purposes and that, under no circumstances will you use this Data to:  (1) allow, enable, or otherwise support the transmission of mass unsolicited, commercial advertising or solicitations via e-mail (spam); or (2) enable high volume, automated, electronic processes that apply to Name.com LLC (or its systems). Name.com LLC reserves the right to modify these terms at any time.  By submitting this query, you agree to abide by this policy.

Cached on: 2013-10-29T03:36:00-06:00
sloth
  • 99,095
  • 21
  • 171
  • 219
  • can we use webclient or webrequest instead? – user4951 Oct 29 '13 at 09:38
  • 1
    @JimThio Why? `WebClient` uses http, not the whois-protocol. It's like asking to use ftp to query a http resource or using ICMP to query a ftp resource. You could of course use a `WebClient` to query a whois proxy server, but then you depend on a single website and its specific implementation of a single service provider, so you should really not do that. What's wrong with a simple `TcpClient`? – sloth Oct 29 '13 at 09:44
  • By the way your solution doesn't work for domain google.com I wonder why – user4951 Oct 30 '13 at 13:23
  • @JimThio What does *your solution doesn't work for domain google.com* mean? – sloth Oct 30 '13 at 13:24
  • With google.com I got "NO DOMAIN (1)" & vbLf & "" & vbLf & "Cached on: 2013-10-30T07:23:39-06:00" & vbLf & "" I pretty much copy and paste your code. – user4951 Oct 30 '13 at 13:24
  • replace stackoverflow.com with google.com and it'll say no domain. Strange. – user4951 Oct 30 '13 at 13:27
  • @JimThio `"NO DOMAIN (1)" & vbLf & "" & vbLf & "Cached on: 2013-10-30T07:23:39-06:00" & vbLf & ""` is the response from the whois server you're using. I don't know what *your solution doesn't work* mean if you successfully queried the whois server and got a response. – sloth Oct 30 '13 at 13:27
  • @JimThio My code didn't say *no domain*. It's the whois server that says that. – sloth Oct 30 '13 at 13:28
  • Yea well, google.com is a domain name. Why the whois server return no domain? I think I'll make another question here. – user4951 Oct 30 '13 at 13:28
  • @JimThio Probably because *whois.name.com* returns informations about domains registered at *name.com* only (since it's the whois server of a domain registrar, it's up to them to return what they want). Just use another whois server. – sloth Oct 30 '13 at 13:35
  • What are the whois servers that return all domains? – user4951 Oct 30 '13 at 13:39
  • @J.Chang use the registry whois server, so `whois.verisign-grs.com` for all .COM domain names. But remember it is a thin registry so you will not get contact data there you will need to query the specific registrar whois server for the involved domain name, which name will appear in the first whois reply. Have a look at the following other replies of mine: https://unix.stackexchange.com/a/407030/211833 and https://webmasters.stackexchange.com/a/111639/75842 – Patrick Mevzek Jan 03 '18 at 19:54