로우패킷 보낼때 잘 안보내지는군요... WinPCAB 라이브러리 사용했어요.
아래와 같은 형식으로 보냈는데 패킷이 안보내지는것 같아요.
winpcab는 로우패킷 보낼때 ip 헤더부터 만들지 않고 그 앞에 14바이트가 더 있더라고요
그 14바이트는 물리 계층인가여? 맥어드래스 주고받는 12바이트하고 몬지 모르는 값이 8 0 인 두바이트가 있어서 그대로 적어줬거든요.
나머진 다 잘쓴거 같은데 안가지는거 같아요. 아이덴터티하고 시퀀스 번호는 적당한 값 너준건데 이게 문제가 되나요? 사용 안했을법한
값을 넣어줬거든요. 패킷캡춰해서 오던 값보다 적당히 몇개 더 큰 값 너준것이에요.
IPHEADER hdr;
ICMPMESSAGE icmp;
hdr.ip_hl = 5;
hdr.ip_v = 4;
hdr.ip_tos = 0;
hdr.ip_len = 60;
hdr.ip_id = 10000;
hdr.ip_off = 0;
hdr.ip_ttl = 1;
hdr.ip_p = 1;
hdr.ip_checksum=0 ;
tmp = sizeof(hdr);
memcpy(&hdr.ip_src,src,4);
memcpy(&hdr.ip_dst,dst,4);
hdr.ip_checksum =checksum((unsigned short*)&hdr,20);
buff[0] = 0x00;
buff[1] = 0x1A;
buff[2] = 0x92;
buff[3] = 0xD5;
buff[4] = 0x48;
buff[5] = 0xC4;
buff[6] = 0x00;
buff[7] = 0x0E;
buff[8] = 0x2E;
buff[9] = 0xEC;
buff[10] = 0xC9;
buff[11] = 0xB3;
buff[12] = 8;
buff[13] = 0;
memcpy(buff+14,&hdr,20);
icmp.icmp_type = 8;
icmp.icmp_code = 0;
icmp.icmp_id = 2;
icmp.icmp_seq = 0x30;
icmp.icmp_cksum = 0;
icmp.icmp_cksum =checksum((unsigned short*)&icmp,8) ;
memcpy(buff+34,&icmp,8);
/* Retrieve the device list */
pcap_findalldevs(&alldevs, errbuf);
/* Open the adapter */
if ((fp = pcap_open_live(alldevs->next->name, // name of the device
65536, // portion of the packet to capture. It doesn't matter in this case
1, // promiscuous mode (nonzero means promiscuous)
1000, // read timeout
errbuf // error buffer
)) == NULL)
{
fprintf(stderr,"\nUnable to open the adapter. %s is not supported by WinPcap\n", argv[1]);
return 2;
}
/* Send down the packet */
if (pcap_sendpacket(fp, // Adapter
buff, // buffer with the packet
74 // size
) != 0)
{
fprintf(stderr,"\nError sending the packet: \n", pcap_geterr(fp));
return 3;
}
pcap_close(fp);
자답...
주소랑 길이 등을 빅엔디안 리틀엔디안때문에 순서를 바꿔주니까 되네여...
어렵군요
아이고 답글 지우기가 없어요 ㅠㅠ
편집에서 못빠져 나가요 삭제 어덯게 하나요
지금 무한 루프에 빠졌어요 ㅠㅠ
<에이다의 저주>
댓글 달기