Skip to content

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

#ToolCommandDescription
1TraceroutetracerouteNetwork path analysis
2Ping TestpingICMP echo test
3DNS LookupdnsDNS record query
4Reverse DNSrdnsPTR record lookup
5Find DNS HosthostsearchFind DNS A records
6Find Shared DNSshareddnsFind shared DNS servers
7Zone TransferzonetransferAXFR zone transfer
8Whois LookupwhoisDomain registration info
9IP GeolocationgeoipGeographic IP location
10Reverse IPreverseipDomains on same IP
11Port ScanportscanTCP port scanning
12Subnet CalcsubnetSubnet calculator
13HTTP HeadersheadersHTTP header analysis
14Page LinkspagelinksExtract 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 featurestimeout: 30max_retries: 3backoff_factor: 0.5logging:
level: INFOfile: null # or "/path/to/logfile.log"colored: trueoutput:
format: console # console, json, csv, xml, htmlcolored: trueverbose: falsebatch:
delay: 1.0# Seconds between requestscontinue_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

fromsourceimportHackerTargetAPI# Create API clientapi=HackerTargetAPI()
# DNS lookupresult=api.query(3, "google.com")
print(result)
# With context manager (recommended)withHackerTargetAPI(timeout=60) asapi:
result=api.query(3, "google.com")
print(result)

Advanced Usage

fromsourceimportHackerTargetAPIfromsource.exceptionsimportAPIError, RateLimitError# API client with custom settingsapi=HackerTargetAPI(
api_key="your-key-here",
timeout=60,
max_retries=5,
backoff_factor=1.0
)
# Batch querytargets= ["google.com", "github.com", "stackoverflow.com"]
results=api.batch_query(
choice=3, # DNS lookuptargets=targets,
delay=1.0
)
fortarget, resultinresults.items():
ifresult["success"]:
print(f"{target}: {result['data']}")
else:
print(f"{target}: ERROR - {result['error']}")
# Error handlingtry:
result=api.query(3, "example.com")
exceptRateLimitErrorase:
print(f"Rate limit exceeded. Retry after: {e.retry_after}s")
exceptAPIErrorase:
print(f"API Error: {e}")

Output Formatting

fromsource.formattersimportget_formatter# Get formatterformatter=get_formatter('json')
# Format dataresult=api.query(3, "google.com")
formatted=formatter.format(
result,
metadata={'tool': 'DNS Lookup', 'target': 'google.com'}
)
print(formatted)
# Save to filewithopen('output.json', 'w') asf:
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

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages