Skip to content

Modern command-line interface for HackerTarget network reconnaissance and security testing toolkit. Use open source tools and network intelligence to help organizations with attack surface discovery and identification of security vulnerabilities.

License

Notifications You must be signed in to change notification settings

offsec-toolkit/hackertarget

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

3 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

HackerTarget CLI v3.0 🎯


Modern command-line interface for HackerTarget network reconnaissance and security testing toolkit.

Use open source tools and network intelligence to help organizations with attack surface discovery and identification of security vulnerabilities.

πŸš€ What's New in v3.0

✨ Complete rewrite with modern Python best practices!

  • 🎨 Modern CLI with argparse and subcommands
  • πŸ“Š Multiple Formats: JSON, CSV, XML, HTML output
  • ⚑ Batch Processing: Scan multiple targets from file
  • πŸ”‘ API Key Support: Premium features integration
  • 🎯 Smart Retry: Automatic retry with exponential backoff
  • 🌈 Colored Output: Beautiful terminal output
  • βš™οΈ Configuration: YAML config files support
  • πŸ“ Better Logging: File and console with rotation
  • πŸ›‘οΈ Robust Errors: Enhanced error handling
  • πŸ”„ Backward Compatible: Old interface still works!

πŸ“¦ Installation

Quick Install

git clone https://github.com/ismailtsdln/hackertarget.git
cd hackertarget/
pip install -e .

From PyPI (coming soon)

pip install hackertarget

Requirements

  • Python 3.7+
  • requests >= 2.31.0
  • pyyaml >= 6.0

🎯 Quick Start

Modern CLI Mode (New!)

# DNS Lookup
hackertarget dns google.com

# Whois with JSON output
hackertarget whois github.com -o json

# Port scan and save to file
hackertarget portscan 192.168.1.1 -s results.json -o json

# Batch processing
hackertarget batch -f domains.txt -t dns -o csv

# Get help
hackertarget --help

Interactive Mode (Classic)

python hackertarget.py

Interactive menu with 14 tools will appear. Choose an option and enter your target.

πŸ› οΈ Available Tools

# Tool Command Description
1 Traceroute traceroute Network path analysis
2 Ping Test ping ICMP echo test
3 DNS Lookup dns DNS record query
4 Reverse DNS rdns PTR record lookup
5 Find DNS Host hostsearch Find DNS A records
6 Find Shared DNS shareddns Find shared DNS servers
7 Zone Transfer zonetransfer AXFR zone transfer
8 Whois Lookup whois Domain registration info
9 IP Geolocation geoip Geographic IP location
10 Reverse IP reverseip Domains on same IP
11 Port Scan portscan TCP port scanning
12 Subnet Calc subnet Subnet calculator
13 HTTP Headers headers HTTP header analysis
14 Page Links pagelinks Extract hyperlinks

πŸ“– Usage Examples

Basic Usage

# DNS lookup
hackertarget dns example.com

# Whois information
hackertarget whois github.com

# Port scan
hackertarget portscan 8.8.8.8

Advanced Usage

Output Formats

# JSON output
hackertarget dns google.com -o json

# CSV output
hackertarget whois github.com -o csv

# HTML report
hackertarget headers example.com -o html

# XML output
hackertarget geoip 8.8.8.8 -o xml

Save to File

# Save JSON results
hackertarget dns google.com -o json -s dns_results.json

# Save CSV results
hackertarget portscan 192.168.1.1 -o csv -s scan.csv

# Save HTML report
hackertarget whois example.com -o html -s report.html

Batch Processing

Create a file with targets (one per line):

google.com
github.com
stackoverflow.com

Process them:

# DNS lookup for all domains
hackertarget batch -f domains.txt -t dns -o json -s results.json

# Whois for multiple domains with custom delay
hackertarget batch -f domains.txt -t whois -d 2.0 -o csv

Configuration

# Initialize configuration file
hackertarget config init

# Set API key
hackertarget config set api.api_key YOUR_API_KEY_HERE

# View current configuration
hackertarget config show

# Get specific value
hackertarget config get api.timeout

Logging

# Verbose mode with debug logging
hackertarget dns google.com --log-level DEBUG -v

# Save logs to file
hackertarget dns google.com --log-file scan.log

# Disable colored output
hackertarget dns google.com --no-color

βš™οΈ Configuration File

Create ~/.hackertarget.yaml:

api:
  api_key: YOUR_API_KEY  # Optional, for premium features
  timeout: 30
  max_retries: 3
  backoff_factor: 0.5

logging:
  level: INFO
  file: null  # or "/path/to/logfile.log"
  colored: true

output:
  format: console  # console, json, csv, xml, html
  colored: true
  verbose: false

batch:
  delay: 1.0  # Seconds between requests
  continue_on_error: true

Or use environment variables:

export HACKERTARGET_API_KEY="your-key-here"
export HACKERTARGET_TIMEOUT=60
export HACKERTARGET_LOG_LEVEL=DEBUG

🐍 Python API

Basic Usage

from source import HackerTargetAPI

# Create API client
api = HackerTargetAPI()

# DNS lookup
result = api.query(3, "google.com")
print(result)

# With context manager (recommended)
with HackerTargetAPI(timeout=60) as api:
    result = api.query(3, "google.com")
    print(result)

Advanced Usage

from source import HackerTargetAPI
from source.exceptions import APIError, RateLimitError

# API client with custom settings
api = HackerTargetAPI(
    api_key="your-key-here",
    timeout=60,
    max_retries=5,
    backoff_factor=1.0
)

# Batch query
targets = ["google.com", "github.com", "stackoverflow.com"]
results = api.batch_query(
    choice=3,  # DNS lookup
    targets=targets,
    delay=1.0
)

for target, result in results.items():
    if result["success"]:
        print(f"{target}: {result['data']}")
    else:
        print(f"{target}: ERROR - {result['error']}")

# Error handling
try:
    result = api.query(3, "example.com")
except RateLimitError as e:
    print(f"Rate limit exceeded. Retry after: {e.retry_after}s")
except APIError as e:
    print(f"API Error: {e}")

Output Formatting

from source.formatters import get_formatter

# Get formatter
formatter = get_formatter('json')

# Format data
result = api.query(3, "google.com")
formatted = formatter.format(
    result,
    metadata={'tool': 'DNS Lookup', 'target': 'google.com'}
)

print(formatted)

# Save to file
with open('output.json', 'w') as f:
    f.write(formatted)

πŸ”’ Security & Privacy

  • All data is queried from HackerTarget's public API
  • No data is stored locally (except optional caching)
  • HTTPS used for all API communications
  • Rate limiting respected automatically
  • API keys supported for authenticated access

🀝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

πŸ“ License

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

πŸ‘¨β€πŸ’» Author

İsmail Taşdelen

πŸ™ Acknowledgments

  • HackerTarget for providing the excellent API
  • All contributors to this project

πŸ’° Support

If you find this tool useful, please consider:

PayPal: https://paypal.me/ismailtsdln

LiberaPay: Donate using Liberapay

πŸ“š Additional Resources


Note: This tool is not affiliated with HackerTarget. It's an independent CLI wrapper built for educational and authorized security testing purposes only.

About

Modern command-line interface for HackerTarget network reconnaissance and security testing toolkit. Use open source tools and network intelligence to help organizations with attack surface discovery and identification of security vulnerabilities.

Topics

Resources

License

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages