Coder Social home page Coder Social logo

attackgithub / transporthttp Goto Github PK

View Code? Open in Web Editor NEW

This project forked from cuddycomindustries/transporthttp

0.0 1.0 0.0 168 KB

Faction HTTP Transport Server

License: BSD 3-Clause "New" or "Revised" License

Dockerfile 0.54% C# 17.76% HTML 81.69%

transporthttp's Introduction

Repository Build Status
Master Master Build Status
Development Development Build Status

Overview

Faction supports a "plug and play" like framework for Transports, this project is a simple HTTP Server written in .NET Core configured to run as a Docker Container. Like Faction, this transport is designed to be flexible and compatible with any Faction agent that has a corresponding module. We've written a module for Marauder, our .NET based Faction agent that can be found here.

Getting Started

To get started, ensure you have Docker installed on a host you intend to serve as the Http Transport, then git pull this repo.

git clone https://github.com/FactionC2/TransportHTTP.git

Using an SSL Certificate

If you want to use a valid SSL Certificate, create the certificate and if necessary convert it to a .pfx file named cert.pfx, otherwise the installation will create a self signed SSL certificate.

To convert from openssl to .pfx:

openssl pkcs12 -export -out cert.pfx -inkey privateKey.key -in certificate.crt

Configuring the HTTP Transport

