예제 #1
0
        public bool updateHashcat()
        {
            hcUpdateProper hcUpd   = new hcUpdateProper();
            jsonClass      jsonUpd = new jsonClass {
                debugFlag = debugFlag, connectURL = client.connectURL
            };

            hcUpd.token = client.tokenID;
            string hcBinName = "hashcat";

            if (client.osID == 0)
            {
                hcBinName = hcBinName + "64.bin";
            }
            else if (client.osID == 1)
            {
                hcBinName = hcBinName + "64.exe";
            }

            string hcBinLoc = Path.Combine(AppPath, "hashcat", hcBinName);

            if (File.Exists(hcBinLoc))
            {
                hcUpd.force = 0; //HC exists, we don't need to force
            }
            else
            {
                hcUpd.force = 1; //HC doesn't exist, we need to force
            }

            string jsonString = jsonUpd.toJson(hcUpd);
            string ret        = jsonUpd.jsonSend(jsonString);

            if (jsonUpd.getRetVar(ret, "version") == "NEW")
            {
                downloadClass dlClass = new downloadClass();

                if (client.osID != 1)
                {
                    dlClass.DownloadFileCurl(jsonUpd.getRetVar(ret, "url"), Path.Combine(AppPath, "hcClient.7z"));
                }
                else
                {
                    dlClass.DownloadFile(jsonUpd.getRetVar(ret, "url"), Path.Combine(AppPath, "hcClient.7z"));
                }

                sevenZip.xtract(Path.Combine(AppPath, "hcClient.7z"), Path.Combine(AppPath, "hcClient"));
                if (Directory.Exists(Path.Combine(AppPath, "hashcat")))
                {
                    Directory.Delete(Path.Combine(AppPath, "hashcat"), true);
                }
                Directory.Move(Path.Combine(AppPath, "hcClient", jsonUpd.getRetVar(ret, "rootdir")), Path.Combine(AppPath, "hashcat"));
                Directory.Delete(Path.Combine(AppPath, "hcClient"));


                if (client.osID != 1) //Chmod for non windows
                {
                    Console.WriteLine("Applying execution permissions to 7zr binary");
                    Process.Start("chmod", "+x \"" + hcBinLoc + "\"");
                }
            }

            if (File.Exists(hcBinLoc))
            {
                return(true);
            }

            return(false);
        }
예제 #2
0
        public void runUpdate()
        {
            string currentBin = Environment.GetCommandLineArgs()[0]; //Grab current bin name

            if (System.AppDomain.CurrentDomain.FriendlyName == launcherProcName)
            {
                for (int i = 0; i < arguments.Length; i++)
                {
                    if (arguments[i] != "debug")
                    {
                        parentProc = (arguments[i]);
                        break;
                    }
                }

                //Looks like user isn't using custom name, use the default one
                if (string.IsNullOrEmpty(parentProc))
                {
                    parentProc = "hashtopussy.exe";
                }

                waitForProcess(parentProc);
                File.Copy(launcherProcName, parentProc, true);


                if (Type.GetType("Mono.Runtime") != null)
                {
                    Console.WriteLine("Client has now been updated, please re-launch the agent");
                }
                else
                {
                    Process reSpawn = new Process();
                    reSpawn.StartInfo.FileName = parentProc;
                    reSpawn.Start();
                }
                Environment.Exit(0);
            }
            else //We are either user-run bin or spanwed bin
            {
                waitForProcess(launcherProcName);
                if (File.Exists(launcherProcName))
                {
                    Console.WriteLine("Cleaning up files post update");
                    File.Delete(launcherProcName);
                }

                Console.WriteLine("Checking for client updates");
                updProps uProps = new updProps
                {
                    version = htpVersion
                };

                jsonClass jsC = new jsonClass {
                    debugFlag = debugFlag, connectURL = connectURL
                };
                string jsonString = jsC.toJson(uProps);
                string ret        = jsC.jsonSend(jsonString);

                if (jsC.isJsonSuccess(ret))
                {
                    if (jsC.getRetVar(ret, "version") == "OK")
                    {
                        Console.WriteLine("You are using the latest client version");
                        return;
                    }
                    else
                    {
                        downloadClass dl     = new downloadClass();
                        string        dlFrom = Path.Combine(jsC.getRetVar(ret, "url"));
                        string        dlTo   = Path.Combine(parentPath, launcherProcName);
                        dl.DownloadFile(dlFrom, dlTo);
                        Console.WriteLine("Finished downloading latest client");
                        Console.WriteLine("Client will now relaunch");
                        Process Spawn = new Process();
                        Spawn.StartInfo.WorkingDirectory = parentPath;
                        if (Type.GetType("Mono.Runtime") != null)
                        {
                            Spawn.StartInfo.FileName  = "mono";
                            Spawn.StartInfo.Arguments = launcherProcName + " " + parentProc;
                        }
                        else
                        {
                            Spawn.StartInfo.FileName  = launcherProcName;
                            Spawn.StartInfo.Arguments = parentProc;
                        }

                        Spawn.Start();
                        Environment.Exit(0);
                    }
                }
            }
        }