Ejemplo n.º 1
0
        private Boolean getFile(string fileName)
        {
            FileProps get = new FileProps
            {
                action = "file",
                token  = client.tokenID,
                task   = taskID,
                file   = fileName
            };

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

            if (jsC.isJsonSuccess(ret))
            {
                string fileDl = jsC.getRetVar(ret, "url");
                {
                    downloadClass dlHdl  = new downloadClass();
                    string        dlFrom = Path.Combine(prefixServerdl, jsC.getRetVar(ret, "url"));
                    string        dlTo   = Path.Combine(filepath, fileName);
                    dlHdl.DownloadFile(dlFrom, dlTo);
                    Console.WriteLine("Finished downloading file");
                    //Check if file exists. check if return success
                    return(true);
                }
            }
            return(false);
        }
Ejemplo n.º 2
0
        public Boolean init7z()
        {
            binPath = Path.Combine(appPath, "7zr");
            if (osID == 1)
            {
                binPath += ".exe";
            }

            if (!File.Exists(binPath))
            {
                Console.WriteLine("Downloading 7zip binary");
                jsonClass jsC = new jsonClass {
                    debugFlag = true, connectURL = connectURL
                };

                dlProps dlzip = new dlProps
                {
                    token = tokenID
                };


                string jsonString = jsC.toJson(dlzip);
                string ret        = jsC.jsonSend(jsonString);
                if (jsC.isJsonSuccess(ret))

                {
                    string        dlLocation = jsC.getRetVar(ret, "executable");
                    downloadClass dlClass    = new downloadClass();

                    if (!dlClass.DownloadFile(dlLocation, binPath))
                    {
                        Console.WriteLine("Unable to download requested file");
                    }
                    else
                    {
                        Console.WriteLine("Finished downloading file");
                    }
                }
                if (osID != 1) //If OS is not windows, we need to set the permissions
                {
                    try
                    {
                        Console.WriteLine("Applying execution permissions to 7zr binary");
                        Process.Start("chmod", "+x \"" + binPath + "\"");
                    }
                    catch (Exception e)
                    {
                        Console.Write(e.Data);
                        Console.WriteLine("Unable to change access permissions of 7zr, execution permissions required");
                    }
                }
            }

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

            return(false);
        }
Ejemplo n.º 3
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);
        }
Ejemplo n.º 4
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);
                    }
                }
            }
        }