This document outlines a server and client for remote command execution. The server runs on a specified port, accepts connections from clients, and executes commands sent by the client using a bash process. It returns the output to the client. The client connects to the server, takes input from the user and sends it to the server, and prints the response until it receives a "bye" message. References are provided for the source code and presentation platform used.
This presentation was presented at IT Audit & IT Security Meetup #4 at Indonesian Cloud, Jakarta.
The exploit development process was quite challenging and we think that it's worth to share.
For educational purposes only.
Exploit Development: EzServer Buffer Overflow oleh Tom Gregoryzakiakhmad
EzServer adalah video server yang dapat melakukan stream dengan kualitas full HD ke berbagai mesin. Buffer overflow ditemukan pada aplikasi EzServer yang berjalan pada port 8000. Attacker dapat mengirimkan sejumlah kode berbahaya ke port 8000 dan mendapatkan akses setara dengan hak akses aplikasi EzServer. Pada kesempatan ini, penulis akan memaparkan proses pembuatan exploit terhadap aplikasi EzServer menggunakan Python.
Tom Gregory: Security consultant at Spentera, Metasploit exploit developer/contributor.
http://www.python.or.id/2013/04/kopi-darat-komunitas-python-indonesia.html
This presentation was presented at IT Audit & IT Security Meetup #4 at Indonesian Cloud, Jakarta.
The exploit development process was quite challenging and we think that it's worth to share.
For educational purposes only.
Exploit Development: EzServer Buffer Overflow oleh Tom Gregoryzakiakhmad
EzServer adalah video server yang dapat melakukan stream dengan kualitas full HD ke berbagai mesin. Buffer overflow ditemukan pada aplikasi EzServer yang berjalan pada port 8000. Attacker dapat mengirimkan sejumlah kode berbahaya ke port 8000 dan mendapatkan akses setara dengan hak akses aplikasi EzServer. Pada kesempatan ini, penulis akan memaparkan proses pembuatan exploit terhadap aplikasi EzServer menggunakan Python.
Tom Gregory: Security consultant at Spentera, Metasploit exploit developer/contributor.
http://www.python.or.id/2013/04/kopi-darat-komunitas-python-indonesia.html
various tricks for remote linux exploits by Seok-Ha Lee (wh1ant)CODE BLUE
Modern operating systems include hardened security mechanisms to block exploit attempts. ASLR and NX (DEP) are two examples of the mechanisms that are widely implemented for the sake of security. However, there exists ways to bypass such protections by leveraging advanced exploitation techniques. It becomes harder to achieve code execution when the exploitation originates from a remote location, such as when the attack originates from a client, targeting server daemons. In such cases it is harder to find out the context information of target systems and, therefore, harder to achieve code execution. Knowledge on the memory layout of the targeted process is a crucial piece of the puzzle in developing an exploit, but it is harder to figure out when the exploit attempt is performed remotely. Recently, there have been techniques to leverage information disclosure (memory leak) vulnerabilities to figure out where specific library modules are loaded in the memory layout space, and such classes of vulnerabilities have been proven to be useful to bypass ASLR. However, there is also a different way of figuring out the memory layout of a process running in a remote environment. This method involves probing for valid addresses in target remote process. In a Linux environment, forked child processes will inherit already randomized memory layout from the parent process. Thus every client connection made to server daemons will share the same memory layout. The memory layout randomization is only done during the startup of the parent service process, and not randomized again when it is forking a child process to handle client connections. Due to the inheritance of child processes, it is possible to figure out a small piece of different information from every connection, and these pieces can be assembled later to get the idea of a big picture of the target process's remote memory layout. Probing to see if a given address is a valid memory address in context of the target remote process and assembling such information together, an attacker can figure out where the libc library is loaded on the memory, thus allowing exploits to succeed further in code execution. One might call it brute force, but with a smart brute forcing strategy, the number of minimal required attempts are significantly reduced to less than 10 in usual cases. In this talk, we will be talking about how it is possible to probe for memory layout space utilizing a piece of code to put the target in a blocked state, and to achieve stable code execution in remote exploit attempt scenarios using such information, as well as other tricks that are often used in remote exploit development in the Linux environment.
http://codeblue.jp/en-speaker.html#SeokHaLee
[2007 CodeEngn Conference 01] seaofglass - Linux Virus AnalysisGangSeok Lee
2007 CodeEngn Conference 01
리눅스 바이러스인 Sickabs.dr에 대해 각 함수별 상세 분석 설명과 이를 C 언어로 구현하여 설명한다. File #1은 Sickabs.dr 바이러스를 C로 복원한 파일이고, File #2는 Sickabs.dr 바이러스 백신이다.
http://codeengn.com/conference/01
There are 13 System level program codes in C language. Same algorithm can be used for other languages such as YACC or LEX. The programs are as follows:
1. Create a file, add view:
2. Single Pass Assembler
3. Pass 1 Direct Linking Loader
4. Pass 2 Direct Linking Loader
5. Absolute Loader
6. Relocation Loader
7. Pass 1 Macro Processor
8. Pass 2 Macro Processor
9. Lexical Analyzer
10. Parse Tree
This project is all about the wireless operation of a DC Motor. In this project, we will control the speed of a DC Motor. Direction of the rotation will also be controlled. Wireless facility is provided with the help of Bluetooth connectivity. An android handset is required to control the operation. As the name suggests that “Speed and Direction Control of DC Motor using Android Mobile Application” is controlling the speed of a DC motor with any mobile phone containing some medium of connectivity such as Bluetooth. Various terms related to this project can be discussed as follows. Since we are concern with the wireless application that is why we are using here a mobile phone to control the whole process. Now the question is why should we use a mobile phone? Which is the most suitable mobile phone? So the answer is that mobile is used only for a Bluetooth connection. We need not to carry an extra device for transmitting the data. This transmitter is already inbuilt in a mobile phone. Now come with the question of most suitable mobile phone, so it can be observed that Android phones are the most widely used phones. Android phones are very easy from the operating point of view. I-phones and windows phones are not as popular as the Android phones. So the Android phone will be used here.
FrontDays #3. Иван Федяев, Эволюция JavaScript. Обзор нововведений ECMAScript 6FrontDays
Общий обзор новых возможностей ES6, сравнение с более ранними стандартами. Почему стоит использовать ES6 уже сейчас? Поговорим о таких нововведениях как: поддержка классов, шаблоны строк, модули, стрелочные функции, генераторы и о многом другом.
Viele performante und gut skalierbare Architekturen setzen auf asynchrone Verarbeitung. Das Testen des asynchronen Codes stellt Entwickler allerdings vor neue Herausforderungen. Dieser Vortrag bietet Orientierung für einige typischen Fragestellungen. Am Beispiel von NodeJS und Mocha wird gezeigt, wie das Testen beim Einsatz einer nicht-blockierenden Event Loop funktioniert. Anschließend illustriert der Vortrag, wie asynchroner Code mit JUnit auf der JVM – einer klassischen Multithreading-Plattform – getestet werden kann. Insbesondere wird darauf eingegangen, welche Synchronisationsmechanismen genutzt werden können und wie Race Conditions durch Unit Tests aufgedeckt werden können.
Code unter: https://github.com/andreassimon/talk-asynchronen-code-testen
various tricks for remote linux exploits by Seok-Ha Lee (wh1ant)CODE BLUE
Modern operating systems include hardened security mechanisms to block exploit attempts. ASLR and NX (DEP) are two examples of the mechanisms that are widely implemented for the sake of security. However, there exists ways to bypass such protections by leveraging advanced exploitation techniques. It becomes harder to achieve code execution when the exploitation originates from a remote location, such as when the attack originates from a client, targeting server daemons. In such cases it is harder to find out the context information of target systems and, therefore, harder to achieve code execution. Knowledge on the memory layout of the targeted process is a crucial piece of the puzzle in developing an exploit, but it is harder to figure out when the exploit attempt is performed remotely. Recently, there have been techniques to leverage information disclosure (memory leak) vulnerabilities to figure out where specific library modules are loaded in the memory layout space, and such classes of vulnerabilities have been proven to be useful to bypass ASLR. However, there is also a different way of figuring out the memory layout of a process running in a remote environment. This method involves probing for valid addresses in target remote process. In a Linux environment, forked child processes will inherit already randomized memory layout from the parent process. Thus every client connection made to server daemons will share the same memory layout. The memory layout randomization is only done during the startup of the parent service process, and not randomized again when it is forking a child process to handle client connections. Due to the inheritance of child processes, it is possible to figure out a small piece of different information from every connection, and these pieces can be assembled later to get the idea of a big picture of the target process's remote memory layout. Probing to see if a given address is a valid memory address in context of the target remote process and assembling such information together, an attacker can figure out where the libc library is loaded on the memory, thus allowing exploits to succeed further in code execution. One might call it brute force, but with a smart brute forcing strategy, the number of minimal required attempts are significantly reduced to less than 10 in usual cases. In this talk, we will be talking about how it is possible to probe for memory layout space utilizing a piece of code to put the target in a blocked state, and to achieve stable code execution in remote exploit attempt scenarios using such information, as well as other tricks that are often used in remote exploit development in the Linux environment.
http://codeblue.jp/en-speaker.html#SeokHaLee
[2007 CodeEngn Conference 01] seaofglass - Linux Virus AnalysisGangSeok Lee
2007 CodeEngn Conference 01
리눅스 바이러스인 Sickabs.dr에 대해 각 함수별 상세 분석 설명과 이를 C 언어로 구현하여 설명한다. File #1은 Sickabs.dr 바이러스를 C로 복원한 파일이고, File #2는 Sickabs.dr 바이러스 백신이다.
http://codeengn.com/conference/01
There are 13 System level program codes in C language. Same algorithm can be used for other languages such as YACC or LEX. The programs are as follows:
1. Create a file, add view:
2. Single Pass Assembler
3. Pass 1 Direct Linking Loader
4. Pass 2 Direct Linking Loader
5. Absolute Loader
6. Relocation Loader
7. Pass 1 Macro Processor
8. Pass 2 Macro Processor
9. Lexical Analyzer
10. Parse Tree
This project is all about the wireless operation of a DC Motor. In this project, we will control the speed of a DC Motor. Direction of the rotation will also be controlled. Wireless facility is provided with the help of Bluetooth connectivity. An android handset is required to control the operation. As the name suggests that “Speed and Direction Control of DC Motor using Android Mobile Application” is controlling the speed of a DC motor with any mobile phone containing some medium of connectivity such as Bluetooth. Various terms related to this project can be discussed as follows. Since we are concern with the wireless application that is why we are using here a mobile phone to control the whole process. Now the question is why should we use a mobile phone? Which is the most suitable mobile phone? So the answer is that mobile is used only for a Bluetooth connection. We need not to carry an extra device for transmitting the data. This transmitter is already inbuilt in a mobile phone. Now come with the question of most suitable mobile phone, so it can be observed that Android phones are the most widely used phones. Android phones are very easy from the operating point of view. I-phones and windows phones are not as popular as the Android phones. So the Android phone will be used here.
FrontDays #3. Иван Федяев, Эволюция JavaScript. Обзор нововведений ECMAScript 6FrontDays
Общий обзор новых возможностей ES6, сравнение с более ранними стандартами. Почему стоит использовать ES6 уже сейчас? Поговорим о таких нововведениях как: поддержка классов, шаблоны строк, модули, стрелочные функции, генераторы и о многом другом.
Viele performante und gut skalierbare Architekturen setzen auf asynchrone Verarbeitung. Das Testen des asynchronen Codes stellt Entwickler allerdings vor neue Herausforderungen. Dieser Vortrag bietet Orientierung für einige typischen Fragestellungen. Am Beispiel von NodeJS und Mocha wird gezeigt, wie das Testen beim Einsatz einer nicht-blockierenden Event Loop funktioniert. Anschließend illustriert der Vortrag, wie asynchroner Code mit JUnit auf der JVM – einer klassischen Multithreading-Plattform – getestet werden kann. Insbesondere wird darauf eingegangen, welche Synchronisationsmechanismen genutzt werden können und wie Race Conditions durch Unit Tests aufgedeckt werden können.
Code unter: https://github.com/andreassimon/talk-asynchronen-code-testen
BioGaia ProDentis - pirmas klinikiniais tyrimais patvirtintas probiotikas dan...Gitana Rėderienė
Gerosios bakterijos jau seniai vartojamos atstatyti žarnyno mikroflorą po antibiotikų vartojimo, patirtų stresų ar kelionių metu, o paskutiniai moksliniai tyrimai rodo, kad specifinės bakterijų padermės yra naudingos ir burnos sveikatai
A simple client-server application in java in which a client sends a message to a server and the server tries to be funny by sending back a funny response.
The Qualcomm® Snapdragon™ LLVM, a product of Qualcomm Technologies, Inc. is an optimizing compiler tuned for 32- and 64-bit Snapdragon processors. In this session you will learn how to use Snapdragon LLVM to build your Android app’s native code. We’ll provide guidelines on how to target your C and C++ code to exploit Snapdragon LLVM and sample code demonstrating areas of acceleration.
Learn more about Snapdragon LLVM Compiler for Android: https://developer.qualcomm.com/mobile-development/increase-app-performance/snapdragon-llvm-compiler-android
Watch this presentation on YouTube:
https://www.youtube.com/watch?v=6lKOY2_Bg70
Fraglight: Shedding Light on Broken Pointcuts Using Structural CommonalityRaffi Khatchadourian
Talk at New York City College of Technology, City University of New York, Brooklyn, NY. Presentation on “Fraglight: Shedding Light on Broken Pointcuts in Evolving Aspect-Oriented Software.” See bit.ly/fraglight.
1- Modeling Hierarchy
2- Creating Testbenches
Skills gained:
1- Reuse design units several times in a design hierarchy
2- Automate testing of design units
This is part of VHDL 360 course
Fraglight: Shedding Light on Broken Pointcuts in Evolving Aspect-Oriented Sof...Raffi Khatchadourian
Pointcut fragility is a well-documented problem in Aspect-Oriented Programming; changes to the base-code can lead to join points in- correctly falling in or out of the scope of pointcuts. Deciding which pointcuts have broken due to base-code changes is a daunting venture, especially in large and complex systems. We demonstrate an automated tool called FRAGLIGHT that recommends a set of pointcuts that are likely to require modification due to a particular base-code change. The underlying approach is rooted in harnessing unique and arbitrarily deep structural commonality between program elements corresponding to join points selected by a pointcut in a particular software version. Patterns describing such commonality are used to recommend pointcuts that have potentially broken with a degree of confidence as the developer is typing. Our tool is implemented as an extension to the Mylyn Eclipse IDE plug-in, which maintains focused contexts of entities relevant to a task.
Detecting Broken Pointcuts using Structural Commonality and Degree of InterestRaffi Khatchadourian
Pointcut fragility is a well-documented problem in Aspect-Oriented Programming; changes to the base-code can lead to join points incorrectly falling in or out of the scope of pointcuts. Deciding which pointcuts have broken due to base-code changes is a daunting venture, especially in large and complex systems. We present an automated approach that recommends pointcuts that are likely to require modification due to a particular base-code change, as well as ones that do not. Our hypothesis is that join points selected by a pointcut exhibit common structural characteristics. Patterns describing such commonality are used to recommend pointcuts that have potentially broken with a degree of confidence as the developer is typing. The approach is implemented as an extension to the popular Mylyn Eclipse IDE plug-in, which maintains focused contexts of entities relevant to the task at hand using a Degree of Interest (DOI) model. We show that it is accurate in revealing broken pointcuts by applying it to multiple versions of several open source projects and evaluating the quality of the recommendations produced against actual modifications.
This is inspired from Tom Mitchell's book on Machine Learning. You can achieve a bit exact implementation of the back propagation algorithm if you follow the code in this.
Harnessing WebAssembly for Real-time Stateless Streaming PipelinesChristina Lin
Traditionally, dealing with real-time data pipelines has involved significant overhead, even for straightforward tasks like data transformation or masking. However, in this talk, we’ll venture into the dynamic realm of WebAssembly (WASM) and discover how it can revolutionize the creation of stateless streaming pipelines within a Kafka (Redpanda) broker. These pipelines are adept at managing low-latency, high-data-volume scenarios.
A review on techniques and modelling methodologies used for checking electrom...nooriasukmaningtyas
The proper function of the integrated circuit (IC) in an inhibiting electromagnetic environment has always been a serious concern throughout the decades of revolution in the world of electronics, from disjunct devices to today’s integrated circuit technology, where billions of transistors are combined on a single chip. The automotive industry and smart vehicles in particular, are confronting design issues such as being prone to electromagnetic interference (EMI). Electronic control devices calculate incorrect outputs because of EMI and sensors give misleading values which can prove fatal in case of automotives. In this paper, the authors have non exhaustively tried to review research work concerned with the investigation of EMI in ICs and prediction of this EMI using various modelling methodologies and measurement setups.
ACEP Magazine edition 4th launched on 05.06.2024Rahul
This document provides information about the third edition of the magazine "Sthapatya" published by the Association of Civil Engineers (Practicing) Aurangabad. It includes messages from current and past presidents of ACEP, memories and photos from past ACEP events, information on life time achievement awards given by ACEP, and a technical article on concrete maintenance, repairs and strengthening. The document highlights activities of ACEP and provides a technical educational article for members.
Hierarchical Digital Twin of a Naval Power SystemKerry Sado
A hierarchical digital twin of a Naval DC power system has been developed and experimentally verified. Similar to other state-of-the-art digital twins, this technology creates a digital replica of the physical system executed in real-time or faster, which can modify hardware controls. However, its advantage stems from distributing computational efforts by utilizing a hierarchical structure composed of lower-level digital twin blocks and a higher-level system digital twin. Each digital twin block is associated with a physical subsystem of the hardware and communicates with a singular system digital twin, which creates a system-level response. By extracting information from each level of the hierarchy, power system controls of the hardware were reconfigured autonomously. This hierarchical digital twin development offers several advantages over other digital twins, particularly in the field of naval power systems. The hierarchical structure allows for greater computational efficiency and scalability while the ability to autonomously reconfigure hardware controls offers increased flexibility and responsiveness. The hierarchical decomposition and models utilized were well aligned with the physical twin, as indicated by the maximum deviations between the developed digital twin hierarchy and the hardware.
6th International Conference on Machine Learning & Applications (CMLA 2024)ClaraZara1
6th International Conference on Machine Learning & Applications (CMLA 2024) will provide an excellent international forum for sharing knowledge and results in theory, methodology and applications of on Machine Learning & Applications.
7. Introduction The Server The Echo Client References
THE SERVER I
/∗
∗ Copyright ( c ) 2013, Oracle and / or i t s a f f i l i a t e s . A l l r i g h t s reserved .
∗
∗ R e d i s t r i b u t i o n and use in source and binary forms , with or without
∗ modification , are permitted provided that the f o l l o w i n g conditions
∗ are met :
∗
∗ − Redistributions of source code must r e t a i n the above copyright
∗ notice , t h i s l i s t of conditions and the f o l l o w i n g disclaimer .
∗
∗ − Redistributions in binary form must reproduce the above copyright
∗ notice , t h i s l i s t of conditions and the f o l l o w i n g disclaimer in the
∗ documentation and / or other materials provided with the d i s t r i b u t i o n .
∗
∗ − Neither the name of Oracle or the names of i t s
∗ c o n t r i b u t o r s may be used to endorse or promote products derived
∗ from t h i s software without s p e c i f i c p r i o r w r i t t e n permission .
∗
∗ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
∗ IS " AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
∗ THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
∗ PURPOSE ARE DISCLAIMED . IN NO EVENT SHALL THE COPYRIGHT OWNER OR
∗ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT , INCIDENTAL , SPECIAL ,
∗ EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
∗ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
∗ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
∗ LIABILITY , WHETHER IN CONTRACT, STRICT LIABILITY , OR TORT (INCLUDING
∗ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
∗ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
8. Introduction The Server The Echo Client References
THE SERVER II
∗/
import java . net . ∗ ;
import java . io . ∗ ;
public class TelnetServer {
public static void main ( String [ ] args ) throws IOException {
i f ( args . length != 1) {
System . err . p r i n t l n ( "Usage : java EchoServer <port number>" ) ;
System . e x i t ( 1 ) ;
}
int portNumber = Integer . parseInt ( args [ 0 ] ) ;
try (
ServerSocket serverSocket =
new ServerSocket ( Integer . parseInt ( args [ 0 ] ) ) ;
Socket clientSocket = serverSocket . accept ( ) ;
P r i n t W r i t e r out =
new P r i n t W r i t e r ( clientSocket . getOutputStream ( ) , true ) ;
BufferedReader in = new BufferedReader (
new InputStreamReader ( clientSocket . getInputStream ( ) ) ) ;
) {
String inputLine ;
String n u l l S t r =null ;
while ( ( inputLine = in . readLine ( ) ) != null ) {
ProcessBuilder processB=new ProcessBuilder ( " bash " , "−c " , inputLine ) ;
processB . redirectErrorStream ( true ) ;
9. Introduction The Server The Echo Client References
THE SERVER III
Process process = processB . s t a r t ( ) ;
BufferedReader br = new BufferedReader (
new InputStreamReader ( process . getInputStream ( ) ) ) ;
/ / BufferedReader errorReader = new BufferedReader (
/ / new InputStreamReader ( process . getErrorStream ( ) ) ) ;
while ( ( inputLine=br . readLine ( ) ) ! = null ) {
out . p r i n t l n ( inputLine ) ;
System . out . p r i n t l n ( " Log : "+ inputLine ) ;
}
out . p r i n t l n ( " bye " ) ;
out . flush ( ) ;
System . out . p r i n t l n ( "Bye Input ! " ) ;
System . out . p r i n t l n ( "Bye Error ! " ) ;
br . close ( ) ;
process . destroy ( ) ;
/ / out . p r i n t l n ( " Bye : " ) ;
}
} catch ( IOException e ) {
System . out . p r i n t l n ( " Exception caught when t r y i n g to l i s t e n on port "
+ portNumber + " or l i s t e n i n g f o r a connection " ) ;
System . out . p r i n t l n ( e . getMessage ( ) ) ;
}
}
}
10. Introduction The Server The Echo Client References
THE CLIENT I
/∗
∗ Copyright ( c ) 1995, 2013, Oracle and / or i t s a f f i l i a t e s . A l l r i g h t s reserved .
∗
∗ R e d i s t r i b u t i o n and use in source and binary forms , with or without
∗ modification , are permitted provided that the f o l l o w i n g conditions
∗ are met :
∗
∗ − Redistributions of source code must r e t a i n the above copyright
∗ notice , t h i s l i s t of conditions and the f o l l o w i n g disclaimer .
∗
∗ − Redistributions in binary form must reproduce the above copyright
∗ notice , t h i s l i s t of conditions and the f o l l o w i n g disclaimer in the
∗ documentation and / or other materials provided with the d i s t r i b u t i o n .
∗
∗ − Neither the name of Oracle or the names of i t s
∗ c o n t r i b u t o r s may be used to endorse or promote products derived
∗ from t h i s software without s p e c i f i c p r i o r w r i t t e n permission .
∗
∗ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
∗ IS " AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
∗ THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
∗ PURPOSE ARE DISCLAIMED . IN NO EVENT SHALL THE COPYRIGHT OWNER OR
∗ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT , INCIDENTAL , SPECIAL ,
∗ EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
∗ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
∗ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
∗ LIABILITY , WHETHER IN CONTRACT, STRICT LIABILITY , OR TORT (INCLUDING
∗ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
∗ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
11. Introduction The Server The Echo Client References
THE CLIENT II
∗/
import java . io . ∗ ;
import java . net . ∗ ;
public class TelnetClient {
public static void main ( String [ ] args ) throws IOException {
i f ( args . length != 2) {
System . err . p r i n t l n (
"Usage : java TelnetClient <host name> <port number>" ) ;
System . e x i t ( 1 ) ;
}
String hostName = args [ 0 ] ;
int portNumber = Integer . parseInt ( args [ 1 ] ) ;
try (
Socket echoSocket = new Socket ( hostName , portNumber ) ;
P r i n t W r i t e r out =
new P r i n t W r i t e r ( echoSocket . getOutputStream ( ) , true ) ;
BufferedReader in =
new BufferedReader (
new InputStreamReader ( echoSocket . getInputStream ( ) ) ) ;
BufferedReader stdIn =
new BufferedReader (
new InputStreamReader ( System . in ) )
) {
String userInput , serverOutput ;
12. Introduction The Server The Echo Client References
THE CLIENT III
while ( ( userInput = stdIn . readLine ( ) ) != null ) {
out . p r i n t l n ( userInput ) ;
System . out . p r i n t l n ( " t e l n e t : " ) ;
while ( ! ( serverOutput=in . readLine ( ) ) . equals ( " bye " ) )
System . out . p r i n t l n ( serverOutput ) ;
System . out . p r i n t l n ( "Bye Client " ) ;
}
} catch ( UnknownHostException e ) {
System . err . p r i n t l n ( "Don ’ t know about host " + hostName ) ;
System . e x i t ( 1 ) ;
} catch ( IOException e ) {
System . err . p r i n t l n ( " Couldn ’ t get I /O f o r the connection to " +
hostName ) ;
System . e x i t ( 1 ) ;
}
}
}
13. Introduction The Server The Echo Client References
REFERENCES
The source code has been taken from
here.
This presentation has been produced with LATEX.
Frankfurt, monarcha.