1. 程式人生 > >mac下自定義偽協議配置

mac下自定義偽協議配置

xxx element https src internet -c pos tro six

之前查了很多資料,最近也在挖掘研究這方面的漏洞.

windows的很簡單,在註冊表配置就好了,但是mac os 是unix的,沒有註冊表這麽一說。

但是發現騰訊等配置了自定義等協議,例如:tencent://xxxxx,

那麽他們是怎麽配置的,查了寫資料,比較少。分享一下:

mac應用程序安裝的時候在安裝軟件有一個info.plist,可以在配置文件中配置CFBundleURLName.

1. Use Script Editor to save this script as an Application Bundle (no startup screen):

on open location localURL
    
    set oldDelims to AppleScript‘s text item delimiters
    set AppleScript‘s text item delimiters to "local://"
    set thePath to item 2 of the text items of localURL
    set AppleScript‘s text item delimiters to oldDelims
    
    tell application "System Events"
        open ((POSIX file thePath) as string)
    end tell
    
end open location

2.Use the method described here and here to set CFBundleSignature to LOCL and add

<key>CFBundleURLTypes</key>
<array>
    <dict>
        <key>CFBundleURLName</key>
        <string>Local File</string>
        <key>CFBundleURLSchemes</key
> <array> <string>local</string> </array> </dict> </array> <key>NSUIElement</key> <true/>

to the application bundle‘s Info.plist file, then change the PkgInfo file to contain APPLLOCL
3.Use the More Internet preference pane to add ‘local‘ as a new protocol and choose the new application as the handler.

4.Make hyperlinks in the form local:///path/to/your/local/folder. Clicking those links should then open that file or folder.

更詳細的可以到蘋果開發文檔參考:

https://developer.apple.com/library/content/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html

以我的電腦為例:

技術分享圖片

例如在鏈接中<a href="ssh://xxx">click me</a>那麽就會喚iTerm程序來執行ssh

關於偽協議,其中有很多好玩的東西,大家可以自己挖掘。

參考:

http://hublog.hubmed.org/archives/001154.html

https://developer.apple.com/library/content/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html

https://code.i-harness.com/zh-CN/q/7321d

mac下自定義偽協議配置