예제 #1
0
        public override Task InitAsync()
        {
            MsgTemplate         = LaunchArgs.Parent as MessageTemplate;
            Simulator           = LaunchArgs.GetParam <LagoVista.IoT.Simulator.Admin.Models.Simulator>("simulator");
            ReceivedMessageList = LaunchArgs.GetParam <ObservableCollection <ReceivedMessage> >("receviedmessages");

            BuildRequestContent();

            switch (Simulator.DefaultTransport.Value)
            {
            //                case TransportTypes.AMQP:
            case TransportTypes.MQTT:
            case TransportTypes.AzureIoTHub:
            case TransportTypes.TCP:
            case TransportTypes.UDP:
                //              case TransportTypes.RabbitMQ:
                ViewSelectorVisible = true;
                break;

            case TransportTypes.AzureEventHub:
            case TransportTypes.AzureServiceBus:
            case TransportTypes.RestHttp:
            case TransportTypes.RestHttps:
                ViewSelectorVisible = false;
                break;
            }

            ShowSendStatus();

            return(base.InitAsync());
        }
예제 #2
0
        private async Task SendIoTHubMessage()
        {
            var textPayload = ReplaceTokens(MsgTemplate.TextPayload);
            var msg         = new Microsoft.Azure.Devices.Client.Message(GetMessageBytes());
            await LaunchArgs.GetParam <DeviceClient>("azureIotHubClient").SendEventAsync(msg);

            ReceivedContennt = $"{DateTime.Now} {SimulatorCoreResources.SendMessage_MessagePublished}";
        }
예제 #3
0
 private void OKTapped()
 {
     if (!String.IsNullOrEmpty(PasswordOrAccessKey))
     {
         LaunchArgs.SelectedAction(PasswordOrAccessKey);
         this.CloseScreen();
     }
 }
예제 #4
0
 static void StartServer(LaunchArgs arg)
 {
     ServerConnection = new TcpClient();
     ServerConnection.Connect(arg.IP);
     ServerStream = ServerConnection.GetStream();
     if (arg.Password != null)
     {
         SendPassword(arg.Password);
     }
 }
예제 #5
0
        public OldUnitDiffReporter()
        {
            var filePathFinder = new FilePathFinder();

            imageDiffTool   = filePathFinder.Find(imageDiffTool);
            textDiffProgram = filePathFinder.Find(textDiffProgram);

            var tortoise = new LaunchArgs(textDiffProgram, textDiffArguments);

            AddDiffReporter("*", tortoise);
            AddDiffReporter(".tif", new LaunchArgs(imageDiffTool, imageDiffArgs));
            AddDiffReporter(".tiff", new LaunchArgs(imageDiffTool, imageDiffArgs));
            AddDiffReporter(".png", new LaunchArgs(imageDiffTool, imageDiffArgs));
        }
예제 #6
0
        public override Task <InvokeResult> SaveRecordAsync()
        {
            if (IsCreate)
            {
                var parent = LaunchArgs.GetParent <IoT.Simulator.Admin.Models.MessageTemplate>();
                if (parent.MessageHeaders.Where(attr => attr.Key == Model.Key).Any())
                {
                    return(Task.FromResult(InvokeResult.FromErrors(ClientResources.Common_KeyInUse.ToErrorMessage())));
                }
                parent.MessageHeaders.Add(Model);
            }

            return(Task.FromResult(InvokeResult.Success));
        }
예제 #7
0
        private async Task SendMQTTMessage()
        {
            var qos = QOS.QOS0;

            if (!EntityHeader.IsNullOrEmpty(MsgTemplate.QualityOfServiceLevel))
            {
                switch (MsgTemplate.QualityOfServiceLevel.Value)
                {
                case QualityOfServiceLevels.QOS1: qos = QOS.QOS1; break;

                case QualityOfServiceLevels.QOS2: qos = QOS.QOS2; break;
                }
            }

            await LaunchArgs.GetParam <IMQTTDeviceClient>("mqttclient").PublishAsync(ReplaceTokens(MsgTemplate.Topic), GetMessageBytes(), qos, MsgTemplate.RetainFlag);

            ReceivedContennt = $"{DateTime.Now} {SimulatorCoreResources.SendMessage_MessagePublished}";
        }
