Get a Pentest and security assessment of your IT network.

Cyber Security

Access Card ID System

TL;DR

This guide shows you how to build a simple access card system that also acts as an identification tool. We’ll cover the hardware, software setup (using Python), and basic security considerations.

Hardware Setup

  1. RFID Reader: Choose an RFID reader compatible with your chosen cards (125kHz or 13.56MHz are common). Connect it to your computer via USB.
  2. Access Cards/Tags: Purchase a set of RFID cards or tags. Ensure they work with your selected reader.
  3. Microcontroller (Optional): For standalone operation, use a microcontroller like an Arduino or Raspberry Pi Pico. This adds flexibility but increases complexity. If connecting directly to a computer, this step isn’t needed.
  4. Door Strike/Relay: A door strike is the mechanism that locks and unlocks the door. A relay controls power to the strike.
  5. Power Supply: Provide appropriate power for all components (RFID reader, microcontroller, relay).

Software Setup (Python)

We’ll use Python with a library like rcio or similar to read the RFID card IDs. This example assumes direct connection to a computer.

Step 1: Install Required Libraries

pip install rcio pyserial

Step 2: Identify Your RFID Reader’s Serial Port

On Linux/macOS, check /dev/tty*. On Windows, look in Device Manager under ‘Ports (COM & LPT)’. Note the port name (e.g., /dev/ttyUSB0 or COM3).

Step 3: Python Code to Read Card IDs

import rcio

def read_card_id(port):
    try:
        reader = rcio.RFIDReader(port)
        card_id = reader.read()
        return card_id
    except Exception as e:
        print(f"Error reading card: {e}")
        return None

if __name__ == "__main__":
    serial_port = "/dev/ttyUSB0"  # Replace with your port
    card_id = read_card_id(serial_port)
    if card_id:
        print(f"Card ID: {card_id}")

Step 4: Store Card IDs and User Information

Create a dictionary or database to store the relationship between card IDs and user names/details. A simple Python dictionary is sufficient for small systems.

user_database = {
    "1234567890": "Alice Smith",
    "9876543210": "Bob Johnson"
}

Step 5: Implement Access Control Logic

Modify the Python code to check if a scanned card ID exists in the database and grant/deny access accordingly.

def authorise_access(card_id):
    if card_id in user_database:
        print("Access Granted!")
        # Add code here to activate the relay controlling the door strike.
    else:
        print("Access Denied! Unknown Card ID.")

Security Considerations

  1. Card Cloning: RFID cards can be cloned. Consider using more secure card types (e.g., Mifare DESFire) or implementing anti-cloning measures.
  2. Data Encryption: If storing sensitive user information, encrypt the database.
  3. Physical Security: Protect the RFID reader and microcontroller from tampering.
  4. Network Security (if applicable): If connecting to a network, secure the connection with appropriate firewalls and authentication mechanisms.
  5. Cyber security: Ensure your system is protected against malware and unauthorised access. Keep software updated.

Further Improvements

  • Web Interface: Create a web interface to manage users and card IDs.
  • Logging: Log all access attempts for auditing purposes.
  • Real-time Monitoring: Implement real-time monitoring of access events.
Related posts
Cyber Security

Zip Codes & PII: Are They Personal Data?

Cyber Security

Zero-Day Vulnerabilities: User Defence Guide

Cyber Security

Zero Knowledge Voting with Trusted Server

Cyber Security

ZeroNet: 51% Attack Risks & Mitigation