Giter Club home page Giter Club logo

tulip's Introduction

๐ŸŒท Tulip

Tulip is a flow analyzer meant for use during Attack / Defence CTF competitions. It allows players to easily find some traffic related to their service and automatically generates python snippets to replicate attacks.

Origins

Tulip was developed by Team Europe for use in the first International Cyber Security Challenge. The project is a fork of flower, but it contains quite some changes:

  • New front-end (typescript / react / tailwind)
  • New ingestor code, based on gopacket
  • IPv6 support
  • Vastly improved filter and tagging system.
  • Deep links for easy collaboration
  • Added an http decoding pass for compressed data
  • Synchronized with Suricata.
  • Flow diffing
  • Time and size-based plots for correlation.
  • Linking HTTP sessions together based on cookies (Experimental, disabled by default)

Screenshots

Configuration

Before starting the stack, edit services/configurations.py:

vm_ip = "10.60.4.1"
services = [{"ip": vm_ip, "port": 18080, "name": "BIOMarkt"},
            {"ip": vm_ip, "port": 5555, "name": "SaaS"},
]

You can also edit this during the CTF, just rebuild the api service:

docker-compose up --build -d api

Usage

The stack can be started with docker-compose, after creating an .env file. See .env.example as an example of how to configure your environment.

cp .env.example .env
# < Edit the .env file with your favourite text editor >
docker-compose up -d --build

To ingest traffic, it is recommended to create a shared bind mount with the docker-compose. One convenient way to set this up is as follows:

  1. On the vulnbox, start a rotating packet sniffer (e.g. tcpdump, suricata, ...)
  2. Using rsync, copy complete captures to the machine running tulip (e.g. to /traffic)
  3. Add a bind to the assembler service so it can read /traffic

The ingestor will use inotify to watch for new pcap's and suricata logs. No need to set a chron job.

Suricata synchronization

Metadata

Tags are read from the metadata field of a rule. For example, here's a simple rule to detect a path traversal:

alert tcp any any -> any any (msg: "Path Traversal-../"; flow:to_server; content: "../"; metadata: tag path_traversal; sid:1; rev: 1;)

Once this rule is seen in traffic, the path_traversal tag will automatically be added to the filters in Tulip.

eve.json

Suricata alerts are read directly from the eve.json file. Because this file can get quite verbose when all extensions are enabled, it is recommended to strip the config down a fair bit. For example:

# ...
  - eve-log:
      enabled: yes
      filetype: regular #regular|syslog|unix_dgram|unix_stream|redis
      filename: eve.json
      pcap-file: false
      community-id: false
      community-id-seed: 0
      types:
        - alert:
            metadata: yes
            # Enable the logging of tagged packets for rules using the
            # "tag" keyword.
            tagged-packets: yes
# ...

Sessions with matched alerts will be highlighted in the front-end and include which rule was matched.

Security

Your Tulip instance will probably contain sensitive CTF information, like flags stolen from your machines. If you expose it to the internet and other people find it, you risk losing additional flags. It is recommended to host it on an internal network (for instance behind a VPN) or to put Tulip behind some form of authentication.

Contributing

If you have an idea for a new feature, bug fixes, UX improvements, or other contributions, feel free to open a pull request or create an issue!
When opening a pull request, please target the devel branch.

Credits

Tulip was written by @RickdeJager and @Bazumo, with additional help from @Sijisu. Thanks to our fellow Team Europe players and coaches for testing, feedback and suggestions. Finally, thanks to the team behind flower for opensourcing their tooling.

tulip's People

Contributors

0x5eba avatar badlamb avatar bazumo avatar dependabot[bot] avatar devgianlu avatar diedb avatar eciavatta avatar erdnaxe avatar gfelber avatar lavish avatar liskaant avatar maxgroot avatar meme-lord avatar nicomazz avatar perschrijver avatar qyn-ctf avatar rickdejager avatar samdaaman avatar sijisu avatar simone36050 avatar wert310 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

tulip's Issues

[improvement] Add dynamic window size to volume graph

The volume graph is useful to detect the volume associated with certain tags / search queries.
image

