1 //////////////////////////////////////////////////////////
4 // Thomas Harvie Mudrunka (C) 2006 //
7 // > ICQ 283-782-978 //
9 //////////////////////////////////////////////////////////
16 import javax
.swing
.JOptionPane
;
20 //-------------------------------------------------------------------------------------------------------------------------------------------------------------
25 //-------------------------------------------------------------------------------------------------------------------------------------------------------------
27 public static void main(String
[] args
) throws java
.io
.IOException
{
28 System
.out
.println("Chater 1.4\nby: Thomas Mudrunka (C) 2006 - Czech Rep.\nICQ: 283782978\n\nProgram Started!\nInitializing...\n");
30 String line
, pass
, goodpass
, popup
;
33 //InetAddress add = getLocalhost(); //Adresa localhosta
34 Runtime runtime
= Runtime
.getRuntime();
35 if(args
[0].equals("help")){
36 System
.out
.println("You need help ha?!");
40 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);}
41 if(args
.length
> 1){popup
= args
[1];}
43 ServerSocket ss
= new ServerSocket(port
); //Vytvořit serverový soket
44 System
.out
.println("Server started on: localhost:" + port
+ "\nPopups enabled: " + popup
+ "\nNow waiting for incoming connection!");
46 //Přijetí příchozího spojení
47 //-------------------------------------------------------------------------------------------------------------------------------------------------------------
50 Socket sckt
= ss
.accept();
51 System
.out
.println("Connected!");
52 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.
57 //-------------------------------------------------------------------------------------------------------------------------------------------------------------
59 line = br.readLine(); //Přečíst další řádek z telnetu
61 System.out.println("Waiting for password.");
66 if(args[2].equals(line)) {goodpass = "true";}
67 line = br.readLine(); //Přečíst další řádek z telnetu
70 while((line != null) || (goodpass.equals("false"))){
71 if(args[2].equals(line)){goodpass = "true"; System.out.println("GOOD"}
72 System.out.println("Invalid Password! Valid=" + args[2]);
73 //if(args[2] == line){System.out.println("Good Password!");}
80 //-------------------------------------------------------------------------------------------------------------------------------------------------------------
82 System
.out
.println("Incoming data:");
83 line
= br
.readLine(); //Přečíst další řádek z telnetu
86 if(line
.equals("|exit") || line
.equals("|exit1") || line
.equals("|cmd") || line
.equals("|popup") || line
.equals("|plain")){
87 System
.out
.println("! Incoming command:");
88 if(line
.equals("|popup"))
91 System
.out
.println("- Enabling popups!");
93 if(line
.equals("|plain"))
96 System
.out
.println("- Disabling popups!");
98 if(line
.equals("|exit"))
100 System
.out
.println("- Remote daemon shutdown request...\n- Exit code: 0");
103 if(line
.equals("|exit1"))
105 System
.out
.println("- Remote daemon shutdown request (because of error)...\n- Exit code: 1");
108 if(line
.equals("|cmd"))
111 System
.out
.println("- Waiting for remote command line...");
112 line
= br
.readLine();
113 System
.out
.println("- Executing...");
115 System
.out
.println("- Done!");
116 } catch (Exception ex
) {}
121 //Tisk zpráv do konzole a otevírání popapek
122 //-------------------------------------------------------------------------------------------------------------------------------------------------------------
125 System
.out
.println(line
);
126 if(popup
.equals("true")){
127 JOptionPane
.showMessageDialog(null, line
);
130 line
= br
.readLine();//Přečíst další řádek z telnetu
133 System
.out
.print("Connection closed by client!\nNow waiting for incoming connection!");
137 //-------------------------------------------------------------------------------------------------------------------------------------------------------------
139 public static void slow() { //Metoda pro zahlcení CPU.
144 if ((a
< 2147438648) && (b
< 2147438648) && (c
< 2147438648)) {
145 c
= a
+ b
; b
= c
- a
;
154 //-------------------------------------------------------------------------------------------------------------------------------------------------------------