Skip to content

Manoj-Root/FlagSniff

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

23 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐ŸŽฏ FlagSniff - CLI Tool for Red Teaming & CTF Practice

FlagSniff is a powerful command-line tool designed for red teamers and CTF players to quickly analyze .pcap files and extract flags, credentials, tokens, and other sensitive information.

๐Ÿš€ Features

โœ… Core Features (v1.0)

  • ๐Ÿ“ PCAP & PCAPNG File Analysis: Load and parse .pcap or .pcapng files using Scapy
  • ๐Ÿ” Multi-Protocol Support: HTTP, DNS, FTP, Telnet, TCP, UDP
  • ๐Ÿšฉ Flag Detection: Automatically find CTF flags with patterns like flag{}, CTF{}, HTB{}
  • ๐Ÿ” Credential Extraction: Detect Basic Auth, form-based logins, passwords
  • ๐ŸŽซ Token Recognition: JWT tokens, API keys, Bearer tokens, AWS keys
  • ๐ŸŽจ Colorized Output: Beautiful terminal output using Rich
  • ๐Ÿ“Š Statistics: Detailed analysis statistics
  • ๐Ÿ’พ Export Results: Save findings to JSON format
  • ๐Ÿ”ง Custom Regex: Use your own regex patterns for specific searches

๐Ÿ›  Supported Pattern Types

  • Flags: flag{}, CTF{}, HTB{}, DUCTF{}, PICOCTF{}
  • Credentials: usernames, passwords, Basic Auth
  • Tokens: JWT, API keys, Bearer tokens, Slack tokens, AWS keys
  • Emails: Standard email format detection
  • Hashes: MD5, SHA1, SHA256
  • URLs: HTTP/HTTPS links

๐Ÿ“ฆ Installation

Prerequisites

  • Python 3.7+
  • pip package manager

Install Dependencies

pip install -r requirements.txt

Required packages:

  • scapy - Packet parsing and analysis
  • rich - Beautiful terminal output

๐Ÿงช Usage

Basic Commands

1. Find all flags in a PCAP file:

python flagsniff.py -f capture.pcap --find flag

2. Search for credentials:

python flagsniff.py -f capture.pcap --find credentials

3. Find everything (flags, credentials, tokens):

python flagsniff.py -f capture.pcap --find all

4. Use custom regex pattern:

python flagsniff.py -f capture.pcap --find all --regex "flag\\{.*?\\}"

5. Export results to JSON:

python flagsniff.py -f capture.pcap --find all --export results.json

6. Verbose output:

python flagsniff.py -f capture.pcap --find all --verbose

Command Line Arguments

usage: flagsniff.py [-h] -f FILE [--find {flag,credentials,tokens,all}] 
                    [--regex REGEX] [--export EXPORT] [--verbose]

๐ŸŽฏ FlagSniff - CLI Tool for Packet Analysis & Flag Extraction

optional arguments:
  -h, --help            show this help message and exit
  -f FILE, --file FILE  Path to .pcap file
  --find {flag,credentials,tokens,all}
                        What to search for (default: all)
  --regex REGEX         Custom regex pattern to search
  --export EXPORT       Export results to file (JSON format)
  --verbose, -v         Verbose output

๐Ÿ“Š Output Example

๐Ÿ“ Loading PCAP file: sample.pcap
โœ… Loaded 1500 packets

๐ŸŽฏ FlagSniff Results
โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”“
โ”ƒ Type       โ”ƒ Protocol โ”ƒ Source        โ”ƒ Destination   โ”ƒ Found Data                                        โ”ƒ
โ”กโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ฉ
โ”‚ FLAG       โ”‚ HTTP     โ”‚ 192.168.1.10  โ”‚ 192.168.1.1   โ”‚ flag{h3ll0_w0rld_fr0m_p4ck3t5}                   โ”‚
โ”‚ CREDENTIAL โ”‚ HTTP     โ”‚ 192.168.1.20  โ”‚ 192.168.1.1   โ”‚ username=admin&password=secret123                โ”‚
โ”‚ TOKEN      โ”‚ HTTP     โ”‚ 192.168.1.30  โ”‚ 192.168.1.1   โ”‚ eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...         โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

โ”Œโ”€ Statistics โ”€โ”
โ”‚ ๐Ÿ“Š Analysis Statistics โ”‚
โ”‚                        โ”‚
โ”‚ Total Packets: 1500    โ”‚
โ”‚ Analyzed Packets: 847  โ”‚
โ”‚ ๐Ÿšฉ Flags Found: 3      โ”‚
โ”‚ ๐Ÿ” Credentials Found: 7โ”‚
โ”‚ ๐ŸŽซ Tokens Found: 2     โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐Ÿ—‚ Project Structure

flagsniff/
โ”œโ”€โ”€ flagsniff.py           # Main CLI tool
โ”œโ”€โ”€ utils/
โ”‚   โ”œโ”€โ”€ __init__.py        # Package initialization
โ”‚   โ”œโ”€โ”€ parsers.py         # Packet parsing utilities
โ”‚   โ””โ”€โ”€ patterns.py        # Pattern matching & regex
โ”œโ”€โ”€ test_data/
โ”‚   โ””โ”€โ”€ sample.pcap        # Sample PCAP for testing
โ”œโ”€โ”€ requirements.txt       # Python dependencies
โ””โ”€โ”€ README.md             # This file

๐Ÿงฐ Technical Details

Architecture

  • Scapy: Handles PCAP file loading and packet parsing
  • Rich: Provides colorized terminal output and tables
  • Modular Design: Separate utilities for parsing and pattern matching

Supported Protocols

  • HTTP: Web traffic, form data, headers
  • DNS: Query/response analysis
  • FTP: File transfer protocol
  • Telnet: Remote terminal sessions
  • TCP/UDP: General packet analysis

Pattern Recognition

The tool uses carefully crafted regex patterns to identify:

  • CTF Flags: Various flag formats from different competitions
  • Authentication: Basic Auth, form-based, API keys
  • Tokens: JWT, Bearer, API keys, cloud service tokens
  • Sensitive Data: Emails, hashes, URLs

๐Ÿ”ง Advanced Usage

Custom Patterns

You can create custom regex patterns for specific needs:

# Search for Bitcoin addresses
python flagsniff.py -f capture.pcap --regex "[13][a-km-zA-HJ-NP-Z1-9]{25,34}"

# Find specific flag formats
python flagsniff.py -f capture.pcap --regex "MYCTF\\{[a-zA-Z0-9_]+\\}"

Programmatic Usage

from flagsniff import FlagSniff

# Initialize
fs = FlagSniff()

# Load packets
packets = fs.load_pcap("capture.pcap")

# Analyze
fs.analyze_packets(packets, ['flag', 'credentials'])

# Get results
results = fs.found_items

๐Ÿš€ Future Features (v2.0+)

  • ๐ŸŒ Web Dashboard: Visual traffic flow and analysis
  • ๐Ÿ“ˆ Advanced Statistics: Detailed protocol breakdowns
  • ๐Ÿ”„ Real-time Analysis: Live packet capture analysis
  • ๐Ÿ“Š CSV Export: Multiple export formats
  • ๐ŸŽฎ Gaming Mode: CTF scoring system
  • ๐Ÿ” Deep Inspection: SSL/TLS analysis, encrypted content
  • ๐Ÿ“ฑ Mobile App: Companion mobile application

๐Ÿค Contributing

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature-name
  3. Commit changes: git commit -am 'Add feature'
  4. Push to branch: git push origin feature-name
  5. Submit a Pull Request

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

โš ๏ธ Disclaimer

FlagSniff is designed for educational purposes, authorized penetration testing, and CTF competitions. Always ensure you have proper authorization before analyzing network traffic. The authors are not responsible for any misuse of this tool.

๐Ÿ† Credits

Created for the red teaming and CTF community. Special thanks to:

  • Scapy developers for the powerful packet analysis library
  • Rich library for beautiful terminal interfaces
  • The CTF community for inspiration and feedback

Happy Flag Hunting! ๐Ÿšฉ

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages