-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
83 lines (68 loc) · 2.93 KB
/
Main.java
File metadata and controls
83 lines (68 loc) · 2.93 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
import java.io.File;
import java.util.Scanner;
public class HarshScanner {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
InfectionReport lastReport = new InfectionReport(); // Create a report object for the session
printBanner();
while (true) {
printMenu();
String choice = scanner.nextLine();
switch (choice) {
case "1":
performScan(scanner, lastReport);
break;
case "2":
lastReport.printReport();
break;
case "3":
lastReport.fileManagementMenu(scanner);
break;
case "4":
System.out.println("Exiting Harsh Security Scanner. Stay safe!");
System.exit(0);
break;
default:
System.out.println("Invalid choice. Please try again.");
}
}
}
private static void printBanner() {
System.out.println("===========================================");
System.out.println(" HARSH SECURITY SCANNER v1.0");
System.out.println(" Designed for IIIT Lucknow");
System.out.println(" By: Harsh");
System.out.println("===========================================");
}
private static void printMenu() {
System.out.println("\nMAIN MENU:");
System.out.println("1. Scan a Directory");
System.out.println("2. View Last Scan Report");
System.out.println("3. Manage Infected Files (Delete/Export)");
System.out.println("4. Exit");
System.out.print("Enter your choice: ");
}
private static void performScan(Scanner scanner, InfectionReport report) {
System.out.print("\nEnter directory path to scan: ");
String path = scanner.nextLine();
File directory = new File(path);
if (!directory.exists() || !directory.isDirectory()) {
System.out.println("[-] Invalid directory path.");
return;
}
System.out.println("[*] Starting scan on: " + directory.getAbsolutePath());
PatternMatcher matcher = new PatternMatcher();
DirectoryScanner dirScanner = new DirectoryScanner(matcher, report);
// Basic progress indicator start
System.out.print("Scanning");
long startTime = System.currentTimeMillis();
dirScanner.scanDirectory(directory);
long endTime = System.currentTimeMillis();
System.out.println("\n[+] Scan complete in " + (endTime - startTime) + "ms.");
if (report.hasInfections()) {
System.out.println("[!] Threats detected! Use option '2' to view report.");
} else {
System.out.println("[+] No threats found.");
}
}
}