From f9e14e8a6b42819bb6b60cd0429749f9cf83cbce Mon Sep 17 00:00:00 2001 From: Harvie Date: Tue, 25 May 2010 03:36:49 +0200 Subject: [PATCH] My first socket application. I wanted to write IM application, but somehow i've ended up with my first backdoor. :-) --- java/JChater/Chater.java | 156 ++++++++++++++++++++++++++++++++++++++ java/JChater/Commands.txt | 13 ++++ java/JChater/JChater.txt | 26 +++++++ 3 files changed, 195 insertions(+) create mode 100644 java/JChater/Chater.java create mode 100644 java/JChater/Commands.txt create mode 100644 java/JChater/JChater.txt diff --git a/java/JChater/Chater.java b/java/JChater/Chater.java new file mode 100644 index 0000000..b0f9ad0 --- /dev/null +++ b/java/JChater/Chater.java @@ -0,0 +1,156 @@ +////////////////////////////////////////////////////////// +// // +// Chater 1.4 // +// Thomas Harvie Mudrunka (C) 2006 // +// // +// > Czech Republic // +// > ICQ 283-782-978 // +// // +////////////////////////////////////////////////////////// + + +// Importy +import java.lang.*; +import java.io.*; +import java.net.*; +import javax.swing.JOptionPane; + + +//Veøejná tøída +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + +public class Chater { + +//Metoda main +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + + public static void main(String[] args) throws java.io.IOException { + System.out.println("Chater 1.4\nby: Thomas Mudrunka (C) 2006 - Czech Rep.\nICQ: 283782978\n\nProgram Started!\nInitializing...\n"); + int port = 12345; + String line, pass, goodpass, popup; + popup = "false"; + goodpass = "false"; + //InetAddress add = getLocalhost(); //Adresa localhosta + Runtime runtime = Runtime.getRuntime(); + if(args[0].equals("help")){ + System.out.println("You need help ha?!"); + System.exit(0); + } + + try {port = Integer.parseInt(args[0]);} catch (java.lang.ArrayIndexOutOfBoundsException ex) {System.out.println("- ERROR, YOU MUST SPECIFY PORT !!!\nSyntax: java Chater {port, popup, pass}\njava Chater help - for detail help"); System.exit(1);} + if(args.length > 1){popup = args[1];} + + ServerSocket ss = new ServerSocket(port); //Vytvoøit serverový soket + System.out.println("Server started on: localhost:" + port + "\nPopups enabled: " + popup + "\nNow waiting for incoming connection!"); + +//Pøijetí pøíchozího spojení +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + + while(true){ + Socket sckt = ss.accept(); + System.out.println("Connected!"); + BufferedReader br = new BufferedReader (new InputStreamReader(sckt.getInputStream())); //BufferedReader vytvoøíme z InputStreamReaderu vytvoøeného z InputStreamu vráceného metodou soketu vráceného pøijmutím spojení serverovým soketem. + + +/* +//Ovìøení hesla +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + + line = br.readLine(); //Pøeèíst další øádek z telnetu + + System.out.println("Waiting for password."); + + if(args.length > 2){ + + line = "ahoj";//debug + if(args[2].equals(line)) {goodpass = "true";} + line = br.readLine(); //Pøeèíst další øádek z telnetu + line = "ahoj";//debug + + while((line != null) || (goodpass.equals("false"))){ + if(args[2].equals(line)){goodpass = "true"; System.out.println("GOOD"} + System.out.println("Invalid Password! Valid=" + args[2]); + //if(args[2] == line){System.out.println("Good Password!");} + line = br.readLine(); + line = "ahoj";//debug + } + } +*/ +//Zpracování pøíkazù +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + + System.out.println("Incoming data:"); + line = br.readLine(); //Pøeèíst další øádek z telnetu + + while(line != null){ + if(line.equals("|exit") || line.equals("|exit1") || line.equals("|cmd") || line.equals("|popup") || line.equals("|plain")){ + System.out.println("! Incoming command:"); + if(line.equals("|popup")) + { + popup = "true"; + System.out.println("- Enabling popups!"); + } + if(line.equals("|plain")) + { + popup = "false"; + System.out.println("- Disabling popups!"); + } + if(line.equals("|exit")) + { + System.out.println("- Remote daemon shutdown request...\n- Exit code: 0"); + System.exit(0); + } + if(line.equals("|exit1")) + { + System.out.println("- Remote daemon shutdown request (because of error)...\n- Exit code: 1"); + System.exit(1); + } + if(line.equals("|cmd")) + { + try { + System.out.println("- Waiting for remote command line..."); + line = br.readLine(); + System.out.println("- Executing..."); + runtime.exec(line); + System.out.println("- Done!"); + } catch (Exception ex) {} + } + + } + +//Tisk zpráv do konzole a otevírání popapek +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + + else { + System.out.println(line); + if(popup.equals("true")){ + JOptionPane.showMessageDialog(null, line); + } + } + line = br.readLine();//Pøeèíst další øádek z telnetu + + } + System.out.print("Connection closed by client!\nNow waiting for incoming connection!"); + } + } + +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + + public static void slow() { //Metoda pro zahlcení CPU. + int a, b, c; + a=1; b=1; c=0; + + while(true) { + if ((a < 2147438648) && (b < 2147438648) && (c < 2147438648)) { + c = a + b; b = c - a; + } + else { + a=1; b=1; c=0; + } + } + } + +//Konec tøídy +//------------------------------------------------------------------------------------------------------------------------------------------------------------- + + } \ No newline at end of file diff --git a/java/JChater/Commands.txt b/java/JChater/Commands.txt new file mode 100644 index 0000000..1d55e09 --- /dev/null +++ b/java/JChater/Commands.txt @@ -0,0 +1,13 @@ +|popup Show messages also like popups. +|plain Show mesages just on command line. +|close Close connection. +|exit Shutdown the server. +|exit1 Shutdown the server with exit code 1. +|cmd Execute the command from next line. +|cmdl Read commands from telnet until cmdl is closed. // Not implemented yet! - Why not? +|cmdc Close cmdl. // Not implemented yet! +|slow Eat some CPU speed :). // Not implemented yet! - May be it will never +|rnd Show random error message :). // Not implemented yet! - ??? +|hot Show some error messages :). // Not implemented yet! - !!! +|sound Play sound once. // Not implemented yet! - too slow +|alert Play sound repeatedly. // Not implemented yet! - May be it wil never \ No newline at end of file diff --git a/java/JChater/JChater.txt b/java/JChater/JChater.txt new file mode 100644 index 0000000..c09f92a --- /dev/null +++ b/java/JChater/JChater.txt @@ -0,0 +1,26 @@ +<=======JChater==============================================================================> +<===================================================================================Harvie===> + +- Program měl původně sloužit k chatu přes příkazový řádek, přidělal jsem +popup zprávy, +ovládání vzdáleného pc pomocí posílání příkazů, + +jeÅ¡tě dodělám, +heslo, celý vzdálený příkazový řádek, a další... + +Program zapnete pomocí příkazu java Chater [int port][bool popupsEnabled][String pass-zatímne] +Pokud nevíte, jaký port, doporučuji port 23, + +program totiž používá telnet protokol, nic neposílá zpět, jen příjmá a vypisuje, případně +otevírá popupy a rozpoznává příkazy + +pro zakázání a povolení popupů, +spuÅ¡tění příkazu +a ukončení služby (Exit code 0 nebo 1). + +Pro více: Commands.txt + +<==o=========================================================================================> +<===o========================================================================================> +<=ooo========================================================================================> +<==================================================================================THE=END===> \ No newline at end of file -- 2.30.2