Skip to content
RCE Write-up Intermediate

How I hacked into a Telecom Network

A JBoss server on a telecom network was vulnerable to remote code execution via the JMXInvokerServlet method. An attacker could exploit this to gain a foothold and potentially access sensitive call data records.

Harpreet Singh Follow

Published on infosecwriteups.com

Hi everyone, this is my first post on Medium and I hope you guys enjoy reading it! There is a lot of information that I had to redact because of the sensitive nature of this info.

Harpreet Singh, on infosecwriteups.com

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 5 min read.

Context

This is an account of a red team engagement against a telecom company. The stated objective was to get inside the network and reach the Call Data Records (CDRs) of the telecom network. The author quotes Wikipedia's definition of a CDR: a data record produced by a telephone exchange or other telecommunications equipment that documents the details of a telephone call or other telecommunications transaction (for example a text message) that passes through that facility or device, containing attributes such as time, duration, completion status, source number and destination number.

The foothold was obtained on the company's Network Monitoring System (NMS). The initial access came from simple network service exploitation to get remote code execution, and the harder part was getting a stable shell. The author redacted a lot of information because of the sensitive nature of it, and the post is the first of a series: part 2 covers TCP tunnelling, part 3 covers stealthy SSH and dynamic SSH tunnels, and part 4 covers getting access to CDRs, SS7 applications and VLRs.

Setup

The engagement was a red team exercise for a client. The author lists the recon options considered: DNS enumerations, ASN and BGP lookups, passive recon from multiple search engines, checking source code repositories such as GitHub, BitBucket and GitLab for something useful, and OSINT on employees for spear phishing in case no RCE was found. On the phishing route the author notes that fooling an employee into downloading and executing malicious documents is easy, but only if the obstacles of antivirus and email spam filters can be overcome.

The tools used in this part are aiodnsbrute for DNS enumeration, a full port scan against the discovered sub-domain, and Jexboss for JBoss exploitation. The author notes that JBoss can also be exploited with Metasploit but prefers Jexboss, which includes many methods and exploitation techniques and covers application and servlet deserialisations and Struts2.

Finding it

The author started with DNS enumeration itself:

Text
aiodnsbrute -v -t 7000 — no-verify -w dns-list.uniq.lst ******.com.** | grep -v Timeout | grep -v Misformatted | grep -v exception

The command runs aiodnsbrute verbosely with 7000 threads, without verification, against a wordlist, and filters out timeouts, misformatted results and exceptions from the output. The wordlist used contains 2.77 million unique DNS records, which the author calls out as a fun fact.

From the original on infosecwriteups.com

The screenshot shows the output of that enumeration run.

The author's point about methodology is that most hunters look only at ports 80 and 443 on the sub-domains they find, and that a full port scan is sometimes the safer choice. In this case the enumeration produced a sub-domain named e[REDACTED]-nms.[REDACTED].com.[REDACTED], and a full port scan of it returned interesting results.

From the original on infosecwriteups.com

The scan output is shown in the screenshot above.

Ports 12000/tcp and 14000/tcp were nothing special, but 14100/tcp was, in the author's words, a lucky day.

From the original on infosecwriteups.com

The screenshot shows the scan results including 14100/tcp.

Exploitation

Step 1: run Jexboss against the JBoss port

Once JBoss was discovered, the author fired up Jexboss:

Text
./jexboss.py -u http://[REDACTED]:14100/

The tool takes the target URL with -u, here the redacted host on port 14100 over plain HTTP.

From the original on infosecwriteups.com

The screenshot shows the tool running against the target.

Step 2: exploit JMXInvokerServlet for RCE

The server was vulnerable. Using the JMXInvokerServlet method, the author obtained remote code execution on the server. The author describes the exploitation as pretty straightforward.

From the original on infosecwriteups.com

The screenshot shows the vulnerable result reported by the tool.

Step 3: attempt a reverse shell

With the foothold in place, the real problem appeared. As usual after an RCE, the author tried to get a reverse shell.

From the original on infosecwriteups.com

A back connection was obtained.

From the original on infosecwriteups.com

The screenshot shows the incoming connection.

However, the shell was not stable: the python process was killed after a few seconds. The author tried other reverse shell one-liner payloads, different common ports, and even UDP, with the same result. Metasploit reverse_tcp, reverse_http and reverse_https payloads in different forms were also tried to get meterpreter connections, but the meterpreter shells were disconnected after a few seconds as well.

The author had seen situations like this before and had always wondered how to proceed when a reverse shell is not possible. The answer given here is a bind shell connection over an HTTP tunnel, which is continued in part 2 of the series.

Root cause

The report does not analyse the root cause of the JBoss vulnerability itself. What it establishes is that the JBoss instance on port 14100 was reachable from the internet-facing position the author scanned, and that it was exploitable through the JMXInvokerServlet method, which Jexboss detected and used. The JBoss instance on 14100/tcp was found by a full port scan of the sub-domain.

The second failure, the unstable reverse shell, is described only by its symptoms: the python process was killed after a few seconds, and neither other one-liners, other common ports, UDP, nor Metasploit reverse_tcp/http/https meterpreter payloads survived. The report does not say what was killing the process or blocking the connections.

Impact

On this engagement the RCE gave the author a foothold on the telecom company's Network Monitoring System. From there the author went on to proxify internal network scans and, per the summary and the later parts of the series, obtained access to CDRs and VLR with an SS7 application. The report does not give the number of records, systems or subscribers affected, and much of the detail is redacted because of the sensitivity of the information.

Fix

Judged from what is shown, the JBoss instance on 14100/tcp should not have been reachable in the way it was, and the JMXInvokerServlet exposure that Jexboss exploited should have been removed or protected.

Variants to test

  1. Full port scans on every sub-domain found by DNS enumeration, not just 80 and 443. A positive result is any high port running JBoss or another middleware console, as happened here on 14100/tcp.
  2. Jexboss against any JBoss instance discovered, checking whether it reports the target as vulnerable and whether the JMXInvokerServlet method yields command execution.
  3. When a reverse shell dies after a few seconds, try a bind shell over an HTTP tunnel instead, which is the path the author takes in part 2.
  4. Large DNS wordlists with high thread counts and output filtering, as in the aiodnsbrute command above, to surface internal-sounding names such as the NMS sub-domain found here.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 14 min read.

What happened, in plain words

A security tester was hired by a telecom company to break into its network on purpose, as a test. This kind of job is called a red team engagement: the company gives permission, and the tester plays the role of an attacker to find out how far an intruder could get. The goal set for this job was to get inside the network and reach the Call Data Records (CDRs) of the telecom network.

A CDR is a record that a phone network keeps about each call or text message. The author quotes Wikipedia's definition: a call detail record is a data record produced by a telephone exchange or other telecommunications equipment that documents the details of a telephone call or other telecommunications transaction (for example a text message) that passes through that facility or device. The record contains attributes such as time, duration, completion status, source number and destination number. In everyday terms, a CDR is like the itemised bill your phone company keeps: who called whom, when, for how long, and whether the call connected. For a telecom company, these records are extremely sensitive, which is why reaching them was the objective.

The tester got in through the company's Network Monitoring System (NMS). An NMS is software that watches over a network: it collects health and performance data from routers, switches and servers so that operators can see what is working and what is broken. Because it sits in the middle of everything and talks to many devices, an NMS is a valuable target: whoever controls it can often see and reach a lot of the network.

The way in was a simple network service exploitation that gave remote code execution (RCE). RCE means the attacker can make the target computer run commands of their choosing, as if they were sitting at its keyboard. The author describes the initial foothold as way too easy; the hard part was getting a stable shell. A shell is a command prompt on the remote machine: a way to type commands and read the answers. Stable means it stays alive long enough to be useful.

A lot of information in the post is redacted because of the sensitive nature of it. The post is the first in a series: part 2 covers TCP tunnelling, part 3 covers stealthy SSH and dynamic SSH tunnels, and part 4 covers getting access to CDRs, SS7 applications and VLRs. Tunnelling, SSH, SS7 and VLRs are explained in the glossary at the end; for now, think of tunnelling as wrapping one kind of traffic inside another so it can pass where it normally could not.

Reconnaissance

Reconnaissance is the information-gathering phase: finding out what exists on the target's network before trying to break anything. The author quotes the saying about spending the first four hours sharpening the axe before chopping down a tree: the more thorough the reconnaissance, the better the odds when exploitation begins.

For this engagement the author lists the recon options considered:

  1. DNS enumerations.
  2. ASN and BGP lookups.
  3. Passive recon from multiple search engines.
  4. Checking source code repositories such as GitHub, BitBucket and GitLab for something useful.
  5. OSINT on employees for spear phishing, in case no RCE was found.