Then create a new Transport within the Faction Console as documented here. Update the Config/server.json file with the correct TransportId, FactionAPIKey, and FactionAPISecret as well as the URL of your Faction instance and the URLs for this HTTP Transport instance. These can be a either DNS or IP address, but should be begin with the protocol to use (http:// or https://), specify the port number if not default (:8443), and should not have a trailing slash (/).

Default Response

The DefaultResponse section details what to do with requests that aren't a Faction message. The following are valid configuration options:

Proxy a website

This will render a website in response to an invalid request. Users will stay on the URL they navigated to.

{
  "Action": "PROXY",
  "Value": "<URL TO PROXY>"
}

Redirect to a website

This will redirect the user to a different website

{
  "Action": "REDIRECT",
  "Value": "<URL TO REDIRECT TO>"
}

Render HTML

This will return the contents of an HTML file

{
  "Action": "HTML",
  "Value": "</path/to/html/file>"
}

Example Server Configuration:

{
  "Hosts": [
    "https://transport-url-01",
    "https://transport-url-02",
    "etc"
  ],
  "DefaultResponse": {
    "Action": "PROXY",
    "Value": "http://www.example.com"
  },
  "Port": 443,
  "UseSSL": false,
  "FactionURL": "https://<THE_URL_FOR_YOUR_FACTION_INSTANCE>",
  "TransportId": TRANSPORT_ID,
  "FactionAPIKey": "<THE_API_KEY_PROVIDED_BY_FACTION>",
  "FactionAPISecret": "<THE_API_SECRET_PROVIDED_BY_FACTION>"
}

Running the Transport

Finally, build and run the Docker container.

docker build -t transporthttp .

# Replace [PORT] below with the port your server will be 
# listening on, the same port that you entered in config.json
docker run -p [PORT]:[PORT] transporthttp

If using a custom SSL certificate, you can override the default SSL Certificate Path and Secret within Docker by overriding the enviornment variables FACTION_PFX_FILE and FACTION_PFX_SECRET as such:

docker run -d -p 443:443 -e "FACTION_PFX_FILE=./opt/faction/cert.pfx" -e "FACTION_PFX_SECRET=Sup3rS3cr3t" transporthttp

Customization

The transport is designed to support customization of how the Http Server and agent module communicate with each other. Settings for both the server and agent are defined within the Config/profile.json file.

Note that you'll have to restart the HTTP Transport for changes to this file to take effect, and any agents or payloads using the old profile will no longer work.

Example Profile

(Comments in the example below are for documentation purposes only and are not present or required in the actual profile)

{
  "Server": {
    "_urls_comment": "This section defines what URLs the agent should use to communicate with the server.
      Marauder's HTTP transport module is designed to pick one of these at random, and then
      combine it with a random hostname (defined in Config/server.json)",
    "URLs": [
      "/status/",
      "/update/",
      "/heartbeat/"
    ],
    "Headers": {
      "_comment": "These headers are added to every Server response",
      "Accept": "application/json",
      "X-Frame-Options": "deny",
      "X-Cache": "Hit"
    },
    "Cookies": {
      "_comment": "These cookies are set with each Server response",
    },

    "MessageConfig": {
      "_comment": "The message config defines how the server sends messages to the client
        If there is no message for that agent, the default string is sent. If there is a message,
        it is wrapped in the Prepend and Append values",
      "Default": "{\"Status\":\"Updated\"}",
      "Prepend": "{\"Status\":\"",
      "Append": "\"}"
    }
  },
  "Agent": {
    "Headers": {
      "_comment": "These headers are added to each request from the agent",
      "Accept": "application/json",
      "User-Agent": "Mozilla/5.0 (compatible, MSIE 11, Windows NT 6.3; Trident/7.0; rv:11.0) like Gecko",
      "Authorization": "RWxpIGlzIGEgdmVyeSB2ZXJ5IGdvb2QgZG9nLg=="
    },
    "Cookies": {
      "_comment": "These cookies are included in each request from the agent",
      "Timestamp": "1990-01-01T00:00:00.000Z"
    },
    "StagingIdentifier": {
      "_comment": "This section defines where the staging identifier for the payload
        is placed when it sends a staging message. Valid options for location are 
        Header or Cookie",
      "Location": "Cookie",
      "Name": "AuthStatus"
    },
    "CheckinIdentifier": {
      "_comment": "This section defines where the agent name is placed in each
        each checkin from the agent. Valid options for location are 
        Header or Cookie",
      "Location": "Cookie",
      "Name": "SessionId"
    },
    "MessageConfig": {
      "_comment": "This section defines how a request to the transport server
        is formated. If there are no task results, the Default message is sent. 
        If there are results from a task to be sent to Faction it is wrapped 
        in the Prepend and Append values.",
      "Default": "{}",
      "Prepend": "{\"Update\":\"",
      "Append": "\"}"
    }
  }
}

Issues

Please submit any issues you have with Faction here and use the provided templates if applicable.

If you find a security related issue in Faction, please email it to jared at c2 dot lol. It's preferred that you use the following PGP key to encrypt your message, but by no means required.

-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: OpenPGP.js v4.5.1
Comment: https://openpgpjs.org

xsFNBFudOHkBEACYQ+WJ3galbDCKhJYHkvZe6WIhqkA34pltG6YSRj41Vkh5
HRZdHuxVZxSNkYU7PewzLOT0LMlHU740QeV8CMnnB5uIYbVN1IsPU+C5Pozv
T3jKZNR1F8J1oZX09zCnsZZ9iU3L7AAIHv+Mvv8f/bJ9mYTzrGtITsr7xe7G
XhRq6NtEpjfAxgYRYEVwnPo5z85cQCd8KFMq/t1wN9p3OlYMoFSqAsR6Cqtd
XmkNX0DllVIAol9pgWjVCAve0n4f/ZTpY62Q8tsnfjs0Ip4pWLl2hEw4H9LH
L8NXyQHHoSQq4OB+nmfHfEpZujuTJEpabXMRaat3SF+KHvmfICtbBRzTgj+d
c2WDobH/bRBlSwMXgyLTCOGG7zkK0RJv7LRl816dvfmT0zIrKyPbfoT0XSDo
W8vDKfCrbcpiznkq4O7h+p6y7ZHI6d9MmA//aZVIPrB3AFiZIzv+Nf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hra1yJjdkjjh5CZFohN97wa1Q29dAk0+6FBkuMe/DQI5RmB92cFiy/3
xtk2gg0lShPnc/uRN3KEBDkY+UoKPjX1Gick0jc3OlPQWfF3A9prjUMIMZas
zeNLcuEwFsmyiVHE/6fQAJQbyUOrhWjhOFcOo/OCf2oMoNngfEfvPS+bTh3T
ROiVmEfvAoHRkwl9jWFX/0fyGO8NBHCxr5MVdyVAwESyRN5jvCw6FljCTIrI
vSvnX/ZcKPAUd0n8YqxXeWe8E37OKBGkW9a4GCTHF7pG3rHEzIQlB2B05Xzk
2X1hLzwAvHAqOyHDVEWZSG5ghQNV3XI+IP7t+cTAiEr44b1qh8rTtUUK9I2G
f7RzcW5jaOtDB6KpkU54jg==
=FL5R
-----END PGP PUBLIC KEY BLOCK-----

IBM Corporation and the author are not responsible or liable for this code or its use cases currently.

transporthttp's People

Contributors

jaredhaight avatar

Watchers

 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.