
์๋ ํ์ธ์.
scapy๋ ํ์ด์ฌ ํจํท์ ๋ค๋ฃจ๋ ๋ผ์ด๋ธ๋ฌ๋ฆฌ ์ค ๊ฐ์ฅ ๊ฐ๋ ฅํ๊ณ ๊ธฐ๋ฅ์ด ๋ค์ํฉ๋๋ค.
์ด๋ฒ ์๊ฐ์๋ ๋ด ์ปดํจํฐ์ ์ค๊ณ ๊ฐ๋ ํจํท์ ์บก์ฒํ๋ ๊ฐ์ฅ ๊ฐ๋จํ ์ฝ๋๋ฅผ ์ดํด๋ณด๊ฒ ์ต๋๋ค.
Scapy
Packet crafting for Python2 and Python3
scapy.net
pip install scapy
์ ๋ช ๋ น์ด๋ก scapy๋ฅผ ์ค์นํด ์ค๋๋ค.
from scapy.all import *
from scapy.arch.windows import IFACES
import time
n = 50
iface = "Intel(R) Ethernet Connection (7) I219-V"
IFACES.show()
def cap():
for i in range(0, n):
packet = sniff(iface=iface, count = 6)
data = (packet[0].payload)
#packet.show()
src_ip = packet[0][1].src
dst_ip = packet[0][1].dst
nowtime = time.strftime('%c', time.localtime(time.time()))
print('\033[95m'+'[ '+nowtime+' ] '+'\033[92m'+src_ip+'\033[94m'+" -> "+'\033[92m'+dst_ip+' \033[96m'+ str(data)) #data
cap()
์ ์ฒด์ฝ๋ ์ ๋๋ค.
๋ณ์ n์ ๋ฐ๋ณตํ ํ์๋ฅผ
iface๋ ์บก์ฒํ ๋คํธ์ํฌ ์ธํฐํ์ด ์ค์ ๋ํ๋ ๋๋ค.
๊ฐ์ฌํฉ๋๋ค.
๊ถ๊ธํ ์ ์ด ์์ผ์๋ค๋ฉด ๋๊ธ๋ก ๋จ๊ฒจ์ฃผ์ธ์!
์๊ฐ ๋ ๋ ํ์ธํ๊ฒ ์ต๋๋ค :)
'๐ป๊ธฐ์ > Python' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[ Python ] OpenCV ์ ๊ฒ์ถ๊ณผ ์ผ๊ตด ๋ชจ์์ดํฌ (0) | 2020.08.08 |
---|

์๋ ํ์ธ์.
scapy๋ ํ์ด์ฌ ํจํท์ ๋ค๋ฃจ๋ ๋ผ์ด๋ธ๋ฌ๋ฆฌ ์ค ๊ฐ์ฅ ๊ฐ๋ ฅํ๊ณ ๊ธฐ๋ฅ์ด ๋ค์ํฉ๋๋ค.
์ด๋ฒ ์๊ฐ์๋ ๋ด ์ปดํจํฐ์ ์ค๊ณ ๊ฐ๋ ํจํท์ ์บก์ฒํ๋ ๊ฐ์ฅ ๊ฐ๋จํ ์ฝ๋๋ฅผ ์ดํด๋ณด๊ฒ ์ต๋๋ค.
Scapy
Packet crafting for Python2 and Python3
scapy.net
pip install scapy
์ ๋ช ๋ น์ด๋ก scapy๋ฅผ ์ค์นํด ์ค๋๋ค.
from scapy.all import *
from scapy.arch.windows import IFACES
import time
n = 50
iface = "Intel(R) Ethernet Connection (7) I219-V"
IFACES.show()
def cap():
for i in range(0, n):
packet = sniff(iface=iface, count = 6)
data = (packet[0].payload)
#packet.show()
src_ip = packet[0][1].src
dst_ip = packet[0][1].dst
nowtime = time.strftime('%c', time.localtime(time.time()))
print('\033[95m'+'[ '+nowtime+' ] '+'\033[92m'+src_ip+'\033[94m'+" -> "+'\033[92m'+dst_ip+' \033[96m'+ str(data)) #data
cap()
์ ์ฒด์ฝ๋ ์ ๋๋ค.
๋ณ์ n์ ๋ฐ๋ณตํ ํ์๋ฅผ
iface๋ ์บก์ฒํ ๋คํธ์ํฌ ์ธํฐํ์ด ์ค์ ๋ํ๋ ๋๋ค.
๊ฐ์ฌํฉ๋๋ค.
๊ถ๊ธํ ์ ์ด ์์ผ์๋ค๋ฉด ๋๊ธ๋ก ๋จ๊ฒจ์ฃผ์ธ์!
์๊ฐ ๋ ๋ ํ์ธํ๊ฒ ์ต๋๋ค :)
'๐ป๊ธฐ์ > Python' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[ Python ] OpenCV ์ ๊ฒ์ถ๊ณผ ์ผ๊ตด ๋ชจ์์ดํฌ (0) | 2020.08.08 |
---|