ductai05 avatar
Control Computer via Gmail (Net)

Control Computer via Gmail (Net)

A C++ remote server administration tool operating over LAN, utilizing Gmail (IMAP/SMTP) as a secure command-and-control bridge.

November 1, 2024 → December 31, 2024

Introduction

This project implements a remote computer administration system designed to control a cluster of server machines on a Local Area Network (LAN) from a remote client. What makes this system unique is its use of a Gmail account as a communication bridge, bypassing traditional firewall and NAT traversal issues by relying on standard email protocols.

Summary (Core Capabilities)

The system allows the remote client to perform various operations on the target servers, including:

  • Capturing screenshots and toggling webcams.
  • Listing, starting, and terminating applications (by name or PID).
  • Browsing directories, retrieving files, and deleting files.
  • Managing power states (shutdown).

Technical Architecture

The project is developed using a procedural programming approach in C++17 and relies heavily on low-level networking libraries.

Note (Libraries Used)
  • cURL: For executing HTTP requests and transferring data via URLs.
  • OpenSSL: Ensures secure, encrypted communication with the Gmail servers.
  • winsock2.h: Provides the Windows Sockets API for LAN communication.
  • SDL2: Used to render the graphical user interface on the client side.

Network Flow

The system consists of three main entities:

  1. Client: The user interface. It sends commands as emails and reads replies.
  2. Task Dispatcher: A central node on the LAN that polls the Gmail account for new commands, parses them, and forwards them to the appropriate server.
  3. Servers: The target machines on the LAN executing the actual commands.
graph TD
Client[Client App] -->|SMTP (Send Command)| Gmail[Gmail Server]
Gmail -->|IMAP (Fetch Reply)| Client
TaskDispatcher[Task Dispatcher] -->|IMAP (Fetch Command)| Gmail
TaskDispatcher -->|SMTP (Send Reply)| Gmail
TaskDispatcher -->|WinSock (TCP/IP)| Server1[Server Node 1]
TaskDispatcher -->|WinSock (TCP/IP)| Server2[Server Node 2]
Server1 -->|Execute| OS1[Windows OS]

Implementation Details

Email Communication Bridge

We utilize cURL combined with OpenSSL to interact with Google’s servers.

We parse the email subjects and bodies to extract the command type, target server IP, and any required parameters (like a file path or Process ID). Data such as screenshots are Base64 encoded and attached to the emails.

Warning (Security & Authentication)

To bypass modern 2FA restrictions while maintaining security, the system utilizes Google’s App Passwords. This allows our C++ application to authenticate programmatically via IMAP/SMTP without triggering interactive login prompts.

LAN Socket Programming

Within the local network, the Task Dispatcher uses Windows Sockets API (WinSock) to manage TCP/IP connections.

Client User Interface

Instead of a simple command-line tool, we built a fully functional Graphical User Interface (GUI) using SDL2 (Simple DirectMedia Layer).

The client interface includes: