Skip to content

Commit 28b8762

Browse files
author
Nicky Bloor
committedSep 24, 2017
Initial release.
1 parent fe72ba3 commit 28b8762

File tree

79 files changed

+9199
-23
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+9199
-23
lines changed
 

‎.gitignore

+28-22
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,28 @@
1-
# Compiled class file
2-
*.class
3-
4-
# Log file
5-
*.log
6-
7-
# BlueJ files
8-
*.ctxt
9-
10-
# Mobile Tools for Java (J2ME)
11-
.mtj.tmp/
12-
13-
# Package Files #
14-
*.jar
15-
*.war
16-
*.ear
17-
*.zip
18-
*.tar.gz
19-
*.rar
20-
21-
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
22-
hs_err_pid*
1+
# Compiled class file
2+
*.class
3+
4+
# Log file
5+
*.log
6+
7+
# BlueJ files
8+
*.ctxt
9+
10+
# Mobile Tools for Java (J2ME)
11+
.mtj.tmp/
12+
13+
# Package Files #
14+
*.jar
15+
*.war
16+
*.ear
17+
*.zip
18+
*.tar.gz
19+
*.rar
20+
21+
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
22+
hs_err_pid*
23+
/nbproject/
24+
/build.xml
25+
/manifest.mf
26+
/build/
27+
/dist/
28+
/test/

‎README.md

+100-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,101 @@
11
# BaRMIe
2-
Java RMI enumeration and attack tool.
2+
BaRMIe is a tool for enumerating and attacking Java RMI (Remote Method Invocation) services.
3+
4+
RMI services often expose dangerous functionality without adequate security controls, however RMI services tend to pass under the radar during security assessments due to the lack of effective testing tools. In 2008 Adam Boulton spoke at AppSec USA ([YouTube](https://www.youtube.com/watch?v=owN9EnoLsFY)) and released some RMI attack tools which disappeared soon after, however even with those tools a successful zero-knowledge attack relies on a significant brute force attack (~64-bits/9 quintillion possibilities) being performed over the network.
5+
6+
The goal of BaRMIe is to enable security professionals to identify, attack, and secure insecure RMI services. Using partial RMI interfaces from existing software, BaRMIe can interact directly with those services without first brute forcing 64-bits over the network.
7+
8+
### Disclaimer
9+
BaRMIe was written to aid security professionals in identifying insecure RMI services on systems which the user has prior permission to attack. Unauthorised access to computer systems is illegal and BaRMIe must be used in accordance with all relevant laws. Failure to do so could lead to you being prosecuted. The developers of BaRMIe assume no liability and are not responsible for any misuse or damage caused by this program.
10+
11+
## Usage
12+
Use of BaRMIe is straightforward. Run BaRMIe with no parameters for usage information.
13+
14+
$ java -jar BaRMIe.jar
15+
▄▄▄▄ ▄▄▄ ██▀███ ███▄ ▄███▓ ██▓▓█████
16+
▓█████▄ ▒████▄ ▓██ ▒ ██▒▓██▒▀█▀ ██▒▓██▒▓█ ▀
17+
▒██▒ ▄██▒██ ▀█▄ ▓██ ░▄█ ▒▓██ ▓██░▒██▒▒███
18+
▒██░█▀ ░██▄▄▄▄██ ▒██▀▀█▄ ▒██ ▒██ ░██░▒▓█ ▄
19+
░▓█ ▀█▓ ▓█ ▓██▒░██▓ ▒██▒▒██▒ ░██▒░██░░▒████▒
20+
░▒▓███▀▒ ▒▒ ▓▒█░░ ▒▓ ░▒▓░░ ▒░ ░ ░░▓ ░░ ▒░ ░
21+
▒░▒ ░ ▒ ▒▒ ░ ░▒ ░ ▒░░ ░ ░ ▒ ░ ░ ░ ░
22+
░ ░ ░ ▒ ░░ ░ ░ ░ ▒ ░ ░
23+
░ ░ ░ ░ ░ ░ ░ ░
24+
░ v1.0
25+
Java RMI enumeration tool.
26+
Written by Nicky Bloor (@NickstaDB)
27+
28+
Warning: BaRMIe was written to aid security professionals in identifying the
29+
insecure use of RMI services on systems which the user has prior
30+
permission to attack. BaRMIe must be used in accordance with all
31+
relevant laws. Failure to do so could lead to your prosecution.
32+
The developers assume no liability and are not responsible for any
33+
misuse or damage caused by this program.
34+
35+
Usage:
36+
BaRMIe -enum [options] [host] [port]
37+
Enumerate RMI services on the given endpoint(s).
38+
Note: if -enum is not specified, this is the default mode.
39+
BaRMIe -attack [options] [host] [port]
40+
Enumerate and attack the given target(s).
41+
Options:
42+
--threads The number of threads to use for enumeration (default 10).
43+
--timeout The timeout for blocking socket operations (default 5,000ms).
44+
--targets A file containing targets to scan.
45+
The file should contain a single host or space-separated
46+
host and port pair per line.
47+
Alternatively, all nmap output formats are supported, BaRMIe will
48+
parse nmap output for port 1099, 'rmiregistry', or 'Java RMI'
49+
services to target.
50+
Note: [host] [port] not supported when --targets is used.
51+
Reliability:
52+
A +/- system is used to indicate attack reliability as follows:
53+
[+ ]: Indicates an application-specific attack
54+
[- ]: Indicates a JRE attack
55+
[ + ]: Attack insecure methods (such as 'writeFile' without auth)
56+
[ - ]: Attack Java deserialization (i.e. Object parameters)
57+
[ +]: Does not require non-default dependencies
58+
[ -]: Non-default dependencies are required
59+
60+
Enumeration mode (-enum) extracts details of objects that are exposed through an RMI registry service and lists any known attacks that affect the endpoint.
61+
62+
Attack mode (-attack) first enumerates the given targets, then provides a menu system for launching known attacks against RMI services.
63+
64+
A single target can be specified on the command line. Alternatively BaRMIe can extract targets from a simple text file or nmap output.
65+
66+
## No Vulnerable Targets Identified?
67+
Great! This is your opportunity to help improve BaRMIe! BaRMIe relies on *some* knowledge of the classes exposed over RMI so contributions will go a long way in improving BaRMIe and the security of RMI services.
68+
69+
If you have access to JAR files or source code for the target application then producing an attack is as simple as compiling code against the relevant JAR files. Retrieve the relevant remote object using the *LocateRegistry* and *Registry* classes and call the desired methods. Alternatively look for remote methods that accept arbitrary objects or otherwise non-primitive parameters as these can be used to deliver deserialization payloads. More documentation on attacking RMI and producing attacks for BaRMIe will be made available in the near future.
70+
71+
Alternatively, [get in touch](https://nickbloor.co.uk/contact/), and provide as much detail as possible including BaRMIe -enum output and ideally the relevant JAR files.
72+
73+
## Attack Types
74+
BaRMIe is capable of performing three types of attacks against RMI services. A brief description of each follows. Further technical details will be published in the near future at [https://nickbloor.co.uk/](https://nickbloor.co.uk/). In addition to this, I presented the results of my research at 44CON 2017 and the slides can be found here: [BaRMIe - Poking Java's Back Door](https://www.slideshare.net/NickBloor3/nicky-bloor-barmie-poking-javas-back-door-44con-2017).
75+
76+
### 1. Attacking Insecure Methods
77+
The first and most straightforward method of attacking insecure RMI services is to simply call insecure remote methods. Often dangerous functionality is exposed over RMI which can be triggered by simply retrieving the remote object reference and calling the dangerous method. The following code is an example of this:
78+
79+
//Get a reference to the remote RMI registry service
80+
Registry reg = LocateRegistry.getRegistry(targetHost, targetPort);
81+
82+
//Get a reference to the target RMI object
83+
Foo bar = (Foo)reg.lookup(objectName);
84+
85+
//Call the remote executeCommand() method
86+
bar.executeCommand(cmd);
87+
88+
### 2. Deserialization via Object-type Paraeters
89+
Some RMI services do not expose dangerous functionality, or they implement security controls such as authentication and session management. If the RMI service exposes a method that accepts an arbitrary Object as a parameter then the method can be used as an entry point for deserialization attacks. Some examples of such methods can be seen below:
90+
91+
public void setOption(String name, Object value);
92+
public void addAll(List values);
93+
94+
### 3. Deserialization via Illegal Method Invocation
95+
Due to the use of serialization, and insecure handling of method parameters on the server, it is possible to use any method with non-primitive parameter types as an entry point for deserialization attacks. BaRMIe achieves this by using TCP proxies to modify method parameters at the network level, essentially triggering illegal method invocations. Some examples of vulnerable methods can be seen below:
96+
97+
public void setName(String name);
98+
public Long add(Integer i1, Integer i2);
99+
public void sum(int[] values);
100+
101+
The parameters to each of these methods can be replaced with a deserialization payload as the method invocation passes through a proxy. This attack is possible because Java does not attempt to verify that remote method parameters received over the network are compatible with the actual parameter types before deserializing them.

0 commit comments

Comments
 (0)
Please sign in to comment.