관리 메뉴

웹개발자의 기지개

[ASP] web.config - SQL injection 필터링 기능 본문

ASP

[ASP] web.config - SQL injection 필터링 기능

웹개발자 워니 2025. 9. 27. 00:33

asp 코드상으로도 GET, POST 변수값들에게 SQL injection 방지 필터링도 걸수 있지만

[ASP] SQL injection 방지

 

[ASP] SQL injection 방지

sql injection 방지 소스이다. injection_filter = "union|delete|select|update|drop table|drop column|alter table|alter column|create |insert|;--|declare|exec|set @|sysadmin|db_name|convert|rtrim|table_cursor|syscolumn|--|having|kill|xp_" injection_filt

wonpaper.tistory.com

 

 

web.config 환경설정 파일로도 보다 시스템적으로 해당 개별 웹사이트에 대하여 injection 방지 필터링 기능을 아래 예제 소스처럼

걸수 있다.

 

[web.config] 참고 예제

 

 

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
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
 
        <security>
          <requestFiltering allowDoubleEscaping="false" allowHighBitCharacters="true">
            <denyUrlSequences>
              <add sequence="DBMS_PIPE" />
              <add sequence="RECEIVE_MESSAGE" />
              <add sequence="CHR&#40;" />
              <add sequence="%7C" />
              <!--<add sequence="%3B" />
              <add sequence="%2C" />-->
              <add sequence="pg_sleep" />
              <add sequence="union%20select" />
              <add sequence="information_schema" />
              <add sequence="xp_cmdshell" />
              <add sequence="update%20set" />
              <add sequence="update+set" />
              <add sequence="%75%70%64%61%74%65%20%73%65%74" />
            </denyUrlSequences>
            <!--<requestLimits maxAllowedContentLength="30000000" maxUrl="4096" maxQueryString="2048" />-->
          </requestFiltering>
        </security>
 
        <defaultDocument>
            <files>
                <clear />
                <add value="index.asp" />
                <add value="login.asp" />
                <add value="index.php" />
                <add value="Default.htm" />
                <add value="Default.asp" />
                <add value="index.htm" />
                <add value="index.html" />
                <add value="iisstart.htm" />
                <add value="default.aspx" />
            </files>
        </defaultDocument>
        <httpErrors errorMode="Detailed" />
        <staticContent>
            <remove fileExtension=".zip" />
            <mimeMap fileExtension=".zip" mimeType="application/x-zip-compressed" />
            <remove fileExtension=".mp4" />
            <mimeMap fileExtension=".mp4" mimeType="video/mpeg" />
        </staticContent>
    </system.webServer>
    <location path="" overrideMode="Deny">
        <system.data>
            <DbProviderFactories />
        </system.data>
    </location>
    <location path="" overrideMode="Allow">
        <appSettings />
    </location>
</configuration>
 
cs

 

 

 

최상의 예제 소스는 아니지만 이를 응용해서 추가하면 되겠다.

 

<security> 태그는 반드시 하나만 나와야 함으로 이 안쪽에 태그를 연이어 추가하면 되겠다.

웹사이트의 개발 소스와 특성에 따라 적절히 각 태그의 키워드 들을 추가/삭제해 나가면 되겠다.

 

파일 수정후에는 반드시 IIS 를 restart 해야 한다.

 

 

 

Comments