Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

6 Commits

Folders and files

Repository files navigation

Malware Scanner Chrome Extension

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.

Technologies Used

  • Chrome Extension (Manifest v3)
  • JavaScript, HTML, CSS
  • Node.js with Express
  • PostgreSQL
  • VirusTotal Public API
  • pgAdmin / DBeaver (for DB management)

Folder Structure (Based on Assignment)

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

Setup Instructions

1. Clone the Repository

Clone or download this repository to your local machine.

2. Set Up PostgreSQL

  • Open pgAdmin or DBeaver.
  • Create a new database called malware_detection.
  • Run the init.sql script inside the database/ 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
);

3. Configure the Node.js Backend

cd server
npm install

Create 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

4. Load the Chrome Extension

  • Open Chrome and go to chrome://extensions
  • Enable Developer Mode
  • Click "Load unpacked" and select the extension/ folder

How It Works

  1. When a file is downloaded, the extension listens using the Downloads API.
  2. It stores the latest file name and shows a notification.
  3. The popup displays the file name and prompts the user to upload the file manually.
  4. The file is hashed in the browser using SHA-256.
  5. The hash and file name are sent to the Node.js Express backend.
  6. The server queries VirusTotal and stores the scan result in PostgreSQL.
  7. Results and history are shown in the popup.

Testing with a Known Malware Sample

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.

Features

  • 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

Known Limitations

  • 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

API Endpoints

  • 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

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages