Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
Check url using virustotal
  • Loading branch information
barbossa2406 committed Dec 3, 2023
1 parent f30def6 commit 08a446b
Show file tree
Hide file tree
Showing 4 changed files with 147 additions and 0 deletions.
27 changes: 27 additions & 0 deletions background.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
function scanURLWithVirusTotal(url, tabId, callback) {
const API_KEY = 'd952e200fd50390b51eba3157347d8d44f7be039dbafd8091216fdcf428cda3b'; // Replace with your API key
const API_URL = `https://www.virustotal.com/vtapi/v2/url/report?apikey=${API_KEY}&resource=${url}`;

fetch(API_URL)
.then(response => {
if (!response.ok) {
throw new Error('Network response was not ok.');
}
return response.json();
})
.then(data => {
if (data.response_code === 0) {
throw new Error('URL not found or no information available.');
}
const scanAnalytics = {
score: data.positives || 0,
totalScans: data.total || 0,
scanResults: data.scans || {}
// You can extract and process more data here as needed
};
callback(scanAnalytics);
})
.catch(error => {
callback({ error: error.message });
});
}
19 changes: 19 additions & 0 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"manifest_version": 2,
"name": "VirusTotal URL Scanner",
"version": "1.0",
"permissions": [
"https://www.virustotal.com/*",
"activeTab"
],
"background": {
"scripts": ["background.js"],
"persistent": false
},
"browser_action": {
"default_popup": "popup.html",
"default_icon": {

}
}
}
80 changes: 80 additions & 0 deletions popup.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>VirusTotal URL Scanner</title>
<link rel="stylesheet" href="style.css">
<script defer src="popup.js"></script>
<style>
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
background-color: #f9f9f9;
margin: 0;
padding: 20px;
text-align: center;
}

h1 {
color: #333;
margin-bottom: 20px;
}

label {
font-size: 16px;
display: block;
margin-top: 15px;
color: #555;
}

input {
width: 100%;
padding: 10px;
margin-top: 8px;
box-sizing: border-box;
font-size: 16px;
border: 1px solid #ccc;
border-radius: 5px;
}

button {
width: 100%;
padding: 12px;
margin-top: 20px;
background-color: #4CAF50;
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
font-size: 18px;
}

button:hover {
background-color: #45a049;
}

#result {
margin-top: 30px;
color: #333;
font-size: 18px;
}

.error {
color: #d9534f;
font-size: 16px;
margin-top: 10px;
}
</style>
</head>
</head>
<body>
<div class="container">
<h1>VirusTotal URL Scanner</h1>
<div class="input-container">
<input type="text" id="urlInput" placeholder="Enter URL">
<button id="scanButton">Scan</button>
</div>
<div id="scanResult"></div>
</div>
</body>
</html>
21 changes: 21 additions & 0 deletions popup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
document.addEventListener('DOMContentLoaded', function () {
const scanButton = document.getElementById('scanButton');
const urlInput = document.getElementById('urlInput');
const scanResult = document.getElementById('scanResult');

scanButton.addEventListener('click', function () {
const url = urlInput.value.trim();
if (url !== '') {
chrome.tabs.query({ active: true, currentWindow: true }, function (tabs) {
const activeTab = tabs[0];
chrome.runtime.getBackgroundPage(function (backgroundPage) {
backgroundPage.scanURLWithVirusTotal(url, activeTab.id, function (result) {
scanResult.innerText = JSON.stringify(result, null, 2);
});
});
});
} else {
scanResult.innerText = 'Please enter a URL.';
}
});
});

0 comments on commit 08a446b

Please sign in to comment.