whym / whois-gateway

Web-based whois gateway written in Python for lighttpd
BSD 3-Clause "New" or "Revised" License
26 stars 20 forks source link

Description not displayed in RIPE data #18

Open strainu opened 4 years ago

strainu commented 4 years ago

Compare https://whois.toolforge.org/gateway.py?lookup=true&ip=145.64.254.243 with https://apps.db.ripe.net/db-web-ui/query?bflag=false&dflag=false&rflag=true&searchtext=145.64.254.243&source=RIPE

Is this a change in RIPE, in the gateway or just a bug?

lucasbfr commented 4 years ago

It looks like most IP I've checked today have no host either, this seems to be related

wiki-ST47 commented 4 years ago

I have no idea what is going on here. Here is a sample whois query using ipwhois 1.2.0 on python 3.5 from the toolforge login server

tools.whois-referral@tools-sgebastion-07:~$ python3.5 -m virtualenv -p /usr/bin/python3.5 venv3.5
Already using interpreter /usr/bin/python3.5
Using base prefix '/usr'
New python executable in /mnt/nfs/labstore-secondary-tools-project/whois-referral/venv3.5/bin/python3.5
Also creating executable in /mnt/nfs/labstore-secondary-tools-project/whois-referral/venv3.5/bin/python
Installing setuptools, pkg_resources, pip, wheel...done.
tools.whois-referral@tools-sgebastion-07:~$ source venv3.5/bin/activate
(venv3.5) tools.whois-referral@tools-sgebastion-07:~$ which pip
/mnt/nfs/labstore-secondary-tools-project/whois-referral/venv3.5/bin/pip
(venv3.5) tools.whois-referral@tools-sgebastion-07:~$ pip install ipwhois
DEPRECATION: Python 3.5 reached the end of its life on September 13th, 2020. Please upgrade your Python as Python 3.5 is no longer maintained. pip 21.0 will drop support for Python 3.5 in January 2021. pip 21.0 will remove support for this functionality.
Collecting ipwhois
  Using cached ipwhois-1.2.0-py2.py3-none-any.whl (73 kB)
Collecting dnspython<=2.0.0
  Using cached dnspython-1.16.0-py2.py3-none-any.whl (188 kB)
Installing collected packages: dnspython, ipwhois
Successfully installed dnspython-1.16.0 ipwhois-1.2.0
(venv3.5) tools.whois-referral@tools-sgebastion-07:~$ python
Python 3.5.3 (default, Jul  9 2020, 13:00:10)
[GCC 6.3.0 20170516] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from ipwhois import IPWhois
>>> IPWhois("145.64.254.243").lookup_whois()
{'asn_date': '1993-09-01', 'raw_referral': None, 'asn_description': 'EPO-AS, NL', 'asn_country_code': 'DE', 'nir': None, 'query': '145.64.254.243', 'asn': '28756', 'nets': [{'cidr': '145.64.0.0/16', 'handle': 'ENA7-RIPE', 'range': '145.64.0.0 - 145.64.255.255', 'emails': ['admin_network@epo.org'], 'city': None, 'postal_code': None, 'country': 'NL', 'state': None, 'description': 'European Patent Office\nP.O. Box 5818\n2280 HV  Rijswijk', 'created': '1970-01-01T00:00:00Z', 'updated': '2020-08-28T09:51:50Z', 'name': 'EPONET', 'address': 'Patentlaan 2\n2288EE\nRijswijk\nNETHERLANDS'}, {'cidr': '145.64.254.0/24', 'handle': None, 'range': '145.64.254.0 - 145.64.254.255', 'emails': None, 'city': None, 'postal_code': None, 'country': None, 'state': None, 'description': 'European Patent Office', 'created': '2019-06-26T13:23:13Z', 'updated': '2019-06-26T13:23:13Z', 'name': None, 'address': None}], 'raw': None, 'asn_cidr': '145.64.252.0/22', 'referral': None, 'asn_registry': 'ripencc'}
>>>

Here is the same command from inside webservice python3.5 shell

tools.whois-referral@interactive:~$ source venv3.5/bin/activate
(venv3.5) tools.whois-referral@interactive:~$ which python
/usr/bin/python
(venv3.5) tools.whois-referral@interactive:~$ venv3.5/bin/python
Python 3.5.3 (default, Jul  9 2020, 13:00:10)
[GCC 6.3.0 20170516] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from ipwhois import IPWhois
>>> IPWhois("145.64.254.243").lookup_whois()
{'asn_description': 'EPO-AS, NL', 'query': '145.64.254.243', 'asn_country_code': 'DE', 'raw': None, 'asn_cidr': '145.64.252.0/22', 'referral': None, 'nir': None, 'asn': '28756', 'raw_referral': None, 'nets': [], 'asn_date': '1993-09-01', 'asn_registry': 'ripencc'}

It seems to only be RIPE - or at least, ARIN is not affected. I get the same output for my home IP in both cases.

wiki-ST47 commented 4 years ago

The problem persists on Python 3.7, as well as with other versions of ipwhois - I tried 1.2.0, 1.1.0, 1.0.0, and 0.15.0.

wiki-ST47 commented 4 years ago

Oh.

>>> from ipwhois import net
>>> net.Net("145.64.254.243").get_whois('ripencc')
'% This is the RIPE Database query service.\n% The objects are in RPSL format.\n%\n% The RIPE Database is subject to Terms and Conditions.\n% See http://www.ripe.net/db/support/db-terms-conditions.pdf\n\n%ERROR:201: access denied for 185.15.56.1\n%\n% Sorry, access from your host has been permanently\n% denied because of a repeated excessive querying.\n% For more information, see\n% http://www.ripe.net/data-tools/db/faq/faq-db/why-did-you-receive-the-error-201-access-denied\n\n% This query was served by the RIPE Database Query Service version 1.98 (HEREFORD)\n\n\n'
>>>
wiki-ST47 commented 4 years ago

https://phabricator.wikimedia.org/T265784

whym commented 4 years ago

I tried running it locally and full information was displayed for 145.64.254.243, so it does seem like the tool's host is blocked from the database.

A workaround is that the blue 「RIPENCC」 link from https://whois.toolforge.org/gateway.py?lookup=true&ip=145.64.254.243 is clickable and it let you see information on the RIPE website itself.