-
Notifications
You must be signed in to change notification settings - Fork 109
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #24 from qtc-de/develop
Prepare v4.2.0 release
- Loading branch information
Showing
13 changed files
with
636 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package de.qtc.rmg.io; | ||
|
||
import java.io.ByteArrayOutputStream; | ||
|
||
import de.qtc.rmg.internal.ExceptionHandler; | ||
|
||
/** | ||
* The SingleOpOutputStream class is used during SSRF operations. When the SSRF option is used, | ||
* remote-method-guesser collects output data into an byte array instead of sending it to a remote | ||
* server. The corresponding RMI calls always use the stream protocol, which is not ideal for SSRF | ||
* attacks. The SingleOpOutputStream abuses the fact that Java RMI calls the flush method on the | ||
* stream directly before and after the handshake that is performed within the stream protocol. | ||
* This allows to cleanly cutoff the handshake and to switch the contents of the resulting byte | ||
* array to the single operation protocol. | ||
* | ||
* @author Tobias Neitzel (@qtc_de) | ||
*/ | ||
public class SingleOpOutputStream extends ByteArrayOutputStream { | ||
|
||
private int flushCount; | ||
|
||
public SingleOpOutputStream() { | ||
super(); | ||
flushCount = 0; | ||
} | ||
|
||
/** | ||
* Java RMI calls the flush method before and after the handshake. During the first call, only the | ||
* RMI magic, the protocol version and the protocol type are contained in the stream. After the | ||
* second call, the client host and client port are contained. Afterwards, the handshake has completed | ||
* and the RMI communication starts. | ||
*/ | ||
public synchronized void write(byte[] b, int off, int len) | ||
{ | ||
switch( flushCount++ ) { | ||
|
||
case 0: | ||
|
||
if( b[len - 1] != 0x4b ) | ||
ExceptionHandler.internalError("SingleOpOutputStream.write", "invalid protocol type"); | ||
|
||
b[len - 1] = 0x4c; | ||
break; | ||
|
||
case 1: | ||
|
||
return; | ||
|
||
case 2: | ||
|
||
if( b[0] != 0x50 ) | ||
ExceptionHandler.internalError("SingleOpOutputStream.write", "invalid operation type"); | ||
|
||
break; | ||
} | ||
|
||
super.write(b, off, len); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.