Unveiling the Cunning: A Demo of Google Calendar RAT Exploiting Calendar Service for C2 Operations

Chenny Ren
5 min readNov 8, 2023

In a recent discovery that sounds more like Hollywood fiction than reality, attackers have been found using Google Calendar as a Command and Control (C2) server. This method was originally highlighted in a thought-provoking blog post, which you can delve into here: Google Calendar RAT: A New C2 Vector.

The concept is as intriguing as it is concerning. By leveraging a tool as commonplace as Google Calendar, attackers can fly under the radar, executing commands undetected. The existence of a Proof of Concept (POC), named GCR-Google-Calendar-RAT on GitHub, proves that this isn’t just a theoretical risk.


To better understand how this attack works, I’ve put together a demo using the POC. This hands-on demonstration unpacks the attack step by step, showcasing how a seemingly innocuous calendar can be turned into a discreet orchestrator of malicious activities.

As we pull back the curtain on this novel attack method, it’s a stark reminder of the importance of staying vigilant and constantly updating our cyber defenses against such innovative threats.

GCRWorkflow Attack
  1. Command Placement by Attacker:
  • The attacker crafts a command to be executed on the target machine.
  • This command is then placed in the description field of a Google Calendar event, formatted to follow a predefined C2 protocol to be recognized by the RAT script.
  • The attacker ensures the event is in the correct calendar that has been shared with the service account associated with the compromised machine.

2. Initial Connection and Polling by Target:

  • Upon initial execution, the RAT script on the target machine authenticates with Google using the service account credentials and establishes a connection with the Google Calendar API.
  • The target machine begins polling the Google Calendar at regular intervals, searching for events with descriptions that match the C2 protocol pattern.
  • The polling interval is predefined (in the variable pollingTime) to balance between prompt command retrieval and maintaining a low profile to avoid detection.

3. Command Retrieval:

  • When the target detects a new event with a command in the description, the script parses the event to extract the command.
  • Before executing the command, the script may perform checks to ensure it is not repeating the execution of a previously executed command (e.g., by comparing timestamps or using a marker in the event).

4. Command Execution:

  • The script executes the command using system functions such as subprocess in Python.
  • It captures the command’s output, handling any execution errors gracefully to ensure the RAT remains operational even if a command fails.

5. Command Output Update:

  • After command execution, the script encodes the output (typically with base64 encoding to ensure compatibility with the Google Calendar event description field).
  • The script updates the event description with the encoded command output using the Google Calendar API.
  • The script may also append additional information such as execution status, timestamps, or error messages to the event description for the attacker to review.

6. Continuous Operation:

  • The script then resumes polling for new commands, allowing the attacker to continue issuing commands as needed.
  • The attacker monitors the Google Calendar for the results and may modify or delete events to issue new commands or manage the flow of information.

7. Stealth Maintenance:

  • Throughout the operation, the RAT script and the attacker take steps to maintain stealth, such as using legitimate-looking event names and descriptions, and choosing polling intervals that mimic normal user behavior.
  • The attacker might also rotate calendars or create new events to further evade detection.


Setup a Google service account and obtain the credentials.json file, place the file in the same directory of the script

export the key as credentials.json

Also need to enable the Google Calendar API

2. Create a new Google calendar and share it with the new created service account

in the calendar settings, go to ‘Share with specific people or groups’ , then paste the service account email address to here.

3. Edit the script to point your calendar address

4. Once executed on the target machine an event with a unique target ID is automatically created autoexecuting the “whoami” command

Decrypt the base64 encoded string, we can see ‘whoami’ has been executed on the target host.

The Google Calendar RAT attack is a new challenge for cybersecurity because it uses Google’s trusted service to hide malicious actions, making them harder to spot. Attackers don’t need complex tools to launch these attacks, which means even less experienced hackers could use this method to cause widespread problems. Since Google Calendar is everywhere, the number of potential victims is huge. This makes it tough for security teams to respond since they’re not used to seeing threats come through a service like this. Companies might have to change how they watch over their networks and use more advanced tools to catch these sneaky attacks. There’s also the tricky issue of following the law and keeping people’s information private while trying to catch these hidden threats. This attack shows just how important it is for security measures to keep evolving as technology becomes a bigger part of our lives and attackers get smarter.



Chenny Ren

OSCP | OSWP | OSEP | CRTP |CRTE | CRTO | Red Team Professional | SOC engineer