当前位置: 首页 > news >正文

企业网站托管点餐小程序开发

企业网站托管,点餐小程序开发,陕西住房和建设厅网站,百度上传网站服务器linux下可以用libpcap函数库实现监听数据包#xff0c;使用libnet 函数库发送数据包安装:在命令行下apt-get install 就可以了libpcap的使用:/*author hjjdate 2011-1-21function:capture packet with the ruler and output the packet informationmodify 2011-1-23function:g…linux下可以用libpcap函数库实现监听数据包使用libnet 函数库发送数据包安装:在命令行下apt-get install 就可以了libpcap的使用:/*author hjjdate 2011-1-21function:capture packet with the ruler and output the packet informationmodify 2011-1-23function:get dns packet*/#include#include#include#include#include#include#include#include#include#define ETHER_ADDR_LEN 6/*以太网头*/struct sniff_ethernet{u_char ether_dhost[ETHER_ADDR_LEN];u_char ether_shost[ETHER_ADDR_LEN];u_short ether_type;};/*IP头*/struct sniff_ip{u_char ip_vhl;u_char ip_tos;u_short ip_len;u_short ip_id;u_short ip_off;#define IP_RF 0x8000#define IP_DF 0x4000#define IP_MF 0x2000#define IP_OFFMASK 0x1fffu_char ip_ttl;u_char ip_p;u_short ip_sum;struct in_addr ip_src,ip_dst;};/*TCP头*/typedef u_int tcp_seq;struct sniff_tcp{u_short th_sport;u_short th_dport;tcp_seq th_seq;tcp_seq th_ack;u_char th_offx2;u_char th_flags;u_short th_win;u_short th_sum;u_short th_urp;};/*UDP报头*/struct sniff_udp{u_short udp_sport;u_short udp_dport;u_short udp_len;u_short udp_sum;};/*DNS报头*/struct sniff_dns{u_short dns_id;u_short dns_flag;u_short dns_ques;u_short dns_ans;u_short dns_auth;u_short dns_add;u_int8_t *dsn_data;};//数据包到达回调函数void packetcall(u_char *user,const struct pcap_pkthdr *pcap_head,const u_char *packet);char *ipstr(struct in_addr s_addr);char* getpackettype(u_short packet_type);char* toString(u_long s);//由u_char[6]获取网卡地址字符串char *getMac(u_char *host);int main(int argc,char **argv){char *dev,errbuf[PCAP_ERRBUF_SIZE];pcap_t *handler;struct bpf_program fp;char filter_exp[50]ip and dst 172.20.92.118;if(argc3){sprintf(filter_exp,dst %s and dst port %s,argv[1],argv[2]);}if(argc5){sprintf(filter_exp,dst %s and dst port %s or src %s and src port %s,argv[1],argv[2],argv[3],argv[4]);}bpf_u_int32 mask;bpf_u_int32 net;struct pcap_pkthdr header;const u_char *packet;devpcap_lookupdev(errbuf);if(devNULL){fprintf(stderr,could not find default device:%s\n,errbuf);return 2;}printf(device:%s\n,dev);if(pcap_lookupnet(dev,net,mask,errbuf)-1){fprintf(stderr,counld not get netmask for device %s;%s\n,dev,errbuf);net0;mask0;}handlerpcap_open_live(dev,BUFSIZ,1,10000,errbuf);if(handlerNULL){fprintf(stderr,could not open device %s;%s,dev,errbuf);return 2;}if(pcap_compile(handler,fp,filter_exp,0,net)-1){fprintf(stderr,counld not parse filter %s;%s\n,filter_exp,pcap_geterr(handler));return 2;}if(pcap_setfilter(handler,fp)-1){fprintf(stderr,counld not install filter %s;%s\n,filter_exp,pcap_geterr(handler));return 2;}//捕获数据包 int packetnums20;packetpcap_loop(handler,packetnums,packetcall,NULL);pcap_close(handler);return 0;}//数据包到达回调函数void packetcall(u_char *user,const struct pcap_pkthdr *pcap_head,const u_char *packet){static int count1;//数据包计数 struct sniff_ethernet *ethernet;//以太网包头struct sniff_ip *ip;//ip包头struct sniff_udp *udp;//udp包头struct sniff_dns *dns;//dns报头const u_char *payload;//数据包负载的数据int pay_size;//数据包负载的数据大小ethernet(struct sniff_ethernet*)(packet);ip(struct sniff_ip*)(packet sizeof(struct sniff_ethernet));udp(struct sniff_udp*)(packet sizeof(struct sniff_ethernet)sizeof(struct sniff_ip));dns(struct sniff_dns*)(packet sizeof(struct sniff_ethernet) sizeof(struct sniff_ip) sizeof(struct sniff_udp));payload(u_char *)(packetsizeof(struct sniff_ethernet)sizeof(struct sniff_ip)sizeof(struct sniff_udp)sizeof(struct sniff_dns));pay_sizentohs(udp-udp_len)-sizeof(struct sniff_udp)-sizeof(struct sniff_dns);printf(-------------数据包:%d\n,count);printf(数据包类型:%s\n,getpackettype(ethernet-ether_type));printf(源地址:%X:%X:%X:%X:%X:%X\n,(ethernet-ether_shost)[0],(ethernet-ether_shost)[1],(ethernet-ether_shost)[2],(ethernet-ether_shost)[3],(ethernet-ether_shost)[4],(ethernet-ether_shost)[5]);printf(目的地址:%X:%X:%X:%X:%X:%X\n,(ethernet-ether_dhost)[0],(ethernet-ether_dhost)[1],(ethernet-ether_dhost)[2],(ethernet-ether_dhost)[3],(ethernet-ether_dhost)[4],(ethernet-ether_dhost)[5]);printf(From:%s\n,inet_ntoa(ip-ip_src));printf(To:%s\n,inet_ntoa(ip-ip_dst));printf(源端口:%d\n,ntohs(udp-udp_sport));printf(目的端口:%d\n,ntohs(udp-udp_dport));printf(DNS查询问题数%d\n,ntohs(dns-dns_ques));if(pay_size0){printf(Payload data size %d\n,pay_size);const u_char *chpayload;int i,j;for(i0;idns_ques);i){//获取各查询名 printf(第%d个查询名\n,i);int k1;//标志符号; while(1){if(*ch0)break;u_int8_t identify_size*ch;printf(\t第%d个标志符号\n,k);ch;for(j0;j{if(isprint(*ch)){printf(%c,*ch);}else{printf(.);}}k;}}}count;}libnet的使用/*author hjjdate 2011-1-20function: send an arp packet to all machine on local net*/#include#include#define MAC_ADDR_LEN 6#define IP_ADDR_LEN 4#define LIBNET_DNS_H 0xcint main(int argc,char **argv){libnet_t *net_tNULL;char *deveth0;char err_buf[LIBNET_ERRBUF_SIZE];libnet_ptag_t p_tag;unsigned char src_mac[MAC_ADDR_LEN]{0x00,0x00,0xf1,0xe8,0x0e,0xc8};//发送者网卡地址unsigned char dst_mac[MAC_ADDR_LEN]{0xff,0xff,0xff,0xff,0xff,0xff};//接收者网卡地址 char *src_ip_str172.20.92.117;if(argc2){if(strcmp(argv[1],-h)0||strcmp(argv[1],--help)0){printf(%s,help message);}else{src_ip_strargv[1];}}unsigned long src_ip,dst_ip0;src_iplibnet_name2addr4(net_t,src_ip_str,LIBNET_RESOLVE);//将字符串类型的ip转换为顺序网络字节流 net_tlibnet_init(LIBNET_LINK_ADV,dev,err_buf);//初始化发送包结构 if(net_tNULL){printf(libnet_init error\n);exit(0)}p_taglibnet_build_arp(ARPHRD_ETHER,//hardware type ethernet ETHERTYPE_IP,//protocol type MAC_ADDR_LEN,//mac length IP_ADDR_LEN,//protocol length ARPOP_REPLY,//op type (u_int8_t*)src_mac,//source mac addr这里的作用是更新目的地的arp表 (u_int8_t*)src_ip,//source ip addr (u_int8_t*)dst_mac,//source mac addr (u_int8_t*)dst_ip,//dest ip addr NULL,//payload 0,//payload length net_t,//libnet context 0//0 stands to build a new one );if(-1 p_tag){printf(libnet_build_arp error);exit(0);}//以太网头部 p_taglibnet_build_ethernet(//create ethernet header (u_int8_t*)dst_mac,//dest mac addr (u_int8_t*)src_mac,//source mac addr ETHERTYPE_ARP,//protocol type NULL,//payload 0,//payload length net_t,//libnet context 0//0 to build a new one );if(-1 p_tag){printf(libnet_build_ethernet error!\n);exit(1);}int res;if(-1(reslibnet_write(net_t))){printf(libnet_write error!\n);exit(1);}libnet_destroy(net_t);return 0;}
http://www.sadfv.cn/news/256833/

