Skip to content

Commit

Permalink
extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
cn-kali-team committed Feb 25, 2024
1 parent 8f58e3d commit d028c00
Show file tree
Hide file tree
Showing 11 changed files with 199 additions and 2 deletions.
13 changes: 13 additions & 0 deletions extensions/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Mark CVE
---
[![github]](https://github.com/emo-crab/scap-rs/tree/main/extensions)

[github]: https://img.shields.io/badge/github-8da0cb?style=for-the-badge&labelColor=555555&logo=github

- Mark the current page CVE.

## Using

- Install the plugin, open a webpage with a CVE number, click on the plugin, and you will see a button added after the CVE.

![](assets/Screenshot AttackerKB.png)
Binary file added extensions/assets/Screenshot AttackerKB.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added extensions/assets/emo-crab.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions extensions/background.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// A placeholder for OnSuccess in .then
function onSuccess(message) {
// console.log(`Send OK: ${JSON.stringify(message)}`);
}

// A placeholder for OnError in .then
function onError(error) {
// console.error(`Promise error: ${error}`);
}

// A placeholder for OnError in .then
function onErrorWithLog(error) {
console.error(`Promise error: ${error}`);
}
1 change: 1 addition & 0 deletions extensions/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
wasm-pack build --release --no-typescript --target web
38 changes: 38 additions & 0 deletions extensions/content-script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
(function () {
function Mark() {
const userSelection = window.getSelection();
const id = userSelection.toString();
let cve = userSelection.getRangeAt(0).startContainer.parentNode;
if (cve.getElementsByClassName("Marked").length > 0) {
return
}
const spanElement = document.createElement("span");
spanElement.setAttribute("class", "Marked");
const selectedTextRange = userSelection.getRangeAt(0);
selectedTextRange.surroundContents(spanElement);
const icon = document.createElement("a")
icon.href = "https://scap.kali-team.cn/cve/" + id;
icon.target = "_blank"
const svg = document.createElement('img');
svg.setAttribute("style", "background-color: rgb(154, 205, 50);");
svg.src = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGNsYXNzPSJpY29uIGljb24tdGFibGVyIGljb24tdGFibGVyLWJ1ZyIgd2lkdGg9IjI0IiBoZWlnaHQ9IjI0IiB2aWV3Qm94PSIwIDAgMjQgMjQiIHN0cm9rZS13aWR0aD0iMiIgc3Ryb2tlPSJjdXJyZW50Q29sb3IiIGZpbGw9Im5vbmUiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCI+PHBhdGggc3Ryb2tlPSJub25lIiBkPSJNMCAwaDI0djI0SDB6IiBmaWxsPSJub25lIi8+PHBhdGggZD0iTTkgOXYtMWEzIDMgMCAwIDEgNiAwdjEiIC8+PHBhdGggZD0iTTggOWg4YTYgNiAwIDAgMSAxIDN2M2E1IDUgMCAwIDEgLTEwIDB2LTNhNiA2IDAgMCAxIDEgLTMiIC8+PHBhdGggZD0iTTMgMTNsNCAwIiAvPjxwYXRoIGQ9Ik0xNyAxM2w0IDAiIC8+PHBhdGggZD0iTTEyIDIwbDAgLTYiIC8+PHBhdGggZD0iTTQgMTlsMy4zNSAtMiIgLz48cGF0aCBkPSJNMjAgMTlsLTMuMzUgLTIiIC8+PHBhdGggZD0iTTQgN2wzLjc1IDIuNCIgLz48cGF0aCBkPSJNMjAgN2wtMy43NSAyLjQiIC8+PC9zdmc+";
icon.appendChild(svg)
spanElement.appendChild(icon)
}

function FindCVE() {
const regex = new RegExp('\\bCVE-\\d{4}-\\d{4,7}\\b', 'gmi')
document.designMode = "on";
const sel = window.getSelection();
sel.collapse(document.body, 0);
let m;
while (m = regex.exec(document.body.innerText)) {
while (window.find(m)) {
Mark()
}
}
document.designMode = "off";
}

FindCVE();
})();
2 changes: 0 additions & 2 deletions extensions/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>scap-rs</title>
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@tabler/icons-webfont@latest/tabler-icons.min.css"/>
</head>
<body>
<span>CVE-2023-46805</span>
Expand Down Expand Up @@ -44,7 +43,6 @@
let m;
while (m = regex.exec(document.body.innerText)) {
while (window.find(m)) {
console.log(document)
Mark()
// document.execCommand("HiliteColor", false, "YellowGreen");
}
Expand Down
69 changes: 69 additions & 0 deletions extensions/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
{
"manifest_version": 3,
"name": "Mark CVE",
"description": "Mark the current page CVE",
"version": "0.1.0",
"homepage_url": "https://github.com/emo-crab/scap-rs/tree/main/extensions",
"author": "Kali-Team",
"action": {
"default_title": "Mark the current page CVE",
"default_icon": {
"19": "assets/emo-crab.png",
"16": "assets/emo-crab.png",
"32": "assets/emo-crab.png",
"38": "assets/emo-crab.png"
}
},
"icons": {
"19": "assets/emo-crab.png",
"16": "assets/emo-crab.png",
"32": "assets/emo-crab.png",
"38": "assets/emo-crab.png"
},
"content_security_policy": {
"extension_pages": "script-src 'self' 'wasm-unsafe-eval'; object-src 'self';"
},
"background": {
"type": "module",
"scripts": [
"background.js"
]
},
"host_permissions": [
"*://*/*",
"file:///*/*"
],
"permissions": [
"find",
"activeTab",
"scripting",
"storage"
],
"content_scripts": [
{
"run_at": "document_end",
"all_frames": false,
"matches": [
"*://*/*"
],
"js": [
"content-script.js"
]
}
],
"web_accessible_resources": [
{
"matches": [
"<all_urls>"
],
"resources": [

]
}
],
"browser_specific_settings": {
"gecko": {
"id": "{59705b32-553e-429d-a9e7-d4d887b419a5}"
}
}
}
30 changes: 30 additions & 0 deletions extensions/popup/popup.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
html, body {
width: 100px;
}

.hidden {
display: none;
}

button {
border: none;
width: 100%;
margin: 3% auto;
padding: 4px;
text-align: center;
font-size: 1.5em;
cursor: pointer;
background-color: #E5F2F2;
}

button:hover {
background-color: #CFF2F2;
}

button[type="reset"] {
background-color: #FBFBC9;
}

button[type="reset"]:hover {
background-color: #EAEA9D;
}
20 changes: 20 additions & 0 deletions extensions/popup/popup.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<!DOCTYPE html>

<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="popup.css"/>
</head>

<body>
<div id="popup-content">
<button id="mark">Mark</button>
<button type="reset">Reset</button>
</div>
<div id="error-content" class="hidden">
<p>Can't mark this web page.</p><p>Try a different page.</p>
</div>
<script src="popup.js"></script>
</body>

</html>
14 changes: 14 additions & 0 deletions extensions/popup/popup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
browser.action.onClicked.addListener(async (tab) => {
try {
await browser.scripting.executeScript({
target: {
tabId: tab.id,
},
func: () => {
alert("XSS");
},
});
} catch (err) {
console.error(`failed to execute script: ${err}`);
}
});

0 comments on commit d028c00

Please sign in to comment.