6

I tried exporting into http_proxy and https_proxy but that didn't seem to work.

I am guessing that there is another way to use a proxy when querying whois information from the command line?

4 Answers 4

5

The whois command talks in a specific protocol and port, namely whois 43/tcp ; so obviously trying to use an HTTP(S) (HTTP port 80/tcp and HTTPS 443/tcp by default).

So HTTP proxies-aware won't work, as those protocols are not involved with the inner workings of the whois protocol.

If you need to setup an external proxy, you would need a socks aware proxy, as this example https://stackoverflow.com/questions/6718836/how-can-i-implement-a-simple-whois-proxy-in-perl

For a Whois proxy in python, see uwhoisd and for further clarifications on how to use it: python: how to perform whois with uwhoisd proxy

see also About the WHOIS Protocol

The WHOIS protocol is a simple, plaintext-based protocol that listens on TCP port 43. There is an RFC that defines the protocol, RFC 3912.

4
  • This link explains how to do this in perl, how do you do this in python?
    – HashWizard
    May 26, 2017 at 12:55
  • @HashWizard added to the answer. May 26, 2017 at 12:58
  • My main objective is to get past the limitations of the query server, say to query 10 times instead of 5 times (which is the limit) by using public proxies. Would the solution that you provided allow me to do that ? Thanks for taking the time to address my problem
    – HashWizard
    May 26, 2017 at 13:00
  • Because from the looks of it, the solution doesn't seem to be accepting different proxies (proxies provided by me) , the solution seems to be a 'proxy' /intermediary' for solving domain extension ambiguities (for example getting the correcting results if I whois something.com and something.org)
    – HashWizard
    May 26, 2017 at 13:04
2

WHOIS is a TCP/IP protocol, HTTP doesn't play a part in the query and so an HTTP proxy won't work.

If your proxy server also presents a SOCKS interface, you could attempt to use tsocks or proxychains-ng as described here to perform the query.

2

for me this worked:

ncat --listen --exec '/usr/bin/ncat --proxy <proxy_ip>:<proxy_port> whois.ripe.net 43' 8043 &

the query:

whois --host localhost --port 8043 <ip_that_i_want_to_whois>
6
  • this is a socks5 proxy that you used with ncat? Jun 5, 2023 at 14:20
  • no, this is a http proxy i guess for socks5 u need to add --proxy-type socks5 the default is http according to man ncat
    – Booker B
    Jun 6, 2023 at 16:38
  • thanks Booker B worked for me, but unfortunately I couldn't find a workaround to close the ncat connection when the data is received via the proxy-ied connection Jun 8, 2023 at 10:30
  • ctrl+c should work
    – Booker B
    Jun 8, 2023 at 15:07
  • yes, sure, but I wanted to have a non-interactive script, thus sending additional signals is not desired. Nevertheless, thank you for your example. Jun 9, 2023 at 14:21
0

if you allow port 43 to egress your http proxies then you can use a shell script to do the deed via an explicit CONNECT request

passing $1 as the whois host eg whois.nic.iana, , $2 as the query and $3 as the proxy host

#!/bin/sh
(
sleep 1
echo "CONNECT $1:43 HTTP/1.1"
echo ""

sleep 2
echo "$2"
echo ""
sleep 4

) | telnet $3 8080

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .