You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: documentation/modules/exploit/windows/smb/psexec.md
+34-17Lines changed: 34 additions & 17 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,8 +1,5 @@
1
-
psexec is one of the most popular exploits against Microsoft Windows. It is a great way to test password security and demonstrate how a stolen password could lead to a complete compromise of an entire corporate network.
2
-
3
-
The Metasploit Framework actually includes different module types of psexec for different scenarios. exploit/windows/smb/psexec is the father of them all and is used the same way
4
-
you normally would with any Metasploit exploits.
5
-
1
+
PSexec is one of the most popular exploits against Microsoft Windows. It is a great way to test password security and demonstrate how a
2
+
stolen password could lead to a complete compromise of an entire corporate network.
6
3
7
4
## Vulnerable Application
8
5
@@ -11,7 +8,9 @@ To be able to use exploit/windows/smb/psexec:
11
8
1. You must have a valid username/password.
12
9
2. The firewall must allow SMB traffic.
13
10
3. The target must use SMBv1.
14
-
4. The remote Windows machine's network security policy must allow it. If you see [one of these errors](https://github.com/rapid7/metasploit-framework/wiki/What-does-my-Rex%3A%3AProto%3A%3ASMB-Error-mean%3F), then the Windows machine does not allow it.
11
+
4. The remote Windows machine's network security policy must allow it. If you see
12
+
[one of these errors](https://github.com/rapid7/metasploit-framework/wiki/What-does-my-Rex%3A%3AProto%3A%3ASMB-Error-mean%3F), then the
13
+
Windows machine does not allow it.
15
14
16
15
## Verification Steps
17
16
@@ -43,7 +42,8 @@ meterpreter >
43
42
44
43
## Options
45
44
46
-
By default, using exploit/windows/smb/psexec can be as simple as setting the RHOST option, and you're ready to go. But in reality, you will probably need to at least configure:
45
+
By default, using exploit/windows/smb/psexec can be as simple as setting the RHOST option, and you're ready to go. But in reality, you will
46
+
probably need to at least configure:
47
47
48
48
**The SMBUser Option**
49
49
@@ -58,7 +58,8 @@ This can be either the plain text version or the Windows hash.
58
58
59
59
**Pass the Hash**
60
60
61
-
One common penetration testing scenario using psexec is that attackers usually begin by breaking into a box, dumping the hashes, and using some of those hashes to log into other boxes on the network using psexec. So in that scenario, with the following stolen hash:
61
+
One common penetration testing scenario using psexec is that attackers usually begin by breaking into a box, dumping the hashes, and using
62
+
some of those hashes to log into other boxes on the network using psexec. So in that scenario, with the following stolen hash:
62
63
63
64
```
64
65
meterpreter > hashdump
@@ -93,28 +94,44 @@ meterpreter >
93
94
94
95
**Automatic Target**
95
96
96
-
There are multiple targets available for exploit/windows/smb/psexec. The Automatic target is the default target. If the Automatic target detects Powershell on the remote machine, it will try Powershell, otherwise it uses the natvie upload. Each target is explained below.
97
+
There are multiple targets available for exploit/windows/smb/psexec. The Automatic target is the default target. If the Automatic target
98
+
detects Powershell on the remote machine, it will try Powershell, otherwise it uses the natie upload. Each target is explained below.
97
99
98
100
**Powershell Target**
99
101
100
-
The Powershell target forces the psexec module to run a Powershell command with a payload embedded in it. Since this approach does not leave anything on disk, it is a very powerful way to evade antivirus. However, older Windows machines might not support Powershell by default.
102
+
The Powershell target forces the psexec module to run a Powershell command with a payload embedded in it. Since this approach does not
103
+
leave anything on disk, it is a very powerful way to evade antivirus. However, older Windows machines might not support Powershell by
104
+
default.
101
105
102
-
Because of this, you will probably want to use the Automatic target setting. The automatic mode will check if the target supports Powershell before it tries it; the manually set Powershell target won't do that.
106
+
Because of this, you will probably want to use the Automatic target setting. The automatic mode will check if the target supports
107
+
Powershell before it tries it; the manually set Powershell target won't do that.
103
108
104
109
**Native Upload Target**
105
110
106
111
The Native target will attempt to upload the payload (executable) to SYSTEM32 (which can be modified with the
107
112
SHARE datastore option), and then execute it with psexec.
108
113
109
-
This approach is generally reliable, but has a high chance of getting caught by antivirus on the target. To counter this, you can try to use a template by setting the EXE::Path and EXE::Template datastore options. Or, you can supply your own custom EXE by setting the EXE::Custom option.
114
+
This approach is generally reliable, but has a high chance of getting caught by antivirus on the target. To counter this, you can try to
115
+
use a template by setting the EXE::Path and EXE::Template datastore options. Or, you can supply your own custom EXE by setting the
116
+
`EXE::Custom` option.
110
117
111
118
**MOF Upload Target**
112
119
113
-
The [MOF](https://github.com/rapid7/metasploit-framework/wiki/How-to-use-WbemExec-for-a-write-privilege-attack-on-Windows) target technically does not use psexec; it does not explicitly tell Windows to execute anything. All it does is upload two files: the payload (exe) in SYSTEM32 and a managed object
114
-
format file in SYSTEM32\wbem\mof\ directory. When Windows sees the MOF file in that directory, it automatically runs it. Once executed, the code inside the MOF file basically tells Windows to execute our payload in SYSTEM32, and you get a session.
120
+
The [MOF](https://github.com/rapid7/metasploit-framework/wiki/How-to-use-WbemExec-for-a-write-privilege-attack-on-Windows) target
121
+
technically does not use psexec; it does not explicitly tell Windows to execute anything. All it does is upload two files: the payload
122
+
(exe) in SYSTEM32 and a managed object format file in SYSTEM32\wbem\mof\ directory. When Windows sees the MOF file in that directory, it
123
+
automatically runs it. Once executed, the code inside the MOF file basically tells Windows to execute our payload in SYSTEM32, and you get
124
+
a session.
125
+
126
+
Although it's a neat trick, Metasploit's MOF library only works against Windows XP and Windows Server 2003. And since it writes files to
127
+
disk, there is also a high chance of getting caught by antivirus on the target.
115
128
116
-
Although it's a neat trick, Metasploit's MOF library only works against Windows XP and Windows Server 2003. And since it writes files to disk, there is also a high chance of getting
117
-
caught by antivirus on the target.
129
+
The best way to counter antivirus is still the same. You can either use a different template by setting the EXE::Path and EXE::Template
130
+
datastore options or you can supply your own custom EXE by setting the EXE::Custom option.
118
131
119
-
The best way to counter antivirus is still the same. You can either use a different template by setting the EXE::Path and EXE::Template datastore options or you can supply your own custom EXE by setting the EXE::Custom option.
132
+
**Command**
120
133
134
+
The command target causes the psexec operation to execute an operating system command. This can either be a `cmd/windows/` payload provided
135
+
by Metasploit, or the user can specify their own by using the `cmd/windows/generic` payload and setting `CMD`. The output of the command
136
+
will be written to a file and then retrieved so that it is accessible. If the command does not immediately return, then reading the output
0 commit comments