Giter Site home page Giter Site logo

hartl3y94 / flyingafalseflag Goto Github PK

View Code? Open in Web Editor NEW

This project forked from monoxgas/flyingafalseflag

0.0 0.0 0.0 7.34 MB

Slides and Code for the BHUSA 2019 talk: Flying a False Flag

License: GNU General Public License v3.0

C++ 48.74% Python 45.69% PowerShell 5.56%

flyingafalseflag's Introduction

Flying A False Flag

This repo contains the slides and concept code for my BlackHat USA 2019 talk about Command and Control.

There are three projects in this repo:

  • CloudRacoon - Tools to hunt for orphaned DNS records by fast cycling cloud IPs
  • PostOffice - C2 via Exchange EWS services, account piggybacking, and SendGrid
  • Addendum - C2 concept via VirusTotal sample updates and property extraction

CloudRacoon - Clound Hunting

I've provided three scripts for AWS, Azure, and GCP hunting. This involves collecting a random IP, checking it's history for interesting records, and either keeping or releasing it. All of these scripts require valid authentication to the specific provider. AWS is by far the best canidate for collection. The process is fast and there are many orphaned records. It's not uncommon to achieve a 1-3% success rate during a cycle of 100 IPs (taking less than a couple minutes).

Edit 11/2019 - It would appear AWS has begun serving elastic IPs from a small account-specific pool (similar to GCP). This severly limits the diversity of addresses recieved.

> python racoon_aws.py us-west-1 -aK <access_key> -sK <secret_key>

[+] Connected to AWS. Hunting in us-west-1 ... (max: 100)

        +++ 54.241.90.186 : docker.wooagency.com
        +++ 52.8.1.47 : next-donate.sanguinebio.com
        = 52.52.237.229 : 13.52.45.201.hczvxliealbqzvdy.com
        
> python racoon_aws.py -l all -aK <access_key> -sK <secret_key>

[+] us-west-1 has 3

13.52.14.26     :
52.8.1.47       : next-donate.sanguinebio.com
54.241.90.186   : docker.wooagency.com

PostOffice - EWS C2

This project is provided as a python server side, and C++ client side. It requires the most setup with a valid SendGrid API key, authenticated domain, configured MX record, and inbound parse hook.

Setup

  1. Setup a SendGrid account and add an authenticated domain
  2. Select an email address to use, such as c2@[mydomain.com]
  3. Configure the MX record for your mail domain to point to mx.sendgrid.net
  4. Choose a public host for the C2 server, and configure an inbound parse hook in SendGrid (http://[myserver.com]/inbox)

Server

A Python 3 script with uses the bottle HTTP library for inbound hooks, and the sendgrid library for outbound emails.

  1. Put your SG API key and email into post_office.py
  2. Execute the server on your public host to wait for a callback
> python post_office.py

 _____         _   _____ ___ ___ _         
|  _  |___ ___| |_|     |  _|  _|_|___ ___ 
|   __| . |_ -|  _|  |  |  _|  _| |  _| -_|
|__|  |___|___|_| |_____|_| |_| |_|___|___|
        EWS Mail C2 - Proof of Concept

# 

Client

A Visual Studio C++ project which compiles into an EXE. It uses WinInet for requests, and is capable of extracting mailbox credentials from the Windows credential vault for authentication.

  1. Place your target email address into client\Exchanger\Exchanger.cpp.
  2. Build the solution and execute. You should recieve a new "callback" on the server.

Notes

  • The actual C2 data is Base64 encoded and placed inside a mail header. This means email contents can be benign to slip past filtering.
  • Email headers, and emails in general, have various size limitations depending on the provider. For real-world use, an additional chunking mechanic would likely be needed.

Addendum - VirusTotal C2

This is a simple python script the masquerades as both the server in the client. It runs in two phases:

  1. Random data is generated and packing into the HyperlinkBase property of an office document.
  2. The document is uploaded to VT and the script waits until analysis finishes
  3. A comment is made on the new sample using the account credentials provided

  1. The "client" code now pulls a list of comments using only the username of the account
  2. The sample is identified, downloaded, and the random data is extracted.
  3. The data is checked to ensure it matches

Naturally these steps could be performed in seperate code, with each one uploading, tagging, and pulling down samples.

Notes

  • There are also more file types that include data extraction as part of the analysis. PE files, for instance, have their import table extracted and available in any public response.
  • Outside of samples, commands and profile information could be used as their own C2 channel

flyingafalseflag's People

Contributors

monoxgas avatar ne0nd0g avatar

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.