2009년 7월 14일 화요일

확장저장프로시저 xp_cmdShell 제거

확장프로시저에 접근이 가능하다면 다음과 같은 구문으로 신규 계정을 생성할수 있다.

이와 같이 어드민 계정이 생성되면 그 이후에는 그 서버는 마음대로 주무를수 있게 된다.

 

xp_cmdshell 'net user hacker1 Akld5793/add'
xp_cmdshell 'net localgroup administrators hacker1 /add'

 

이를 방지하기 위해 제거 해버린다.

 

use master
if object_id('[dbo].[xp_cmdshell]') is not null begin
   exec sp_dropextendedproc 'xp_cmdshell'
end

exec sp_addextendedproc 'xp_cmdshell', 'xplog70.dll'

use master
if object_id('[dbo].[xp_cmdshell]') is not null begin
   exec sp_dropextendedproc 'xp_cmdshell'
end

 


재설치

 

sp_dropextendedproc을 해도 해당 DLL이 메모리에 남아 있다.
다음 명령어로 동적 연결 라이브러리(DLL)를 메모리에서 내리면 기존 파일이 지워진다.
dbcc xp_cmdshell(free)


use master
exec sp_helptext xp_cmdshell
여기서 나타난 DLL 이름을 기억해 둡니다. 이것은 나중에 다시 등록할 때 필요함.

 

use master
exec sp_dropextendedproc ‘xp_cmdshell’

 

다시 등록시
use master
exec sp_addextendedproc ‘xp_cmdshell’, ‘xplog70.dll’
앞에서 알아냈던 dll

댓글 없음:

댓글 쓰기