메뉴 건너뛰기

infra

[scapy] dhcp discover packet sending

lispro062017.11.20 06:04조회 수 1379댓글 1

  • 3
    • 글자 크기

fam,hw = get_if_raw_hwaddr("enp0s17")
macaddress= get_if_hwaddr("enp0s17")
conf.iface = "enp0s17"
ethernet = Ether(dst="ff:ff:ff:ff:ff:ff",src=macaddress,type=0x800)
ip = IP(src="0.0.0.0",dst="255.255.255.255")
udp = UDP(sport=68,dport=67)
bootp = BOOTP(chaddr =hw,xid=0x10000000)
dhcp = DHCP(options=[("message-type","discover"),("hostname","ubu1"), ("end")])
packet=ethernet/ip/udp/bootp/dhcp
sendp(packet,iface="enp0s17")


http://scapy.readthedocs.io/en/latest/installation.html#installing-scapy-v2-x


위 사이트에서 설치 한후, 소스를 우여곡절 끝에 POC(Proof of Concept)라고 되어 있는 코드 부분에서 추출하여 사용하였다.


그렇게 하지 않으면, mac address 에 도착할 수 없으므로 브로드캐스팅하라는 워닝이 나오면서 접근되지 않아 그렇다.


아무튼 hostname 까지 넣어서 dhcp discover 메시지를 보내면, DHCP 클라이언트 목록에 해당 IP가 출력되지 않는다. 또한 end 가 없으면 다운되는 현상이 있다.

client.jpg

좀 더 확인해볼 게 많은 공유기이다.


[discover log]

log.jpg

[packet 확인]

dhcp.jpg

lispro06 (비회원)
  • 3
    • 글자 크기
[XML] 임의의 데이터(Arbitrary Data)와 XML문서 암호화 (by 박영식) [XE] 서버 이전 후, 메뉴가 나타나지 않는 현상 (by 박영식)

댓글 달기

댓글 1
  • windows 에서 사용시 필요한 내용들
    pip install scapy-python3
    인터페이스(랜카드)가 설정 안 될 경우
    conf.iface = IFACES.dev_from_name(get_windows_if_list()[0]["name"])

    스니핑
    from scapy.all import *
    b=sniff(count=10,filter="tcp")

    TCP Reset 패킷
    a=Ether()/IP(dst="",flags="DF",ihl=5,len=40,ttl=128)/TCP(sport=xxxx,dport=xxxx,flags="RA",dataofs=5,window=0)
첨부 (3)
dhcp.jpg
114.3KB / Download 60
client.jpg
24.1KB / Download 66
log.jpg
18.9KB / Download 65
위로