过国内外的waf的一些奇淫绝技<转>

本文分享了几个针对MySQL的WAF(Web应用防火墙)绕过技巧,包括使用特殊字符和语法来规避常见的过滤规则,例如利用`控制符进行表名格式输出、-+符号的巧妙运用等。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

作者:livers
研究过国内外的waf。分享一些 奇淫绝技。
一些大家都了解的技巧如:/*!*/,SELECT[0x09,0x0A-0x0D,0x20,0xA0]xx FROM 不再重造轮子。
Mysql

tips1: 神奇的 `  (格式输出表的那个控制符)

过空格和一些正则。

mysql> select`version`();
+----------------------+
|
`version`()
|
+----------------------+
|
5.1.50-community-log |
+----------------------+
1 row in set
(0.00 sec)

一个更好玩的技巧,这个`控制符可以当注释符用(限定条件)。
mysql> select id from qs_admins where id=1;`dfff and comment it;
+----+
| id |
+----+
|
1
|
+----+
1 row in set
(0.00 sec)


usage : where  id =’0′`’xxxxcomment on.

tips2:神奇的- + .

mysql> select id from qs_admins;
+----+
| id |
+----+
|
1
|
+----+
1 row in set
(0.00 sec)   mysql> select+id-1+1.from qs_admins;
+----------+
|
+id-1+1.
|
+----------+
|
1
|
+----------+
1 row in set
(0.00 sec)   mysql> select-id-1+3.from qs_admins;
+----------+
|
-id-1+3.
|
+----------+
|
1
|
+----------+
1 row in set
(0.00 sec)
(有些人不是一直在说关键字怎么过?过滤一个from …    就是这样连起来过)

tips3: @

mysql> select@^1.from qs_admins;
+------|+
|
@^1.
|
+------|+
| NULL |
+------|+
这个是bypass  曾经dedeCMS filter .
或者这样也是ok.

tips4:mysql function() as xxx  也可以不用as 和空格

mysql> select-count(id)test from qs_admins;
+------|+
| test |
+------|+
|
-1
|
+------|+
1 row in set
(0.00 sec)
tips5:/*![>5000]*/ 新构造  版本号(这个可能有些过时了。)
mysql>
/\*!40000select\*/ id from qs_admins;
+----+
| id |
+----+
|
1
|
+----+
1 row in set
(0.00 sec)
先分享这么多,哈。
作者:livers

转载于:https://www.cnblogs.com/demonspider/archive/2013/06/01/3113290.html

<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0"> <display-name>web application framework</display-name> <resource-ref> <description>DB Connection</description> <res-ref-name>jdbc/waf</res-ref-name> <res-type>javax.sql.DataSource</res-type> <res-auth>Container</res-auth> </resource-ref> <session-config> <session-timeout>60</session-timeout> <cookie-config><name>JSESSIONID</name></cookie-config> </session-config> <context-param> <param-name>contextConfigLocation</param-name> <param-value> classpath:spring_context.xml ,classpath:quartz_context.xml ,classpath:spring_context_misc.xml ,classpath:bpms_context.xml, classpath:process_group.xml </param-value> </context-param> <listener> <listener-class>cn.ccccltd.waf.listener.SessionListener</listener-class> </listener> <listener> <listener-class>cn.ccccltd.waf.listener.CacheFileEvent</listener-class> </listener> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <listener> <listener-class>org.apache.commons.fileupload.servlet.FileCleanerCleanup</listener-class> </listener> <listener> <listener-class>cn.ccccltd.bpms.BpmsInitializer</listener-class> </listener> <listener> <listener-class>cn.ccccltd.bpms.ou.listener.BpmsSessionListener</listener-class> </listener> <filter> <filter-name>SigninFilter</filter-name> <filter-class>cn.ccccltd.waf.SigninFilter</filter-class> <init-param> <param-name>signinUrlPattern</param-name> <param-value>bo,dhtml,dhtm,shtml,shtm</param-value> </init-param> </filter> <filter-mapping> <filter-name>SigninFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <!-- ****************************************************************************** --> <filter> <filter-name>xssFilter</filter-name> <filter-class>cn.ccccltd.waf.filter.XssFilter</filter-class> </filter> <filter-mapping> <filter-name>xssFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <filter> <filter-name>SSOLoginFilter</filter-name> <filter-class>cn.ccccltd.waf.sso.controller.SSORequestController</filter-class> </filter> <filter-mapping> <filter-name>SSOLoginFilter</filter-name> <url-pattern>*.bo</url-pattern> </filter-mapping> <!--<filter> <filter-name>springSessionRepositoryFilter</filter-name> <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class> </filter> <filter-mapping> <filter-name>springSessionRepositoryFilter</filter-name> <url-pattern>/*</url-pattern> <dispatcher>REQUEST</dispatcher> <dispatcher>ERROR</dispatcher> </filter-mapping>--> <servlet> <servlet-name>appDispatcher</servlet-name> <servlet-class>cn.ccccltd.waf.AppDispatcher</servlet-class> <init-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:spring_dispatcher_context.xml</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <!-- Spring MVC 请求映射 --> <servlet-mapping> <servlet-name>appDispatcher</servlet-name> <url-pattern>*.bo</url-pattern> </servlet-mapping> <servlet> <servlet-name>appLoader</servlet-name> <servlet-class>cn.ccccltd.waf.AppLoader</servlet-class> <load-on-startup>2</load-on-startup> </servlet> <servlet> <servlet-name>monitorLoader</servlet-name> <servlet-class>cn.ccccltd.waf.MonitorLoader</servlet-class> <load-on-startup>30</load-on-startup> </servlet> <servlet> <servlet-name>fileUpload</servlet-name> <servlet-class>cn.ccccltd.waf.tool.FileUpload</servlet-class> <load-on-startup>97</load-on-startup> </servlet> <servlet> <servlet-name>randomCode</servlet-name> <servlet-class>cn.ccccltd.waf.tool.RandomCode</servlet-class> <load-on-startup>99</load-on-startup> </servlet> <servlet-mapping> <servlet-name>appDispatcher</servlet-name> <url-pattern>*.dhtml</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>appDispatcher</servlet-name> <url-pattern>*.dhtm</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>appDispatcher</servlet-name> <url-pattern>*.shtml</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>appDispatcher</servlet-name> <url-pattern>*.shtm</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>fileUpload</servlet-name> <url-pattern>/waf/tool/fileUpload</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>randomCode</servlet-name> <url-pattern>/waf/tool/randomCode</url-pattern> </servlet-mapping> <servlet> <servlet-name>FileUploadServlet</servlet-name> <servlet-class>cn.ccccltd.comm.upload.FileUploadServlet</servlet-class> <init-param> <param-name>fileSizeLimit</param-name> <param-value>2000</param-value> </init-param> </servlet> <servlet> <servlet-name>DeleteFileServlet</servlet-name> <servlet-class>cn.ccccltd.comm.upload.DeleteFileServlet</servlet-class> </servlet> <servlet> <servlet-name>FileDownloadServlet</servlet-name> <servlet-class>cn.ccccltd.comm.upload.FileDownloadServlet</servlet-class> </servlet> <!-- 帆软报表 --> <!-- <servlet> <servlet-name>ReportServer</servlet-name> <servlet-class>com.fr.web.ReportServlet</servlet-class> <load-on-startup>0</load-on-startup> </servlet> <servlet-mapping> <servlet-name>ReportServer</servlet-name> <url-pattern>/ReportServer</url-pattern> </servlet-mapping> --> <servlet-mapping> <servlet-name>FileDownloadServlet</servlet-name> <url-pattern>/FileDownloadServlet</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>FileUploadServlet</servlet-name> <url-pattern>/FileUploadServlet</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>DeleteFileServlet</servlet-name> <url-pattern>/DeleteFileServlet</url-pattern> </servlet-mapping> <welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list> <!-- error-page START --> <!-- 400 --> <error-page> <error-code>400</error-code> <location>/errorPage.jsp</location> </error-page> <!-- 403 --> <error-page> <error-code>403</error-code> <location>/errorPage.jsp</location> </error-page> <!-- 404 --> <error-page> <error-code>404</error-code> <location>/errorPage.jsp</location> </error-page> <!-- 500 --> <error-page> <error-code>500</error-code> <location>/errorPage.jsp</location> </error-page> <!-- error-page END --> </web-app>那你给我修改一下文件都在项目之中。
最新发布
06-11
<think>我们正在解决如何修改web.xml以确保所有引用的配置文件都存在于项目目录中并正确加载的问题。根据引用,web.xml中主要使用contextConfigLocation参数指定Spring配置文件,以及通过其他方式(如quartz的插件)加载配置文件。步骤:1.检查contextConfigLocation参数:该参数用于指定Spring的配置文件位置。在引用[1]中,使用了classpath:前缀,表示从类路径加载;引用[2]中使用了/WEB-INF/目录。我们需要确保这些文件在项目的对应位置存在。2.对于quartz的配置文件,引用[3]提到quartz会使用插件加载自己的xml配置文件,默认从classes目录加载(如classes/quartz_jobs.xml)。我们需要确保这些文件存在。3.检查DispatcherServlet的配置,如引用[4]中配置了DispatcherServlet,它会默认加载WEB-INF下的[servlet-name]-servlet.xml(如springDispatcherServlet-servlet.xml)。同时也可能通过contextConfigLocation指定其他文件。具体操作:1.在web.xml中,我们通常会使用context-param来定义全局的Spring配置文件,然后使用listener(ContextLoaderListener)来加载。例如:<context-param><param-name>contextConfigLocation</param-name><param-value>classpath:spring-common-config.xml,classpath:spring-budget-config.xml</param-value></context-param><listener><listener-class>org.springframework.web.context.ContextLoaderListener</listener-class></listener>注意:这里使用了classpath,那么这些文件应该放在项目的src/main/resources目录下(如果是Maven项目),这样编译后才会在类路径中。2.另外,我们可能还有DispatcherServlet的配置,它会加载自己的配置文件。但是,如果我们在contextConfigLocation中已经包含了所有的配置,DispatcherServlet也可以不单独配置,或者只配置一个空的contextConfigLocation,然后通过父上下文来共享。3.对于quartz的配置文件,引用[3]提到需要放在classes目录下(即类路径下)。所以,在项目中我们放在src/main/resources/scheduler/quartz_jobs.xml,然后在配置中指定路径。如何确保文件存在?-在IDE中检查文件位置:*对于classpath:spring-common-config.xml,在src/main/resources下应该有spring-common-config.xml。*对于/WEB-INF/applicationContext*.xml,在webapp/WEB-INF目录下应该有applicationContext开头的xml文件(如果使用这种配置方式)。-如果不存在,需要创建这些文件或调整路径。修改建议:-统一使用classpath方式加载,这样无论文件在哪个模块,只要在类路径中就可以。-如果有些配置文件必须放在WEB-INF目录下(如为了安全),则使用/WEB-INF/...的路径,并确保文件位置。示例:修改contextConfigLocation,确保所有配置文件都存在且路径正确<context-param><param-name>contextConfigLocation</param-name><param-value>classpath:spring/spring-common-config.xml,classpath:spring/spring-budget-config.xml,/WEB-INF/applicationContext-security.xml</param-value></context-param>注意:如果混合使用classpath和文件路径,需要注意Spring是否支持。通常,Spring支持多种前缀,包括classpath:、file:、以及不使用前缀(相对于Web应用根路径)。但是,为了避免混淆,建议全部使用classpath。另外,如果使用多个模块,可以考虑使用通配符,如引用[2]中的:/WEB-INF/applicationContext*.xml但是,通配符在classpath中也是支持的,如:classpath*:spring/applicationContext-*.xml关于quartz的配置:通常,quartz的配置文件并不在contextConfigLocation中指定,而是由quartz自己加载。因此,我们需要按照引用[3]所说,将文件放在类路径下的指定位置。例如,我们可以在quartz.properties中指定:org.quartz.plugin.jobInitializer.fileNames=scheduler/quartz_jobs.xml那么,在项目中的位置就是src/main/resources/scheduler/quartz_jobs.xml。最后,建议检查项目结构,确保所有文件都被正确放置在以下位置:-Spring配置文件:src/main/resources/spring/...-WEB-INF下的配置文件:src/main/webapp/WEB-INF/...-quartz配置文件:src/main/resources/scheduler/...并且,在构建后(如mvnpackage),这些文件会被复制到:-classpath下的文件会在WEB-INF/classes目录下(或jar文件内)-WEB-INF下的配置文件会直接在WEB-INF目录下因此,修改web.xml后,需要确保这些文件在项目构建后出现在目标位置。可以通过检查构建后的war文件结构来确认。总结步骤:1.检查web.xml中contextConfigLocation参数指定的文件路径。2.确保这些文件在项目中存在(检查源代码目录中的位置)。3.如果文件不存在,创建它们或者调整路径。4.对于其他框架的配置文件(如quartz),确保它们被放在正确的路径并被正确配置(不一定是web.xml中,可能是框架的配置文件)。5.测试应用启动,查看日志是否有配置文件加载失败的错误。特别提示:如果项目是使用Maven构建,在pom.xml中需要确保资源文件被正确包含(默认src/main/resources下的文件会被包含到类路径)。</think> ### 修正 web.xml 配置的完整指南 #### 步骤 1:验证 contextConfigLocation 配置 1. **检查所有引用文件路径**: ```xml <context-param> <param-name>contextConfigLocation</param-name> <param-value> classpath:spring-common-config.xml, classpath:spring-budget-config.xml, classpath:/scheduler/quartz_jobs.xml </param-value> </context-param> ``` *需要确保这些文件存在于以下位置:* - `src/main/resources/spring-common-config.xml` - `src/main/resources/spring-budget-config.xml` - `src/main/resources/scheduler/quartz_jobs.xml` 2. **项目目录验证**(Maven 标准结构): ``` project-root/ └── src/ └── main/ ├── java/ ├── resources/ │ ├── spring-common-config.xml │ ├── spring-budget-config.xml │ └── scheduler/ │ └── quartz_jobs.xml └── webapp/ └── WEB-INF/ └── web.xml ``` [^1][^2] #### 步骤 2:解决 Quartz 配置加载 1. **明确配置 Quartz 初始化器**: ```xml <context-param> <param-name>quartz:configLocation</param-name> <param-value>classpath:scheduler/quartz_jobs.xml</param-value> </context-param> ``` 在 `quartz_jobs.xml` 中确保包含: ```xml <job> <job-detail> <name>ExampleJob</name> <job-class>com.example.QuartzJob</job-class> </job-detail> </job> ``` [^3] #### 步骤 3:优化 Spring 上下文加载 1. **通配符简化配置**: ```xml <context-param> <param-name>contextConfigLocation</param-name> <param-value> classpath*:spring-*-config.xml </param-value> </context-param> ``` *匹配所有以 `spring-` 开头且以 `-config.xml` 结尾的文件* 2. **DispatcherServlet 配置优化**: ```xml <servlet> <servlet-name>springDispatcherServlet</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <init-param> <param-name>contextConfigLocation</param-name> <param-value></param-value> <!-- 使用根上下文 --> </init-param> <load-on-startup>1</load-on-startup> </servlet> ``` [^4] #### 步骤 4:验证配置的工具方法 1. **启动检查脚本** (在应用初始化时执行): ```java public void contextInitialized(ServletContextEvent sce) { String[] configs = {"spring-common-config.xml", "scheduler/quartz_jobs.xml"}; for(String config : configs) { if(getClass().getClassLoader().getResource(config) == null) { throw new RuntimeException("缺失配置文件: " + config); } } } ``` 2. **日志验证配置**: ```xml <!-- 在 log4j2.xml 中添加 --> <Logger name="org.springframework.context" level="DEBUG"/> ``` 启动时会输出: ``` DEBUG: Loading Spring contexts from [classpath:spring-common-config.xml] ``` #### 最佳实践建议 1. **配置集中管理**: - 创建核心配置文件 `spring-core-config.xml` - 其他文件通过 `<import>` 引入: ```xml <import resource="classpath:spring-security-config.xml"/> ``` 2. **环境区分策略**: ```xml <context-param> <param-name>spring.profiles.active</param-name> <param-value>production</param-value> </context-param> ``` 对应创建 `spring-common-config-production.xml` 3. **构建时验证**(Maven POM 配置): ```xml <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>build-helper-maven-plugin</artifactId> <executions> <execution> <id>verify-resources</id> <phase>process-resources</phase> <goals> <goal>validate</goal> </goals> <configuration> <files> <file>src/main/resources/quartz_jobs.xml</file> </files> </configuration> </execution> </executions> </plugin> ``` #### 常见问题排查 1. **404 配置文件错误**: - 检查类路径:`mvn dependency:build-classpath` - 确认资源过滤:`mvn resources:resources` 2. **XML 语法错误**: ```bash xmllint --noout src/main/resources/*.xml ``` 3. **Spring 上下文初始化失败**: - 查看 `org.springframework.context` 的 DEBUG 日志 - 检查是否有 `BeanDefinitionStoreException` > **关键点**:所有路径需遵循 Maven/Gradle 的约定,资源文件必须放在 `src/main/resources` 下才能正确打包到 WAR 文件的 `WEB-INF/classes` 中。[^1][^2][^4]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值