程式狂想筆記

一個攻城師奮鬥史

0%

Windows 註冊瀏覽器協定方法

最近要使用瀏覽器套件 暴力猴 操作一些程式
一直再想有什麼可以執行 bash 方法
最後有找到一篇 window 註冊協定

找到這篇Register protocol - MozillaZine Knowledge Base
簡單設定登錄檔就能解決

1
2
3
4
5
6
7
8
9
10
11
12
REGEDIT4

[HKEY_CLASSES_ROOT\foo]
@="URL:foo Protocol"
"URL Protocol"=""

[HKEY_CLASSES_ROOT\foo\shell]

[HKEY_CLASSES_ROOT\foo\shell\open]

[HKEY_CLASSES_ROOT\foo\shell\open\command]
@="\"C:\\Program Files\\Application\\program.exe\" \"%1\""

就這麼簡單,這邊的 %1 是 url 代的網址,後面都會加/( 我是用 Firefox,Chrome不確定 )

番外小記

跟本篇沒有關係
其實我呼就出我的 sh
做開啟反向代理
但還是失敗了…

1
2
3
4
5
6
7
8
9
10
11
12
13
cd /d/
# pwd
# ./caddy2.exe stop
# ./caddy2.exe start --config caddyfile.json

# curl -X PATCH \
# http://localhost:2019/config/apps/http/servers/proxy/routes/0/handle/0/headers/request/set/Cookie/0 \
# -H 'Content-Type: application/json' \
# -H 'cache-control: no-cache' \
# -d "\"${1:12:-1}\""
sed -i -E "s/header_upstream Cookie \".+\"/header_upstream Cookie \"${1:12:-1}\"/" Caddyfile
ps aux | grep caddy | awk '{print $1}' | xargs kill -9
./caddy

caddy2 不知道要怎麼調整到反向代理到 https
但是 caddy1 竟然可以輕鬆調整

caddy2 好處可以用 api 方式去調整設定 Server
但是用瀏覽器做 AJAX caddy2 admin api 調整竟然會有 OPTIONS 過不去…
最後想到用 sh 呼叫執行
發現 caddy2 不能不會調整反向代理到 https
只能摸摸鼻子用 caddy1

最後還是大失敗
那個網站 Cookie 竟然是用 httponly
這個是讓你沒辦法用 JS 控制有設定 httponly 的 Cookies (浅谈Js 操作Cookie,以及HttpOnly 的限制 - 知乎)
所以終究大失敗 QQ

其實 Cookie httponly 感覺已可以寫一篇記錄
因為還發現 Cookie 也可以針對 Path 去做發送 指定Cookie
一直以為 Cookie 不是很安全,但 httponly 真的還滿安全

Caddyfile

1
2
3
4
5
6
7
8
9
10
localhost:8881
gzip
log test.log

proxy / https://xxxxx/ {
websocket
header_upstream -Referern
header_upstream -Server
header_upstream Cookie "test=1572361464;a=xxx"
}

caddyfile.json

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
{
"apps": {
"http": {
"servers": {
"proxy": {
"listen": [
":888"
],
"routes": [
{
"handle": [
{
"handler": "reverse_proxy",
"headers": {
"request": {
"set": {
"Host": [
"{http.handlers.reverse_proxy.upstream.host}"
],
"delete": [
"Referern",
"Server"
],
"Cookie": [
"test=test"
]
}
}
},
"transport": {
"protocol": "tls"
},
"upstreams": [
{
"dial": "localhost:519"
}
]
}
],
"match": [
{
"host": [
"localhost"
]
}
]
}
]
}
}
}
}
}

REG

1
2
3
4
5
6
7
8
9
10
11
12
REGEDIT4

[HKEY_CLASSES_ROOT\caddycurl]
@="URL:caddycurl Protocol"
"URL Protocol"=""

[HKEY_CLASSES_ROOT\caddycurl\shell]

[HKEY_CLASSES_ROOT\caddycurl\shell\open]

[HKEY_CLASSES_ROOT\caddycurl\shell\open\command]
@="\"C:\\Program Files\\Git\\git-bash.exe\" \"/d/caddycurl.sh\" \"%1\""

番外中的番外 小記
python3.7安装后ssl问题-苏黎世1995的博客-51CTO博客
【Python】CentOs7 Python3安装Openssl以及解决ssl问题 - 梦琪小生 - 博客园