A few of those need explaining. DNS is the internet's phone book: it translates a name people can read, like example.com, into the numeric address of a machine. DNS enumeration means asking that phone book, over and over with a large list of candidate names, which names actually exist under a company's domain. ASN stands for Autonomous System Number, an identifier for a large block of internet addresses managed by one organisation; BGP is the routing protocol that tells the internet how to reach those blocks. Looking them up helps map which address ranges belong to the target. Passive recon means gathering information without touching the target directly, for example from search engines that have already indexed it. OSINT is open-source intelligence: information available publicly, such as employees' names and roles on social media. Spear phishing is a targeted fake email designed to trick a specific person into doing something harmful.

On the phishing route the author notes that fooling an employee into downloading and executing malicious documents is easy, but only if the obstacles of antivirus software (AVs) and email spam filters can be overcome. Antivirus is software on the victim's computer that tries to recognise malicious files; spam filters sit on the mail server and block suspicious messages before they arrive.

In this case the author started with DNS enumeration itself:

Text
aiodnsbrute -v -t 7000 — no-verify -w dns-list.uniq.lst ******.com.** | grep -v Timeout | grep -v Misformatted | grep -v exception

Line by line, in plain words:

  • aiodnsbrute is the name of the tool being run. It is a program that tries many DNS names quickly.
  • -v means verbose: print more detail about what is happening.
  • -t 7000 sets the number of threads, that is, how many lookups run at the same time. Seven thousand at once is a very aggressive setting.
  • — no-verify is written in the original with a long dash; it tells the tool not to verify results, which makes it faster but less careful.
  • -w dns-list.uniq.lst points to the wordlist: a text file full of candidate names to try, one per line.
  • ******.com.** is the target domain, with parts redacted.
  • The vertical bar | takes the output of the first command and feeds it to the next one.
  • grep -v Timeout removes lines containing the word Timeout, so failed lookups do not clutter the screen.
  • grep -v Misformatted removes lines about badly formatted entries.
  • grep -v exception removes lines reporting errors.

The wordlist used contains 2.77 million unique DNS records, which the author calls out as a fun fact: the tool was trying millions of possible names against the target's domain.

From the original on infosecwriteups.com

The screenshot shows the output of that enumeration run: the stream of results the tool produced while working through the wordlist.

The author's point about methodology is that most hunters look only at ports 80 and 443 on the sub-domains they find. A port is a numbered doorway on a machine; different services listen on different doorways. Port 80 is the standard doorway for unencrypted web traffic and port 443 for encrypted web traffic, so websites live there. But other services can listen on other ports, and if you only knock on the two web doorways you will miss them. That is why a full port scan, which tries every doorway, is sometimes the safer choice.

In this case the enumeration produced a sub-domain named e[REDACTED]-nms.[REDACTED].com.[REDACTED]. A sub-domain is a name that sits under the main domain, like a department inside a company. The nms in the name suggests a network monitoring system. A full port scan of that sub-domain returned interesting results.

From the original on infosecwriteups.com

The scan output is shown in the screenshot above: the list of doorways found open on that machine.

Ports 12000/tcp and 14000/tcp were nothing special, but 14100/tcp was, in the author's words, a lucky day. The /tcp suffix simply says these are TCP ports; TCP is the reliable, connection-based protocol that most services use, as opposed to UDP, which is connectionless and does not guarantee delivery.

From the original on infosecwriteups.com

The screenshot shows the scan results including 14100/tcp.

JBoss is a Java application server: software that runs Java web applications for an organisation. It is a well-known piece of enterprise middleware, and older versions have well-known ways of being exploited, which is why finding it exposed was significant. The author's reaction, J-Fuggin-Boss, is a pun on the product name.

Exploitation

Exploitation is the step where a weakness is actually used to gain access, as opposed to merely being noticed.

Step 1: run Jexboss against the JBoss port

Once JBoss was discovered, the author fired up Jexboss:

Text
./jexboss.py -u http://[REDACTED]:14100/

Line by line:

  • ./jexboss.py runs a Python script called jexboss.py from the current directory. Jexboss is a free tool written to test and exploit known JBoss weaknesses.
  • -u tells the tool which URL to attack.
  • http://[REDACTED]:14100/ is that URL: plain, unencrypted HTTP, a host whose name is redacted, and port 14100, the doorway found in the scan.

