- 论坛徽章:
- 0
|
#include <stdio.h>
#include "nids.h"
#include <time.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <malloc.h>
#include <string.h>
#include <stdlib.h>
void tcp_connect_callback(struct tcp_stream* ftp_control_stream,void **arg);
//////////////////////////////////zhu han shu de fen ge xian//////////////////////////////////
int main()
{
if (!nids_init())
{
printf("error:%s\n",nids_errbuf);
exit(1);
}
nids_register_tcp(tcp_connect_callback);
nids_run();
return 0;
}
//////////////////////////////////han shu shi xian de fen ge xian/////////////////////////////////
void tcp_connect_callback(struct tcp_stream* ftp_control_stream,void **arg)
{
struct half_stream *hlf = NULL;//半连接指针,取数据时用
printf("Now in callback");
switch(ftp_control_stream->nids_state)
{
case NIDS_JUST_EST:
ftp_control_stream->client.collect++;
ftp_control_stream->server.collect++;
ftp_control_stream->client.collect_urg++;
ftp_control_stream->server.collect_urg++;
return ;
case NIDS_DATA:
printf("data\n");
if( ftp_control_stream->server.count_new )
{
printf("SERVER in\n");
hlf = &ftp_control_stream->server;
}
else
{
printf("Client in\n");
hlf = &ftp_control_stream->client;
}
return ;
break;
default:
break;
}//switch
return;
}
|
编译的时候:gcc -o test test.c -lnids -lpcap -lnet
可是运行的时候只能够抓到发送到自己机器的数据包,而自己机器向外发的数据包都漏了
环境:Ubuntu7.04 libnids1.21
3Q Very |
|