tor – matoken's blog https://matoken.org/blog Is there no plan B? Wed, 13 Nov 2024 22:32:26 +0000 ja hourly 1 https://wordpress.org/?v=6.7.2 https://matoken.org/blog/wp-content/uploads/2025/03/cropped-1865f695c4eecc844385acef2f078255036adccd42c254580ea3844543ab56d9-32x32.jpeg tor – matoken's blog https://matoken.org/blog 32 32 Google検索のgooglerのようにターミナル上でDuckDuckGo検索が出来るddgr https://matoken.org/blog/2024/11/14/ddgr-that-allows-you-to-search-duckduckgo-on-the-terminal-like-googler-of-google-search/ https://matoken.org/blog/2024/11/14/ddgr-that-allows-you-to-search-duckduckgo-on-the-terminal-like-googler-of-google-search/#comments Wed, 13 Nov 2024 22:24:17 +0000 https://matoken.org/blog/?p=4233

GooglerというターミナルでGoogle検索の出来るgooglerJというコマンドがあります.便利なのですが,自分はDuckDuckGoをメインに利用しています.DuckDuckGoを端末で利用する場合,こんな感じで検索していました. w3m https://html.duckduckgo.com/html?q=クエリー
ターミナルアプリケーション紹介サイトのTerminalTriveで今週のおすすめにDuckDuckGo版googler的なddgrが紹介されていたので試してみました.

View on Mastodon



導入

ddgrはPython製でPython 3.8以降が必要です.
各種パッケージマネージャでも配布されています.snapやPyPIが汎用的でしょうか.

DebianやUbuntuではこんな感じ.

$ rmadison ddgr
ddgr       | 1.6-1         | oldoldstable | source, all
ddgr       | 1.9-2         | oldstable    | source, all
ddgr       | 2.1-1         | stable       | source, all
ddgr       | 2.2-1         | testing      | source, all
ddgr       | 2.2-1         | unstable     | source, all
$ rmadison ddgr -u ubuntu
 ddgr | 1.2-1                     | bionic/universe   | source, all
 ddgr | 1.7+git20190928.bccdc92-2 | focal/universe    | source, all
 ddgr | 1.9-2                     | jammy/universe    | source, all
 ddgr | 2.2-1                     | noble/universe    | source, all
 ddgr | 2.2-1                     | oracular/universe | source, all
 ddgr | 2.2-1                     | plucky/universe   | source, all

今回最新の2.2のパッケージのあるDebian sid環境にディストリビューションパッケージから導入しました.

$ apt show ddgr

Package: ddgr
Version: 2.2-1
Priority: optional
Section: misc
Maintainer: SZ Lin (林上智) <szlin@debian.org>
Installed-Size: 132 kB
Depends: python3:any, python3 (>= 3.5)
Homepage: https://github.com/jarun/ddgr
Download-Size: 37.3 kB
APT-Manual-Installed: yes
APT-Sources: http://ftp.jp.debian.org/debian sid/main amd64 Packages
Description: DuckDuckGo from the terminal
Features
.
– Fast and clean (no ads, stray URLs or clutter), custom color
– Navigate result pages from omniprompt, open URLs in browser
– Search and option completion scripts for Bash, Zsh and Fish
– DuckDuckGo Bang support (along with completion)
– Open the first result directly in browser (as in I’m Feeling Ducky)
– Non-stop searches: fire new searches at omniprompt without exiting
– Keywords (e.g. filetype:mime, site:somesite.com) support
– Specify region, disable safe search
– HTTPS proxy support, Do Not Track set, optionally disable User Agent
– Support custom url handler script or cmdline utility
– Comprehensive documentation, man page with handy usage examples
– Minimal dependencies

$ sudo apt install ddgr
$ ddgr -h
usage: ddgr [-h] [-n N] [-r REG] [--colorize [{auto,always,never}]] [-C] [--colors COLORS] [-j] [-t SPAN] [-w SITE] [-x] [-p URI]
            [--unsafe] [--noua] [--json] [--gb] [--np] [--rev] [--url-handler UTIL] [--show-browser-logs] [-v] [-d]
            [KEYWORD ...]

