mirror of
				https://github.com/TeaOSLab/EdgeNode.git
				synced 2025-11-04 07:40:56 +08:00 
			
		
		
		
	WAF规则模板中SQL注入规则使用“包含SQL注入”操作符替代以往的正则表达式
This commit is contained in:
		@@ -292,16 +292,31 @@ func testTemplate6001(a *assert.Assertion, t *testing.T, template *waf.WAF) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
func testTemplate7001(a *assert.Assertion, t *testing.T, template *waf.WAF) {
 | 
					func testTemplate7001(a *assert.Assertion, t *testing.T, template *waf.WAF) {
 | 
				
			||||||
	for _, id := range []string{
 | 
						for _, id := range []string{
 | 
				
			||||||
		"union select",
 | 
							" union all select id from credits",
 | 
				
			||||||
		" and if(",
 | 
							"' or 1=1",
 | 
				
			||||||
		"/*!",
 | 
							"' or '1'='1",
 | 
				
			||||||
		" and select ",
 | 
							"1' or '1'='1')) /*",
 | 
				
			||||||
		" and id=123 ",
 | 
							"OR 1/** this is comment **/=1",
 | 
				
			||||||
		"(case when a=1 then ",
 | 
							"AND 1=2",
 | 
				
			||||||
		" and updatexml (",
 | 
							"; INSERT INTO users (...)",
 | 
				
			||||||
		"; delete from table",
 | 
							"order by 10--",
 | 
				
			||||||
 | 
							"UNION SELECT 1,null,null--",
 | 
				
			||||||
 | 
							"' AND ASCII(SUBSTRING(username, 1, 1))=97 AND '1'='1",
 | 
				
			||||||
 | 
							"||UTL_INADDR.GET_HOST_NAME((SELECT user FROM dual) )--",
 | 
				
			||||||
 | 
							" AND IF(version() like '5%', sleep(10), 'false')",
 | 
				
			||||||
 | 
							"; update tablename set code='javascript code' where 1--",
 | 
				
			||||||
 | 
							"AND @@version like '5.0%', ",
 | 
				
			||||||
 | 
							"/*!40110 and 1=0*/",
 | 
				
			||||||
 | 
							"AND 1=0 UNION SELECT DATABASE()",
 | 
				
			||||||
 | 
							"load_file('filename')",
 | 
				
			||||||
 | 
							"limit 1 into outfile 'aaa'",
 | 
				
			||||||
 | 
							"OR IF(1, BENCHMARK(#ofcicies, action_to_be_performed), 'false')",
 | 
				
			||||||
 | 
							"AND 1=CONVERT(int, db_name())",
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							// PostgresSQL
 | 
				
			||||||
 | 
							"and 1::int=1",
 | 
				
			||||||
	} {
 | 
						} {
 | 
				
			||||||
		req, err := http.NewRequest(http.MethodPost, "http://example.com/?id="+url.QueryEscape(id), nil)
 | 
							req, err := http.NewRequest(http.MethodPost, "https://example.com/?id=1 "+url.QueryEscape(id), nil)
 | 
				
			||||||
		if err != nil {
 | 
							if err != nil {
 | 
				
			||||||
			t.Fatal(err)
 | 
								t.Fatal(err)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
@@ -312,7 +327,7 @@ func testTemplate7001(a *assert.Assertion, t *testing.T, template *waf.WAF) {
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
		a.IsNotNil(result)
 | 
							a.IsNotNil(result)
 | 
				
			||||||
		if result != nil {
 | 
							if result != nil {
 | 
				
			||||||
			a.IsTrue(lists.ContainsAny([]string{"7001", "7002", "7003", "7004", "7005"}, result.Code))
 | 
								a.IsTrue(lists.ContainsAny([]string{"7010"}, result.Code))
 | 
				
			||||||
		} else {
 | 
							} else {
 | 
				
			||||||
			t.Log("break:", id)
 | 
								t.Log("break:", id)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
@@ -365,7 +380,7 @@ func BenchmarkTemplateSQLInjection(b *testing.B) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	b.RunParallel(func(pb *testing.PB) {
 | 
						b.RunParallel(func(pb *testing.PB) {
 | 
				
			||||||
		for pb.Next() {
 | 
							for pb.Next() {
 | 
				
			||||||
			req, err := http.NewRequest(http.MethodPost, "https://example.com/?id=1234" + types.String(rand.Int()%10000), nil)
 | 
								req, err := http.NewRequest(http.MethodPost, "https://example.com/?id=1234"+types.String(rand.Int()%10000), nil)
 | 
				
			||||||
			if err != nil {
 | 
								if err != nil {
 | 
				
			||||||
				b.Fatal(err)
 | 
									b.Fatal(err)
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user