1
2
3
4
5
6
7
8
9
10
11 package com.jsql.view.swing.tab;
12
13 import com.jsql.util.I18nUtil;
14 import com.jsql.view.swing.manager.*;
15 import com.jsql.view.swing.util.MediatorHelper;
16 import com.jsql.view.swing.util.UiUtil;
17 import org.apache.commons.lang3.StringUtils;
18
19 import javax.swing.*;
20 import javax.swing.plaf.metal.MetalTabbedPaneUI;
21 import java.awt.*;
22
23
24
25
26 public class TabManagersProxy extends JTabbedPane {
27
28 private final ManagerWebShell managerWebShell = new ManagerWebShell();
29 private final ManagerFile managerFile = new ManagerFile();
30 private final ManagerUpload managerUpload = new ManagerUpload();
31 private final ManagerSqlShell managerSqlShell = new ManagerSqlShell();
32
33
34
35
36 public TabManagersProxy() {
37
38 this.setName("tabManagersProxy");
39
40
41 this.setUI(new MetalTabbedPaneUI() {
42
43 @Override
44 protected int calculateTabAreaHeight(int tabPlacement, int horizRunCount, int maxTabHeight) {
45
46 return 0;
47 }
48 });
49
50 var managerScanList = new ManagerScan();
51 var managerDatabase = new ManagerDatabase();
52 var managerAdminPage = new ManagerAdminPage();
53 var managerBruteForce = new ManagerBruteForce();
54
55 MediatorHelper.register(this.managerWebShell);
56 MediatorHelper.register(this.managerFile);
57 MediatorHelper.register(this.managerUpload);
58 MediatorHelper.register(this.managerSqlShell);
59 MediatorHelper.register(managerScanList);
60 MediatorHelper.register(managerAdminPage);
61 MediatorHelper.register(managerBruteForce);
62
63 this.setMinimumSize(new Dimension(100, 0));
64
65 this.buildI18nTab("DATABASE_TAB", UiUtil.ICON_DATABASE_SERVER, managerDatabase);
66 this.buildI18nTab("ADMINPAGE_TAB", UiUtil.ICON_ADMIN_SERVER, managerAdminPage);
67 this.buildI18nTab("FILE_TAB", UiUtil.ICON_FILE_SERVER, this.managerFile);
68 this.buildI18nTab("WEBSHELL_TAB", UiUtil.ICON_SHELL_SERVER, this.managerWebShell);
69 this.buildI18nTab("SQLSHELL_TAB", UiUtil.ICON_SHELL_SERVER, this.managerSqlShell);
70 this.buildI18nTab("UPLOAD_TAB", UiUtil.ICON_UPLOAD, this.managerUpload);
71 this.buildI18nTab("BRUTEFORCE_TAB", UiUtil.ICON_BRUTER, managerBruteForce);
72 this.buildI18nTab("CODER_TAB", UiUtil.ICON_CODER, new ManagerCoder());
73 this.buildI18nTab("SCANLIST_TAB", UiUtil.ICON_SCANLIST, managerScanList);
74 }
75
76 public void addToLists(String path, String name) {
77
78
79 this.managerWebShell.addToList(path.replace(name, StringUtils.EMPTY));
80 this.managerUpload.addToList(path.replace(name, StringUtils.EMPTY));
81 this.managerSqlShell.addToList(path.replace(name, StringUtils.EMPTY));
82 }
83
84 public void markFileSystemInvulnerable() {
85
86 this.managerFile.changePrivilegeIcon(UiUtil.ICON_SQUARE_RED);
87 this.managerFile.endProcess();
88
89 this.managerWebShell.changePrivilegeIcon(UiUtil.ICON_SQUARE_RED);
90 this.managerWebShell.endProcess();
91
92 this.managerUpload.changePrivilegeIcon(UiUtil.ICON_SQUARE_RED);
93 this.managerUpload.endProcess();
94
95 this.managerSqlShell.changePrivilegeIcon(UiUtil.ICON_SQUARE_RED);
96 this.managerSqlShell.endProcess();
97 }
98
99 public void endPreparation() {
100
101 this.managerFile.setButtonEnable(true);
102 this.managerWebShell.setButtonEnable(true);
103 this.managerSqlShell.setButtonEnable(true);
104 this.managerUpload.setButtonEnable(true);
105 }
106
107 public void markFileSystemVulnerable() {
108
109 this.managerFile.changePrivilegeIcon(UiUtil.ICON_TICK);
110 this.managerWebShell.changePrivilegeIcon(UiUtil.ICON_TICK);
111 this.managerSqlShell.changePrivilegeIcon(UiUtil.ICON_TICK);
112 this.managerUpload.changePrivilegeIcon(UiUtil.ICON_TICK);
113 }
114
115 private void buildI18nTab(String keyLabel, Icon icon, Component manager) {
116 this.addTab(I18nUtil.valueByKey(keyLabel), icon, manager);
117 }
118 }