티스토리 뷰
참조 : http://www.prasannatech.net/2008/07/socket-programming-tutorial.html
검색하다가 괜찮은 것 같아 블로그에 올려본다.
혹시 의미를 오역할까봐 그냥 원문으로 올린다.
Generic Socket Programming tutorial
S.Prasanna
sprasanna199@gmail.com
This is a generic socket programming tutorial which mainly concentrates on how to communicate with two machines using TCP/IP and UDP/IP protocols irrespective of the programming language used to implement the server and client
I will list a simple Connection oriented (TCP) and Connectionless (UDP) Server and Client programs for all the four languages namely Python , Perl, C and Java. The TCP Server program is an iterative one which means it will process clients one by one. The communication between the TCP Server and the Client is a simple chat program. If the client quits, the current TCP connection between the server and the client gets disconnected and the server processes the next client and if the server decides to quit, that client gets disconnected and the server processes the next client.
The UDP Server program is very simple. The server recieves datagrams from many clients and prints them.
In all the programs , the Server process listens at port 5000 and I have used loopback address for the Server so that you can run the server and the client in different terminals in the same system. Besides you can use any of the four servers implemented in Python , Perl, C and Java with any of the four client programs implemented inthe four languages.In short you can use a Client program in Perl with a Server program in python , Server program in python with a Client progam in C , etc. Morever you can invoke the client program without any command line arguments since the client and the server are designed to communicate using the loopback address.
I will go from easy to difficult ( in terms of readability and lines of code ). i.e for example socket programming is simple and easy to understand in Python than in C or java.
1. Socket programming in Python
Connection oriented Server and Client program.
Connectionless Server and Client program.
2. Socket programming in Perl
Connection oriented Server and Client program.
Connectionless Server and Client program.
3. Socket programming in C
Connection oriented Server and Client program.
Connectionless Server and Client program.
4. Socket programming in Java
Connection oriented Server and Client program.
Connectionless Server and Client program.
I will list similar programs in as many languages in future. I could have explained about the details of sockets, how system calls like socket , bind, listen, etc works, but those should be explained from the perspectives different languages which is beyond the scope of this tutorial. In general these programs explain the fundamental concepts of socket programming irrespective of their implementation language.
Socket programming can be easily understood in interpreted languages like Perl and Python. Perl, especially is weapon for hackers. Dangerous scripts can be developed in minutes, in perl. For example spoofing source IP address can easliy be done in Perl but it requires some effort in C or in other languages. This small script shows how to spoof UDP source address.
Raw Sockets Programming (UDP Spoofing):
When you run the above simple script as client you can see the fake IP source address and the port the client used at the UDPServer. To execute the Perl script you need the Net::RawIP Module which can be downloaded here and also its documentation.
TCP/IP spoofing is a challenging task and involves a lot of calculation involving prediction of sequence numbers,etc but worth giving a try.
'Study > Code' 카테고리의 다른 글
Ubuntu 14.04 LTS에서 R 사용하기 (0) | 2014.10.15 |
---|---|
[PHP]페이지 리다이렉트 시키기 (0) | 2012.10.05 |
- Total
- Today
- Yesterday
- ssl decrypt
- tcpdstat
- webhack
- MySQL csv
- excel_aton
- 윈도우 패스워드 복구
- docker_dvwa
- docker
- NX ASLR
- filesystem check
- bash modification
- oracle 11gr2
- text2pcap
- bash parameter
- megacli
- 도커
- mergecap
- recovery file on linux
- tshark
- dvwa_bruteforce
- pcapng
- 리눅스 버전
- dvwa
- ${1##*.}
- metasploitable3
- capinfos
- dvwa_command
- editcap
- history timestamp
- cisco ssh
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |