Skip to content

Inn0vision/Military-Encrypted-Messaging

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

Military Secure Messaging System

A location-based secure messaging system that enables encrypted communication between military officers. Messages can only be decrypted when the receiver is physically present at a specific location.

Features

  • Location-Based Encryption: Messages are encrypted using AES with a key derived from password + message + GPS coordinates
  • Real-time Communication: WebSocket-based real-time message delivery
  • Interactive Map: Leaflet.js integration for location selection
  • Geolocation Validation: GPS tolerance radius ensures receiver must be at target location
  • Secure by Design: SHA-256 hashing + AES encryption

Technology Stack

Frontend

  • React (with Vite)
  • Tailwind CSS
  • Leaflet.js for maps
  • crypto-js for encryption
  • Socket.io-client for real-time communication

Backend

  • Node.js + Express
  • Socket.io for WebSocket communication
  • Built-in crypto module
  • CORS enabled for cross-origin requests

Installation & Setup

1. Clone and Navigate

cd military-secure-messaging

2. Backend Setup

cd backend
npm install
npm start

Server will run on http://localhost:3001

3. Frontend Setup (in new terminal)

cd frontend
npm install
npm run dev

Frontend will run on http://localhost:5173

4. For Mobile Development (HTTPS Required)

Since geolocation API requires HTTPS on mobile devices when accessing from external networks:

cd frontend
npm run dev:https

This starts the development server with HTTPS enabled. Accept the self-signed certificate warning in your browser.

Mobile Network Access

To access from mobile devices on your local network:

  1. Find your local IP address:

    • Linux/Mac: ip addr show or ifconfig
    • Windows: ipconfig
  2. Start services:

    # Backend (in one terminal)
    cd backend
    npm start
    
    # Frontend with HTTPS (in another terminal)  
    cd frontend
    npm run dev:https
  3. Access from mobile:

    • Frontend: https://YOUR_LOCAL_IP:5173
    • Accept certificate warning when prompted

How to Use

For Sender (Officer A):

  1. Navigate to "Send Message" tab
  2. Enter your secure message
  3. Enter a shared password (known to both officers)
  4. Select target location on map or use "Get Current Location"
  5. Click "Send Encrypted Message"

For Receiver (Officer B):

  1. Navigate to "Receive Message" tab
  2. Click "Get Current Location" to obtain your GPS coordinates
  3. Select a message from the available messages list
  4. Enter the shared password
  5. Click "Decrypt Message" (only works if you're within 100m of target location)

Security Features

Encryption Algorithm

Key = SHA-256(password + message + latitude + longitude)
Encrypted Message = AES(message, key)

Location Validation

  • GPS tolerance radius: 100 meters
  • Haversine formula for distance calculation
  • High-accuracy geolocation required
  • Default location set to Pune, India (18.5204°N, 73.8567°E)

Message Lifecycle

  • Messages are stored temporarily on server
  • Automatically deleted after successful decryption
  • Real-time updates via WebSocket

File Structure

military-secure-messaging/
├── frontend/
│   ├── src/
│   │   ├── components/
│   │   │   ├── MapComponent.jsx      # Leaflet map integration
│   │   │   ├── SenderInterface.jsx   # Message creation UI
│   │   │   └── ReceiverInterface.jsx # Message decryption UI
│   │   ├── utils/
│   │   │   ├── crypto.js            # Encryption/decryption utilities
│   │   │   └── geolocation.js       # GPS utilities
│   │   ├── App.jsx                  # Main application
│   │   └── index.css                # Tailwind styles
│   ├── package.json
│   └── tailwind.config.js
└── backend/
    ├── server.js                    # Express + Socket.io server
    └── package.json

Security Considerations

  1. Local Network Only: Designed for local military network deployment
  2. Temporary Storage: Messages are not persisted to disk
  3. Location Privacy: GPS coordinates are only used for encryption/validation
  4. Password Security: Shared passwords should follow military security protocols

Testing

  1. Start both backend and frontend servers
  2. Open two browser windows/tabs
  3. Use one as sender, one as receiver
  4. Test with different locations to verify location-based decryption

Troubleshooting

Geolocation Issues

  • "Only secure origins are allowed": Use HTTPS by running npm run dev:https
  • Location access denied: Enable location permissions in your browser
  • Location unavailable: Ensure GPS is enabled on mobile devices

Connection Issues

  • Mobile can't connect: Use your local IP address, not localhost
  • CORS errors: Backend is configured to allow all origins for development

Deployment Notes

  • Configure CORS settings for production environment
  • Use HTTPS in production
  • Consider adding user authentication
  • Implement proper logging and monitoring
  • Add rate limiting for API endpoints

License

This project is intended for military/defense applications and should be used in accordance with relevant security protocols.# Military-Encrypted-Messaging

About

Cyber Security Project

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published