hack のためのネタ帳, etc,,,

まとめ

Linux の場合 proxychains または proxychains4 を入れて、
/etc/proxychains.conf に
http 1.2.3.4 8080
みたいな感じで IP アドレスとポートを指定した後、
proxychains whois google.com
みたいにすればよい。

なお Cygwin には proxychains の package が収録されておらず、dlsym() の RTLD_NEXT 拡張が未実装なので self build による port も不能だったが
WSL 経由で、
wsl proxychains whois google.com
みたいなことは可能だった。

状況

PROXY 必須の環境下から whois を引きたい。
socks は使えず http proxy のみが使える状況。

ssh みたいに connect-proxy コマンドが使えんのだろうかと「whois "connect-proxy"」探してみたのだが、こちらは有力情報が見当たらず、
whois "http proxy"」でググったら、以下のページを見つけた。

proxychains を使うと良いとかなんとか。
たまたま手元の実機環境の Ubuntu 16.04.7 LTS に入ってたので試してみたら
$ proxychains whois google.com
ProxyChains-3.1 (http://proxychains.sf.net)
|S-chain|-<>-xxx.xx.xxx.xxx:8080-<><>-192.34.234.30:43-<><>-OK
   Domain Name: GOOGLE.COM
   Registry Domain ID: 2138514_DOMAIN_COM-VRSN
   Registrar WHOIS Server: whois.markmonitor.com
   Registrar URL: http://www.markmonitor.com
   Updated Date: 2019-09-09T15:39:04Z
   Creation Date: 1997-09-15T04:00:00Z
   Registry Expiry Date: 2028-09-14T04:00:00Z
   Registrar: MarkMonitor Inc.
   Registrar IANA ID: 292
   Registrar Abuse Contact Email: abusecomplaints@markmonitor.com
   Registrar Abuse Contact Phone: +1.2083895740
   Domain Status: clientDeleteProhibited https://icann.org/epp#clientDeleteProhibited
   Domain Status: clientTransferProhibited https://icann.org/epp#clientTransferProhibited
   Domain Status: clientUpdateProhibited https://icann.org/epp#clientUpdateProhibited
   Domain Status: serverDeleteProhibited https://icann.org/epp#serverDeleteProhibited
   Domain Status: serverTransferProhibited https://icann.org/epp#serverTransferProhibited
   Domain Status: serverUpdateProhibited https://icann.org/epp#serverUpdateProhibited
   Name Server: NS1.GOOGLE.COM
   Name Server: NS2.GOOGLE.COM
   Name Server: NS3.GOOGLE.COM
   Name Server: NS4.GOOGLE.COM
   DNSSEC: unsigned
   URL of the ICANN Whois Inaccuracy Complaint Form: https://www.icann.org/wicf/
>>> Last update of whois database: 2021-07-15T07:42:38Z <<<

For more information on Whois status codes, please visit https://icann.org/epp

NOTICE: The expiration date displayed in this record is the date the
registrar's sponsorship of the domain name registration in the registry is
currently set to expire. This date does not necessarily reflect the expiration
date of the domain name registrant's agreement with the sponsoring
registrar.  Users may consult the sponsoring registrar's Whois database to
view the registrar's reported date of expiration for this registration.

TERMS OF USE: You are not authorized to access or query our Whois
database through the use of electronic processes that are high-volume and
automated except as reasonably necessary to register domain names or
modify existing registrations; the Data in VeriSign Global Registry
Services' ("VeriSign") Whois database is provided by VeriSign for
information purposes only, and to assist persons in obtaining information
about or related to a domain name registration record. VeriSign does not
guarantee its accuracy. By submitting a Whois query, you agree to abide
by the following terms of use: You agree that you may 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, telephone,
or facsimile; or (2) enable high volume, automated, electronic processes
that apply to VeriSign (or its computer systems). The compilation,
repackaging, dissemination or other use of this Data is expressly
prohibited without the prior written consent of VeriSign. You agree not to
use electronic processes that are automated and high-volume to access or
query the Whois database except as reasonably necessary to register
domain names or modify existing registrations. VeriSign reserves the right
to restrict your access to the Whois database in its sole discretion to ensure
operational stability.  VeriSign may restrict or terminate your access to the
Whois database for failure to abide by these terms of use. VeriSign
reserves the right to modify these terms at any time.

The Registry database contains ONLY .COM, .NET, .EDU domains and
Registrars.
みたいな感じですんなりと通って一件落着。

しかし、その後がいろいろと大変だった。

じゃ、cygwin でもと思ったら、公式 package にない。
仕方ないので、 から upstream を見つけ、ソースを拾って来て make してみたのだが、ver 3, 4 共に dysym() に渡してる RTLD_NEXT が undefined でコンパイルが通らない。

RTLD_NEXT cygwin」でググってみると、これは GNU 拡張なんだそうで glibc ではなく newlibc ベースの cygwin じゃ無理、それ以前にそもそも Windows じゃ無理みたいな雰囲気。
ただし Cygwin で man dysym 引くとしれっと RTLD_DEFAULT、RTLD_NEXT の用途説明されてて「は!?」みたいな。
よくよく見てみると「The following special purpose values for handle are reserved for future use and have the indicated meanings:」みたいな但し書き付いてて、あー、現時点で使えないし使える見込みもないんですねみたいな。
と言う事で、とりあえず、cygwin に関しては順調に挫折 orz

じゃ、仕方ないから WSL で我慢すっかと、Ubuntu 18.04.5 LTS に proxychain と proxychain4 入れてみたんだが、どっちも、
$ proxychains whois google.com
ProxyChains-3.1 (http://proxychains.sf.net)
|DNS-request| whois.verisign-grs.com
|S-chain|-<>-127.0.0.1:9050-<--timeout
|DNS-response|: whois.verisign-grs.com does not exist
getaddrinfo(whois.verisign-grs.com): Unknown error
$ proxychains4 whois google.com
[proxychains] config file found: /etc/proxychains.conf
[proxychains] preloading /usr/lib/x86_64-linux-gnu/libproxychains.so.4
[proxychains] DLL init: proxychains-ng 4.12
[proxychains] Strict chain  ...  127.0.0.1:9050  ...  timeout
connect: Connection refused
みたいな感じで上手く動かない。

WSL のエミュレーションの限界かもと思い、
VirtualBox に入れてる Ubuntu 20.04.2 LTS でも同様に試してみたのだが、
$ proxychains3 whois google.com
ProxyChains-3.1 (http://proxychains.sf.net)
|DNS-request| whois.verisign-grs.com 
|S-chain|-<>-127.0.0.1:9050-<--timeout
|DNS-response|: whois.verisign-grs.com does not exist
getaddrinfo(whois.verisign-grs.com): 不明なエラー
$ proxychains4 whois google.com
[proxychains] config file found: /etc/proxychains.conf
[proxychains] preloading /usr/lib/x86_64-linux-gnu/libproxychains.so.4
[proxychains] DLL init: proxychains-ng 4.14
[proxychains] Strict chain  ...  127.0.0.1:9050  ...  timeout
connect: 接続を拒否されました
みたいな感じで上手く動かず、しばらく悩んだ。

いずれの環境も
$ declare -p {f,ht}tp{,s}_proxy 2>/dev/null
declare -x ftp_proxy="http://proxy.example.com:8080"
declare -x http_proxy="http://proxy.example.com:8080"
declare -x https_proxy="http://proxy.example.com:8080"
のように環境変数に proxy が設定してあってこれを拾っているとばかり思っていたのが災いした。

よく見てみると、実機は
$ proxychains whois google.com
ProxyChains-3.1 (http://proxychains.sf.net)
|S-chain|-<>-xxx.xx.xxx.xxx:8080-<><>-192.34.234.30:43-<><>-OK
...
みたいになっているのだが、
WLS は
$ proxychains whois google.com
ProxyChains-3.1 (http://proxychains.sf.net)
|DNS-request| whois.verisign-grs.com
|S-chain|-<>-127.0.0.1:9050-<--timeout
...
VirtualBox は
$ proxychains3 whois google.com
ProxyChains-3.1 (http://proxychains.sf.net)
|DNS-request| whois.verisign-grs.com 
|S-chain|-<>-127.0.0.1:9050-<--timeout
...
のように、「127.0.0.1:9050」を proxy として経由させようとしていて、環境変数から proxy 拾ってないじゃん!!!と。
これに気付くのに時間がかかってしまったのが敗因。

結局これは /etc/proxychains.conf に中にある以下の設定を拾っていた。
socks4         127.0.0.1 9050
実機はこれが、
#socks4         127.0.0.1 9050
#http   proxy.example.com 8080
http    xxx.xx.xxx.xxx 8080
のように変更されていたので上手く行っていたらしい。
タイムスタンプを確認してみると
$ ls -l --time-style="+%F %T" /etc/proxychains.conf
-rw-r--r-- 1 root root 1740 2021-04-26 13:19:35 /etc/proxychains.conf
みたいになってて、作業記録漁ってみると、どうも当日、http proxy 越しに nmap する方法を調べてたらしいところまでは分かったんだが、詳細はメモしてなかった。
状況的には proxychains を入れて、http proxy の設定を試したらしくて、その設定が残っていたため上手く行っていたようだ。

nmap over http proxy に関しては、
$ sudo proxychains nmap -Pn  google.com -p 80,443
ProxyChains-3.1 (http://proxychains.sf.net)

Starting Nmap 7.01 ( https://nmap.org ) at 2021-07-15 17:40 JST
Nmap scan report for google.com (142.250.76.142)
Host is up.
Other addresses for google.com (not scanned): 2404:6800:400a:80e::200e
rDNS record for 142.250.76.142: kix07s06-in-f14.1e100.net
PORT    STATE    SERVICE
80/tcp  filtered http
443/tcp filtered https

Nmap done: 1 IP address (1 host up) scanned in 3.22 seconds
みたいになるので、proxychains では解決できず、匙を投げたためメモも残さなかったのかなと思ったのだが、
map proxychais 引いてみるとあれ? nmap の例が出ている。
何パターンか試してみたのだが、一般ユーザーのままやると通る。
$ proxychains nmap google.com -p 80,443
ProxyChains-3.1 (http://proxychains.sf.net)

Starting Nmap 7.01 ( https://nmap.org ) at 2021-07-15 18:07 JST
|S-chain|-<>-xxx.xx.xxx.xxx:8080-<><>-142.250.76.142:80-<><>-OK
|S-chain|-<>-xxx.xx.xxx.xxx:8080-<><>-142.250.76.142:80-<><>-OK
|S-chain|-<>-xxx.xx.xxx.xxx:8080-<><>-142.250.76.142:443-<><>-OK
Nmap scan report for google.com (142.250.76.142)
Host is up (0.010s latency).
Other addresses for google.com (not scanned): 2404:6800:400a:80e::200e
rDNS record for 142.250.76.142: kix07s06-in-f14.1e100.net
PORT    STATE SERVICE
80/tcp  open  http
443/tcp open  https

Nmap done: 1 IP address (1 host up) scanned in 0.07 seconds
ひょっとして sudo で権限昇格させると今く行かないのかも???
閑話休題。

と言う事で、他の環境にも /etc/proxychains.conf に
http    xxx.xx.xxx.xxx 8080
のようにして http proxy の IP アドレスと port を指定してやったところ無事 whois over http proxy 出来るようになったのであった。

なお、proxy サーバーのアドレスは数値形式で与える必要があり、
proxy.example.com のようにドメイン名で与えると
Ubuntu 18.04.5 LTS は
$ proxychains whois google.com
ProxyChains-3.1 (http://proxychains.sf.net)
|DNS-request| whois.verisign-grs.com
|DNS-response|: whois.verisign-grs.com does not exist
getaddrinfo(whois.verisign-grs.com): Unknown error
$ proxychains4 whois google.com
[proxychains] config file found: /etc/proxychains.conf
[proxychains] preloading /usr/lib/x86_64-linux-gnu/libproxychains.so.4
proxy proxy.example.com has invalid value or is not numeric
Ubuntu 20.04.2 LTS は
$ proxychains3 whois google.com
ProxyChains-3.1 (http://proxychains.sf.net)
|DNS-request| whois.verisign-grs.com 
|DNS-response|: whois.verisign-grs.com does not exist
getaddrinfo(whois.verisign-grs.com): 不明なエラー
$ proxychains4 whois google.com
[proxychains] config file found: /etc/proxychains.conf
[proxychains] preloading /usr/lib/x86_64-linux-gnu/libproxychains.so.4
proxy proxy.example.com has invalid value or is not numeric
non-numeric ips are only allowed under the following circumstances:
chaintype == strict (true), proxy is not first in list (false), proxy_dns active (true)
のようなエラーとなる。

コメントをかく


「http://」を含む投稿は禁止されています。

利用規約をご確認のうえご記入下さい

Wiki内検索

フリーエリア

管理人/副管理人のみ編集できます