Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can trusted 1.5 applets execute system commands?

If so, is there any limitation to this ability? Specifically, I need to target Mac OSX.

like image 930
Stefan Kendall Avatar asked Jan 24 '23 08:01

Stefan Kendall


2 Answers

I have used this before to launch things on a windows system never tried it on a Mac though.

public void launchScript(String args)
{
    String cmd = null;
    try
    {
        cmd = getParameter(PARAM_CMD);
        System.out.println("args value : = " + args);
        System.out.println("cmd value : = " + cmd);
        System.out.println("Full command:  = " + cmd + " " + args);
        if (cmd != null && !cmd.trim().equals(""))
        {
            if (args == null || args.trim().equals(""))
            {
                final String tempcmd = cmd;
                AccessController.doPrivileged(new PrivilegedAction() {
                public Object run() {
                try
                {
                    Runtime.getRuntime().exec(tempcmd);
                }
                catch (Exception e)
                {
                    System.out.println("Caught exception in privileged block, Exception:" + e.toString());
                }
                return null; // nothing to return
            }
            });                    
                System.out.println(cmd);
            }
            else
            {
                final String tempargs = args;
                final String tempcmd1 = cmd;
                AccessController.doPrivileged(new PrivilegedAction() {
                    public Object run() 
                    {
                        try
                        {
                            Runtime.getRuntime().exec(tempcmd1 + " " + tempargs);
                        }
                        catch (Exception e)
                        {
                            System.out.println("Caught exception in privileged block, Exception:" + e.toString());
                        }
                        return null; // nothing to return
                    }
                });                        
                System.out.println(cmd + " " + args);
            }
        }
        else
        {
            System.out.println("execCmd parameter is null or empty");
        }
    }
    catch (Exception e)
    {
        System.out.println("Error executing command --> " + cmd + " (" + args + ")");
        System.out.println(e);
    }
}
like image 150
Keibosh Avatar answered Jan 25 '23 21:01

Keibosh


As it turns out, they can.

like image 33
Stefan Kendall Avatar answered Jan 25 '23 22:01

Stefan Kendall