DuckDuckGo from the terminal.

positional arguments:
  KEYWORD               search keywords

options:
  -h, --help            show this help message and exit
  -n N, --num N         show N (0<=N<=25) results per page (default 10); N=0 shows actual number of results fetched per page
  -r REG, --reg REG     region-specific search e.g. 'us-en' for US (default); visit https://duckduckgo.com/params
  --colorize [{auto,always,never}]
                        whether to colorize output; defaults to 'auto', which enables color when stdout is a tty device; using
                        --colorize without an argument is equivalent to --colorize=always
  -C, --nocolor         equivalent to --colorize=never
  --colors COLORS       set output colors (see man page for details)
  -j, --ducky           open the first result in a web browser; implies --np
  -t SPAN, --time SPAN  time limit search [d (1 day), w (1 wk), m (1 month), y (1 year)]
  -w SITE, --site SITE  search sites using DuckDuckGo
  -x, --expand          Show complete url in search results
  -p URI, --proxy URI   tunnel traffic through an HTTPS proxy; URI format: [http[s]://][user:pwd@]host[:port]
  --unsafe              disable safe search
  --noua                disable user agent
  --json                output in JSON format; implies --np
  --gb, --gui-browser   open a bang directly in gui browser
  --np, --noprompt      perform search and exit, do not prompt
  --rev, --reverse      list entries in reversed order
  --url-handler UTIL    custom script or cli utility to open results
  --show-browser-logs   do not suppress browser output (stdout and stderr)
  -v, --version         show program's version number and exit
  -d, --debug           enable debugging

omniprompt keys:
  n, p, f               fetch the next, prev or first set of search results
  index                 open the result corresponding to index in browser
  o [index|range|a ...] open space-separated result indices, ranges or all
  O [index|range|a ...] like key 'o', but try to open in a GUI browser
  d keywords            new DDG search for 'keywords' with original options
                        should be used to search omniprompt keys and indices
  x                     toggle url expansion
  c index               copy url to clipboard
  q, ^D, double Enter   exit ddgr
  ?                     show omniprompt help
  *                     other inputs are considered as new search keywords

Version 2.2
Copyright © 2016-2024 Arun Prakash Jana <engineerarun@gmail.com>
License: GPLv3
Webpage: https://github.com/jarun/ddgr

利用例

普通に検索
$ ddgr 検索キーワード

 1.  ラッコキーワード|無料のキーワード分析ツール(サジェスト・共起語・月間検索数など) [rakkokeyword.com]
     ラッコキーワードは、検索キーワードを入力するとサジェスト、共起語、月間検索数などの情報を提供するキーワードリサーチツールです。個人利用や有料プランで利用できる機能や料金プラン、マニュ
     アルなどの情報もあります。

 2.  【2024年最新】SEOに効く!無料&有料キーワードツール17選 [mieru-ca.com]
     キーワードツールは、Webサイトへのアクセス数を増やすためのSEO対策において
     ユーザーが検索エンジンで入力するキーワードを調査・分析するためのツールです。この記事では、キーワードツールの使い方や重要性、有料&無料のおすすめキーワードツールなどをご紹介します。

 3.  【検索キーワード】の調べ方・選定方法・効果的な活用のしかたを徹底解説 [www.conoha.jp]
     ブログやアフィリエイトサイトの収益化には検索キーワードの選定が重要です。この記事では、検索キーワードの種類や選定方法、検索ボリュームの調べ方、おすすめのツールなどを徹底解説します。

 4.  Google トレンド [trends.google.co.jp]
     Google トレンドは、Google
     検索のデータを分析して、話題になっているキーワードやイベントを表示するサービスです。地域や時間帯、カテゴリーなどで検索キーワードを調べたり、トレンドデータを活用したりできます。

 5.  【2024年最新版】おすすめキーワードツール17選!無料版・有料版の違いも紹介 [www.seohacks.net]
     キーワードツールは、SEOに必要な検索ボリュームや関連キーワードなどを分析できるツールです。この記事では、総合的なツールからサジェストキーワードやトレンドキーワードに特化したツールまで、
     無料版と有料版の違いや使い方を詳しく解説します。

 6.  2024年版:無料のキーワード調査ツール10選 - Ahrefs [ahrefs.jp]
     SEOに役立つキーワード調査の方法とツールを紹介する記事です。AhrefsのキーワードジェネレーターやGoogleトレンドなど、無料で使えるツールの特徴と活用方法を解説します。

 7.  キーワードツール16選!キーワードプランナーの代わりの選定ツールなど無料から紹介|ディーボのSEOラボ [seolaboratory.jp]
     キーワードツールとは、キーワードの競合性や検索ボリューム、関連キーワードなどがわかるSEOツールです。この記事では、キーワードプランナーの代わりとして人気のキーワードツールを16個厳選し、
     機能や料金などを一覧で比較して紹介します。

 8.  無料キーワードジェネレーターツール:数秒で100以上のキーワード候補を見つけましょう [ahrefs.com]
     一日中、キーワード候補を探しましょう. 80億以上のクエリからなる 当社のデータベース から、関連キーワードを検索しましょう。.
     最大10個の単語またはフレーズを入力し、6つのキーワード候補レポートの中から1つを選択するだけです。. 数週間、数ヶ月 ...

 9.  無料のキーワード調査ツール10選(Googleキーワードプランナー以外のもの) | Ahrefsブログ- 使えるSEO情報をお届け | SEO ... [ahrefs.jp]
     Googleキーワードプランナー以外の無料のキーワード調査ツールを紹介します。Googleトレンド、Ahrefsキーワードジェネレーター、Keyword
     Sheeterなど、検索ボリュームやコンペティション、関連キーワードなどの情報を得ることができます。

 10. SEOキーワード調査の手順を徹底解説 - Kinsta [kinsta.com]
     SEOに効果的なキーワードを見つけるための手順と、おすすめの分析ツールを解説します。キーワードの難易度、検索ボリューム、ユーザーの意図などを把握し、ビジネスに有益なキーワードを選択するコ
     ツを学びましょう。

ddgr (? for help) ?

omniprompt keys:
  n, p, f               fetch the next, prev or first set of search results
  index                 open the result corresponding to index in browser
  o [index|range|a ...] open space-separated result indices, ranges or all
  O [index|range|a ...] like key 'o', but try to open in a GUI browser
  d keywords            new DDG search for 'keywords' with original options
                        should be used to search omniprompt keys and indices
  x                     toggle url expansion
  c index               copy url to clipboard
  q, ^D, double Enter   exit ddgr
  ?                     show omniprompt help
  *                     other inputs are considered as new search keywords

ddgr (? for help) 1 (1)
ddgr (? for help) d 猫 季語 (2)

 1.  季語として表現される猫たち 春や冬の季語や猫の俳句を詠んだ俳人たちを紹介 | ペトコト(Petokoto) [petokoto.com]
     猫が春の季語として使われる理由や、猫に関する有名な俳句や猫の恋について紹介するペトコトの記事です。猫の季語や猫の俳句を知りたい方はぜひご覧ください。
  (以下省略)
$ ddgr -n5 検索キーワード (3)
$ ddgr -j ddgr DuckDuckGo (4)
  1. 1件目の検索結果をデフォルトのウェブブラウザで開く

  2. 別の検索キーワード

  3. 検索結果が画面に収まらないので1ページ5件に

  4. 検索結果の一件目を開く

ddgrの検索結果を特定のウェブブラウザで使う

ddgr は環境変数 BROWSER を認識するのでこれを指定することでddgrの検索結果をデフォルト以外のウェブブラウザで開くことが出来ます,端末で動作するw3mやlynxなどのテキストブラウザであれば同じ端末の中で起動して,ウェブブラウザを終了するとまたddgrに戻ってきます.

$ BROWSER=dillo ddgr -n5 検索キーワード (1)
$ BROWSER=w3m ddgr -n5 検索キーワード (2)
  1. ウェブブラウザに軽量なdilloを利用

  2. ウェブブラウザにテキストブラウザのw3mを利用

tor経由で利用

torifyやtorsocksを挟んでtor経由で利用したりも.

$ BROWSER=w3m torify ddgr -n5 site:torproject.org check
$ BROWSER=w3m torsocks ddgr -j site:torproject.org check

便利に使えそうです :)

