コード例 #1
0
        private void ReadLog()
        {
            wa.selectApi = wa.selectApi.Replace("table", "accesslog");
            string MaxID = null;

            while (true)
            {
                object o = new
                {
                    id__gt = MaxID
                };
                var     res = HttpHleper.PostMoths(wa.selectApi, o, null, DCookieContainer);
                JObject js  = JObject.Parse(res);
                if (js["status"].ToString() == "error" && js["msg"].ToString() == "没有查询到对应的数据")
                {
                    ILog.log.Debug($"数据查完了,没有多余的数据");
                    Thread.Sleep(6000);
                }
                else
                {
                    string count = js["data_count"].ToString();///总的记录条数
                    JArray jlist = JArray.Parse(js["data"].ToString());
                    MaxID = jlist[jlist.Count - 1]["id"].ToString();
                    foreach (var item in jlist)
                    {
                        mm.WriteAccessLog(item);
                    }
                }
            }
        }
コード例 #2
0
 public void GetCookie()
 {
     try
     {
         object s = new
         {
             username = this.XmlData.Name,
             password = this.XmlData.Password
         };
         var     raspone = HttpHleper.PostMoths($"http://{this.XmlData.Domain}/login_api/", s, null, null);
         JObject json    = JObject.Parse(raspone);
         string  token   = json["user_token"].ToString();
         DCookieContainer = new CookieContainer();
         ck        = new Cookie("user_token", token);
         ck.Domain = this.XmlData.Ip;
         DCookieContainer.Add(ck);
     }
     catch (Exception ex)
     {
         ILog.log.Error($"错误信息:{ex}====获取token失败");
     }
 }
コード例 #3
0
        /// <summary>
        /// 读取api返回的信息 处理后进行第二次的上传文件
        /// 此函数用于增加漏洞
        /// </summary>
        public string ReadResultDeal(string result, string filePath, TaskFileiInfo taskid)
        {
            var res = "";

            try
            {
                JObject job = (JObject)JsonConvert.DeserializeObject(result);
                //重要的得到id 和文件名
                string status = job["status"].ToString();
                if (status == "success")
                {
                    ILog.log.Debug($"上传第一次数据返回的信息:{job}");
                    string id       = job["data"]["id"].ToString();
                    string filename = job["data"]["evilfile"].ToString().Trim('/');//evilfile   "file_a22e624b-6b38-4b8a-8c66-cba4d95c747a.7z"
                    filename = filename.Replace("_", "__");
                    string data = string.Format("id={0}&evilfile={1}", id, filename);
                    string aa   = filename.Split('_')[2].ToString() + "=";
                    filePath = string.Format("{0}" + filePath, aa);
                    string updateApi = wa.updateApi;
                    string url       = updateApi.Replace("table", "exploit");
                    string newUrl    = url.Replace("id", id);
                    res = HttpHleper.PostExploit(newUrl, data, filePath, DCookieContainer);
                }
                else
                {
                    ILog.log.Debug($"上传文件之前的发送json给api返回的是失败的状态:{result}");
                    taskid.DealResult = ApiStatus.fail;
                }
            }
            catch (Exception ex)
            {
                ILog.log.Error($"错误信息:{ex}====ReadResultDeal中处理出现了问题");
                taskid.DealResult = ApiStatus.fail;
            }
            return(res);
        }
