Browse Source

修复安全漏洞

娄底高职分支
dao 2 months ago
parent
commit
1bdf8ce755
6 changed files with 67 additions and 6 deletions
  1. +2
    -0
      Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Controllers/EmpInfoEnternalController.cs
  2. +4
    -0
      Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_TaskScheduling/Controllers/TSSchemeController.cs
  3. +36
    -6
      Learun.Framework.Ultimate V7/Learun.Application.Web/Controllers/UserCenterController.cs
  4. +23
    -0
      Learun.Framework.Ultimate V7/Learun.Application.Web/Extensions/StrHelper.cs
  5. +1
    -0
      Learun.Framework.Ultimate V7/Learun.Application.Web/Learun.Application.Web.csproj
  6. +1
    -0
      Learun.Framework.Ultimate V7/Learun.Application.WebApi/Modules/SunshineEducationApi.cs

+ 2
- 0
Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Controllers/EmpInfoEnternalController.cs View File

@@ -7,6 +7,7 @@ using System.Linq;
using System.Web; using System.Web;
using System.Web.Mvc; using System.Web.Mvc;
using Learun.Application.Organization; using Learun.Application.Organization;
using Learun.Application.Web.Extensions;


namespace Learun.Application.Web.Areas.EducationalAdministration.Controllers namespace Learun.Application.Web.Areas.EducationalAdministration.Controllers
{ {
@@ -36,6 +37,7 @@ namespace Learun.Application.Web.Areas.EducationalAdministration.Controllers
[AjaxOnly] [AjaxOnly]
public ActionResult GetMap(string code, string ver, string where) public ActionResult GetMap(string code, string ver, string where)
{ {
where=StrHelper.DelErrChar(where);
var data = dataSourceIBLL.GetDataTable(code, where); var data = dataSourceIBLL.GetDataTable(code, where);


string md5 = Md5Helper.Encrypt(data.ToJson(), 32); string md5 = Md5Helper.Encrypt(data.ToJson(), 32);


+ 4
- 0
Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_TaskScheduling/Controllers/TSSchemeController.cs View File

@@ -1,5 +1,6 @@
using Learun.Application.Extention.TaskScheduling; using Learun.Application.Extention.TaskScheduling;
using Learun.Util; using Learun.Util;
using System.Text.RegularExpressions;
using System.Web.Mvc; using System.Web.Mvc;


namespace Learun.Application.Web.Areas.LR_TaskScheduling.Controllers namespace Learun.Application.Web.Areas.LR_TaskScheduling.Controllers
@@ -123,6 +124,9 @@ namespace Learun.Application.Web.Areas.LR_TaskScheduling.Controllers
[AjaxOnly] [AjaxOnly]
public ActionResult SaveForm(string keyValue,string strSchemeInfo,string strScheme) public ActionResult SaveForm(string keyValue,string strSchemeInfo,string strScheme)
{ {
//var rex = new Regex("exec", RegexOptions.IgnoreCase);
//strScheme = rex.Replace(strScheme, "");
if (strScheme.ToLower().Contains("exec")) return Fail("不可执行EXEC命令");
TSSchemeInfoEntity tSSchemeInfoEntity = strSchemeInfo.ToObject<TSSchemeInfoEntity>(); TSSchemeInfoEntity tSSchemeInfoEntity = strSchemeInfo.ToObject<TSSchemeInfoEntity>();
TSSchemeEntity tSSchemeEntity = new TSSchemeEntity() { TSSchemeEntity tSSchemeEntity = new TSSchemeEntity() {
F_Scheme = strScheme, F_Scheme = strScheme,


+ 36
- 6
Learun.Framework.Ultimate V7/Learun.Application.Web/Controllers/UserCenterController.cs View File

@@ -273,6 +273,7 @@ namespace Learun.Application.Web.Controllers
UserInfo userInfo = LoginUserInfo.Get(); UserInfo userInfo = LoginUserInfo.Get();


string FileEextension = Path.GetExtension(files[0].FileName); string FileEextension = Path.GetExtension(files[0].FileName);
if (FileEextension.ToLower() != ".png" && FileEextension.ToLower() != ".jpg") return Fail("只可上传JPG、PNG格式的图片");
string filePath = Config.GetValue("AnnexesFile"); string filePath = Config.GetValue("AnnexesFile");
string uploadDate = DateTime.Now.ToString("yyyyMMdd"); string uploadDate = DateTime.Now.ToString("yyyyMMdd");
string fileGuid = Guid.NewGuid().ToString(); string fileGuid = Guid.NewGuid().ToString();
@@ -285,12 +286,41 @@ namespace Learun.Application.Web.Controllers
Directory.CreateDirectory(path); Directory.CreateDirectory(path);
files[0].SaveAs(fullFileName); files[0].SaveAs(fullFileName);


UserEntity userEntity = new UserEntity();
userEntity.F_UserId = userInfo.userId;
userEntity.F_Account = userInfo.account;
userEntity.F_HeadIcon = saveFileName;
userIBLL.SaveEntity(userEntity.F_UserId, userEntity);
return Success("上传成功。");
var fs = new System.IO.FileStream(fullFileName, System.IO.FileMode.Open, System.IO.FileAccess.Read);
var r = new System.IO.BinaryReader(fs);
string fileclass = "";
byte buffer;
try
{
buffer = r.ReadByte();
fileclass = buffer.ToString();
buffer = r.ReadByte();
fileclass += buffer.ToString();

}
catch
{

}
r.Close();
fs.Close();
if (fileclass == "255216" || fileclass == "13780")//说明255216是jpg;7173是gif;6677是BMP,13780是PNG;7790是exe,8297是rar
{
UserEntity userEntity = new UserEntity();
userEntity.F_UserId = userInfo.userId;
userEntity.F_Account = userInfo.account;
userEntity.F_HeadIcon = saveFileName;
userIBLL.SaveEntity(userEntity.F_UserId, userEntity);
return Success("上传成功。");
}
else
{
System.IO.File.Delete(fullFileName);
return Fail("只可上传JPG、PNG格式的图片");
}


} }
/// <summary> /// <summary>
/// 验证旧密码 /// 验证旧密码


+ 23
- 0
Learun.Framework.Ultimate V7/Learun.Application.Web/Extensions/StrHelper.cs View File

@@ -0,0 +1,23 @@
namespace Learun.Application.Web.Extensions
{
public class StrHelper
{

public static string DelErrChar(string str)
{
str = str.Trim().ToLower();
if (string.IsNullOrEmpty(str))
return string.Empty;

string[] ErrStr = new string[] { "select", "update", "insert", "delete", "'", ";", ":", "@", "or", "and", "drop", "alter", "create", "exec" };
for (int i = 0; i < ErrStr.Length; i++)
{
if (str.Contains(ErrStr[i]))
{
str = str.Replace(ErrStr[i], string.Empty);
}
}
return str;
}
}
}

+ 1
- 0
Learun.Framework.Ultimate V7/Learun.Application.Web/Learun.Application.Web.csproj View File

@@ -584,6 +584,7 @@
<Compile Include="Controllers\UserCenterController.cs" /> <Compile Include="Controllers\UserCenterController.cs" />
<Compile Include="Controllers\UtilityController.cs" /> <Compile Include="Controllers\UtilityController.cs" />
<Compile Include="Extensions\HtmlHelperExtensions.cs" /> <Compile Include="Extensions\HtmlHelperExtensions.cs" />
<Compile Include="Extensions\StrHelper.cs" />
<Compile Include="Global.asax.cs"> <Compile Include="Global.asax.cs">
<DependentUpon>Global.asax</DependentUpon> <DependentUpon>Global.asax</DependentUpon>
</Compile> </Compile>


+ 1
- 0
Learun.Framework.Ultimate V7/Learun.Application.WebApi/Modules/SunshineEducationApi.cs View File

@@ -74,6 +74,7 @@ namespace Learun.Application.WebApi
if (result.Result.code == "0") if (result.Result.code == "0")
{ {
redisCache.Write<string>("sunshinesmscode_"+mobileVerify.pagecode +"_"+ mobileVerify.mobile, raRndNum, new TimeSpan(0, 5, 0)); redisCache.Write<string>("sunshinesmscode_"+mobileVerify.pagecode +"_"+ mobileVerify.mobile, raRndNum, new TimeSpan(0, 5, 0));
redisCache.Remove("sunshineimgvcode_" + mobileVerify.pagecode);
//日志 //日志
logEntity = new LogEntity(); logEntity = new LogEntity();
logEntity.F_CategoryId = 3; logEntity.F_CategoryId = 3;


Loading…
Cancel
Save