環境
$ dpkg-query -W ddgr w3m tor torsocks dillo
ddgr    2.2-1
dillo   3.0.5-7.1
tor     0.4.8.13-2
torsocks        2.4.0-2
w3m     0.5.3+git20230121-2+b3
$ lsb_release -dr
Description:    Debian GNU/Linux trixie/sid
Release:        n/a
$ arch
x86_64
]]>
https://matoken.org/blog/2024/11/14/ddgr-that-allows-you-to-search-duckduckgo-on-the-terminal-like-googler-of-google-search/feed/ 1
torのhidden serviceで使うアドレスを計算する(Vanity Addresses) https://matoken.org/blog/2020/06/12/calculate-the-address-to-use-in-tor-hidden-service-vanity-addresses/ https://matoken.org/blog/2020/06/12/calculate-the-address-to-use-in-tor-hidden-service-vanity-addresses/#comments Thu, 11 Jun 2020 22:10:21 +0000 http://matoken.org/blog/?p=2810

最近このような記事を読みました.

今のインターネットはドメイン頼りな割に単一障害点となってしまってあまりよろしくない.でも逃げ道があまりないのですよね…….
とりあえず以前からそのうちやろうと思って放置していたtorのhidden serviceでミラーを立てるのをやってみようかなと思い立ちました.

