From 29b63872457c88975850d859ad420a040876cf84 Mon Sep 17 00:00:00 2001
From: Fedi6431 <102946457+Fedi6431@users.noreply.github.com>
Date: Sat, 8 Jun 2024 20:38:47 +0200
Subject: [PATCH] Add files via upload
---
Local_Host_Executer.iml | 11 ++++
.../Local_Host_Executer/Client.class | Bin 0 -> 2766 bytes
.../Local_Host_Executer/Server.class | Bin 0 -> 2779 bytes
src/Client.java | 55 ++++++++++++++++++
src/Server.java | 54 +++++++++++++++++
5 files changed, 120 insertions(+)
create mode 100644 Local_Host_Executer.iml
create mode 100644 out/production/Local_Host_Executer/Client.class
create mode 100644 out/production/Local_Host_Executer/Server.class
create mode 100644 src/Client.java
create mode 100644 src/Server.java
diff --git a/Local_Host_Executer.iml b/Local_Host_Executer.iml
new file mode 100644
index 0000000..9465dd8
--- /dev/null
+++ b/Local_Host_Executer.iml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/out/production/Local_Host_Executer/Client.class b/out/production/Local_Host_Executer/Client.class
new file mode 100644
index 0000000000000000000000000000000000000000..9c7457d26b6dd8a53b33c7431533634cffb9dec0
GIT binary patch
literal 2766
zcmaJ@X;%|h7=A7UCd5G`$f{CQuz<3-v|6K9jZ)GAv4B|Awhm#0fiM#%6OitE?Y>v5
z-8atZH$5%1VEY4l`U84S`#buv_PH|wCW1YLd+)sO^X~6`XMX>8{x<*zF%v=_@)ZPB
z6rfOG-IzA1wIwxkq%A%)rY9VM!UKkBIEMuC8=D4-5JZuJkcu@>$%`fp-ISoTl^EA~
zDD84Jn7Y%}=aM2)WUY!4tP?0O%v6S`Y7b>tZO1f6i%DXiW9!<4iw>(O!+I*UGL8$c
z$$`gRY8J1cLZIX}n<12=N=8&IP|@fKyD?G7Fh?S>rU3;T1S(y*m0lEK6KWOQrJ@d-
zbCS|Gop$sIfjq+$C|`2RA3+E;*eZ?J3shx|(}W))&2J;uZ{8o3^uJL>6Pg*@i0=4#
zQfbqYVLvAlLIZY4%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Si`o|9d
literal 0
HcmV?d00001
diff --git a/out/production/Local_Host_Executer/Server.class b/out/production/Local_Host_Executer/Server.class
new file mode 100644
index 0000000000000000000000000000000000000000..852c2922661ad196c53e44f0b1c22d0f469ead10
GIT binary patch
literal 2779
zcmaJ@ZCeyo7`}(MS(ZU$5fns1MFj-cm$G!#Qk2{RF&8nkvSIeP4D8OVyR#r=_Fne>
zUZ%a;3zyebAM7gVg6aoUm;QtPL4E3TcAwc<7%r$UGiRQ2KhL?J`+3ee^Xoq|zW~^a
z$smeQtfE9iDasTqAJND3a8kDt;l7~}VK@rP_L!FG>{C$O+BQ&*0LoPaHB><3Tufxf
zM23T`ZHx+{t9#rCmT%0bklQHroeK}l=0Z9p1s
z)6k5yjIA4nNRvuUYnzXFK0g)f6|8iFE~cnrgM!tC$pg7FXGBKCeK`cN39TyHG_+&0
zf~t9Po}kMT!tvp`RDlCm^G!s8XhEmUV2grPt#cyyAu_9V=v1+dkOCl4Lfls36q|GPOj}~M1KAm65NhmlHhLEbe`Y>jAXbKy8_s&fPHf}iy_XL
zP7wQXKt-2^gE+LHOIcadO3)otRqs~61Hs6+Bvb0l1!mFgLnYPRKzs&<2YNV
zpr{W+25IS$wElxF)i{9%RSar4iBsHNZV;E_v7F_YDW(}@1?E0#7v$lYBLO^2u0|>z
z;-){X;Zf-9qm(`>x@^nPofD=r%u&|SEhnpB<5I%qbM(t2xfvSbAPH7U7z$cjPc6oI
z?cll|&De&>X4wmykkBwJ&zw>tX=jD3OG3q{PpN3%p>uNInYISv8q(FN5d_
z5rTr#a_+2#3`jk|xh_2?%RjeI+=csxGxoSXloXK=PrRJeU`#=qKht@LpRw0CD$Xfr
zSR}uX;5bqt6iYheI2&a1Hd2-@J5DN9J*Fj&C~aO1*mWC%Ckv?F^e)
zp~96hM>j@$^|VK`zk(=CAy@bWnKo;8nZ`5IIl*&bGvoJu`?42F8M3z0rNo*
z>sCA|vMoKfJ(^2Le6o15`Ya0^`zO+33AjJW{2dwb_lp;zOHU?arX#rbE>obe(X0gU
z5nCbJ*DMNMy;~YTp$>DEX*S&E4d64LNnY6&;1y_5%MzKcq@K-+tcoubY*-}GQkkpx
zNG~=Si_z81fcwlGJXMnwNFE7
zSAKvhAC>Y^Eg!Y*v#1|jJ&o1U+WtK%r_dx(vsgDcia4;we8Zzi
zzHjghD8>cqFh*s7AayK7Iki~^m47z@qAGb`S0RiL_Rw+|wK$GC==|-7qX8*2B1hlz
zXkwgZTw+D8U_GwV>l(IjrA_!2t@sIT_>JE;uo*Yefj`iRKNUC;kX5*x9G}W#DJpm7RJt7?1Ccs
z2^vOp72{3J>{Yy$?*QJ=#cn)p7J(yIUf
literal 0
HcmV?d00001
diff --git a/src/Client.java b/src/Client.java
new file mode 100644
index 0000000..0bdf706
--- /dev/null
+++ b/src/Client.java
@@ -0,0 +1,55 @@
+import java.io.*;
+import java.net.*;
+
+public class Client {
+ private Socket socket = null;
+ private DataInputStream input = null;
+ private DataOutputStream output = null;
+
+ public Client(String address, int port) {
+ try {
+ // establish a connection with the server
+ System.out.println("Client started");
+ socket = new Socket(address, port);
+ System.out.println("Client connected");
+
+ // get input from the terminal
+ input = new DataInputStream(System.in);
+ // send output to the server socket
+ output = new DataOutputStream(socket.getOutputStream());
+
+ // string to read input
+ String line = "";
+
+ // IP of the server and the client
+ String serverIP = socket.getLocalAddress().getHostAddress();
+ String clientIP = Inet4Address.getLocalHost().getHostAddress();
+
+ // loop until "exit" is written
+ while (!line.equalsIgnoreCase("exit")) {
+ // get user input
+ System.out.print(clientIP + " to " + serverIP + "$-");
+ line = input.readLine();
+ // send the received input to the server
+ output.writeUTF(line);
+ }
+ // close the connection
+ input.close();
+ output.close();
+ socket.close();
+ }
+ // handle any errors
+ catch (IOException IOe) {
+ System.out.println("IO exception: " + IOe.getMessage());
+ System.out.println("Exception cause" + IOe.getCause());
+ }
+ catch (RuntimeException RTe) {
+ System.out.println("Runtime exception: " + RTe.getMessage());
+ System.out.println("Exception cause" + RTe.getCause());
+ }
+ }
+
+ public static void main(String args[]) {
+ Client client = new Client("127.0.0.1", 5000);
+ }
+}
diff --git a/src/Server.java b/src/Server.java
new file mode 100644
index 0000000..2b5e098
--- /dev/null
+++ b/src/Server.java
@@ -0,0 +1,54 @@
+import java.net.*;
+import java.io.*;
+
+public class Server {
+ private Socket socket = null;
+ private ServerSocket server = null;
+ private DataInputStream input = null;
+ private DataOutputStream output = null;
+
+ public Server(int port) {
+ try {
+ // create a server socket
+ server = new ServerSocket(port);
+ System.out.println("Server started");
+ // establish a connection with the client
+ socket = server.accept();
+ System.out.println("Client connected");
+
+ // get input from the terminal
+ input = new DataInputStream(
+ new BufferedInputStream(socket.getInputStream()));
+ // send output to the client
+ output = new DataOutputStream(
+ new BufferedOutputStream(socket.getOutputStream()));
+
+ // string to read input
+ String line = "";
+ while (!line.equalsIgnoreCase("exit")) {
+ // read the message sent by the client via socket
+ line = input.readUTF();
+ System.out.println(line);
+ String string_cod = line;
+ // try to execute the command on cmd using Runtime.getRuntime
+ Process cmd_process = Runtime.getRuntime().exec(new String[]{"cmd", "/c " + string_cod});
+ }
+ // close the connection
+ socket.close();
+ input.close();
+ }
+ // handle any errors
+ catch (IOException IOe) {
+ System.out.println("IO exception: " + IOe.getMessage());
+ System.out.println("Exception cause" + IOe.getCause());
+ }
+ catch (RuntimeException RTe) {
+ System.out.println("Runtime exception: " + RTe.getMessage());
+ System.out.println("Exception cause" + RTe.getCause());
+ }
+ }
+
+ public static void main(String args[]) {
+ Server server = new Server(5000);
+ }
+}