1
mirror of https://github.com/rapid7/metasploit-payloads synced 2025-03-30 22:19:17 +02:00

add missing @Override

This commit is contained in:
XenoAmess 2021-02-11 23:20:09 +08:00
parent badaaa4df2
commit 8cac54b070
20 changed files with 42 additions and 0 deletions

@ -87,17 +87,21 @@ public class MemoryBufferURLConnection extends URLConnection {
contentType = file.substring(pos + 1); contentType = file.substring(pos + 1);
} }
@Override
public void connect() throws IOException { public void connect() throws IOException {
} }
@Override
public InputStream getInputStream() throws IOException { public InputStream getInputStream() throws IOException {
return new ByteArrayInputStream(data); return new ByteArrayInputStream(data);
} }
@Override
public int getContentLength() { public int getContentLength() {
return data.length; return data.length;
} }
@Override
public String getContentType() { public String getContentType() {
return contentType; return contentType;
} }

@ -16,6 +16,7 @@ public class MemoryBufferURLStreamHandler extends URLStreamHandler {
private List files = new ArrayList(); private List files = new ArrayList();
@Override
protected URLConnection openConnection(URL u) throws IOException { protected URLConnection openConnection(URL u) throws IOException {
return new MemoryBufferURLConnection(u); return new MemoryBufferURLConnection(u);
} }

@ -80,6 +80,7 @@ public class StreamForwarder extends Thread {
this.closeOut = closeOut; this.closeOut = closeOut;
} }
@Override
public void run() { public void run() {
try { try {
forward(in, out, closeOut); forward(in, out, closeOut);

@ -4,6 +4,7 @@ package metasploit;
import java.applet.*; import java.applet.*;
public class PayloadApplet extends Applet { public class PayloadApplet extends Applet {
@Override
public void init() { public void init() {
try { try {
Payload.main(null); Payload.main(null);

@ -16,6 +16,7 @@ public class PayloadServlet extends HttpServlet implements Runnable {
} }
} }
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse res) protected void doGet(HttpServletRequest req, HttpServletResponse res)
throws ServletException, java.io.IOException { throws ServletException, java.io.IOException {
PrintWriter out = res.getWriter(); PrintWriter out = res.getWriter();

@ -41,6 +41,7 @@ public class RMILoader extends ClassLoader implements Serializable {
return null; return null;
} }
@Override
public URL getResource(String name) { public URL getResource(String name) {
return getClass().getClassLoader().getResource(name); return getClass().getClassLoader().getResource(name);
} }

@ -172,6 +172,7 @@ public class Channel {
this.handleClose = handleClose; this.handleClose = handleClose;
} }
@Override
public void run() { public void run() {
try { try {
byte[] buffer = new byte[1024*1024]; byte[] buffer = new byte[1024*1024];

@ -42,10 +42,12 @@ public class HttpTransport extends Transport {
setTimeouts(transportConfig); setTimeouts(transportConfig);
} }
@Override
public void bind(DataInputStream in, OutputStream rawOut) { public void bind(DataInputStream in, OutputStream rawOut) {
// http, we don't bind to anything as we're stateless // http, we don't bind to anything as we're stateless
} }
@Override
public boolean switchUri(String uri) { public boolean switchUri(String uri) {
try { try {
// can't use getAuthority() here thanks to java 1.2. Ugh. // can't use getAuthority() here thanks to java 1.2. Ugh.
@ -105,9 +107,11 @@ public class HttpTransport extends Transport {
return this.customHeaders; return this.customHeaders;
} }
@Override
public void disconnect() { public void disconnect() {
} }
@Override
protected boolean tryConnect(Meterpreter met) throws IOException { protected boolean tryConnect(Meterpreter met) throws IOException {
URLConnection conn = this.createConnection(); URLConnection conn = this.createConnection();
@ -143,6 +147,7 @@ public class HttpTransport extends Transport {
return false; return false;
} }
@Override
public TLVPacket readPacket() throws IOException { public TLVPacket readPacket() throws IOException {
URLConnection conn = this.createConnection(); URLConnection conn = this.createConnection();
@ -163,6 +168,7 @@ public class HttpTransport extends Transport {
return null; return null;
} }
@Override
public void writePacket(TLVPacket packet, int type) throws IOException { public void writePacket(TLVPacket packet, int type) throws IOException {
URLConnection conn = this.createConnection(); URLConnection conn = this.createConnection();
@ -188,6 +194,7 @@ public class HttpTransport extends Transport {
} }
} }
@Override
public boolean dispatch(Meterpreter met) { public boolean dispatch(Meterpreter met) {
long lastPacket = System.currentTimeMillis(); long lastPacket = System.currentTimeMillis();
long ecount = 0; long ecount = 0;

@ -37,6 +37,7 @@ public class TcpTransport extends Transport {
this.out = out; this.out = out;
} }
@Override
public void run() { public void run() {
if (this.in != null) { if (this.in != null) {
try { try {
@ -95,16 +96,19 @@ public class TcpTransport extends Transport {
this.host = url.substring(url.lastIndexOf("/") + 1, portStart); this.host = url.substring(url.lastIndexOf("/") + 1, portStart);
} }
@Override
public void bind(DataInputStream in, OutputStream rawOut) { public void bind(DataInputStream in, OutputStream rawOut) {
this.inputStream = in; this.inputStream = in;
this.outputStream = new DataOutputStream(rawOut); this.outputStream = new DataOutputStream(rawOut);
} }
@Override
public boolean switchUri(String uri) { public boolean switchUri(String uri) {
// tcp transports don't support URL switching // tcp transports don't support URL switching
return false; return false;
} }
@Override
public void disconnect() { public void disconnect() {
SocketDisposer s = new SocketDisposer(this.sock, this.inputStream, this.outputStream); SocketDisposer s = new SocketDisposer(this.sock, this.inputStream, this.outputStream);
this.sock = null; this.sock = null;
@ -114,6 +118,7 @@ public class TcpTransport extends Transport {
s.start(); s.start();
} }
@Override
protected boolean tryConnect(Meterpreter met) throws IOException { protected boolean tryConnect(Meterpreter met) throws IOException {
if (this.inputStream != null) { if (this.inputStream != null) {
// we're already connected // we're already connected
@ -142,14 +147,17 @@ public class TcpTransport extends Transport {
return false; return false;
} }
@Override
public TLVPacket readPacket() throws IOException { public TLVPacket readPacket() throws IOException {
return this.readAndDecodePacket(this.inputStream); return this.readAndDecodePacket(this.inputStream);
} }
@Override
public void writePacket(TLVPacket packet, int type) throws IOException { public void writePacket(TLVPacket packet, int type) throws IOException {
this.encodePacketAndWrite(packet, type, this.outputStream); this.encodePacketAndWrite(packet, type, this.outputStream);
} }
@Override
public boolean dispatch(Meterpreter met) { public boolean dispatch(Meterpreter met) {
long lastPacket = System.currentTimeMillis(); long lastPacket = System.currentTimeMillis();
int result = 0; int result = 0;

@ -11,6 +11,7 @@ import com.metasploit.meterpreter.command.Command;
public class core_transport_change extends core_transport_add { public class core_transport_change extends core_transport_add {
@Override
public int execute(Meterpreter meterpreter, TLVPacket request, TLVPacket response) throws Exception { public int execute(Meterpreter meterpreter, TLVPacket request, TLVPacket response) throws Exception {
int result = super.execute(meterpreter, request, response); int result = super.execute(meterpreter, request, response);

@ -31,6 +31,7 @@ public class DatagramSocketChannel extends Channel {
new AcceptThread().start(); new AcceptThread().start();
} }
@Override
public void write(byte[] data, int length, TLVPacket request) throws IOException { public void write(byte[] data, int length, TLVPacket request) throws IOException {
String remoteHostName = (String) request.getValue(TLVType.TLV_TYPE_PEER_HOST, null); String remoteHostName = (String) request.getValue(TLVType.TLV_TYPE_PEER_HOST, null);
InetAddress remoteHost = null; InetAddress remoteHost = null;
@ -51,6 +52,7 @@ public class DatagramSocketChannel extends Channel {
datagramSocket.send(dp); datagramSocket.send(dp);
} }
@Override
public void close() throws IOException { public void close() throws IOException {
closed = true; closed = true;
datagramSocket.close(); datagramSocket.close();
@ -62,6 +64,7 @@ public class DatagramSocketChannel extends Channel {
} }
private class AcceptThread extends Thread { private class AcceptThread extends Thread {
@Override
public void run() { public void run() {
try { try {
byte[] datagram = new byte[65536]; byte[] datagram = new byte[65536];

@ -38,6 +38,7 @@ public class ProcessChannel extends Channel {
* @param maxLength The maximum number of bytes to read. * @param maxLength The maximum number of bytes to read.
* @return The bytes read, or <code>null</code> if the end of the stream has been reached. * @return The bytes read, or <code>null</code> if the end of the stream has been reached.
*/ */
@Override
public synchronized byte[] read(int maxLength) throws IOException, InterruptedException { public synchronized byte[] read(int maxLength) throws IOException, InterruptedException {
if (closed) if (closed)
return null; return null;
@ -50,6 +51,7 @@ public class ProcessChannel extends Channel {
return super.read(maxLength); return super.read(maxLength);
} }
@Override
public void close() throws IOException { public void close() throws IOException {
process.destroy(); process.destroy();
inputStream.close(); inputStream.close();
@ -66,6 +68,7 @@ public class ProcessChannel extends Channel {
this.stderrThread = stderrThread; this.stderrThread = stderrThread;
} }
@Override
public void run() { public void run() {
try { try {
stdinThread.start(); stdinThread.start();

@ -30,6 +30,7 @@ public class ServerSocketChannel extends Channel {
new AcceptThread().start(); new AcceptThread().start();
} }
@Override
public void close() throws IOException { public void close() throws IOException {
closed = true; closed = true;
serverSocket.close(); serverSocket.close();
@ -41,6 +42,7 @@ public class ServerSocketChannel extends Channel {
} }
private class AcceptThread extends Thread { private class AcceptThread extends Thread {
@Override
public void run() { public void run() {
try { try {
while (true) { while (true) {

@ -23,6 +23,7 @@ public class SocketChannel extends Channel {
this.socket = socket; this.socket = socket;
} }
@Override
public void close() throws IOException { public void close() throws IOException {
socket.close(); socket.close();
super.close(); super.close();

@ -4,6 +4,7 @@ import java.io.File;
public class stdapi_fs_file_expand_path_V1_5 extends stdapi_fs_file_expand_path { public class stdapi_fs_file_expand_path_V1_5 extends stdapi_fs_file_expand_path {
@Override
protected String getShellPath() { protected String getShellPath() {
String result; String result;
if (File.pathSeparatorChar == ';') if (File.pathSeparatorChar == ';')

@ -1,6 +1,7 @@
package com.metasploit.meterpreter.stdapi; package com.metasploit.meterpreter.stdapi;
public class stdapi_fs_md5 extends HashCommand { public class stdapi_fs_md5 extends HashCommand {
@Override
protected String getAlgorithm() { protected String getAlgorithm() {
return "MD5"; return "MD5";
} }

@ -1,6 +1,7 @@
package com.metasploit.meterpreter.stdapi; package com.metasploit.meterpreter.stdapi;
public class stdapi_fs_sha1 extends HashCommand { public class stdapi_fs_sha1 extends HashCommand {
@Override
protected String getAlgorithm() { protected String getAlgorithm() {
return "SHA-1"; return "SHA-1";
} }

@ -4,6 +4,7 @@ import java.io.File;
public class stdapi_fs_stat_V1_6 extends stdapi_fs_stat { public class stdapi_fs_stat_V1_6 extends stdapi_fs_stat {
@Override
protected boolean canExecute(File file) { protected boolean canExecute(File file) {
return file.canExecute(); return file.canExecute();
} }

@ -15,6 +15,7 @@ import com.metasploit.meterpreter.TLVType;
public class stdapi_net_config_get_interfaces_V1_6 extends stdapi_net_config_get_interfaces_V1_4 { public class stdapi_net_config_get_interfaces_V1_6 extends stdapi_net_config_get_interfaces_V1_4 {
@Override
public Address[] getAddresses(NetworkInterface iface) throws IOException { public Address[] getAddresses(NetworkInterface iface) throws IOException {
List/* <Address> */result = new ArrayList(); List/* <Address> */result = new ArrayList();
List addresses = iface.getInterfaceAddresses(); List addresses = iface.getInterfaceAddresses();
@ -46,6 +47,7 @@ public class stdapi_net_config_get_interfaces_V1_6 extends stdapi_net_config_get
return (Address[]) result.toArray(new Address[result.size()]); return (Address[]) result.toArray(new Address[result.size()]);
} }
@Override
protected void addMTU(TLVPacket ifaceTLV, NetworkInterface iface) throws IOException { protected void addMTU(TLVPacket ifaceTLV, NetworkInterface iface) throws IOException {
ifaceTLV.add(TLVType.TLV_TYPE_MTU, iface.getMTU()); ifaceTLV.add(TLVType.TLV_TYPE_MTU, iface.getMTU());
} }

@ -5,6 +5,7 @@ import java.net.Socket;
public class stdapi_net_socket_tcp_shutdown_V1_3 extends stdapi_net_socket_tcp_shutdown { public class stdapi_net_socket_tcp_shutdown_V1_3 extends stdapi_net_socket_tcp_shutdown {
@Override
protected void shutdown(Socket socket, int how) throws IOException { protected void shutdown(Socket socket, int how) throws IOException {
switch (how) { switch (how) {