The author notes that Jexboss includes many methods and exploitation techniques and covers application and servlet deserialisations and Struts2. In plain terms: a servlet is a small Java program that handles web requests inside a server like JBoss; deserialisation is the process of turning stored or transmitted data back into live objects in memory, and it becomes dangerous when the data comes from an untrusted source and the program trusts it blindly; Struts2 is a popular Java web framework with its own history of serious bugs. Jexboss bundles checks for several of these so the tester does not have to try each one by hand. The author also notes that JBoss can be exploited with Metasploit, another well-known exploitation framework, but prefers Jexboss.

From the original on infosecwriteups.com

The screenshot shows the tool running against the target: the checks it performs and the output it prints as it goes.

Step 2: exploit JMXInvokerServlet for RCE

The server was vulnerable. Using the JMXInvokerServlet method, the author obtained remote code execution on the server. JMXInvokerServlet is a component inside JBoss that accepts requests and acts on them; when it is exposed and not properly protected, an attacker can abuse it to make the server run code. The author describes the exploitation as pretty straightforward.

From the original on infosecwriteups.com

The screenshot shows the vulnerable result reported by the tool: the confirmation that the target could be exploited.

Step 3: attempt a reverse shell

With the foothold in place, the real problem appeared. As usual after an RCE, the author tried to get a reverse shell. A reverse shell is the opposite of what you might expect: instead of the attacker connecting to the victim, the victim is made to connect back out to the attacker's machine and hand over a command prompt. Attackers prefer this direction because outgoing connections are often allowed through firewalls while incoming ones are blocked. The machine that waits for such connections is called a listener.

From the original on infosecwriteups.com

The screenshot shows the attempt to get that connection back.

A back connection was obtained.

From the original on infosecwriteups.com

The screenshot shows the incoming connection arriving at the attacker's side.

However, the shell was not stable: the python process was killed after a few seconds. The author tried other reverse shell one-liner payloads, different common ports, and even UDP, with the same result. A payload is the piece of code that gets executed to produce the desired effect, here a connection back. A one-liner is a payload written as a single short command. Trying different ports and UDP is a way of ruling out the possibility that a firewall was blocking one particular kind of traffic.

Metasploit reverse_tcp, reverse_http and reverse_https payloads in different forms were also tried to get meterpreter connections, but the meterpreter shells were disconnected after a few seconds as well. Metasploit is a framework that packages exploits and payloads; meterpreter is its advanced shell that runs in memory on the victim. The three payload names describe how the connection travels: over raw TCP, over HTTP, or over HTTPS. None of them survived.

The author had seen situations like this before and had always wondered how to proceed when a reverse shell is not possible. The answer given here is a bind shell connection over an HTTP tunnel, which is continued in part 2 of the series. A bind shell is the other direction: the victim machine opens a doorway and waits, and the attacker connects to it. An HTTP tunnel wraps that connection inside ordinary-looking web traffic so it can pass through filters that allow web browsing but block other things.

Root cause

The report does not analyse the root cause of the JBoss vulnerability itself. What it establishes is that the JBoss instance on port 14100 was reachable from the internet-facing position the author scanned, and that it was exploitable through the JMXInvokerServlet method, which Jexboss detected and used. The JBoss instance on 14100/tcp was found by a full port scan of the sub-domain.

The second failure, the unstable reverse shell, is described only by its symptoms: the python process was killed after a few seconds, and neither other one-liners, other common ports, UDP, nor Metasploit reverse_tcp, reverse_http and reverse_https meterpreter payloads survived. The report does not say what was killing the process or blocking the connections.

Impact

On this engagement the RCE gave the author a foothold on the telecom company's Network Monitoring System. From there the author went on to proxify internal network scans and, per the summary and the later parts of the series, obtained access to CDRs and VLR with an SS7 application. A proxy is an intermediary that forwards traffic on your behalf; proxifying a scan means routing the scan through a machine inside the network so it appears to come from there. VLR stands for Visitor Location Register, a database in mobile networks that tracks which subscribers are currently in a given area; SS7 is the signalling system that mobile networks use to talk to each other. The report does not give the number of records, systems or subscribers affected, and much of the detail is redacted because of the sensitivity of the information.

Fix

Judged from what is shown, the JBoss instance on 14100/tcp should not have been reachable in the way it was, and the JMXInvokerServlet exposure that Jexboss exploited should have been removed or protected.

