ÀûÓÃsocket±àдwindowsºÍlinuxͨѶ³ÌÐò
ÀûÓÃsocket±àдwindowsºÍlinuxͨѶ³ÌÐò
socket±à³Ì´ó¼Ò¶¼ºÜÊìϤ£¬ÎÒÔÚÕâÀï¾Í²»ÔÙÂÞàÂÁË¡£Ö±½ÓÇÐÈëÕýÌâ¡£¸Ã³ÌÐò·ÖÁ½²¿·Ö£¬server¶ËºÍclient¶Ë£¨Ë¶¼ÖªµÀ£©¡£ÆäÖÐserver¶Ë²ÉÓÃwindowsƽ̨£¬ÄÇlinuxƽ̨µ±È»ÊÇclient¶ËÁË¡£
ÕâÀïÊÇserver¶Ë³ÌÐò£º
/**********************************/
/* it worked as server under windows platform */
/* written by mlsx 1998-2-7 */
/************************************/
include <windows.h>
#include <stdio.h>
#pragma comment (lib,"WS2_32.lib")
#define USERPORT 10001
#define HOST_IP_ADDR "127.0.0.1"
main(int argc,char *argv[])
{
char buf[128];
SOCKET s,ns;
struct sockaddr_in client;
struct sockaddr_in server;
int namelen,pklen;
int status;
WSADATA wsd;
if((status=WSAStartup(MAKEWORD(2,2),&wsd))!=0)
{
perror("wsastartup() failed:");
exit(1);
}
if((s=socket(AF_INET,SOCK_STREAM,0))< 0)
{
perror("socket failed :");
exit(1);
}
ZeroMemory(&server,sizeof(server));
server.sin_family=AF_INET;
server.sin_port=htons(USERPORT);
server.sin_addr.s_addr=htons(INADDR_ANY);
if(bind(s,(struct sockaddr *)&server,sizeof(server))<0)
{
perror("bind() failed:");
exit(2);
}
if(listen(s,4)!=0)
{
perror("listen()failed :");
exit(3);
}
while(1)
{
namelen=sizeof(client);
if((ns=accept(s,(struct sockaddr*)&client,&namelen))==-1)
{
perror("accept()failed:");
exit(4);
}
printf("accept successful");
for(;;)
{
if((pklen=recv(ns,buf,128,0))<0)
{
perror("recv() failed:");
exit(5);
}
else
if(pklen==0)
{
printf("recv():return FAILED,connected is shut down");
 
Ïà¹ØÎĵµ£º
£¨L2CAPÐÒé¼ò½é£¬L2CAPÔÚBlueZÖеÄʵÏÖÒÔ¼°L2CAP±à³Ì½Ó¿Ú£©
Ò»£ºL2CAPÐÒé¼ò½é£º
Logical Link Control and Adaptation Protocol(L2CAP)
Âß¼Á¬½Ó¿ØÖƺÍÊÊÅäÐÒé (L2CAP) ΪÉϲãÐÒéÌṩÃæÏòÁ¬½ÓºÍÎÞÁ¬½ÓµÄÊý¾Ý·þÎñ£¬²¢Ìṩ¶àÐÒ鹦ÄܺͷָîÖØ×é²Ù×÷¡£L2CAP ³äÐíÉϲãÐÒéºÍÓ¦ÓÃÈí¼þ´«ÊäºÍ½ÓÊÕ×î´ó³¤¶ÈΪ 64K µÄ L2CAP Ê ......
Ê×ÏÈÐèÒªÏÂÔØLinux kernel£¬ÔÚwww.kernel.orgÀïÃæÏÂÔØ¡£È»ºóÐèÒª°²×°kernel-package£¬fakeroot¡£ÕâÑù×¼±¸¹¤×÷¾ÍÍê³ÉÁË¡£
ÏÂÃ濪ʼÄں˵ÄÅäÖá£×îÖØÒªµÄÒ»µãÊÇÈ¥µôkenerl hackingÑ¡ÏÏÂÃæµÄ“±àÒëÄں˴øÓÐdebugÐÅÏ¢”Ñ¡Ï·ñÔò±àÒë³öÀ´µÄÄÚºËÎÞ±ÈÅÓ´ó
¡£È»ºó¸ù¾Ý¸öÈËÐèҪȥµôһЩÇý¶¯¡£²»¹ý±ØÐëÇå³þÖªµÀ×Ô¼ ......
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))·¢ËͽÓÊÕÒÔÌ« ......
/lib/
— °üº¬Ðí¶à±» /bin/ ºÍ /sbin/ ÖеijÌÐòʹÓõĿâÎļþ¡£Ä¿Â¼ /usr/lib/ Öк¬Óиü¶àÓÃÓÚÓû§³ÌÐòµÄ¿âÎļþ¡£
/libĿ¼Ï·ÅÖõÄÊÇ/binºÍ/sbinĿ¼Ï³ÌÐòËùÐèµÄ¿âÎļþ¡£/libĿ¼ÏµÄÎļþµÄÃû³Æ×ñÑÏÂÃæµÄ¸ñʽ£º
libc.so.*
ld*
½ö½ö±»/usrĿ¼ÏµijÌÐòËùʹÓõĹ²Ïí¿â²»±Ø·Åµ½/libĿ¼Ï¡£Ö»ÓÐ/binºÍ/sbin ......