相关文章:

  • 网站开发费用怎么账务处理做电影网站多少钱
  • 可以下载源程序的网站中国电子商务公司排名
  • 网站开发的可行性分析山东已经宣布封城的城市2022年
  • 大型门户网站建设一般多少钱下载asp做网站
  • 陕西服装网站建设韩国男女做游戏视频网站
  • 网站建设全网推广小程序建设企业网站的重要性
  • 网站做伪静态深圳网络推广公司排名
  • 利用云服务器做网站射阳做网站的公司
  • 石家庄网站建设招商变更网站备案信息
  • 扬州市网站建设绵阳高端网站建设
  • 网站建设合同书保密条款wordpress好还是discuz
  • 重庆响应式网站建设费用已有域名 wordpress
  • 网站怎么做uc整合微网站有什么好处
  • tinypng图片压缩网站厦门网站建设推广哪家好
  • 网站开发代码h5福州网站设计企业建站
  • 如何在记事本中做网站链接初中生如何做网站
  • 烟台北京网站建设怎么查看网站的建设时间
  • 共享虚拟主机普惠版做网站焦作市网站建设
  • 重庆网站建设培训机构北京政务服务官方网站
  • 网站后台打打开空白wordpress什么删留言
  • 张店学校网站建设定制网站建设首选玖艺建站信得过
  • 校园网站建设er模型做视频资源网站有哪些难点
  • 网站建设心得总结做校园网站
  • 网站最新一次改版时间什么意思沧州做网站哪家公司好
  • 网站建设的技术需要多少钱网站开发的最后5个阶段
  • 知乎 拒绝 朋友 做网站长沙竞价网站建设价格
  • 民兵信息化网站建设如何开一个微信公众号
  • 滨州五学一做考试网站网页游戏在线
  • 浅谈网站规划建设与管理维护关键词数据分析
  • 北京首钢建设有限公司网站采集网站怎么做