
Python으로 작성된 공격적 MSSQL 툴킷, SQLRecon 기반
PySQLRecon
PySQLRecon은 훌륭한 SQLRecon 프로젝트의 Python 포트입니다. 프로젝트 작성자는 @sanjivkawa입니다. 기능 목록은 명령어 섹션을 참조하세요.
PySQLRecon을 사용한 SCCM TAKEOVER-1 시연 게시물
PySQLRecon은 pip3 install pysqlrecon 명령어나 이 저장소를 클론한 후 pip3 install .을 실행하여 설치할 수 있습니다.
SQLRecon의 모든 주요 모듈에 해당하는 명령어가 있습니다. [PRIV]로 표시된 명령어는 실행에 상승된 권한 또는 sysadmin 권한이 필요합니다. 반대로 [NORM]으로 표시된 명령어는 일반 사용자가 실행할 수 있으며 상승된 권한이 필요하지 않습니다.
가장([I]) 또는 연결된 서버에서의 실행([L]) 지원 여부는 명령어 설명 끝에 표시됩니다.
adsi [PRIV] Obtain ADSI creds from ADSI linked server [I,L]
agentcmd [PRIV] Execute a system command using agent jobs [I,L]
agentstatus [PRIV] Enumerate SQL agent status and jobs [I,L]
checkrpc [NORM] Enumerate RPC status of linked servers [I,L]
clr [PRIV] Load and execute .NET assembly in a stored procedure [I,L]
columns [NORM] Enumerate columns within a table [I,L]
databases [NORM] Enumerate databases on a server [I,L]
disableclr [PRIV] Disable CLR integration [I,L]
disableole [PRIV] Disable OLE automation procedures [I,L]
disablerpc [PRIV] Disable RPC and RPC Out on linked server [I]
disablexp [PRIV] Disable xp_cmdshell [I,L]
enableclr [PRIV] Enable CLR integration [I,L]
enableole [PRIV] Enable OLE automation procedures [I,L]
enablerpc [PRIV] Enable RPC and RPC Out on linked server [I]
enablexp [PRIV] Enable xp_cmdshell [I,L]
impersonate [NORM] Enumerate users that can be impersonated
info [NORM] Gather information about the SQL server
links [NORM] Enumerate linked servers [I,L]
olecmd [PRIV] Execute a system command using OLE automation procedures [I,L]
query [NORM] Execute a custom SQL query [I,L]
rows [NORM] Get the count of rows in a table [I,L]
sample [NORM] Query a sample of table data [I,L]
sccm [SUBM] Submodule for SCCM specific commands
search [NORM] Search a table for a column name [I,L]
smb [NORM] Coerce NetNTLM auth via xp_dirtree [I,L]
tables [NORM] Enumerate tables within a database [I,L]
users [NORM] Enumerate users with database access [I,L]
whoami [NORM] Gather logged in user, mapped user and roles [I,L]
xpcmd [PRIV] Execute a system command using xp_cmdshell [I,L]
SCCM 명령어는 pysqlrecon [옵션] sccm -h를 실행하여 확인할 수 있습니다 (이를 위해서는 전역 플래그를 지정해야 함 - 사용법 참조)
addadmin [PRIV] Elevate an account to Full Administrator [I]
credentials [NORM] Display encrypted credentials [I]
logons [NORM] Display SCCM clients and last logged on user [I]
removeadmin [PRIV] Remove elevated account or elevated privileges [I]
sites [NORM] Gather SCCM site info [I]
taskdata [NORM] Decrypt task sequences [I]
tasklist [NORM] Display task sequences [I]
users [NORM] Enumerate SCCM users [I]
PySQLRecon에는 전역 옵션(모든 명령어에 사용 가능)이 있으며, 일부 명령어는 추가 플래그를 도입합니다. 모든 전역 옵션은 명령어 이름 앞에 지정해야 합니다:
pysqlrecon [GLOBAL_OPTS] COMMAND [COMMAND_OPTS]
전역 옵션 보기:
pysqlrecon --help
명령어별 옵션 보기:
pysqlrecon [GLOBAL_OPTS] COMMAND --help
특정 PySQLRecon 명령어(query, tables, columns, rows)에서 인증할 데이터베이스를 변경하거나 사용하려면 --database 플래그를 사용하세요.
연결된 서버에서 PySQLRecon 명령어를 실행하려면 (인증된 SQL 서버 대신) --link 플래그를 사용하세요.
PySQLRecon 명령어를 실행하는 동안 사용자 계정을 가장하려면 --impersonate 플래그를 사용하세요.
--link와 --impersonate는 함께 사용할 수 없습니다.
PySQLRecon은 proxychains와 함께 사용하여 mssql:// 서비스를 대상으로 릴레이된 인증을 활용할 수 있습니다. ntlmrelayx 세션이 작동하는 방식 때문에 PySQLRecon을 실행할 때 --database 매개변수가 적용되지 않습니다(릴레이 세션은 항상 master 데이터베이스에 연결됩니다). 이는 특히 SCCM 모듈을 사용할 때 문제가 될 수 있습니다. SCCM 모듈은 사이트 데이터베이스를 지정해야 하기 때문입니다. 이 문제를 해결하려면 먼저 query 모듈을 사용하여 데이터베이스 컨텍스트를 변경하십시오(이 변경은 동일한 릴레이 세션에서 이후의 모든 PySQLRecon 사용에 대해 유지됩니다). 예시:
proxychains4 pysqlrecon -t <target> -d <DOMAIN> -u <username> -p FAKE query --query 'use new_db_name'
이제 동일한 ntlmrelayx 세션에서 --database를 지정하지 않고도 해당 특정 데이터베이스 내의 리소스를 대상으로 하는 모듈/쿼리를 실행할 수 있습니다.
pysqlrecon은 종속성 관리를 위해 uv를 사용합니다. 소스에서 설치하고 개발을 위해 설정하려면:
# Install uv
curl -LsSf https://astral.sh/uv/install.sh | sh
# Install pysqlrecon
git clone https://github.com/tw1sm/pysqlrecon
cd pysqlrecon
uv sync
uv run pysqlrecon --help
PySQLRecon은 쉽게 확장 가능합니다. 템플릿과 지침은 resources에서 확인하세요.