Recently, there was an offline competition, and because it was the first time it was held in the city, it was uncertain whether there would be internet access at the venue. I thought about preparing a backup arsenal to ensure performance. However, all the information I have is from the encrypted knowledge base in Yuque. I saw someone in my friends circle who could export in batches, but I couldn't find any methods after searching on Google for a long time. I found a good project on Github that can batch download publicly accessible password-protected knowledge bases using the Cookie method and save them as Markdown. The following is a usage tutorial.
Repo: gxr404/yuque-dl
0x01 Environment Preparation#
Node.js 18.4 or later
This article is based on the Windows platform for demonstration. You can directly use the pre-built installation program to install.
0x02 Program Usage#
Installation command
npm i -g yuque-dl
Usage command
$ yuque-dl --help
Usage:
$ yuque-dl <url>
Commands:
<url> Yuque knowledge base URL
server <serverPath> Start web server
For more info, run any command with the `--help` flag:
$ yuque-dl --help
$ yuque-dl server --help
Options:
-d, --dist-dir <dir> Directory to download to, e.g., -d download (default: download)
-i, --ignore-img Ignore downloading images (default: false)
-k, --key <key> Yuque's cookie key, default is "_yuque_session", may be different in some enterprise versions
-t, --token <token> Value corresponding to Yuque's cookie key
--toc Output document TOC directory (default: false)
-h, --help Display this message
-v, --version Display version number
0x03 Start Downloading#
Private Knowledge Base#
For links shared by someone's private knowledge base, you need to use
-t
to add the token to download.yuque-dl "https://www.yuque.com/yuque/thyzgp" -t "abcd..."
Go to Console
=> Select the Application tab
=> Click on Cookies under Storage to find the Yuque root domain
=> Select _yuque_session and copy its Value
Enterprise Private Service#
I haven't encountered it before, so I'll post the official documentation.
Enterprise services have their own domain names (yellow Yuque logo), not ending with
yuque.com
, such ashttps://yuque.antfin.com/r/zone
.In this case, the key for the token is not unique and may not be
_yuque_session
. Users need to use-k
to specify the token's key and-t
to specify the token's value.As for what the
key
specifically is, users can only find it themselves inBrowser Devtools -> Application -> Cookies
.
Public Password-Protected Knowledge Base#
⚠️ There are two situations for public password-protected knowledge bases:
-
If you are already logged in to Yuque and access a password-protected knowledge base, enter the password and use the
_yuque_session
cookie.yuque-dl "url" -t "value of _yuque_session"
Go to Console
=>Select the Application tab
=>Click on Cookies under Storage to find the Yuque root domain
=>Select _yuque_session and copy its Value
-
If you are not logged in to Yuque and access a password-protected knowledge base, enter the password and use the
verified_books
/verified_docs
cookie.yuque-dl "url" -k "verified_books" -t "value of verified_books"
Go to Console
=>Select the Application tab
=>Click on Cookies under Storage to find the Yuque root domain
=>Select verified_books/verified_docs and copy its Value
After the download is complete, it will look like this. If some files cannot be downloaded successfully, you can try accessing them in the browser to see if they can be accessed.
When you need to update, keep the contents of the downloaded "download" folder unchanged and run the download command again.
0x04 Local Quick Preview#
yuque-dl provides a feature to quickly start a web server using Vitepress to preview the downloaded content.
yuque-dl server ./download/知识库/
➜ Local: http://localhost:5173/
➜ Network: use --host to expose
0x05 Postscript#
The knowledge bases organized by various communities are the crystallization of the knowledge of the community owners. Some are either libraries that record history or the owner's own notes. In any case, it is ethical to keep the exported results for personal use only and sharing them is not ethical.
Here are some publicly accessible knowledge bases that I found:
- Qingyi20210715, Vulnerability20210715, etc.
- PeiQi0/PeiQi-WIKI-Book
- wgpsec/wiki
- timlzh/webArmory
- Threekiii/Vulnerability-Wiki
- SexyBeast233/SecBooks
- teamssix/twiki
- javaweb-sec/javaweb-sec
- BaizeSec/bylibrary
- ybdt/exp-hub
- helloexp/0day
This article is synchronized and updated to xLog by Mix Space.
The original link is https://de3ay.com/posts/sec/yuque-encrypted-download