|
|
|
µ¥ÀÌÅÍ Åë½Å - Packet SnifferÀÇ ±¸Çö |
|
|
|
|
|
|
|
|
Å°¿öµå : |
|
|
¼Ò°³±Û |
µ¥ÀÌÅÍ Åë½Å - Packet SnifferÀÇ ±¸Çö |
¿ä¾à |
<µ¥ÀÌÅÍ Åë½Å °úÁ¦>
Packet SnifferÀÇ ±¸Çö
1.¼Ò½ºÄÚµåºÐ¼® ÀÌ ÇÁ·Î±×·¥Àº ·Î¼ÒÄÏÀ» ÀÌ¿ëÇÑ ½º´ÏÆÛ ÇÁ·Î±×·¥ ÀÌ´Ù. ·Î¼ÒÄÏÀÇ ¡°³×Æ®¿öÅ© °èÃþÀ¸·Î Àü¼ÛµÇ´Â ¸ðµç ÆÐŶÀ» º¼ ¼ö Àִ¡± Ư¼ºÀ» ÀÌ¿ëÇØ TCP ÇÁ·ÎÅäÄÝÀÇ ÆÐŶÀ» ÀÐÀº ÇÁ·Î±×·¥ÀÌ´Ù. ¾Æ·¡ ¼Ò½º¿¡´Â TCP ÆÐŶ¸¸ Àд °ÍÀ̹ǷΠIP Çì´õ¿Í TCP Çì´õ¸¸À» Ãâ·Â ÇßÁö¸¸, ICMP, IGMP, UDP ÆÐŶ µîµîµµ Ãâ·ÂÇÒ ¼ö ÀÖ´Ù. ¶ÇÇÑ packet.h ÀÇ Çì´õÆÄÀÏÀ» °íħÀ¸·Î½á IP Header¿Í TCP headerÀÇ ±âº» °ªµéÀ» ¹Ù²Ü ¼ö ÀÖ´Ù. ¿¹¸¦ µé¸é IP headerÀÇ versionÀ̳ª Çì´õ±æÀÌ µîÀ» »ç¿ëÀÚ°¡ ÀÓÀÇ´ë·Î ¹Ù²Ü ¼ö ÀÖ´Ù. project1.c #include #include #include #include #include #include #include #include #include #include #include "packet.h"
int main() { int sock, ret, len; char buffer[65535], *data; struct sockaddr_in from; struct in_addr src, dst; struct ifreq ifr; char *interface = "eth0"; struct ip_header_t *ip = (struct ip_header_t *)&buffer;//ip header ¼±¾ð struct tcp_header_t *tcp;//tcp header ¼±¾ð
sock = socket(PF_INET, SOCK_RAW, IPPROTO_TCP); //·Î¼ÒÄÏ »ý¼º( PF_INET:ÀÎÅÍ³Ý ÇÁ·ÎÅäÄÝ , SOCK_RAW ´Â ·Î¼ÒÄÏÀ» ¸¸µé°Ú´Ù´Â ÀǹÌ!,IPPROTO_T |
|
|
|
|
À§ Á¤º¸¹× °Ô½Ã¹° ³»¿ëÀÇ Áø½Ç¼º¿¡ ´ëÇÏ¿© º¸ÁõÇÏÁö ¾Æ´ÏÇϸç, ÇØ´ç Á¤º¸ ¹× °Ô½Ã¹° ÀúÀ۱ǰú ±âŸ ¹ýÀû Ã¥ÀÓÀº ÀÚ·á µî·ÏÀÚ¿¡°Ô ÀÖ½À´Ï´Ù. À§ Á¤º¸¹× °Ô½Ã¹° ³»¿ëÀÇ ºÒ¹ýÀû ÀÌ¿ë, ¹«´ÜÀüÀç¹× ¹èÆ÷´Â ±ÝÁöµÇ¾î ÀÖ½À´Ï´Ù. ÀúÀÛ±ÇħÇØ, ¸í¿¹ÈÑ¼Õ µî ºÐÀï¿ä¼Ò ¹ß°ß½Ã ÇÏ´ÜÀÇ ÀúÀÛ±Ç Ä§ÇØ½Å°í¸¦ ÀÌ¿ëÇØ Áֽñ⠹ٶø´Ï´Ù. |
|