This project is a Chrome Extension integrated with a Node.js backend and PostgreSQL database to scan downloaded files for potential malware. It uses the VirusTotal public API to detect malicious files by comparing their hashes.
- Chrome Extension (Manifest v3)
- JavaScript, HTML, CSS
- Node.js with Express
- PostgreSQL
- VirusTotal Public API
- pgAdmin / DBeaver (for DB management)
malware-scanner/
├── database/
│ └── schema.sql # Contains SQL to create the scans table
├── extension/
│ ├── manifest.json
│ ├── background.js
│ ├── popup.html
│ ├── popup.js
│ └── icon.png
├── server/
│ ├── app.js # Node.js Express backend
│ ├── package.json # Node.js dependencies
│ ├── node_modules/ # Installed packages (auto-generated)
│ └── .env (in root) # Environment variables
└── README.md
Clone or download this repository to your local machine.
- Open pgAdmin or DBeaver.
- Create a new database called
malware_detection. - Run the
init.sqlscript inside thedatabase/folder:
CREATE TABLE scans (
id SERIAL PRIMARY KEY,
file_name TEXT NOT NULL,
file_hash TEXT UNIQUE NOT NULL,
status TEXT NOT NULL,
timestamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);cd server
npm installCreate a .env file in the root directory (not in server folder):
DATABASE_URL=postgresql://postgres:yourpassword@localhost:5432/malware_detection
VT_API_KEY=your_virustotal_api_key
Start the Node.js server:
# Development mode (auto-restart on changes)
npm run dev
# Production mode
npm start
# or
node app.js- Open Chrome and go to
chrome://extensions - Enable Developer Mode
- Click "Load unpacked" and select the
extension/folder
- When a file is downloaded, the extension listens using the Downloads API.
- It stores the latest file name and shows a notification.
- The popup displays the file name and prompts the user to upload the file manually.
- The file is hashed in the browser using SHA-256.
- The hash and file name are sent to the Node.js Express backend.
- The server queries VirusTotal and stores the scan result in PostgreSQL.
- Results and history are shown in the popup.
To test with a known test virus (EICAR), create a file named eicar.txt and paste the following line into it:
X5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*
Then upload and scan it using the extension.
- File hash generation using Web Crypto API
- VirusTotal API integration for threat detection
- Download interception using Chrome Downloads API
- Persistent scan history with PostgreSQL
- User-friendly popup with refresh option
- File must be manually selected due to Chrome security restrictions
- Notifications may be suppressed depending on system settings
- Extension works locally and requires Node.js server running
- POST /scan - Scan a file hash with VirusTotal
- GET /data - Get all scan history
- GET /health - Health check endpoint
Server runs on http://localhost:5000