참고로 스카피는 패킷 조작 프로유틸 프로그램이다

( Scapy is a powerful interactive packet manipulation program.  )


아래 소스를 예) scapy.sh 와 같이 만든 후 실행 권한 준 이후 ( chmod +x scapy.sh ) 실행하면 자동 빌드 된다.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/bin/bash
 
echo "We need root permissions to install libdnet"
sudo echo "OK"
curl -"https://bootstrap.pypa.io/get-pip.py"
python get-pip.py --user
PIP_BIN=$HOME/Library/Python/2.7/bin/pip
$PIP_BIN install scapy --user
$PIP_BIN install pypcap --user
curl -L https://github.com/dugsong/libdnet/archive/libdnet-1.12.zip -o libdnet-1.12.zip
unzip libdnet-1.12.zip
cd libdnet-libdnet-1.12
./configure
make
sudo make install
cd python
python setup.py install --user
cs


출처 : https://dustin.li/2016/08/scapy-on-mac-os-x/


서버 프로그램 작성 / 동작 확인 완료


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
32
33
34
35
36
37
38
# server 
# scapy is needed
# source from : http://blog.naver.com/netatom/220323580811
import socket
import time
from optparse import OptionParser
from scapy.all import *
import timeit
 
HOST='127.0.0.1'
PORT=8888
 
def tcp_recv(host,port):
    su = socket.socket(socket.AF_INET)
    su.bind((host,port))
    su.listen(1)
 
    connect, address = su.accept()
    print 'Connected by ',address
    while 1:
        data = connect.recv(1024)
        start_time = time.time()
        if not data: break
        connect.sendall(data)
        su.close()
    connect.close()
    end_time = time.time()
    check_time = end_time - start_time
    return check_time
 
if __name__ == "__main__":
    y = 0
    for x in range(0,5):
        y = y  + tcp_recv(HOST, PORT)
        print y
        print "Received %d" % (x)
    print 'average time : ', y/3
 
cs


+ Recent posts