コード例 #4
0
        public static IList <GameDataModel> HttpGetResult(CollectConfigModel item, Action <GiftBaseData, bool> CallBack)
        {
            var gameList = new List <GameDataModel>();

            if (string.IsNullOrEmpty(item.Url))
            {
                return(null);
            }

            var status    = EnumHelper.GetDescription(item.GiftStatus);
            var giftType  = EnumHelper.GetDescription(item.GiftType);
            var plateform = EnumHelper.GetDescription(item.GiftPlatForm);
            //处理分页问题
            var totalRegex = new Regex(ConstantHelper.TotalGifts);
            //获取总条数采集地址
            var requsetUrl = string.Format(item.Url, plateform, giftType, status);

            string totalResults = new HttpHleper().GetString(requsetUrl, "UTF-8");

            var totalCounts = totalRegex.Matches(totalResults);

            if (totalCounts.Count > 0)
            {
                item.Count = int.Parse(totalCounts[0].Value);
                item.Page  = (item.Count + item.PageSize - 1) / item.PageSize;
            }

            for (int i = 1; i <= item.Count; i++)
            {
                //检测Url为空返回
                string result = "";
                //result = await new HttpHleper().GetStringAsync(requsetUrl, "UTF-8");
                result = new HttpHleper().GetString(string.Concat(requsetUrl, string.Format("&p={0}", i)), "UTF-8");
                //result = new HttpHleper().GetHtml(requsetUrl, "", null, @"<table class=""newGifts"">", "</table>", false);
                //正则匹配数据
                var ScopeRegex        = new Regex(ConstantHelper.ContentScopeRegx);
                var nameRegx          = new Regex(ConstantHelper.NameRegx);
                var validateTimeRegex = new Regex(ConstantHelper.ValidateTimeRegx);
                var remainRegex       = new Regex(ConstantHelper.RemainRegx);
                var urlRegex          = new Regex(ConstantHelper.UrlRegx);

                //获取内容
                var searchMatchData = ScopeRegex.Matches(result);
                //int count = searchMatchData.Count;
                foreach (Match NextMatch in searchMatchData)
                {
                    var str = NextMatch.Value;
                    if (nameRegx.IsMatch(str))
                    {
                        var model = new GameDataModel();
                        try
                        {
                            model.PlateForm      = plateform;
                            model.GiftType       = item.GiftType;
                            model.GiftTypeName   = giftType;
                            model.GiftStatus     = item.GiftStatus;
                            model.GiftStatusName = status;
                            //1.匹配名称
                            var nameData = nameRegx.Matches(str);
                            if (nameData.Count > 0)
                            {
                                model.Name = nameData[0].Value;
                            }
                            //2.提取有效时间
                            var validateTimeData = validateTimeRegex.Matches(str);
                            if (validateTimeData.Count > 0)
                            {
                                model.ValidateTime = validateTimeData[0].Value;
                            }
                            //3.提取礼包剩余量
                            var remainData = remainRegex.Matches(str);
                            if (remainData.Count > 0)
                            {
                                model.Remain = remainData[0].Value;
                            }
                            //4.提取游戏抢包详细页面
                            var urlData = urlRegex.Matches(str);
                            if (urlData.Count > 0)
                            {
                                model.Url = urlData[0].Value;
                            }
                            if (!string.IsNullOrEmpty(model.Name))
                            {
                                gameList.Add(model);
                                GiftBaseData basedata = new GiftBaseData
                                {
                                    GiftName       = model.Name,
                                    GiftStatus     = model.GiftStatus.GetHashCode(),
                                    GiftStatusName = model.GiftStatusName,
                                    GiftType       = model.GiftType.GetHashCode(),
                                    GiftTypeName   = model.GiftTypeName,
                                    PlateForm      = model.PlateForm,
                                    Remain         = model.Remain,
                                    Url            = model.Url,
                                    ValidateTime   = model.ValidateTime
                                };
                                CallBack(basedata, false);
                            }
                        }
                        catch (Exception)
                        {
                            throw;
                        }
                    }
                }
            }

            return(gameList);
        }
コード例 #5
0
        public void UpdatePostApi(Dictionary <TaskFileiInfo, JObject> JsonData)
        {
            if (JsonData.Count != 0)
            {
                TaskFileiInfo key       = null;
                string        updateApi = null;
                string        id        = null;
                string        result    = null;
                foreach (var item in JsonData)
                {
                    id        = item.Value["id"].ToString();
                    updateApi = wa.updateApi;

                    switch (item.Key.taskinfo.tasktype.table)
                    {
                    case "1":
                        updateApi = updateApi.Replace("table", "server");
                        updateApi = updateApi.Replace("id", id);
                        result    = HttpHleper.PostUrl(updateApi, item.Value.ToString(), DCookieContainer);
                        if (ResultIsSuccess(result) == true)
                        {
                            ILog.log.Debug($"{updateApi}请求成功返回的信息{result}");
                            item.Key.DealResult = ApiStatus.success;
                        }
                        else
                        {
                            ILog.log.Debug($"{updateApi}请求失败返回的信息{result}");
                            item.Key.DealResult = ApiStatus.fail;
                        }
                        break;

                    case "2":
                        updateApi = updateApi.Replace("table", "exploit");
                        updateApi = updateApi.Replace("id", id);
                        result    = HttpHleper.PostUrl(updateApi, item.Value.ToString(), DCookieContainer);
                        if (ResultIsSuccess(result) == true)
                        {
                            if (item.Key.filepath.filepath != null)
                            {
                                result = ReadResultDeal(result, item.Key.filepath.filepath, item.Key);
                                if (ResultIsSuccess(result) == true)
                                {
                                    ILog.log.Debug($"{updateApi}请求成功返回的信息{result}");
                                    item.Key.DealResult = ApiStatus.success;
                                }
                                else
                                {
                                    ILog.log.Debug($"{updateApi}请求失败返回的信息{result}");
                                    item.Key.DealResult = ApiStatus.fail;
                                }
                            }
                        }
                        else
                        {
                            ILog.log.Debug($"{updateApi}请求失败返回的信息{result}");
                            item.Key.DealResult = ApiStatus.fail;
                        }
                        break;

                    case "3":
                        updateApi = updateApi.Replace("table", "worktime");
                        updateApi = updateApi.Replace("id", id);
                        result    = HttpHleper.PostUrl(updateApi, item.Value.ToString(), DCookieContainer);
                        if (ResultIsSuccess(result) == true)
                        {
                            ILog.log.Debug($"{updateApi}请求成功返回的信息{result}");
                            item.Key.DealResult = ApiStatus.success;
                        }
                        else
                        {
                            ILog.log.Debug($"{updateApi}请求失败返回的信息{result}");
                            item.Key.DealResult = ApiStatus.fail;
                        }
                        break;

                    default:
                        break;
                    }


                    if (result != null)
                    {
                        key = IsSuccess(result, key, item.Key);
                    }
                }
                if (key != null)
                {
                    DeleteFile(key, JsonData);
                }
            }
        }
