Download - Socket Program Training
![Page 1: Socket Program Training](https://reader030.vdocument.in/reader030/viewer/2022032612/5681325e550346895d98f080/html5/thumbnails/1.jpg)
Socket Program Training
10/24/2011
![Page 2: Socket Program Training](https://reader030.vdocument.in/reader030/viewer/2022032612/5681325e550346895d98f080/html5/thumbnails/2.jpg)
Introduction
• Video Streaming Server– Darwin
• VoIP– Asterisk
• Socket Program– Ex: FTP
• Backdoor Program
2
![Page 3: Socket Program Training](https://reader030.vdocument.in/reader030/viewer/2022032612/5681325e550346895d98f080/html5/thumbnails/3.jpg)
Darwin Streaming Server
– The open source version of Apple’s QuickTime Streaming Server technology
– Updated Version v6.0.3• http://dss.macosforge.org/
– Previous Version• v5.5.5
3
![Page 4: Socket Program Training](https://reader030.vdocument.in/reader030/viewer/2022032612/5681325e550346895d98f080/html5/thumbnails/4.jpg)
Installation
• tar zxf DarwinStreamingSrvr5.5.5-Linux.tar.gz• cd DarwinStreamingSrvrlinux-Linux• ./Install
• Please enter a new administrator user name: user_name
• Please enter a new administrator Password: your_password
4
![Page 5: Socket Program Training](https://reader030.vdocument.in/reader030/viewer/2022032612/5681325e550346895d98f080/html5/thumbnails/5.jpg)
Starting
• sudo /usr/local/sbin/DarwinStreamingServer
• sudo /usr/local/sbin/streamingadminserver.pl
• http://darwin.streaming.server:1220/
5
![Page 6: Socket Program Training](https://reader030.vdocument.in/reader030/viewer/2022032612/5681325e550346895d98f080/html5/thumbnails/6.jpg)
Asterisk
• Asterisk is software that turns an ordinary computer into a communications server.
• The Latest Version 10.0.0-beta1– http://www.asterisk.org/downloads
• V1.8.7.1
6
![Page 7: Socket Program Training](https://reader030.vdocument.in/reader030/viewer/2022032612/5681325e550346895d98f080/html5/thumbnails/7.jpg)
Installation (1/7)
• Run "./configure"
7
![Page 8: Socket Program Training](https://reader030.vdocument.in/reader030/viewer/2022032612/5681325e550346895d98f080/html5/thumbnails/8.jpg)
Installation (2/7)
• Run "make menuselect" [optional]
8
![Page 9: Socket Program Training](https://reader030.vdocument.in/reader030/viewer/2022032612/5681325e550346895d98f080/html5/thumbnails/9.jpg)
Installation (3/7)
• Run "make"
9
![Page 10: Socket Program Training](https://reader030.vdocument.in/reader030/viewer/2022032612/5681325e550346895d98f080/html5/thumbnails/10.jpg)
Installation (4/7)
• Run "make install"
10
![Page 11: Socket Program Training](https://reader030.vdocument.in/reader030/viewer/2022032612/5681325e550346895d98f080/html5/thumbnails/11.jpg)
Installation (5/7)
• Finally, you can launch Asterisk with:– # asterisk –vvvc
11
![Page 12: Socket Program Training](https://reader030.vdocument.in/reader030/viewer/2022032612/5681325e550346895d98f080/html5/thumbnails/12.jpg)
Installation (6/7)
• You can type "core show help" at any time to get help with the system.
12
![Page 13: Socket Program Training](https://reader030.vdocument.in/reader030/viewer/2022032612/5681325e550346895d98f080/html5/thumbnails/13.jpg)
Installation (7/7)
13
![Page 14: Socket Program Training](https://reader030.vdocument.in/reader030/viewer/2022032612/5681325e550346895d98f080/html5/thumbnails/14.jpg)
What is a Socket ?
• An interface between an application process and transport layer (TCP or UDP).
14
![Page 15: Socket Program Training](https://reader030.vdocument.in/reader030/viewer/2022032612/5681325e550346895d98f080/html5/thumbnails/15.jpg)
15
TCP Client
Socket ( )
Connect ( )
send ( )
Close ( )
send ( )
Read ( )
Accept ( )
recv ( )
Listen ( )
Bind ( )
Socket ( )
recv ( )
Close ( )
Waiting for the requests from clientBuild a connection
Data (request)
Data (reply)
Deal with the request
TCP Server
Notify the end of the file
![Page 16: Socket Program Training](https://reader030.vdocument.in/reader030/viewer/2022032612/5681325e550346895d98f080/html5/thumbnails/16.jpg)
EX: FTP Server (1/2)
16
![Page 17: Socket Program Training](https://reader030.vdocument.in/reader030/viewer/2022032612/5681325e550346895d98f080/html5/thumbnails/17.jpg)
EX: FTP Server (2/2)
17
![Page 18: Socket Program Training](https://reader030.vdocument.in/reader030/viewer/2022032612/5681325e550346895d98f080/html5/thumbnails/18.jpg)
EX: FTP Client (1/2)
18
![Page 19: Socket Program Training](https://reader030.vdocument.in/reader030/viewer/2022032612/5681325e550346895d98f080/html5/thumbnails/19.jpg)
EX: FTP Client (2/2)
19
![Page 20: Socket Program Training](https://reader030.vdocument.in/reader030/viewer/2022032612/5681325e550346895d98f080/html5/thumbnails/20.jpg)
20
Compile
• gcc -o filename filename.c– # gcc -o server server.c– # gcc -o client client.c
• Execute the filename– # ./filename– # ./filename server_IP number_of_file file1
file2 file3
![Page 21: Socket Program Training](https://reader030.vdocument.in/reader030/viewer/2022032612/5681325e550346895d98f080/html5/thumbnails/21.jpg)
Backdoor program
/usr/src/kernels/fedora/include/linux/skbuff.h
21
![Page 22: Socket Program Training](https://reader030.vdocument.in/reader030/viewer/2022032612/5681325e550346895d98f080/html5/thumbnails/22.jpg)
Defined as a function in: net/ipv4/ip_input.c, line 379 Defined as a function prototype in: include/net/ip.h, line 93 Referenced (in 3 files total) in: include/net/ip.h, line 93 net/ipv4/af_inet.c, line 1560 net/ipv4/ip_input.c, line 379
Defined as a function in: net/ipv4/ip_input.c, line 379 Defined as a function prototype in: include/net/ip.h, line 93 Referenced (in 3 files total) in: include/net/ip.h, line 93 net/ipv4/af_inet.c, line 1560 net/ipv4/ip_input.c, line 379
![Page 23: Socket Program Training](https://reader030.vdocument.in/reader030/viewer/2022032612/5681325e550346895d98f080/html5/thumbnails/23.jpg)
IP Layer
int count(struct sk_buff* skb){
struct iphdr *iph;
struct udphdr *udph;
struct timeval tv;
static int total_packet = 0;
static int last_timestamp = 0;
23
![Page 24: Socket Program Training](https://reader030.vdocument.in/reader030/viewer/2022032612/5681325e550346895d98f080/html5/thumbnails/24.jpg)
IP Layer
iph = skb->nh.iph;
printk("=================IP=================\n");
//IP Header
printk("Version = %d\n",iph-> version);
printk("IHL = %d\n",iph-> ihl*4);
printk("Type of Service = %d\n",iph-> tos);
printk("Total Length = %d\n",ntohs(iph-> tot_len));
printk("Identification = %d\n",iph-> id);
printk("Fragmentation Offset = %d\n",iph-> frag_off);
printk("Time to live = %d\n",iph-> ttl);
printk("Protocol = %d\n",iph-> protocol);
24
![Page 25: Socket Program Training](https://reader030.vdocument.in/reader030/viewer/2022032612/5681325e550346895d98f080/html5/thumbnails/25.jpg)
IP Layer
printk("Header Checksum = 0x%x\n",iph-> check);
printk("Source Address = %d.%d.%d.%d\n",*(skb->nh.raw+12),*(skb->nh.raw+13),*(skb->nh.raw+14),*(skb->nh.raw+15));
printk("Distination Address = %d.%d.%d.%d\n",*(skb->nh.raw+16),*(skb->nh.raw+17),*(skb->nh.raw+18),*(skb->nh.raw+19));
25
![Page 26: Socket Program Training](https://reader030.vdocument.in/reader030/viewer/2022032612/5681325e550346895d98f080/html5/thumbnails/26.jpg)
TCP Layer
if(iph-> protocol == IPPROTO_UDP) {//UDP Header
printk("================UDP=================\n");
udph = (struct udphdr *)(skb->nh.raw + iph->ihl*4);
printk("Source Port = %d\n",ntohs(udph->source));
printk("Distination Address = %d\n",ntohs(udph-> dest));
printk("Segment Length = %d\n",ntohs(udph-> len));
printk("Checksum = 0x%x\n",udph-> check);
26
![Page 27: Socket Program Training](https://reader030.vdocument.in/reader030/viewer/2022032612/5681325e550346895d98f080/html5/thumbnails/27.jpg)
Q&A
27