-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathNeo_fast_scanner.java
More file actions
380 lines (329 loc) · 13.9 KB
/
Copy pathNeo_fast_scanner.java
File metadata and controls
380 lines (329 loc) · 13.9 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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.net.*;
import java.nio.file.*;
import java.util.*;
import java.util.List;
import javax.swing.*;
import javax.swing.table.*;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
public class Main extends JFrame {
private static final String FONT_PATH = "fonts/Perfect_DOS_VGA_437.ttf";
private Font dosFont;
private JTable matrixTable;
private DefaultTableModel tableModel;
private JTextArea logArea;
private JTextArea mapArea;
private JTextField urlField;
private JButton executeBtn;
private JLabel crtOverlay;
private final Map<String, TargetInfo> results = new LinkedHashMap<>();
public Main() {
setTitle("NEO SCANNER v9.9 - DOS MODE");
setSize(1280, 800);
setDefaultCloseOperation(EXIT_ON_CLOSE);
setLocationRelativeTo(null);
loadDosFont();
initUI();
applyCrtStyle();
startCrtFlicker();
log("SYSTEM BOOT", "INFO");
log("ENTER URL", "INFO");
}
private void loadDosFont() {
try {
if (Files.exists(Paths.get(FONT_PATH))) {
dosFont = Font.createFont(Font.TRUETYPE_FONT, new File(FONT_PATH)).deriveFont(16f);
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
ge.registerFont(dosFont);
log("DOS VGA FONT LOADED", "INFO");
} else {
dosFont = new Font("Monospaced", Font.PLAIN, 16);
log("FONT MISSING: " + FONT_PATH, "ALERT");
}
} catch (Exception e) {
dosFont = new Font("Monospaced", Font.PLAIN, 16);
log("FONT LOAD FAILED", "ALERT");
}
}
private void initUI() {
JPanel mainPanel = new JPanel(new BorderLayout(10, 10));
mainPanel.setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));
mainPanel.setBackground(Color.BLACK);
// Header
JTextArea header = new JTextArea(
"╔══════════════════════════════════════════════════════════════╗\n" +
"║ NEO SCANNER v9.9 - WEB RECON ║\n" +
"╚══════════════════════════════════════════════════════════════╝"
);
header.setEditable(false);
header.setBackground(Color.BLACK);
header.setForeground(new Color(0, 255, 0));
header.setFont(dosFont);
header.setAlignmentX(CENTER_ALIGNMENT);
mainPanel.add(header, BorderLayout.NORTH);
// Center: Table + Map + Log
JSplitPane centerSplit = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
centerSplit.setResizeWeight(0.6);
// Matrix Table
tableModel = new DefaultTableModel(new String[]{"DOMAIN", "PORTS", "TITLE", "SERVER", "SECURITY"}, 0);
matrixTable = new JTable(tableModel);
matrixTable.setFont(dosFont);
matrixTable.getTableHeader().setFont(dosFont);
matrixTable.setRowHeight(28);
matrixTable.setBackground(Color.BLACK);
matrixTable.setForeground(new Color(0, 255,0));
matrixTable.setGridColor(new Color(0,51,0));
centerSplit.setLeftComponent(new JScrollPane(matrixTable));
// Right panel: Map + Log
JSplitPane rightSplit = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
rightSplit.setResizeWeight(0.3);
mapArea = new JTextArea();
mapArea.setEditable(false);
mapArea.setBackground(Color.BLACK);
mapArea.setForeground(new Color(0,255,0));
mapArea.setFont(dosFont);
rightSplit.setTopComponent(new JScrollPane(mapArea));
logArea = new JTextArea();
logArea.setEditable(false);
logArea.setBackground(Color.BLACK);
logArea.setForeground(new Color(0,255,0));
logArea.setFont(dosFont);
rightSplit.setBottomComponent(new JScrollPane(logArea));
centerSplit.setRightComponent(rightSplit);
mainPanel.add(centerSplit, BorderLayout.CENTER);
// Control Panel
JPanel control = new JPanel();
control.setBackground(Color.BLACK);
control.setLayout(new BoxLayout(control, BoxLayout.X_AXIS));
urlField = new JTextField("https://example.com");
urlField.setMaximumSize(new Dimension(600, 40));
urlField.setFont(dosFont);
urlField.setForeground(new Color(0,255,0));
urlField.setBackground(Color.BLACK);
urlField.setCaretColor(Color.GREEN);
control.add(urlField);
executeBtn = new JButton("EXECUTE");
executeBtn.setFont(dosFont);
executeBtn.setBackground(new Color(0,17,0));
executeBtn.setForeground(Color.GREEN);
executeBtn.setFocusPainted(false);
executeBtn.addActionListener(e -> startScan());
control.add(Box.createHorizontalStrut(10));
control.add(executeBtn);
JButton clearBtn = new JButton("PURGE");
clearBtn.setFont(dosFont);
clearBtn.setBackground(new Color(0,17,0));
clearBtn.setForeground(Color.GREEN);
clearBtn.setFocusPainted(false);
clearBtn.addActionListener(e -> clearAll());
control.add(Box.createHorizontalStrut(10));
control.add(clearBtn);
mainPanel.add(control, BorderLayout.SOUTH);
// CRT Overlay
crtOverlay = new JLabel();
crtOverlay.setOpaque(false);
crtOverlay.setBackground(new Color(0, 50, 0, 20));
setLayout(new BorderLayout());
add(mainPanel, BorderLayout.CENTER);
add(crtOverlay, BorderLayout.CENTER);
}
private void applyCrtStyle() {
UIManager.put("Table.gridColor", new Color(0, 51, 0));
UIManager.put("Table.background", Color.BLACK);
UIManager.put("Table.foreground", new Color(0,255,0));
UIManager.put("Table.selectionBackground", new Color(0,80,0));
UIManager.put("TableHeader.background", new Color(0,17,0));
UIManager.put("TableHeader.foreground", new Color(0,255,128));
updateScanlines();
}
private void updateScanlines() {
int w = getWidth(), h = getHeight();
BufferedImage img = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
Graphics2D g2 = img.createGraphics();
g2.setColor(new Color(0, 40, 0, 30));
for (int y = 0; y < h; y += 4) {
g2.drawLine(0, y, w, y);
}
g2.dispose();
crtOverlay.setIcon(new ImageIcon(img));
}
private void startCrtFlicker() {
Timer timer = new Timer(120, e -> {
float alpha = (System.currentTimeMillis() / 500) % 2 == 0 ? 0.04f : 0.07f;
crtOverlay.setBackground(new Color(0, 50, 0, (int)(alpha * 255)));
});
timer.start();
}
@Override
public void paint(Graphics g) {
super.paint(g);
updateScanlines();
}
private void log(String msg, String level) {
String time = new java.text.SimpleDateFormat("HH:mm:ss").format(new Date());
Color color = switch (level) {
case "ALERT" -> Color.RED;
case "OPEN" -> new Color(0,255,128);
case "WEB" -> Color.YELLOW;
default -> new Color(0,255,0);
};
SwingUtilities.invokeLater(() -> {
logArea.append(String.format("[%s] %s%n", time, msg));
logArea.setForeground(color);
logArea.setCaretPosition(logArea.getDocument().getLength());
});
}
private void startScan() {
String input = urlField.getText().trim();
if (input.isEmpty()) {
log("NO TARGET", "ALERT");
return;
}
executeBtn.setEnabled(false);
new Thread(() -> scanTarget(input)).start();
}
private void scanTarget(String urlInput) {
String urlStr = urlInput.startsWith("http") ? urlInput : "http://" + urlInput;
String domain;
try {
URL url = new URL(urlStr);
domain = url.getHost();
if (domain.isEmpty()) throw new Exception();
} catch (Exception ex) {
log("INVALID URL", "ALERT");
SwingUtilities.invokeLater(() -> executeBtn.setEnabled(true));
return;
}
log("LOCK ON: " + urlStr, "INFO");
log("DOMAIN: " + domain, "INFO");
String ip;
try {
ip = InetAddress.getByName(domain).getHostAddress();
log("IP: " + ip, "INFO");
} catch (Exception ex) {
log("DOMAIN NOT FOUND", "ALERT");
SwingUtilities.invokeLater(() -> executeBtn.setEnabled(true));
return;
}
TargetInfo info = new TargetInfo();
int[] ports = {80, 443, 8080, 8443};
for (int port : ports) {
if (isPortOpen(ip, port, 3000)) {
info.ports.add(port);
log("PORT " + port + " OPEN", "OPEN");
if (port == 80 || port == 443 || port == 8080 || port == 8443) {
fetchHttpInfo(domain, port, info);
}
}
}
results.put(domain, info);
updateMatrix();
updateAsciiMap();
log("SCAN COMPLETE", "OPEN");
SwingUtilities.invokeLater(() -> executeBtn.setEnabled(true));
}
private boolean isPortOpen(String ip, int port, int timeout) {
try (Socket s = new Socket()) {
s.connect(new InetSocketAddress(ip, port), timeout);
return true;
} catch (Exception ex) {
return false;
}
}
private void fetchHttpInfo(String domain, int port, TargetInfo info) {
String protocol = (port == 443 || port == 8443) ? "https" : "http";
String url = protocol + "://" + domain + (port != 80 && port != 443 ? ":" + port : "");
try {
HttpURLConnection conn = (HttpURLConnection) new URL(url).openConnection();
conn.setRequestProperty("User-Agent", "Mozilla/5.0");
conn.setConnectTimeout(8000);
conn.setReadTimeout(8000);
conn.setInstanceFollowRedirects(true);
if (conn.getResponseCode() >= 400) return;
String server = conn.getHeaderField("Server");
if (server != null) info.server = server;
// Title via Jsoup
Document doc = Jsoup.connect(url).timeout(8000).get();
String title = doc.title();
if (title.length() > 45) title = title.substring(0, 45) + "...";
if (info.title.equals("NO TITLE")) info.title = title;
log("TITLE: \"" + title + "\"", "WEB");
// Tech detection
String body = doc.body().text().toLowerCase();
if (conn.getHeaderField("X-Powered-By") != null) info.tech.add(conn.getHeaderField("X-Powered-By").split(",")[0]);
if (body.contains("wordpress")) info.tech.add("WordPress");
if (body.contains("react")) info.tech.add("React");
// Security headers
Set<String> required = Set.of("X-Frame-Options", "X-Content-Type-Options", "Strict-Transport-Security");
Set<String> present = new HashSet<>();
for (String h : required) {
if (conn.getHeaderField(h) != null) present.add(h);
else log((conn.getHeaderField(h) == null ? "SEC: " + h + " MISSING" : ""), conn.getHeaderField(h) == null ? "ALERT" : "INFO");
}
info.securityCount = present.size();
} catch (Exception ex) {
log("HTTP ERROR", "ALERT");
}
}
private void updateMatrix() {
SwingUtilities.invokeLater(() -> {
tableModel.setRowCount(0);
for (Map.Entry<String, TargetInfo> entry : results.entrySet()) {
String domain = entry.getKey();
TargetInfo i = entry.getValue();
String ports = i.ports.isEmpty() ? "CLOSED" : i.ports.stream().map(String::valueOf).collect(Collectors.joining(", "));
String tech = i.tech.isEmpty() ? "UNKNOWN" : String.join(" | ", i.tech);
tableModel.addRow(new Object[]{
domain,
ports,
i.title,
i.server + " | " + tech,
i.securityCount + "/3 SEC"
});
}
});
}
private void updateAsciiMap() {
StringBuilder sb = new StringBuilder();
sb.append(" ┌──────────┐\n");
sb.append(" │ INTERNET │\n");
sb.append(" └──────────┘\n");
sb.append(" │\n");
int count = 0;
for (Map.Entry<String, TargetInfo> e : results.entrySet()) {
if (count++ >= 2) break;
String tech = e.getValue().tech.isEmpty() ? "WEB" : e.getValue().tech.get(0);
sb.append(String.format(" │ ◆ [%s] → %s\n", e.getKey(), tech));
}
while (count < 2) { sb.append("\n"); count++; }
sb.append(" ◆ = WEB SERVER → = DATA FLOW");
mapArea.setText(sb.toString());
}
private void clearAll() {
results.clear();
tableModel.setRowCount(0);
mapArea.setText("");
logArea.setText("");
log("MEMORY PURGED", "INFO");
}
// Data holder
static class TargetInfo {
List<Integer> ports = new ArrayList<>();
String title = "NO TITLE";
String server = "UNKNOWN";
List<String> tech = new ArrayList<>();
int securityCount = 0;
}
public static void main(String[] args) {
SwingUtilities.invokeLater(() -> {
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeel());
} catch (Exception ignored) {}
new Main().setVisible(true);
});
}
}