最近在學校 ssrf 攻擊,看到可以用 dict 協議可以加載一個 tcp 端口的提供的服務所返回的部分數據。但是網上很少 dict 協議相關的說明,直到我找到了這個網站:
https://www.cnblogs.com/kkun/archive/2009/03/28/1424052.html
感謝這個博客,讓俺明白了啥是 dict 協議
dict 的初體驗
多說無益,直接上一個用了 dict 協議的服務讓你們來體驗一下
首先在你的電腦上安裝一個 telnet 客戶端 Windows 和 Mac / Linux 上應該都有對應的客戶端
安裝好了以后用這個命令來登陸
由於編碼原因,有些非英文字符在某些系統上可能會亂碼
telnet dict.org 2628
之后如果連接上了,能看到對應的提示:
220 dict.dict.org dictd 1.12.1/rf on Linux 4.19.0-10-amd64 <auth.mime><56180310.14213.1628480435@dict.dict.org>
在終端中輸入 h 來獲取幫助
113 help text follows
DEFINE database word -- look up word in database
MATCH database strategy word -- match word in database using strategy
SHOW DB -- list all accessible databases
SHOW DATABASES -- list all accessible databases
SHOW STRAT -- list available matching strategies
SHOW STRATEGIES -- list available matching strategies
SHOW INFO database -- provide information about the database
SHOW SERVER -- provide site-specific information
OPTION MIME -- use MIME headers
CLIENT info -- identify client to server
AUTH user string -- provide authentication information
STATUS -- display timing information
HELP -- display this help information
QUIT -- terminate connection
The following commands are unofficial server extensions for debugging
only. You may find them useful if you are using telnet as a client.
If you are writing a client, you MUST NOT use these commands, since
they won't be supported on any other server!
D word -- DEFINE * word
D database word -- DEFINE database word
M word -- MATCH * . word
M strategy word -- MATCH * strategy word
M database strategy word -- MATCH database strategy word
S -- STATUS
H -- HELP
Q -- QUIT
在終端中輸入 show db
命令(這個東西貌似不區分大小寫的樣子)來列出所有的字典
在最后我們看到了 english 這個字典
在最后我們輸入 define [字典名] [單詞]
這樣的命令來獲取一個單詞的解釋
比如說 define english hello
服務器就會返回對應的單詞解釋
dict 協議是啥
dict 協議是一個在線網絡字典協議,這個協議是用來架設一個字典服務的。不過貌似用的比較少,所以網上基本沒啥資料(包括谷歌上)。可以看到用這個協議架設的服務可以用 telnet 來登陸,說明這個協議應該是基於 tcp 協議開發的。
所以像 mysql 的服務,因為也是基於 tcp 協議開發,所以用 dict 協議的方式打開也能強行讀取一些 mysql 服務的返回內容
比如說下面這段程序:
<?php
// 文件名: main.php
$url = "dict://localhost:3306"; // localhost:3306 上架設了我的 mysql 服務
$ch = curl_init($url);
curl_exec($ch);
curl_close($ch);
輸出結果:
可以看到雖然亂碼,但是還是強行讀取出來了一些可以辨識的數據,比如說 mysql 的版本號