Arthas 3.5.0發佈,這次終於支持反編譯打印行號了!

Arthas是Alibaba開源的Java診斷工具,深受開發者喜愛。

Github:https://github.com/alibaba/arthas文檔:https://arthas.aliyun.com/doc/

Arthas 最新發布了 3.5.0 版本,最近幾個release 版本帶來下面兩個主要特性:

反編譯支持行號Telnet/Websocket/HTTP API統一支持全面的鑑權

反編譯支持行號

Arthas開源之後的第一個 issue 就是jad命令能否支持顯示行號:

jad命令多年以後終於支持行號了,“不忘初心”😂,效果如下:

如果想不顯示行號,使用--lineNumber false參數即可。

鑑權支持

鑑權主要通過兩方面來支持:

as.sh/arthas-boot命令行參數支持配置用戶名和密碼增加auth命令

配置用戶名和密碼

在Arthas attach時,可以在命令行指定密碼。比如:

java -jar arthas-boot.jar --password ppp

可以通過 --username 選項來指定用戶,默認值是arthas

    •也可以在 arthas.properties 裏中配置 username/password。命令行的優先級大於配置文件。

    •如果只配置username,沒有配置password,則會生成隨機密碼,打印在~/logs/arthas/arthas.log

Using generated security password: 0vUBJpRIppkKuZ7dYzYqOKtranj4unGh

在telnet console裏鑑權

連接到arthas後,直接執行命令會提示需要鑑權:

[arthas@37430]$ help
Error! command not permitted, try to use 'auth' command to authenticates.

使用auth命令來鑑權,成功之後可以執行其它命令。

[arthas@37430]$ auth ppp
Authentication result: true

可以通過 --username 選項來指定用戶,默認值是arthas

Web console密碼驗證

打開瀏覽器,會有彈窗提示需要輸入 用戶名 和 密碼。

成功之後,則可以直接連接上 web console。

HTTP API 驗證

Arthas 採用的是 HTTP 標準的 Basic Authorization,客戶端請求時增加對應的 Authorization header即可。

參考:https://developer.mozilla.org/en-US/docs/Web/HTTP/Authentication

例如,用戶名是:admin,密碼是 admin

則組合爲字符串: admin:admin

base64結果是: YWRtaW46YWRtaW4=

則HTTP 請求增加Authorization header:

curl 'http://localhost:8563/api' \
-H 'Authorization: Basic YWRtaW46YWRtaW4=' \
--data-raw '{"action":"exec","command":"version"}'

總結

Jad wiki: https://arthas.aliyun.com/doc/jad.htmlAuth wiki: https://arthas.aliyun.com/doc/auth.htmlRelease 日誌: https://github.com/alibaba/arthas/releases/tag/arthas-all-3.5.0

END -

「技術分享」某種程度上,是讓作者和讀者,不那麼孤獨的東西。歡迎關注我的微信公衆號:Kirito的技術分享」



本文分享自微信公衆號 - Kirito的技術分享(cnkirito)。
如有侵權,請聯繫 [email protected] 刪除。
本文參與“OSC源創計劃”,歡迎正在閱讀的你也加入,一起分享。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章