とりあえず /etc/tor/torrc で以下のあたりを有効にしてtorを再起動してhttpdの設定をするだけで動きます.

HiddenServiceDir /var/lib/tor/hidden_service/
HiddenServicePort 80 127.0.0.1:80

このときのアドレスはtor再起動後に HiddenServiceDir 以下に作られる hostname ファイルの中の名前になります.

$ sudo cat /var/lib/tor/hidden_service/hostname
tbiettfnprnqpoccrz3ll7hioprbyjoam2n6okihpadf5ukaa4hwrwad.onion

このアドレスは[a-z|3-7]の32文字(BASE32)からなる16文字の onion v2 アドレスと,56文字の onion v3 アドレスがあって,最近は後者のv3アドレスが規定値になっているようです.鍵は RSA から ed25519 になっています.

Onion v2 はホストネームから秘密鍵を求めるのに現実的な時間で済むのが近づいてきているようなのでとても長くて使いづらいですがこれからはOnion v3 アドレスにしたほうが良さそうです.
今はv2,v3 を併用しているところも多いようです.

Onion v2 Onion v3

hostname文字長

16

56

鍵形式

RSA

ed25519

鍵ファイル名

private_key

hs_ed25519_secret_key hs_ed25519_public_key

(無駄に)アドレスを計算して好みの単語にマッチしたものを探す(例えばmatokenから始まるアドレスを探すとか)ことが可能です.
こういったアドレスはVanity Addresses というようです.

他にもアドレスを売っているところもありますが,相手は秘密鍵を持っているわけであまりよくないと思います.

Onion v2 アドレスを eschalot で探す

add 2020-07-28)

Onion v2 アドレスは2021年11月あたりで使えなくなるようです.

Onion v2 アドレスを eschalot というツールを使ってみます.

導入
$ sudo apt install libssl-dev
$ git clone https://github.com/ReclaimYourPrivacy/eschalot
$ cd eschalot
$ make
$ ./eschalot
Version: 1.2.0

usage:
eschalot [-c] [-v] [-t count] ([-n] [-l min-max] -f filename) | (-r regex) | (-p prefix)
  -v         : verbose mode - print extra information to STDERR
  -c         : continue searching after the hash is found
  -t count   : number of threads to spawn default is one)
  -l min-max : look for prefixes that are from 'min' to 'max' characters long
  -n         : Allow digits to be part of the prefix (affects wordlist mode only)
  -f filename: name of the text file with a list of prefixes
  -p prefix  : single prefix to look for (1-16 characters long)
  -r regex   : search for a POSIX-style regular expression

Examples:
  eschalot -cvt4 -l8-12 -f wordlist.txt >> results.txt
  eschalot -v -r '^test|^exam'
  eschalot -ct5 -p test

  base32 alphabet allows letters [a-z] and digits [2-7]
  Regex pattern examples:
    xxx           must contain 'xxx'
    ^foo          must begin with 'foo'
    bar$          must end with 'bar'
    b[aoeiu]r     must have a vowel between 'b' and 'r'
    '^ab|^cd'     must begin with 'ab' or 'cd'
    [a-z]{16}     must contain letters only, no digits
    ^dusk.*dawn$  must begin with 'dusk' and end with 'dawn'
    [a-z2-7]{16}  any name - will succeed after one iteration

以下は -t でスレッド数を指定,-v で冗長出力,-pabc 方始まるホスト名を探しています.
見つかると標準出力にホスト名と秘密鍵が出力されます.

$ time ./eschalot -t`nproc` -v -p abc
Verbose, single result, no digits, 4 threads, prefixes 3-3 characters long.
Thread #1 started.
Thread #2 started.
Thread #3 started.
Thread #4 started.
Running, collecting performance data...
Found a key for abc (3) - abcamzmribeujuzw.onion
----------------------------------------------------------------
abcamzmribeujuzw.onion
-----BEGIN RSA PRIVATE KEY-----
MIICXQIBAAKBgQDIHD5uCynAW/Y1Vmyef8KrKuyFMzavij5Gl6aHYoiaGWNkJOZ7
P/Xc1Z78YTZ7LtzpWCAWLax4PmIhQiwPhldsD/kVWKAi0fODxaP/Z0XoJjqIfx8f
CmVWIQ1L9TVp9kfp8nLtXm9CnawCT98g0VE/jvZEddBV2oaVCuq88BTsoQIEAQBz
4QKBgBHzMeQAOOkyB3yCc51oYOh92jYLyXJuc511HR9yki7b/CxIhjL7miA+GVmJ
n4DD9nKubE5/xE6KrNnm3YZ1kmar2Yl/8fLJxBUrVoDUeGAc7i77i+tqM4d1LCr3
X1Ead8S7WpnnTVSmRHiLjuebaF78BWiMII4+3v9d1e6PQXbRAkEA9IJknhUNSO5b
1bzEIOmybg94r3fvBdWsc9xiwm6ONMBI2WyAVwmxDZ63Spwb/AyKCEblwekcaw6h
NMmhBQeUmQJBANGDs597RqBQUsFqtb5BoBkQgELIVeS4xKgZXrDI9SKfnnpTxv8Z
ypah+g335EN3/bBgfbqy8C7zFZhjHclzFUkCQQDcoP4aDG1zPO4TFcnguwvnGv/j
kOBS3h0CJOVY+rLTlUaekvjD6ugVLQ0olFItL1wyyZ3IifKcDHoDWJo/OOZZAkAQ
82dcvUGLOUpZObyFTdyUkU/eytiXaQZM0UdTDPnGYmrH/CBEaoSSjgRG7MEdFf2k
r+VVLqSnp+g6tFwp9It5AkBI4fJxCrrANt3E/CCrFW4iZXIqP3aPXHHZK5SqtQzJ
gBKUN8HSRxo/dURQPOLKKX0ynVJaMhg5UO4tQ3rHiJwa
-----END RSA PRIVATE KEY-----

Segmentation fault

real    0m0.126s
user    0m0.399s
sys     0m0.015s

-r オプションで正規表現が利用できます.以下の例は abc から始まり bca で終わるホスト名か,deadbeef で始まるアドレスを探しています.

