Class: NetMap::HTMLReporter

Inherits:
Object
  • Object
show all
Defined in:
lib/netmap/html_reporter.rb

Class Method Summary collapse

Class Method Details

.generate(results, filename) ⇒ Object



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
# File 'lib/netmap/html_reporter.rb', line 3

def self.generate(results, filename)
  html = "    <!DOCTYPE html>\n    <html lang=\"id\">\n    <head>\n      <meta charset=\"UTF-8\">\n      <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n      <title>Laporan Pemindaian NetMap Ultimate</title>\n      <style>\n        body { font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; background-color: #f4f7f6; color: #333; margin: 0; padding: 20px; }\n        .container { max-width: 1000px; margin: auto; background: white; padding: 30px; border-radius: 8px; box-shadow: 0 2px 10px rgba(0,0,0,0.1); }\n        h1 { color: #2c3e50; border-bottom: 2px solid #3498db; padding-bottom: 10px; }\n        .stats { display: flex; gap: 20px; margin-bottom: 30px; }\n        .stat-card { flex: 1; background: #3498db; color: white; padding: 20px; border-radius: 8px; text-align: center; }\n        .stat-card.green { background: #27ae60; }\n        table { width: 100%; border-collapse: collapse; margin-top: 20px; }\n        th { background: #34495e; color: white; text-align: left; padding: 12px; }\n        td { padding: 12px; border-bottom: 1px solid #ddd; }\n        tr:hover { background-color: #f1f1f1; }\n        .status-open { color: #27ae60; font-weight: bold; }\n        .os-tag { background: #ecf0f1; padding: 2px 8px; border-radius: 4px; font-size: 0.9em; }\n        .mac-tag { font-family: monospace; color: #7f8c8d; font-size: 0.9em; }\n        footer { margin-top: 50px; text-align: center; font-size: 0.8em; color: #7f8c8d; }\n      </style>\n    </head>\n    <body>\n      <div class=\"container\">\n        <h1>Laporan Pemindaian NetMap</h1>\n        <p>Waktu Pemindaian: \#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}</p>\n        \n        <div class=\"stats\">\n          <div class=\"stat-card\">\n            <h3>Total Port Terbuka</h3>\n            <p style=\"font-size: 2em; margin: 0;\">\#{results.size}</p>\n          </div>\n          <div class=\"stat-card green\">\n            <h3>Target Unik</h3>\n            <p style=\"font-size: 2em; margin: 0;\">\#{results.map { |r| r[:ip] }.uniq.size}</p>\n          </div>\n        </div>\n\n        <table>\n          <thead>\n            <tr>\n              <th>Alamat IP</th>\n              <th>Port</th>\n              <th>Status</th>\n              <th>Sistem Operasi</th>\n              <th>MAC / Vendor</th>\n              <th>Layanan / Banner</th>\n            </tr>\n          </thead>\n          <tbody>\n            \#{results.map { |r| \"\n            <tr>\n              <td>\#{r[:ip]}</td>\n              <td>\#{r[:port]}/\#{r[:type]}</td>\n              <td><span class='status-open'>\#{r[:status]}</span></td>\n              <td><span class='os-tag'>\#{r[:os] || 'Unknown'}</span></td>\n              <td><span class='mac-tag'>\#{r[:mac] || 'N/A'} \#{\"(\#{r[:vendor]})\" if r[:vendor]}</span></td>\n              <td><code>\#{r[:banner]}</code></td>\n            </tr>\" }.join}\n          </tbody>\n        </table>\n\n        <footer>\n          Dihasilkan secara otomatis oleh NetMap Ultimate Upgrade - By IshikawaUta\n        </footer>\n      </div>\n    </body>\n    </html>\n  HTML\n  File.write(filename, html)\nend\n"