-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmain.py
More file actions
executable file
·172 lines (139 loc) · 6.32 KB
/
main.py
File metadata and controls
executable file
·172 lines (139 loc) · 6.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
#!/usr/bin/env python3
"""
Rankle - Web Infrastructure Reconnaissance Tool
Main entry point
Named after Rankle, Master of Pranks from Magic: The Gathering
A comprehensive web infrastructure analyzer:
- DNS enumeration and configuration
- Subdomain discovery via Certificate Transparency
- Technology stack detection (CMS, frameworks, libraries)
- TLS/SSL certificate analysis
- HTTP security headers audit
- CDN and WAF detection
- Geolocation and hosting provider information
- WHOIS lookup
100% Open Source - No API keys required
"""
import argparse
import sys
import traceback
from datetime import UTC, datetime
from pathlib import Path
# Add project root to path
sys.path.insert(0, str(Path(__file__).parent))
try:
from config.settings import OUTPUT_DIR
from rankle.core.scanner import RankleScanner
from rankle.utils.helpers import save_json_file
from rankle.utils.validators import (
extract_domain,
sanitize_filename,
validate_domain,
)
except ImportError as e:
print(f"\n❌ Import Error: {e}")
print("\nPlease ensure all dependencies are installed:")
print(" pip install -r requirements.txt")
sys.exit(1)
def print_banner():
"""Print Rankle banner"""
banner = """
╔═══════════════════════════════════════════════════════════════════════════╗
║ ║
║ ██████╗ █████╗ ███╗ ██╗██╗ ██╗██╗ ███████╗ ║
║ ██╔══██╗██╔══██╗████╗ ██║██║ ██╔╝██║ ██╔════╝ ║
║ ██████╔╝███████║██╔██╗ ██║█████╔╝ ██║ █████╗ ║
║ ██╔══██╗██╔══██║██║╚██╗██║██╔═██╗ ██║ ██╔══╝ ║
║ ██║ ██║██║ ██║██║ ╚████║██║ ██╗███████╗███████╗ ║
║ ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═══╝╚═╝ ╚═╝╚══════╝╚══════╝ ║
║ ║
║ Web Infrastructure Reconnaissance Tool ║
║ Named after Rankle, Master of Pranks (MTG) ║
║ ║
║ 100% Open Source - No API Keys ║
║ ║
╚═══════════════════════════════════════════════════════════════════════════╝
"""
print(banner)
def parse_arguments():
"""Parse command line arguments"""
parser = argparse.ArgumentParser(
description="Rankle - Web Infrastructure Reconnaissance Tool",
formatter_class=argparse.RawDescriptionHelpFormatter,
epilog="""
Examples:
python main.py example.com # Scan and print to terminal
python main.py example.com -o json # Save JSON report
python main.py example.com -o both # Save JSON and text reports
python main.py example.com -v # Verbose output
For more information, visit: https://github.com/javicosvml/rankle
""",
)
parser.add_argument(
"domain",
help="Domain or URL to analyze (e.g., example.com or https://example.com)",
)
parser.add_argument(
"-o",
"--output",
choices=["json", "text", "both"],
default=None,
help="Save output to file (json/text/both). If not specified, only prints to terminal.",
)
parser.add_argument(
"--output-dir",
type=Path,
default=OUTPUT_DIR,
help=f"Output directory (default: {OUTPUT_DIR})",
)
parser.add_argument(
"-v", "--verbose", action="store_true", help="Enable verbose output"
)
parser.add_argument("--version", action="version", version="Rankle v1.0.0")
return parser.parse_args()
def main():
"""Main entry point"""
print_banner()
args = parse_arguments()
# Extract and validate domain
domain = extract_domain(args.domain)
if not validate_domain(domain):
print(f"❌ Invalid input: Invalid domain format: {args.domain}")
sys.exit(1)
# Print scan info
print("=" * 80)
print("🃏 RANKLE - Web Infrastructure Reconnaissance")
print("=" * 80)
print(f"🎯 Target: {domain}")
print(f"⏰ Timestamp: {datetime.now(UTC).strftime('%Y-%m-%d %H:%M:%S')}")
print("=" * 80)
try:
# Initialize scanner
scanner = RankleScanner(domain, verbose=args.verbose)
# Run comprehensive scan
results = scanner.run_full_scan()
# Save results only if explicitly requested
if args.output:
timestamp = datetime.now(UTC).strftime("%Y%m%d_%H%M%S")
base_filename = f"rankle_{sanitize_filename(domain)}_{timestamp}"
if args.output in ["json", "both"]:
json_path = args.output_dir / f"{base_filename}.json"
if save_json_file(results, json_path):
print(f"\n📁 JSON saved: {json_path}")
if args.output in ["text", "both"]:
text_path = args.output_dir / f"{base_filename}.txt"
scanner.save_text_report(text_path)
print(f"📁 Text saved: {text_path}")
print("\n" + "=" * 80)
print("✅ Scan completed successfully!")
print("=" * 80)
except KeyboardInterrupt:
print("\n\n⚠️ Scan interrupted by user")
sys.exit(130)
except Exception as e:
print(f"\n❌ Error during scan: {e!s}")
if args.verbose:
traceback.print_exc()
sys.exit(1)
if __name__ == "__main__":
main()