#PARAN SILVERLIGHT#
  • Tistory
    • 관리자
    • 글쓰기
Carousel 01
Carousel 02
Previous Next

1. SQL Injection

SECURITY 2012. 11. 12. 17:36
아래 쿼리와 Watch 창에서 Injection되는 SQL을 보면 쉽게 이해 할 수 있다.

 

1.  UI에서 Strssearch arg을 받아서 Grid에 보여주는 함수

        private void Show_Data(String strssearch)         {             string connectionName = "MYSTRING";             ConnectionStringSettings cs =                   ConfigurationManager.ConnectionStrings[connectionName];             if (cs == null)                 throw new ConfigurationErrorsException("Invalid connection name \"" + connectionName + "\"");             factory = DbProviderFactories.GetFactory(cs.ProviderName);             using (DbConnection conn = factory.CreateConnection())             {                 if (conn == null)                     throw new Exception("Could not obtain connection from factory");                 conn.ConnectionString = cs.ConnectionString;                 conn.Open();                 String query = "";                  query += " select *           ";                 query += " from ARDOCUMENT    ";                 if (!string.IsNullOrEmpty(strssearch))                 {                     query += " where DOCUTYPE = '" + strssearch + "'";                 }                 query += " order by CUSTOMERNAME   ";                                  DbCommand cmd = factory.CreateCommand();                 cmd.Connection = conn;                                  cmd.CommandText = query;                 DbDataReader reader = null;                 try                 {                     reader = cmd.ExecuteReader();                     GridView1.DataSource = reader;                     GridView1.DataBind();                 }                 catch (Exception ex)                 {                     string ExMsg = ex.Message;                 }                 finally                 {                     reader.Close();                 }             }                      }

 

 

2. UI에서 TXT를 입력을 하면 여러 row의 값을 가져와 보여준다.

 

 

아래 사진과 같이 SQL문이 만들어 진다.

 

 

 

 

 

 

 

 

 

3. 만약 'TXT' OR '1' = '1를 입력하게 된다면 어떤 일이 일어날까?

 

 

 

OR '1' = '1 의 Sql 문이 injection 이 된 것을 확인 할 수 있다.

결과는 TXT 이 외의 table의 모든 값을 가져오게 된다.

 

 

 

 

 

site : Injection Attacks by Example

 http://www.unixwiz.net/techtips/sql-injection.html

 

injetion을 막는 방법을 소개하는 site

http://www.mikesdotnetting.com/Article/113/Preventing-SQL-Injection-in-ASP.NET

 

 

 

 

저작자표시 비영리 (새창열림)
블로그 이미지

파란실버라이트

To remember the time when I started learning Silver Light!

,

카테고리

  • Inforamtion Technology (281)
    • DESIGN PATTERN (33)
      • 실용주의 디자인패턴 (29)
    • SOFTWARE ENGINEERING (21)
      • Art Of Readable Code (12)
      • Object Oriented Programming (6)
      • TDD (2)
    • FRAMEWORK (22)
      • Spring.net (2)
      • LightSwitch (20)
    • PROGRAMING (58)
      • C# (20)
      • .NET (6)
      • HTML5 (7)
      • ASP.NET (9)
      • SILVERLIGHT (7)
      • Ruby On Rails (6)
    • PROJECT MANAGEMENT (10)
      • SW Version Management (7)
      • Schedulring Management (1)
    • BOOKS (18)
    • MOBILE APP (1)
      • SENCHA TOUCH (1)
    • SECURITY (5)
    • MES (1)
    • B2B (14)
      • WEBMETHODS (4)
    • ERP (53)
      • SAP/R/3 (51)
    • ABOUT TOOLS (2)
    • FUNDAMENT CONCEPT (21)
    • SOA BPM (22)
    • PORTFOLIO (0)

태그목록

  • 병렬
  • 프로그래밍
  • 동시성

최근에 받은 트랙백

글 보관함

링크

파란실버라이트

블로그 이미지

To remember the time when I started learning Silver Light!

LATEST FROM OUR BLOG

RSS 구독하기

LATEST COMMENTS

BLOG VISITORS

  • Total :
  • Today :
  • Yesterday :

Copyright © 2015 Socialdev. All Rights Reserved.

티스토리툴바