Giter Site home page Giter Site logo

reveng007 / sharpgmailc2 Goto Github PK

View Code? Open in Web Editor NEW
251.0 9.0 43.0 20.46 MB

Our Friendly Gmail will act as Server and implant will exfiltrate data via smtp and will read commands from C2 (Gmail) via imap protocol

License: MIT License

C# 100.00%
c2 gmail hacking-tool imap-client implant powershell redteam redteam-tools redteaming smtp-client

sharpgmailc2's Introduction

SharpGmailC2

Our Friendly Gmail will act as Server and implant will exfiltrate data via smtp and will read commands from C2 (Gmail) via imap protocol

DISCLAIMER:

This Project doesn't work against Windows Defender after 29th of November, 2022. This tool is now signatured by MS Windows as virtool:msil/ "shgmailz." a!mtb. However, I do have plan to upgrade this project in near future, to a newer version named, SharpGmailC2V2


๐Ÿšซ [Disclaimer]: Use of this project is for Educational/ Testing purposes only. Using it on unauthorised machines is strictly forbidden. If somebody is found to use it for illegal/ malicious intent, author of the repo will not be held responsible.


Setup

When setting up the intermediate sender and recipient gmail account(s), enable the POP Download and IMAP Access by following the steps in this (link)[https://support.cloudhq.net/how-to-check-if-imap-is-enabled-in-gmail-or-google-apps-account/]

Once IMAP and POP are enabled, generate an App Password by following the step in this article here. If App Password setting is not visible in Security, enable 2FA verification for the Gmail account first.

When compiling the code, update the lines that set emailToAddress, password and emailToAddress. Value for password should be set to the App Password generated in previous step. Also, note that values for emailToAddress, and emailToAddress can be the same.

Used:

  1. EAGetMail library from Nuget Package Manager.
  2. Costura and Costura Fody from Nuget Package Manager, in order to bundle up all the dlls altogether. This actually bulked up my implant, but for this case, I don't think that will matter much as this implant is FUD till now :).

Precautions to be taken by Operator before Using Gmail as C2:

  1. Make sure the Command sent via Gmail, is in Unread Mode (if not, mark as Unread) as the implant scans the Last/latest Unread mail and checks whether it starts with "in:" or not. If it does start with "in:", it understands that, that particular textbody is a legit command, and marks that particular mail as Read and this continues till the end.

Here is the snippet:

latest_unreadMail

C2 In-Action:

GmailC2.mp4

Quick Scan:

  1. Using @matterpreter's DefenderCheck:

DefenderCheck

  1. Using Antiscan.me:

AntiScan.me

  1. Capa Scan:

capa_scan

It seems like capa is not able to detect the capabilties of my Client implant at all. But definitely creates suspicion, forcing the Malware Analyst to give the binary a second look.

  1. WireShark Packet Capture:

smtp_capture

We can see that the sent commands via Operator via Gmail and the informations that are exfiltrated/ sent out are all encrypted by Gmail's TLS encryption. On top of that, the ip address (marked) isn't suspicious at all, or in other words are OPSEC safe.

ip_lookup

Threat Detection

SharpGmailC2 can generate following generic behaviour which can assist defenders to detect SharpGmailC2 or other processes that leverage Gmail mail protocols for Command and Control:

  • Anamlous increase in DNS calls to imap.google.com and network connections to other Google domains e.g. 1e100.net.
# Monitor high network connections from a particular processID
Channel=Microsoft-Windows-Sysmon
(EventID=3 OR EventID=22)  (3=Network Connection, 22=DNS)
(DestinationHostname=*.1e100.net OR QueryName=*.gmail.com)
  • Invocation of powershell process from a binary process (.dll or .exe)
Channel=Microsoft-Windows-Sysmon
EventID=1
CommandLine=powershell.exe
(ParentImage=*.exe OR ParentImage=*.dll)

Honourable Mentions:

Credits:

  1. Inspired by NamedPipes from malcomvetter.
  2. Much much much thanks to @SoumyadeepBas12 for helping me out with the proper code structure of this project! ๐Ÿ˜ƒ

sharpgmailc2's People

Contributors

manasmbellani avatar reveng007 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sharpgmailc2's Issues

Hello a kind warmth assistance

The compilation of this code leads to errors says Trial version Expired

Can you give some hint or assistance to this ?

Thanks

Referencing issues

Hello i tried compiling this code for traffic analysis but i kept giving me errors referencing errors i used vs2019 <-> 22

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.