The current implementation in devel is pretty naive and just uses a fixed window size. This should be done dynamically based on the timestamps of the first and last item.

[feature request] WebSocket data decoding

Currently Tulip shows WebSocket streams as TCP streams.
It would be nice to format WebSocket streams like browser developer consoles do.

WebSocket can send packet in text mode or binary mode. For binary mode we could use an alternate representation.

[feature request] PCAPs download through Tulip frontend

Currently Tulip shows the path of the PCAP associated with a TCP flow.
It would be nice to change this to a hyperlink pointing to the PCAP, enabling other team members to download it for local analysis.

Should we allow the backend to access PCAPs path to serve it to other users?

HTTP Session tracking panics the assembler

For some specific HTTP requests, the cookie tracking panics the assembler. I have pcaps from BambiCTF that trigger this bug, so I will try to find an example and create a test for it.

[feature request] Add number of matchs in labels

Currently Tulip adds a FLAG label on a flow when the flag regex has one or more match.
It would be useful to store how many times the regex matched the TCP data, then display it like FLAG x3.

This could be useful to spot unusual amount of flags in a TCP flow.

[feature request] OpenTelemetry endpoint in the backend

This needs discussion as we mostly don't want to bloat Tulip.
It would be nice to have a /metrics endpoint in the backend following the OpenTelemetry format.
This could allow teams to monitor their instance and be alerted when something very wrong is happening (before the scoreboard).

Metrics wishlist:

  • (Counter per service) Total count of TCP flows in the MongoDB
  • (Counter per service) Total size in bytes of all payloads in the MongoDB
  • (Counter per service) Total amount of FLAG OUT / IN
  • (Counter) Total amount of backend API requests
  • (Gauge) Average duration of backend API response time

I don't believe we should expose per-TCP flow information as the Tulip frontend is already made for that.

Responsible disclosure policy

Hello ๐Ÿ‘‹

I run a security community that finds and fixes vulnerabilities in OSS. A researcher (@erdnaxe) has found a potential issue, which I would be eager to share with you.

Could you add a SECURITY.md file with an e-mail address for me to send further details to? GitHub recommends a security policy to ensure issues are responsibly disclosed, and it would help direct researchers in the future.

Looking forward to hearing from you ๐Ÿ‘

(cc @huntr-helper)

[feature request] show incomplete TCP streams

During FAUST CTF 2022 there were one service called Ghost which was sending SYN to the vulnbox.
This could be spotted using WireShark.

This is hard to solve as we mostly don't want to bloat Tulip, but maybe something could be done to represent "incomplete TCP flows and UDP" data from PCAPs inside Tulip?

[bug] Command injection in "Copy as ..." functionality

Steps to reproduce

  1. Send a request with " in the URL (not url escaped) and your payload you want to run as python3 code
  2. Wait for someone to "Copy as Requests" and run your script like a normal attacker would
  3. Pop their host

The chances of someone exploiting this are quite low - as it relies on them not seeing the command injection in the "Copy as ..." script. Also in pretty much every CTF this would violate the rules.

Fix

Recommend escaping " characters (or preventing them entirely) in certain request properties or use another way of generating the templates as there is likely other places where this is an issue. Could use repr to add the quote characters and escape automatically like this

print(repr("a\"\'b"))
'a"\'b'

Example

Request (screenshot)

image

Request (python3 code)

req = (
    f'GET /"+__import__("os").system("whoami")+"/path HTTP/1.1\n'
    f'Host: 192.168.1.107:1337\n'
    f'\n'
)
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect(('192.168.1.107', 1337))
sock.sendall(req.encode())
res = sock.recv(4096)
print(res.decode())

Copy as Requests Output (note the command injection in the request.path)

import os
import requests
import sys

host = sys.argv[1]

s = requests.Session()


s.headers = {}

data = {}
s.get("http://{}:1337/"+__import__("os").system("whoami")+"/path".format(host), data=data)

Define flag regex per service instead of global

Not all CTF's maintain flag format over different services. It would be good to either define a global flag format or define format (based on regex) per service, preferably in configurations.py with the services definitions

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.