예제 #8
0
        public override Task InitAsync()
        {
            if (!LaunchArgs.HasParam(VIEW_TYPE))
            {
                throw new Exception("Must pass in VIEW_TYPE as parameter.");
            }
            if (!LaunchArgs.HasParam(VIEW_NAME))
            {
                throw new Exception("Must pass in VIEW_TYPE as parameter.");
            }

            Id        = LaunchArgs.ChildId;
            ViewType  = LaunchArgs.Parameters[VIEW_TYPE].ToString();
            ViewTitle = LaunchArgs.Parameters[VIEW_NAME].ToString();

            ShowStatusHistory();

            return(base.InitAsync());
        }
예제 #9
0
 static void Cont(LaunchArgs opts)
 {
     try
     {
         if (!ValidateArgs(opts))
         {
             Die("Couldn't find one or more required files, exiting.");
         }
         if (opts.AutoConvert)
         {
             ConversionHelper.ConvertHandshakes(opts).Wait();
         }
         RunHashCat(opts);
     }
     catch (Exception ex)
     {
         Die(ex.Message);
     }
 }
예제 #10
0
        public async override Task <InvokeResult> SaveRecordAsync()
        {
            var result = Validator.Validate(this.Model);

            if (LaunchArgs.LaunchType == LaunchTypes.Create)
            {
                var parent = LaunchArgs.GetParent <IoT.Simulator.Admin.Models.Simulator>();
                if (parent.MessageTemplates.Where(tmp => tmp.Key == Model.Key).Any())
                {
                    await this.Popups.ShowAsync(ClientResources.Common_KeyInUse);

                    return(InvokeResult.FromErrors(ClientResources.Common_KeyInUse.ToErrorMessage()));
                }

                parent.MessageTemplates.Add(Model);
            }

            return(InvokeResult.Success);
        }
예제 #11
0
        static void Main(string[] args)
        {
            LaunchArgs.Init(args);
            ModuleCollection[] collections = ModuleCollection.LoadRequestedCollections();

            switch (LaunchArgs.GetValue("action"))
            {
            case "Build":
                Logger.Log("Attempting to build VisualStudio files");
                ActionPrepIDE.Run(collections);
                break;

            default:
                Logger.LogFatal("You must specify a launch valid action");
                break;
            }

            Logger.Log("Action completed..");
            Console.ReadKey();
        }
예제 #12
0
        static bool ValidateArgs(LaunchArgs opts)
        {
            opts.InDir   = Path.GetFullPath(opts.InDir);
            opts.OutDir  = Path.GetFullPath(opts.OutDir);
            opts.DictDir = Path.GetFullPath(opts.DictDir);

            try
            {
                if (File.Exists("hashcat64.exe"))
                {
                    opts.HashCatExec = "hashcat64.exe";
                }
                if (!File.Exists(opts.HashCatExec))
                {
                    return(false);
                }
                if (!Directory.Exists(opts.OutDir))
                {
                    Directory.CreateDirectory(opts.OutDir);
                }
                if (opts.AutoConvert && Directory.GetFiles(opts.InDir, "*.pcap").Length == 0)
                {
                    return(false);
                }
                if (!opts.AutoConvert && Directory.GetFiles(opts.InDir, "*.hccapx").Length == 0)
                {
                    return(false);
                }
                if (Directory.GetFiles(opts.DictDir).Length == 0)
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                Die(ex.Message);
            }

            return(true);
        }
