Skip to main content

Twitter Remote Access Trojan (Twittersploit)

Developed a malware sample that leverages Twitter direct messaging as a channel for command and control.

Web Service Command and Control

Have recently been structuring a lot of my penetration testing efforts around the MITRE ATT&CK framework. One technique that specifically caught my attention while doing an assessment based on the Command & Control (C&C) section was the T1102 - Web Service C&C technique. It references multiple malware samples that leveraged Twitter as a C&C channel. These samples included:
This technique proved to be uniquely effective for a few reasons:
  1. Traditional C&C Channels Blocked - Many organizations are now taking a (quasi) white-listing approach to URL filtering (i.e. blocking unclassified site categories), thereby blocking hastily established C&C channels over HTTP(S)
  2. Web Service Availability - More and more organizations are opening up corporate infrastructure to social media web services (such as Twitter)
  3. Covert Channel - Most security monitoring teams are not going to suspect command and control traffic to be destined for twitter.com
  4. Privacy Considerations - Many organizations that do SSL/TLS termination (to perform deep packet inspection) will often white-list social media sites to be conscientious of employee privacy, thereby making it impossible to detect C&C operations over these channels
I was unable to find a sample of any of the above mentioned malware. But after some consideration, decided that implementation of this technique should not be too difficult to accomplish.

Anatomy of Command & Control Malware

Any command and control malware includes at least two components.
  1. Bi-directional Communication Channel - To send commands from the C2 server to the victim, and send command results from the victim back to the C2 server.
  2. Code Execution Functionality - To execute commands (on demand) on the victim system, as communicated by the C2 server.
Personally (like many hacker types), my go-to language of choice is Python. So I decided to write the code in Python, then use pyinstaller to compile into stand-alone binaries.

My plan for malware operations included the following:
  1. Upon execution of malware, the malware would use the Twitter DM (Direct Message) API call to send a message to a Twitter C2 account, letting it know that a session has been established
  2. On a routine interval (every 2 seconds), it would use the DM API to see if any new messages were received
  3. When a new message is received, the malware would execute the code locally using os.popen(command)
  4. The malware would then send the response from the command back to the C2 account using the DM API

Github Repository

Proof of Concept

Proof of Concept Code

Surprisingly, this malware sample was EXTREMELY easy to write. Probably only about ~20 lines of functional code for the whole thing (admittedly the rest is all fluff -- I mean...there's even an ASCII bird).

Comments

Popular posts from this blog

Another "Fappening" on the Horizon?

So in case you aren't fully up-to-speed on useless hacker trivia, "The Fappening" (also sometimes referred to as "Celebgate") was a series of targeted end-user cyber attacks which occurred back in 2014 (which strangely feels like forever in tech years), that resulted in unauthorized access to the iCloud accounts of several prominent celebrity figures.  Following these breaches, photographs (for many including personal sexually explicit or nude photos) of the celebrities were then publicly released online.  Most evidence points to the attack vector being spear phishing email attacks which directed the victims to a fake icloud login site, and then collected the victim's credentials to subsequently access their real icloud accounts. Migration to MFA In response to these events, Apple has made iCloud one of the very few social web services that implements compulsory MFA ("Multi-Factor Authentication").  But while they might be ahead of the indust...

Bypassing CAPTCHA with Visually-Impaired Robots

As many of you have probably noticed, we rely heavily on bot automation for a lot of the testing that we do at Sociosploit.  And occasionally, we run into sites that leverage CAPTCHA ("Completely Automated Public Turing Test To Tell Computers and Humans Apart") controls to prevent bot automation.   Even if you aren't familiar with the name, you've likely encountered these before. While there are some other vendors who develop CAPTCHAs, Google is currently the leader in CAPTCHA technology.  They currently support 2 products (reCAPTCHA v2 and v3).  As v3 natively only functions as a detective control, I focused my efforts more on identifying ways to possibly bypass reCAPTCHA v2 (which functions more as a preventative control). How reCAPTCHA v2 Works reCAPTCHA v2 starts with a simple checkbox, and evaluates the behavior of the user when clicking it.  While I haven't dissected the underlying operations, I assume this part of the test likely makes determ...

ChatGPT and the Academic Dishonesty Problem

I've recently seen some complaints from students online (across Reddit, ChatGPT, and Blind) who were indicating that they had been falsely accused of using generative AI when writing essays at their schools and universities. After seeing several of these, I decided to look into ZeroGPT (the top tool being used right now by academic organizations to crackdown on generative AI cheating), and what I found was more than a little concerning. Falsely Accused Imagine you are an undergrad student and business major, looking forward to finishing out your senior year and preparing to take your first steps into the real world. After turning in an essay on comparing and contrasting different software licensing models, you are informed that a new university tool has determined that your essay was AI generated. Because of this, you have been asked to stand in front of the University ethics committee and account for your misconduct.  Only problem is — you didn’t use generative AI tools to create ...