$ ./eschalot -t`nproc` -v -r "^abc.*bca^|^deadbeef"

-c オプションで1つ見つかっても中断するまで探し続けます.
ファイルにリダイレクトしておくと便利です.

$ ./eschalot -cvt`nproc` -r "^abc.bca^|^deadbeef" >> result.log

探したいワードが多い場合は1ワード1行の辞書ファイルを作成して -f オプションで指定すると便利です.ただし,辞書ファイル指定時は7文字以下のワードは無視されるようです.-l オプションで 7-16 のように最小文字数を7以下にすればと思ったのですが,このオプションは7以下だとエラーで終了してしまいます.

$ ./eschalot -cvt`nproc` -f ./wordlist.dic >> result.log

GPUを使うツールも複数あります.例えば Scallion こっちのほうがずっと速いでしょう.(ASICとかもあるのかな?)

Onion v3 アドレスを mkp224o で探す

Onion v3 アドレスは mkp224o というツールを使ってみました.

configure optionに --enable-amd64-51-30k , --enable-amd64-64-24k というものがあるので試してみましたが,なし,--enable-amd64-51-30k , --enable-amd64-64-24k のいずれでも有意な速度差は見られませんでした.(Intel® Core™ i5-3320M)

導入
$ sudo apt install libsodium-dev autoconf
$ git clone https://github.com/cathugger/mkp224o
$ cd mkp224o
$ ./autogen.sh
$ ./configure
$ make
$ ./mkp224o
Usage: ./mkp224o filter [filter...] [options]
       ./mkp224o -f filterfile [options]
Options:
        -h  - print help to stdout and quit
        -f  - specify filter file which contains filters separated by newlines
        -D  - deduplicate filters
        -q  - do not print diagnostic output to stderr
        -x  - do not print onion names
        -v  - print more diagnostic data
        -o filename  - output onion names to specified file (append)
        -O filename  - output onion names to specified file (overwrite)
        -F  - include directory names in onion names output
        -d dirname  - output directory
        -t numthreads  - specify number of threads to utilise (default - CPU core count or 1)
        -j numthreads  - same as -t
        -n numkeys  - specify number of keys (default - 0 - unlimited)
        -N numwords  - specify number of words per key (default - 1)
        -z  - use faster key generation method; this is now default
        -Z  - use slower key generation method
        -B  - use batching key generation method (>10x faster than -z, experimental)
        -s  - print statistics each 10 seconds
        -S t  - print statistics every specified ammount of seconds
        -T  - do not reset statistics counters when printing
        -y  - output generated keys in YAML format instead of dumping them to filesystem
        -Y [filename [host.onion]]  - parse YAML encoded input and extract key(s) to filesystem
        --rawyaml  - raw (unprefixed) public/secret keys for -y/-Y (may be useful for tor controller API)
        -p passphrase  - use passphrase to initialize the random seed with
        -P  - same as -p, but takes passphrase from PASSPHRASE environment variable

探したいワードを引数に与えて実行するだけで利用できます.結果はホスト名のディレクトリ以下にファイルとして出力されます.

$ time ./mkp224o abcd
sorting filters... done.
filters:
        abcd
in total, 1 filter
using 4 threads
abcdpr2quwoxranttf2ywckm7g5giysscy62kmhyqmnq2ycvooxbtryd.onion
^Cwaiting for threads to finish... done.

real    0m8.982s
user    0m21.740s
sys     0m0.167s
$ ls -A abcdpr2quwoxranttf2ywckm7g5giysscy62kmhyqmnq2ycvooxbtryd.onion
hostname  hs_ed25519_public_key  hs_ed25519_secret_key

結果を onion ディレクトリに格納するようにしました.

$ time ./mkp224o -d ./onion abcd

フィルタは複数書けます.

$ time ./mkp224o -d ./onion abcd efgh ijkl

-S オプションで指定した秒数ごとに統計上を鵜を出力します.フィルタに辞書ファイルを使います.

$ ./mkp224o -S 300 -d ./onion -f ./wordlist.dic

以下は手元のNotePCとRaspberry Pi 3 model Bでの速度です.PCの方は熱でスロットリングが効いているのもありますが,案外Raspberry Pi が悪くない数字に見えます.自分の環境の場合電気代等を考えるとRaspberry Pi を並列で動かしておくほうが良さそうです.

Intel® Core™ i5-3320M
>calc/sec:202602.624226, succ/sec:0.000000, rest/sec:0.000000, elapsed:300.129147sec
>calc/sec:177378.183948, succ/sec:0.006667, rest/sec:0.006667, elapsed:600.131277sec
>calc/sec:155232.657607, succ/sec:0.006667, rest/sec:0.006667, elapsed:900.106274sec
>calc/sec:111928.180486, succ/sec:0.000000, rest/sec:0.000000, elapsed:1200.166338sec
Raspberry Pi 3 model B(aarch64 kernel)
>calc/sec:103867.893552, succ/sec:0.003333, rest/sec:0.003333, elapsed:300.130969sec
>calc/sec:100761.039921, succ/sec:0.003333, rest/sec:0.003333, elapsed:600.155046sec
>calc/sec:94511.877034, succ/sec:0.009999, rest/sec:0.009999, elapsed:900.194934sec
>calc/sec:91854.274354, succ/sec:0.003334, rest/sec:0.003334, elapsed:1200.130938sec

Vanity Addresses の設定

Onion v2

torrc の HiddenServiceDir 以下の hostname, hs_ed25519_public_key, hs_ed25519_secret_key を退避します.
次に private_key ファイルをtorの権限で作成し,見つけたRSA鍵を保存します.

その後torのサービスを再起動すると反映されて hostname ファイルも作成されます.

$ grep ^HiddenServiceDir /etc/tor/torrc
HiddenServiceDir /var/lib/tor/other_hidden_service/
$ sudo ls -A /var/lib/tor/other_hidden_service/
authorized_clients  hostname  hs_ed25519_public_key  hs_ed25519_secret_key  private_key
$ sudo rm /var/lib/tor/other_hidden_service/hostname /var/lib/tor/other_hidden_service/hs_ed25519_public_key /var/lib/tor/other_hidden_service/hs_ed25519_secret_key
$ sudo install -o debian-tor -g debian-tor -m 400 /dev/null /var/lib/tor/other_hidden_service/private_key
$ echo '-----BEGIN RSA PRIVATE KEY-----
> MIICXQIBAAKBgQDIHD5uCynAW/Y1Vmyef8KrKuyFMzavij5Gl6aHYoiaGWNkJOZ7
> P/Xc1Z78YTZ7LtzpWCAWLax4PmIhQiwPhldsD/kVWKAi0fODxaP/Z0XoJjqIfx8f
> CmVWIQ1L9TVp9kfp8nLtXm9CnawCT98g0VE/jvZEddBV2oaVCuq88BTsoQIEAQBz
> 4QKBgBHzMeQAOOkyB3yCc51oYOh92jYLyXJuc511HR9yki7b/CxIhjL7miA+GVmJ
> n4DD9nKubE5/xE6KrNnm3YZ1kmar2Yl/8fLJxBUrVoDUeGAc7i77i+tqM4d1LCr3
> X1Ead8S7WpnnTVSmRHiLjuebaF78BWiMII4+3v9d1e6PQXbRAkEA9IJknhUNSO5b
> 1bzEIOmybg94r3fvBdWsc9xiwm6ONMBI2WyAVwmxDZ63Spwb/AyKCEblwekcaw6h
> NMmhBQeUmQJBANGDs597RqBQUsFqtb5BoBkQgELIVeS4xKgZXrDI9SKfnnpTxv8Z
> ypah+g335EN3/bBgfbqy8C7zFZhjHclzFUkCQQDcoP4aDG1zPO4TFcnguwvnGv/j
> kOBS3h0CJOVY+rLTlUaekvjD6ugVLQ0olFItL1wyyZ3IifKcDHoDWJo/OOZZAkAQ
> 82dcvUGLOUpZObyFTdyUkU/eytiXaQZM0UdTDPnGYmrH/CBEaoSSjgRG7MEdFf2k
> r+VVLqSnp+g6tFwp9It5AkBI4fJxCrrANt3E/CCrFW4iZXIqP3aPXHHZK5SqtQzJ
> gBKUN8HSRxo/dURQPOLKKX0ynVJaMhg5UO4tQ3rHiJwa
> -----END RSA PRIVATE KEY-----' | sudo -u debian-tor tee /var/lib/tor/other_hidden_service/private_key
$ sudo service tor restart
$ torsocks w3m `sudo -u debian-tor cat /var/lib/tor/other_hidden_service/hostname`