예제 #13
0
        /// <summary>
        /// Reads all files in a given directory, sends them to the hashcat.net online conversion tool.
        /// Only saves the result in inputPath\converted if it's a VALID handshake
        /// </summary>
        /// <param name="inputPath"></param>
        /// <returns></returns>
        public static async Task ConvertHandshakes(LaunchArgs opts)
        {
            string convDir = Path.Combine(opts.InDir, @"converted\");

            if (!Directory.Exists(convDir))
            {
                Directory.CreateDirectory(convDir);
            }

            foreach (var handshake in Directory.GetFiles(opts.InDir))
            {
                Console.Write("Converting {0}... ", Path.GetFileNameWithoutExtension(handshake));
                if (new FileInfo(handshake).Length > 20000000)
                {
                    continue;                                            //Make sure the pcap is smaller than 20MB
                }
                HttpContent bytesContent = new ByteArrayContent(File.ReadAllBytes(handshake));
                using (var client = new HttpClient())
                    using (var formData = new MultipartFormDataContent())
                    {
                        formData.Add(bytesContent, "\"file\"", String.Format("\"{0}\"", Path.GetFileName(handshake)));
                        var response = await client.PostAsync(@"https://hashcat.net/cap2hccapx/index.pl", formData);

                        var convBytes = await response.Content.ReadAsByteArrayAsync();

                        if (!new StreamReader(new MemoryStream(convBytes)).ReadToEnd().ToLower().StartsWith("networks detected:"))
                        {
                            File.WriteAllBytes(Path.Combine(convDir, Path.GetFileNameWithoutExtension(handshake) + ".hccapx"), convBytes);
                            Console.WriteLine("Done");
                        }
                        else
                        {
                            Console.WriteLine("Invalid");
                        }
                    }

                opts.InDir = convDir;
            }
        }
예제 #14
0
        public static ModuleCollection[] LoadRequestedCollections()
        {
            List <ModuleCollection> collections = new List <ModuleCollection>();

            string[] targetFiles = LaunchArgs.GetTargetFiles();
            Logger.Log("Attempting to load " + targetFiles.Length + " collections", 3);

            foreach (string str in targetFiles)
            {
                ModuleCollection collection;

                if (!ModuleCollection.TryLoadFromURL(str, out collection))
                {
                    Logger.LogWarning("Failed to load collection '" + str + "'; skipping");
                    continue;
                }
                else
                {
                    collections.Add(collection);
                }
            }

            return(collections.ToArray());
        }
예제 #15
0
 /// <param name = "extensionWithDot"> Use * for default</param>
 public void AddDiffReporter(string extensionWithDot, LaunchArgs fileParameters)
 {
     types[extensionWithDot] = fileParameters;
 }
 protected async override void ItemSelected(DeviceTypeSummary model)
 {
     LaunchArgs.SelectedAction(model);
     await ViewModelNavigation.GoBackAsync();
 }
예제 #17
0
        protected override void BuildForm(EditFormAdapter form)
        {
            if (IsCreate)
            {
                var parent = LaunchArgs.GetParent <IoT.Simulator.Admin.Models.Simulator>();
                Model.EndPoint    = parent.DefaultEndPoint;
                Model.Port        = parent.DefaultPort;
                Model.Transport   = parent.DefaultTransport;
                Model.QueueName   = parent.QueueName;
                Model.PayloadType = parent.DefaultPayloadType;

                View[nameof(Model.TextPayload).ToFieldKey()].IsVisible   = false;
                View[nameof(Model.BinaryPayload).ToFieldKey()].IsVisible = false;
            }

            if (!EntityHeader.IsNullOrEmpty(Model.Transport))
            {
                ShowErrorMessage = false;
                HasTransport     = true;


                View[nameof(Model.TextPayload).ToFieldKey()].IsVisible   = Model.PayloadType.Value == PaylodTypes.String;
                View[nameof(Model.BinaryPayload).ToFieldKey()].IsVisible = Model.PayloadType.Value == PaylodTypes.Binary;

                form.OptionSelected += Form_OptionSelected;
                form.DeleteItem     += Form_DeleteItem;
                View[nameof(Model.Key).ToFieldKey()].IsUserEditable = IsCreate;
                form.AddViewCell(nameof(Model.Name));
                form.AddViewCell(nameof(Model.Key));

                /* At some point we may want to allow one simulator to target different transports/endpoint/ports
                 * form.AddViewCell(nameof(Model.Transport));
                 * form.AddViewCell(nameof(Model.EndPoint));
                 * form.AddViewCell(nameof(Model.Port));
                 */

                form.AddViewCell(nameof(Model.QualityOfServiceLevel));
                form.AddViewCell(nameof(Model.RetainFlag));
                form.AddViewCell(nameof(Model.To));
                form.AddViewCell(nameof(Model.MessageId));
                form.AddViewCell(nameof(Model.QueueName));
                form.AddViewCell(nameof(Model.Topic));
                form.AddViewCell(nameof(Model.AppendCR));
                form.AddViewCell(nameof(Model.AppendLF));
                form.AddViewCell(nameof(Model.PayloadType));
                form.AddViewCell(nameof(Model.ContentType));
                form.AddViewCell(nameof(Model.HttpVerb));
                form.AddViewCell(nameof(Model.TextPayload));
                form.AddViewCell(nameof(Model.BinaryPayload));
                form.AddViewCell(nameof(Model.PathAndQueryString));

                if (Model.Transport.Value == TransportTypes.RestHttp ||
                    Model.Transport.Value == TransportTypes.RestHttps)
                {
                    form.AddChildList <MessageHeaderViewModel>(nameof(Model.MessageHeaders), Model.MessageHeaders);
                }

                form.AddChildList <DynamicAttributeViewModel>(nameof(Model.DynamicAttributes), Model.DynamicAttributes);

                ModelToView(Model, form);

                HideAll();

                switch (Model.Transport.Value)
                {
                case TransportTypes.AzureIoTHub: SetForAzureIoTHub(); break;

                case TransportTypes.AzureEventHub: SetForAzureEventHub(); break;

                case TransportTypes.MQTT: SetForMQTT(); break;

                case TransportTypes.TCP: SetForTCP(); break;

                case TransportTypes.UDP: SetForUDP(); break;

                case TransportTypes.AzureServiceBus: SetForServiceBus(); break;

                case TransportTypes.RestHttp:
                case TransportTypes.RestHttps: SetForREST(); break;
                }
            }
            else
            {
                ShowErrorMessage = true;
                HasTransport     = false;
            }
        }
예제 #18
0
        /// <summary>
        /// lib类的构造函数
        /// </summary>
        /// <param name="jToken">传入的json标签</param>
        /// <param name="GamePath">游戏路径</param>

        public Libraries(JToken jToken, string GamePath)
        {
            type = LibOperation.GetLibType(jToken);
            switch (type)
            {
            case 0:
                downloads = new Downloads(jToken, type);
                name      = jToken[LibOperation.NAME].ToString();
                path      = downloads.artifact.path;
                path      = path.Replace("/", @"\");
                fullPath  = GamePath + @"\libraries\" + path;
                url       = downloads.artifact.url != null ? downloads.artifact.url : null;
                break;

            case 1:
                downloads = new Downloads(jToken, type);
                name      = jToken[LibOperation.NAME].ToString();
                if (downloads.classifiers.natives_windows == null)
                {
                    if (jToken[LibOperation.NATIVES] != null)
                    {
                        natives = new Natives(jToken);
                    }
                    else
                    {
                        path     = downloads.artifact.path;
                        path     = path.Replace("/", @"\");
                        fullPath = GamePath + @"\libraries\" + path;
                        url      = downloads.artifact.url;
                    }
                }
                else
                {
                    path     = downloads.classifiers.natives_windows.path;
                    path     = path.Replace("/", @"\");
                    fullPath = GamePath + @"\libraries\" + path;
                    url      = downloads.classifiers.natives_windows.url != null ? downloads.classifiers.natives_windows.url : null;
                }
                isNatives = true;
                break;

            case 2:
                name     = jToken[LibOperation.NAME].ToString();
                url_half = jToken[LibOperation.URL].ToString();
                clintReq = jToken[LibOperation.CLIENTREQ] != null ? jToken[LibOperation.CLIENTREQ].ToString() == "true" ? true : false : true;
                path     = LaunchArgs.ConvertPackageToPath(name, null);
                path     = path.Replace("/", @"\");
                url      = url_half + path.Replace(@"\", "/");
                fullPath = GamePath + @"\libraries\" + path;
                break;

            case 3:
                name     = jToken[LibOperation.NAME].ToString();
                path     = LaunchArgs.ConvertPackageToPath(name, null);
                path     = path.Replace("/", @"\");
                fullPath = GamePath + @"\libraries\" + path;
                break;

            default:
                throw (new TypeErrException("Cannot find proper type for this token."));
            }
            if (clintReq == false)
            {
                isUseful = false;
            }
        }
예제 #19
0
        public static void Main(string[] args)
        {
            Console.Title = "Colony Survival RCON Client";
            Console.WriteLine("Launching Colony Survival RCON Client");

            if (args.Length > 0)
            {
                LaunchArgs LaunchArgs = new LaunchArgs();
                int        i          = 0;
                while (i < args.Length - 1)
                {
                    if (string.Equals(args[i], "+server", StringComparison.Ordinal))
                    {
                        int       splitPos = args[i + 1].IndexOf(':');
                        int       port     = int.Parse(args[i + 1].Substring(splitPos + 1, args[i + 1].Length - (splitPos + 1)));
                        IPAddress ip       = IPAddress.Parse(args[i + 1].Substring(0, splitPos));
                        LaunchArgs.IP = new IPEndPoint(ip, port);
                        i            += 2;
                    }
                    else if (string.Equals(args[i], "+password", StringComparison.Ordinal))
                    {
                        LaunchArgs.Password = args[i + 1];
                        i += 2;
                    }
                    else
                    {
                        i++;
                    }
                }

                if (LaunchArgs.IP != null)
                {
                    StartServer(LaunchArgs);
                }
                else
                {
                    ListHelp();
                }
            }
            else
            {
                ListHelp();
            }

            while (true)
            {
                if (Console.KeyAvailable)
                {
                    ReadWriteLogs();
                    Console.WriteLine("--Logging paused. Enter your command:");
                    Console.Write("> ");
                    if (Environment.OSVersion.Platform == PlatformID.Unix || Environment.OSVersion.Platform == PlatformID.MacOSX)
                    {
                        Console.ReadKey(true);
                    }
                    string read = Console.ReadLine();
                    if (read != null)
                    {
                        read = read.TrimStart(' ', '\t', '\n', '\r');
                    }
                    if (string.IsNullOrEmpty(read))
                    {
                        Console.WriteLine("--Logging continue");
                        continue;
                    }

                    string   start  = read;
                    string[] splits = null;
                    if (read.Contains(" "))
                    {
                        splits = read.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);
                        start  = splits[0];
                    }

                    switch (start)
                    {
                    case "list":
                    case "?":
                    case "help":
                        ListHelp();
                        start = null;
                        break;
                    }

                    if (start != null)
                    {
                        if (ServerConnection != null && ServerConnection.Connected)
                        {
                            switch (start)
                            {
                            case "quit_server":
                                StopServer();
                                break;

                            case "chat":
                                SendChat(read.Remove(0, "send ".Length));
                                break;

                            case "players":
                                SendPlayers();
                                break;

                            default:
                                Console.WriteLine("Unknown command");
                                break;
                            }
                        }
                        else
                        {
                            switch (start)
                            {
                            case "connect":
                                StartServer(splits[1], splits[2]);
                                break;

                            default:
                                Console.WriteLine("Unknown command");
                                break;
                            }
                        }
                    }

                    Console.WriteLine("--Logging continue");
                }
                ReadWriteLogs();
                Thread.Sleep(50);
            }
        }
예제 #20
0
 private void CancelledTapped()
 {
     LaunchArgs.CancelledAction();
     this.CloseScreen();
 }
예제 #21
0
        static void RunHashCat(LaunchArgs opts)
        {
            Console.WriteLine();
            Console.WriteLine(
                @"
_________________________________________________________
   _____ _____            _____ _  _______ _   _  _____ 
  / ____|  __ \     /\   / ____| |/ /_   _| \ | |/ ____|
 | |    | |__) |   /  \ | |    | ' /  | | |  \| | |  __ 
 | |    |  _  /   / /\ \| |    |  <   | | | . ` | | |_ |
 | |____| | \ \  / ____ \ |____| . \ _| |_| |\  | |__| |
  \_____|_|  \_\/_/    \_\_____|_|\_\_____|_| \_|\_____|
_________________________________________________________");
            var outDir = Path.Combine(opts.OutDir + @"\" + DateTime.Now.ToString("dd-MM-yy hh,mm"));

            Directory.CreateDirectory(outDir);
            foreach (var handshake in Directory.GetFiles(opts.InDir, "*.hccapx"))
            {
                var hskDir = Path.Combine(outDir, Path.GetFileNameWithoutExtension(handshake));
                Directory.CreateDirectory(hskDir);

                var crackedList = new List <string>();
                foreach (var dictionary in Directory.GetFiles(opts.DictDir).OrderBy(d => new FileInfo(d).Length))
                {
                    var logFile = Path.Combine(hskDir, Path.GetFileNameWithoutExtension(dictionary) + ".txt");
                    using (var sw = new StreamWriter(logFile))
                    {
                        Console.Write("{0}: Running {1} {2} ", DateTime.Now.ToString("hh:mm:ss"), Path.GetFileNameWithoutExtension(handshake), Path.GetFileNameWithoutExtension(dictionary));
                        ProcessStartInfo hashCatInf = new ProcessStartInfo(opts.HashCatExec, String.Format("-m 2500 -w 4 \"{0}\" \"{1}\"", handshake, dictionary))
                        {
                            UseShellExecute        = false,
                            RedirectStandardOutput = true
                        };

                        var hashCatProc = new Process()
                        {
                            StartInfo = hashCatInf
                        };

                        hashCatProc.OutputDataReceived += (sender, args) =>
                        {
                            sw.WriteLine(args.Data);
                            sw.Flush();
                        };

                        hashCatProc.Start();

                        hashCatProc.BeginOutputReadLine();

                        hashCatProc.WaitForExit();

                        sw.Close();
                    }
                    using (var sr = new StreamReader(logFile))
                    {
                        var res = sr.ReadToEnd();

                        if (!res.Contains("Exhausted"))
                        {
                            Console.ForegroundColor = ConsoleColor.Green;
                            Console.WriteLine(" CRACKED!");
                            crackedList.Add(String.Format("{0} - {1}", Path.GetFileNameWithoutExtension(handshake), Path.GetFileNameWithoutExtension(dictionary)));
                        }
                        else
                        {
                            Console.ForegroundColor = ConsoleColor.Red;
                            Console.WriteLine(" Exhausted");
                        }
                        Console.ForegroundColor = ConsoleColor.Gray;
                    }
                }
                if (crackedList.Any())
                {
                    using (var sw = new StreamWriter(Path.Combine(hskDir, "cracked.txt")))
                        foreach (var hsk in crackedList)
                        {
                            sw.WriteLine(hsk);
                        }
                }
            }
        }
예제 #22
0
 private async Task SendUDPMessage()
 {
     var buffer = GetMessageBytes();
     await LaunchArgs.GetParam <IUDPClient>("udpclient").WriteAsync(buffer, 0, buffer.Length);
 }
예제 #23
0
 public OldUnitDiffReporter(LaunchArgs defaultLauncher)
 {
     AddDiffReporter("*", defaultLauncher);
 }
예제 #24
0
 public void Launch(LaunchArgs launchArgs)
 {
     Process.Start(launchArgs.Program, launchArgs.Arguments);
 }