高版本正方教务系统上传后缀过滤不严导致能直接上传Webshell

时间:2023-03-09 04:50:41
高版本正方教务系统上传后缀过滤不严导致能直接上传Webshell

在旧版本中有一个利用插件上传文件的漏洞,但是在新版本中已经没有了这个插件.这个漏洞是由于过滤不严造成的,可以直接上传Webshell进行提权,由于代码在DLL中,全国大部分高校均有此漏洞,影响范围很大,90%以上的学校均可使用这个方法进行提权

上传函数仅判断是否包含".asp" ".php"".exe"字符串 因此可以直接上传如CER格式的Webshell进行提权

jwggfbb.cs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
private void btn_sc_Click(object sender, EventArgs e)
{
if (Strings.InStr(this.loFile.get_PostedFile().get_FileName(), ".asp", 0) > 0)
{
this.RegisterStartupScript("Startup", "<script type="text/javascript" language="javascript">// <![CDATA[
alert('不能上传asp文件!!');
// ]]></script>");
}
else if (Strings.InStr(this.loFile.get_PostedFile().get_FileName(), ".php", 0) &gt; 0)
{
this.RegisterStartupScript("Startup", "<script type="text/javascript" language="javascript">// <![CDATA[
alert('不能上传php文件!!');
// ]]></script>");
}
else if (Strings.InStr(this.loFile.get_PostedFile().get_FileName(), ".exe", 0) &gt; 0)
{
this.RegisterStartupScript("Startup", "<script type="text/javascript" language="javascript">// <![CDATA[
alert(不能上传exe文件,请压缩后上传!!');
// ]]></script>");
}
else
{
this.tcf = false;
this.Button1_Click();
if (!this.tcf)
{
if (StringType.StrCmp(this.scms, "1", false) == 0)
{
this.data_dir.set_Text(ConfigurationSettings.get_AppSettings().get_Item("HTTP1") + "/wbwj/" + this.lstrFileName);
}
if (StringType.StrCmp(this.scms, "2", false) == 0)
{
this.data_dir.set_Text("wbwj/" + this.lstrFileName);
}
}
}
}

scglwj.cs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
private void Button2_Click(object sender, EventArgs e)
{
if (Strings.InStr(this.loFile1.get_PostedFile().get_FileName(), ".asp", 0) &gt; 0)
{
this.get_Response().Write("<script type="text/javascript" language="javascript">// <![CDATA[
alert('不能上传asp文件!!');
// ]]></script>");
}
else if (Strings.InStr(this.loFile1.get_PostedFile().get_FileName(), ".php", 0) &gt; 0)
{
this.get_Response().Write("<script type="text/javascript" language="javascript">// <![CDATA[
alert('不能上传php文件!!');
// ]]></script>");
}
else
{
this.Button1_Click();
string mysql = "insert into jwggfbb (GGBT,GGZW,FBDW,FBSJ,YXQX,mxddx,mxxdx,fbnr,scip) values ('" + this.ggbt.get_Text() + "','" + ConfigurationSettings.get_AppSettings().get_Item("HTTP1") + "UpLoad/" + this.lstrFileName + "','" + this.fbdw.get_Text() + "',to_char(sysdate,'YYYY-MM-DD hh:mi:ss'),'" + this.yxqx.get_Text() + "','','','wjgl','" + this.get_Request().get_UserHostAddress() + "')";
OracleConnection objConnection = new OracleConnection(ConfigurationSettings.get_AppSettings().get_Item("MyConn") + this.zhj.jiemi(ConfigurationSettings.get_AppSettings().get_Item("MyPwd"), this.zhj.str_jm));
if (Module1_sjf.checksql(mysql))
{
OracleCommand objCommand = new OracleCommand(mysql, objConnection);
objConnection.Open();
objCommand.ExecuteNonQuery();
objConnection.Dispose();
this.DataGrid1.set_EditItemIndex(-1);
this.zhj.BindtoGrid("select * from jwggfbb where fbnr='wjgl' order by fbsj,yxqx", this.DataGrid1);
}
}
}

当为asp文件时会提示不能上传asp文件

高版本正方教务系统上传后缀过滤不严导致能直接上传Webshell

直接将asp大马改成CER格式 直接上传无鸭梨 麻麻再也不用担心我的学习啦

高版本正方教务系统上传后缀过滤不严导致能直接上传Webshell

文件存放在网站根目录的wbwj文件夹中 虽然叫wbwj但是还是没有限制运行权限,直接提权得到服务器权限
高版本正方教务系统上传后缀过滤不严导致能直接上传Webshell