Onion v3

torrc の HiddenServiceDir 以下の hostname, hs_ed25519_public_key, hs_ed25519_secret_key を退避します.
次に hs_ed25519_secret_key ファイルをtorの権限でコピーします.

その後torのサービスを再起動すると反映されて hostname, hs_ed25519_public_key ファイルも作成されます.

$ grep ^HiddenServiceDir /etc/tor/torrc
HiddenServiceDir /var/lib/tor/other_hidden_service/
$ sudo ls -A /var/lib/tor/other_hidden_service/
authorized_clients  hostname  hs_ed25519_public_key  hs_ed25519_secret_key  private_key
$ sudo rm /var/lib/tor/other_hidden_service/hostname /var/lib/tor/other_hidden_service/hs_ed25519_public_key /var/lib/tor/other_hidden_service/hs_ed25519_secret_key
$ sudo install -o debian-tor -g debian-tor -m 400 ./onion/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.onion/hs_ed25519_secret_key /var/lib/tor/other_hidden_service/hs_ed25519_secret_key
$ sudo service tor restart
$ torsocks w3m `sudo -u debian-tor cat /var/lib/tor/other_hidden_service/hostname`

まとめ

という感じで3日ほど動かしてみましたが matoken から始まるホスト名を3つほど掘り当てました.近いうちにミラーを設定してみようと思います.(v2, v3のアドレスを1つのtorサービスでホストする方法ってあるのかな?)
しかし設定してもアクセスはほぼ無いような気も…….

ちなみにtorはNAT越えもしてしまうのでsshdなどを許可する場合は注意しましょう.

$ torsocks w3m -dump http://matoken3inrzd4ks.onion/
 _     _   _             ____               _        _              _____
| |__ | |_| |_ _ __ _   / / / __ ___   __ _| |_ ___ | | _____ _ __ |___ /
| '_ \| __| __| '_ (_) / / / '_ ` _ \ / _` | __/ _ \| |/ / _ \ '_ \  |_ \
| | | | |_| |_| |_) | / / /| | | | | | (_| | || (_) |   <  __/ | | |___) |
|_| |_|\__|\__| .__(_)_/_/ |_| |_| |_|\__,_|\__\___/|_|\_\___|_| |_|____/
              |_|
 _                   _ _  _   _                     _                __
(_)_ __  _ __ ______| | || | | | _____   ___  _ __ (_) ___  _ __    / /
| | '_ \| '__|_  / _` | || |_| |/ / __| / _ \| '_ \| |/ _ \| '_ \  / /
| | | | | |   / / (_| |__   _|   <\__ \| (_) | | | | | (_) | | | |/ /
|_|_| |_|_|  /___\__,_|  |_| |_|\_\___(_)___/|_| |_|_|\___/|_| |_/_/
環境
$ dpkg-query -W tor
tor     0.3.5.10-1
$ lsb_release -dr
Description:    Debian GNU/Linux 10 (buster)
Release:        10
$ uname -m
aarch64
$ cat /proc/device-tree/model ;echo
Raspberry Pi 3 Model B Rev 1.2

]]>
https://matoken.org/blog/2020/06/12/calculate-the-address-to-use-in-tor-hidden-service-vanity-addresses/feed/ 3