コード例 #6
0
//----------------------------------------------------------------------------
        #region  api请求相关的函数
        public void AddPostApi(Dictionary <TaskFileiInfo, JObject> JsonData)
        {
            if (JsonData.Count != 0)
            {
                string        addApi = null;
                TaskFileiInfo key    = null;
                string        result = null;
                foreach (var item in JsonData)
                {
                    addApi = wa.addApi;
                    switch (item.Key.taskinfo.tasktype.table)
                    {
                    case "1":
                        addApi = addApi.Replace("table", "server");
                        result = HttpHleper.PostMoths(addApi, item.Value, null, DCookieContainer);
                        if (ResultIsSuccess(result) == true)
                        {
                            ILog.log.Debug($"{addApi}请求成功返回的信息{result}");
                            item.Key.DealResult = ApiStatus.success;
                        }
                        else
                        {
                            ILog.log.Debug($"{addApi}请求失败返回的信息{result}");
                            item.Key.DealResult = ApiStatus.fail;
                        }

                        break;

                    case "2":
                        addApi = addApi.Replace("table", "exploit");
                        ILog.log.Trace($"===urls地址======================={addApi}=============================");
                        result = HttpHleper.PostUrl(addApi, item.Value.ToString(), DCookieContainer);

                        if (ResultIsSuccess(result) == true)
                        {
                            if (item.Key.filepath.filepath != null)
                            {
                                result = ReadResultDeal(result, item.Key.filepath.filepath, item.Key);
                                if (ResultIsSuccess(result) == true)
                                {
                                    ILog.log.Debug($"{addApi}请求成功返回的信息{result}");
                                    item.Key.DealResult = ApiStatus.success;
                                }
                                else
                                {
                                    ILog.log.Debug($"{addApi}请求失败返回的信息{result}");
                                    item.Key.DealResult = ApiStatus.fail;
                                }
                            }
                        }
                        else
                        {
                            ILog.log.Debug($"{addApi}请求失败返回的信息{result}");
                            item.Key.DealResult = ApiStatus.fail;
                        }

                        break;

                    case "3":
                        addApi = addApi.Replace("table", "worktime");
                        result = HttpHleper.PostUrl(addApi, item.Value.ToString(), DCookieContainer);
                        if (ResultIsSuccess(result) == true)
                        {
                            ILog.log.Debug($"{addApi}请求成功返回的信息{result}");
                            item.Key.DealResult = ApiStatus.success;
                        }
                        else
                        {
                            ILog.log.Debug($"{addApi}请求失败返回的信息{result}");
                            item.Key.DealResult = ApiStatus.fail;
                        }
                        break;

                    default:
                        break;
                    }

                    if (result != null)
                    {
                        //这里返回key 的信息无论成功是否都删除
                        key = IsSuccess(result, key, item.Key);
                    }
                }
                if (null != key)
                {
                    DeleteFile(key, JsonData);
                }
            }
        }
コード例 #7
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="uname"></param>
        /// <returns>0:用户不存在</returns>
        public static string getToken(string uname)
        {
            string token = new HttpHleper().GetString(string.Format(tokenUrl, uname), "UTF-8");

            return(token);
        }