linux sock_rawÔʼÌ×½Ó×Ö±à³Ì (ת£©
sock_rawÔʼÌ×½Ó×Ö±à³Ì¿ÉÒÔ½ÓÊÕµ½±¾»úÍø¿¨ÉϵÄÊý¾ÝÖ¡»òÕßÊý¾Ý°ü,¶ÔÓë¼àÌýÍøÂçµÄÁ÷Á¿ºÍ·ÖÎöÊǺÜÓÐ×÷ÓõÄ.Ò»¹²¿ÉÒÔÓÐ3ÖÖ·½Ê½´´½¨ÕâÖÖsocket
1.socket(AF_INET, SOCK_RAW, IPPROTO_TCP|IPPROTO_UDP|IPPROTO_ICMP)·¢ËͽÓÊÕipÊý¾Ý°ü
2.socket(PF_PACKET, SOCK_RAW, htons(ETH_P_IP|ETH_P_ARP|ETH_P_ALL))·¢ËͽÓÊÕÒÔÌ«ÍøÊý¾ÝÖ¡
3.socket(AF_INET, SOCK_PACKET, htons(ETH_P_IP|ETH_P_ARP|ETH_P_ALL))¹ýʱÁË,²»ÒªÓð¡
Àí½âÒ»ÏÂSOCK_RAWµÄÔÀí, ±ÈÈçÍø¿¨ÊÕµ½ÁËÒ»¸ö 14+20+8+100+4 µÄudpµÄÒÔÌ«ÍøÊý¾ÝÖ¡.
Ê×ÏÈ,Íø¿¨¶Ô¸ÃÊý¾ÝÖ¡½øÐÐÓ²¹ýÂË(¸ù¾ÝÍø¿¨µÄģʽ²»Í¬»áÓв»Í¬µÄ¶¯×÷,Èç¹ûÉèÖÃÁËpromisc»ìÔÓģʽµÄ»°,Ôò²»×öÈκιýÂËÖ±½Ó½»¸øÏÂÒ»²ãÊäÈëÀý³Ì,·ñÔò·Ç±¾»úmac»òÕ߹㲥mac»á±»Ö±½Ó¶ªÆú).°´ÕÕÉÏÃæµÄÀý×Ó,Èç¹û³É¹¦µÄ»°,»á½øÈëipÊäÈëÀý³Ì.µ«ÊÇÔÚ½øÈëipÊäÈëÀý³Ì֮ǰ,ϵͳ»á¼ì²éϵͳÖÐÊÇ·ñÓÐͨ¹ýsocket(AF_PACKET, SOCK_RAW, ..)´´½¨µÄÌ×½Ó×Ö.Èç¹ûÓеĻ°²¢ÇÒÐÒéÏà·û,ÔÚÕâ¸öÀý×ÓÖоÍÊÇÐèÒªETH_P_IP»òÕßETH_P_ALLÀàÐÍ.ϵͳ¾Í¸øÿ¸öÕâÑùµÄsocket½ÓÊÕ»º³åÇø·¢ËÍÒ»¸öÊý¾ÝÖ¡¿½±´.È»ºó½øÈëÏÂÒ»²½.
Æä´Î,½øÈëÁËipÊäÈëÀý³Ì(ip²ã»á¶Ô¸ÃÊý¾Ý°ü½øÐÐÈí¹ýÂË,¾ÍÊǼì²éУÑé»òÕ߶ªÆú·Ç±¾»úip»òÕ߹㲥ipµÄÊý¾Ý°üµÈ,¾ßÌåÒª²Î¿¼Ô´´úÂë),Àý×ÓÖоÍÊÇÈç¹û³É¹¦µÄ»°»á½øÈëudpÊäÈëÀý³Ì.µ«ÊÇÔÚ½»¸øudpÊäÈëÀý³Ì֮ǰ,ϵͳ»á¼ì²éϵͳÖÐÊÇ·ñÓÐͨ¹ýsocket(AF_INET, SOCK_RAW, ..)´´½¨µÄÌ×½Ó×Ö.Èç¹ûÓеĻ°²¢ÇÒÐÒéÏà·û,ÔÚÕâ¸öÀý×ÓÖоÍÊÇÐèÒªIPPROTO_UDPÀàÐÍ.ϵͳ¾Í¸øÿ¸öÕâÑùµÄsocket½ÓÊÕ»º³åÇø·¢ËÍÒ»¸öÊý¾ÝÖ¡¿½±´.È»ºó½øÈëÏÂÒ»²½.
×îºó,½øÈëudpÊäÈëÀý³Ì ...
ps:Èç¹ûУÑéºÍ³ö´íµÄ»°,Äں˻áÖ±½Ó¶ªÆú¸ÃÊý¾Ý°üµÄ.¶ø²»»á¿½±´¸øsock_rawµÄÌ×½Ó×Ö,ÒòΪУÑéºÍ¶¼³ö´íÁË,Êý¾Ý¿Ï¶¨ÓÐÎÊÌâµÄ°üÀ¨ËùÓÐÐÅÏ¢¶¼Ã»ÓÐÒâÒåÁË.
½øÒ»²½·ÖÎöËûÃǵÄÄÜÁ¦.
1. socket(AF_INET, SOCK_RAW, IPPROTO_UDP);
ÄÜ:¸ÃÌ×½Ó×Ö¿ÉÒÔ½ÓÊÕÐÒéÀàÐÍΪ(tcp udp icmpµÈ)·¢Íù±¾»úµÄipÊý¾Ý°ü,´ÓÉÏÃæ¿´µÄ¾ÍÊÇ20+8+100.
²»ÄÜ:²»ÄÜÊÕµ½·Ç·¢Íù±¾µØipµÄÊý¾Ý°ü(ipÈí¹ýÂ˻ᶪÆúÕâЩ²»ÊÇ·¢Íù±¾»úipµÄÊý¾Ý°ü).
²»ÄÜ:²»ÄÜÊÕµ½´Ó±¾»ú·¢ËͳöÈ¥µÄÊý¾Ý°ü.
·¢Ë͵Ļ°ÐèÒª×Ô¼º×éÖ¯tcp udp icmpµÈÍ·²¿.¿ÉÒÔsetsockoptÀ´×Ô¼º°ü×°ipÍ·²¿
ÕâÖÖÌ×½Ó×ÖÓÃÀ´Ð´¸öping³ÌÐò±È½ÏÊʺÏ
2. socket(PF_PACKET, SOCK_RAW, htons(x));
Õâ¸öÌ×½Ó×ֱȽÏÇ¿´ó,´´½¨ÕâÖ
Ïà¹ØÎĵµ£º
su -l ĬÈÏΪrootÓû§
Ò²¿Éд×÷ su root -l
»»×öÆäËû¼´ÎªÊ¹ÓÃÆäËûÓû§µÇ¼
´ÓrootÓû§Çл»µ½ÆäËûÓû§²»ÐèÒªÊäÈë¿ÚÁî
ÔÚÆäËûÕË»§¼äÇ뻶¼ÒªÊäÈë¿ÚÁî
ʹÓà sudo ¼ÓÉÏËùÒªÖ´ÐеÄÃüÁî¿ÉÒÔʹµÃÓû§µÄȨÏÞÁÙʱÇл»µ½³¬¼¶¹ÜÀíÔ±µÄ״̬Ï£¬¼´ÁÙʱÇл»ÁËÓû§¡£
Ò»°ãÐèÒªÊäÈë¿ÚÁʹÓúóÔÚÒ»¶Îʱ¼ä´ÁÄÚ²»ÐèÊäÈë¿ÚÁî¡£ ......
LinuxÏÂÖÐÎÄÂÒÂëµÄ½â¾ö·½·¨
ÆäʵÂÒÂëÕâ¸öÎÊÌâÊÇÓÉϵͳ¼¯³ÉµÄ×Ö·û¼¯ÒýÆðµÄ,ÓÉÓÚ²»ÄÜÕýÈ·µÄʹÓÃÏà¶ÔÓ¦×Ö·ûµÄ×Ö·û¼¯,Òò´ËOS²»ÄÜʶ±ð³öÎÄ×Öµ¼ÖÂÁËÂÒÂë,½â¾öµÄ·½·¨²»ÄÑ......
Ê×ÏÈ,ÎÒÃÇÏÈÒªÖªµÀ¿ØÖÆLinux OS µÄÓïÑÔ»·¾³±äÁ¿ÊÇ $LANGºÍ$LC_ALL,Òª½â¾öÂÒÂëµÄÇé¿öÎÒÃÇÖ»ÐèÒª°ÑÉÏÊöµÄÁ½¸ö±äÁ¿ÕýÈ·ÉèÖü´¿É.
ÂÒÂë·ÖÁ½ÖÖÇé ......
Ê×ÏȽéÉÜÒ»¸öÃû´Ê“¿ØÖÆ̨£¨console£©”£¬Ëü¾ÍÊÇÎÒÃÇͨ³£¼ûµ½µÄʹÓÃ×Ö·û²Ù×÷½çÃæµÄÈË»ú½Ó¿Ú£¬ÀýÈçdos¡£ÎÒÃÇ˵¿ØÖÆ̨ÃüÁ¾ÍÊÇָͨ¹ý×Ö·û½çÃæÊäÈëµÄ¿ÉÒÔ²Ù×÷ϵͳµÄÃüÁÀýÈçdosÃüÁî¾ÍÊÇ¿ØÖÆ̨ÃüÁî¡£ÎÒÃÇÏÖÔÚÒªÁ˽âµÄÊÇ»ùÓÚLinux²Ù×÷ϵͳµÄ»ù±¾¿ØÖÆ̨ÃüÁî¡£ÓÐÒ»µãÒ»¶¨Òª×¢Ò⣬ºÍdosÃüÁͬµÄÊÇ£¬LinuxµÄÃü ......
ÒýÓÃhttp://www.icanwen.cn/article.asp?id=13
Ò».¶Ôlinux¼ì²âµÄÁ½ÖÖ·½·¨£º
ssh:(check_by_ssh):±ÈÓÃnrpe²å¼þ¸ü°²È«£¬µ«»á·Ç³£Õ¼Óüà¿ØÖ÷»úºÍÔ¶³ÌÖ÷»úµÄCPU,ÌرðÊÇÔÚ±»¼à¿ØÉ豸ÊýÁ¿¶àµÄʱºò£¬Çé¿ö»á¸üÔã¡£
nrpe:Ï൱ÓÚÖм̳ÌÐò£¬×°ÔÚ±»¼à¿ØµÄunix/linuxϵͳÉÏ¡£Ïà¶ÔÓÚssh ,nrpeÕ¼ÓøüÉÙµÄϵͳ×ÊÔ´¡£ËùÒÔnrpe±»´ó²¿·ÖÍøÂç ......
¡¾Ïà¹Ø²©ÎÄתÔØ/ÍøÖ·Á´½Ó¡¿------------------------
Ò»¡¢linuxÍøÂç±à³Ì----epoll
¢Ùlinux epoll¼¼Êõ½éÉÜ http://woxihuanpes.blog.163.com/blog/static/12423219820099301048160/[woxihuanpes µÄ²©¿Í]
¢Úepoll http://baike.baidu.com/view/1385104.htm?fr=ala0 [°Ù¶È°Ù¿Æ]
¢ÛepollʹÓÃÀý×Ó£ºhttp://blog.csdn.n ......