目录

工欲善其事

实践出真知

活跃标签: linux java mysql 待分类 js springboot win10 电路 vue macOS nginx windows esp32 git docker idea maven esp8266 python Arduino

存档:

X

自定义伪协议配置

当我们用浏览器想打开一个本地应用的时候是不可能的!除了IE能打开本地应用外其他浏览器都不行

查过很多资料之后发现之前的QQ可以通过 qq:// 的方式发开本地应用

在win下面可以通过注册列表实现,mac下?

windows解决方法

注册列表如下:

Windows Registry Editor Version 5.00
 
[HKEY_CLASSES_ROOT\my]
@="protocol Protocol"
"URL Protocol"=""
 
[HKEY_CLASSES_ROOT\my\DefaultIcon]
@="C:\\WINDOWS\\NOTEPAD.EXE"
 
[HKEY_CLASSES_ROOT\my\shell]
@=""
 
[HKEY_CLASSES_ROOT\my\shell\open]
@=""
 
[HKEY_CLASSES_ROOT\my\shell\open\command]
@="\"C:\\WINDOWS\\NOTEPAD.EXE\" \"%1\""

使用a标签或在资源管理器中打开 my://

mac 下自定义伪协议配置

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

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.

例如在链接中 <a href="ssh://xxx">click me </a>那么就会唤iTerm程序来执行ssh

关于伪协议,其中有很多好玩的东西,大家可以自己挖掘。

参考:

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

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

官网文档


标题:自定义伪协议配置
作者:llilei
地址:http://solo.llilei.work/articles/2022/01/31/1643599449571.html