Variants to test

  1. Full port scans on every sub-domain found by DNS enumeration, not just 80 and 443. A positive result is any high port running JBoss or another middleware console, as happened here on 14100/tcp.
  2. Jexboss against any JBoss instance discovered, checking whether it reports the target as vulnerable and whether the JMXInvokerServlet method yields command execution.
  3. When a reverse shell dies after a few seconds, try a bind shell over an HTTP tunnel instead, which is the path the author takes in part 2.
  4. Large DNS wordlists with high thread counts and output filtering, as in the aiodnsbrute command above, to surface internal-sounding names such as the NMS sub-domain found here.

Promotion Time

The author mentions two books co-authored with @himanshu_hax for readers who want to learn more about the techniques and the basic concepts behind them: Hands-On Red Team Tactics and Hands-On Web Application Penetration Testing with Metasploit.

From the original on infosecwriteups.com

Glossary

  • Red team engagement: an authorised test in which a security professional plays the role of an attacker against a client's systems.
  • CDR (Call Detail Record): a record kept by a phone network documenting the details of a call or text message, such as time, duration, completion status, source number and destination number.
  • NMS (Network Monitoring System): software that watches over a network and collects health and performance data from its devices.
  • RCE (Remote Code Execution): a weakness that lets an attacker make a remote machine run commands of their choosing.
  • Shell: a command prompt on a machine, used to type commands and read the results.
  • Stable shell: a shell that stays connected and usable rather than dying after a short time.
  • Reconnaissance: the information-gathering phase before exploitation.
  • DNS: the internet's naming system, which translates readable names into machine addresses.
  • DNS enumeration: systematically trying many candidate names under a domain to discover which exist.
  • Sub-domain: a name that sits under a main domain, like a department inside a company.
  • Wordlist: a text file of candidate names or words that a tool tries one by one.
  • Threads: parallel workers inside a program; more threads means more lookups at once.
  • ASN (Autonomous System Number): an identifier for a large block of internet addresses managed by one organisation.
  • BGP: the routing protocol that tells the internet how to reach address blocks.
  • Passive recon: gathering information without directly touching the target, for example from search engines.
  • OSINT (Open-Source Intelligence): information gathered from publicly available sources.
  • Spear phishing: a targeted fake email designed to trick a specific person into a harmful action.
  • Antivirus (AV): software that tries to detect and block malicious files on a computer.
  • Spam filter: software that blocks suspicious email before it reaches the recipient.
  • Port: a numbered doorway on a machine through which a service listens for connections.
  • Port 80 / 443: the standard doorways for unencrypted and encrypted web traffic respectively.
  • Port scan: trying many doorways on a machine to see which are open.
  • Full port scan: a scan that tries every port, not just the common web ones.
  • TCP: the reliable, connection-based protocol most services use.
  • UDP: a connectionless protocol that does not guarantee delivery.
  • JBoss: a Java application server that runs Java web applications for an organisation.
  • Middleware: software that sits between systems and provides common services to applications.
  • Exploitation: actually using a weakness to gain access, rather than just noticing it.
  • Jexboss: a tool that tests and exploits known JBoss weaknesses.
  • Metasploit: a framework that packages exploits and payloads.
  • Servlet: a small Java program that handles web requests inside a server such as JBoss.
  • Deserialisation: turning stored or transmitted data back into live objects in memory; dangerous when untrusted data is trusted blindly.
  • Struts2: a popular Java web framework with a history of serious bugs.
  • JMXInvokerServlet: a JBoss component that accepts requests and acts on them, abusable when exposed and unprotected.
  • Payload: the piece of code executed to produce a desired effect, such as a connection back to the attacker.
  • One-liner: a payload written as a single short command.
  • Reverse shell: a shell in which the victim machine connects back out to the attacker and hands over a command prompt.
  • Bind shell: a shell in which the victim machine opens a doorway and waits, and the attacker connects to it.
  • Listener: the machine or process waiting to receive an incoming connection.
  • Meterpreter: Metasploit's advanced shell that runs in memory on the victim.
  • reverse_tcp / reverse_http / reverse_https: Metasploit payloads that carry the connection over raw TCP, HTTP or HTTPS respectively.
  • HTTP tunnel: wrapping one kind of connection inside ordinary web traffic so it can pass through filters.
  • Proxy: an intermediary that forwards traffic on your behalf.
  • Proxifying a scan: routing a scan through a machine inside the network so it appears to come from there.
  • VLR (Visitor Location Register): a database in mobile networks tracking which subscribers are currently in a given area.
  • SS7: the signalling system that mobile networks use to talk to each other.

Similar reports

View all

Same bug class and techniques, clearest first.

Remote code execution

The lesson behind this report.

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.