1.配置linux系统日志。
2.在windows接收linux日志
3.通过正则表达式分析出危险操作并警告
首先我们先配置linux的转发
vim /etc/rsyslog.conf
这一样的IP地址是windows的ip*.* @192.168.16.79
然后重启rsyslog:service rsyslog restart。
xsyslog.cpp
#include "XUdp.h"
#incldue <iostream>
using namespace std;
int main(int argc,char *argv[])
{
unsigned short por = 514;
XUdp syslog;
if (!syslog.Bind(port))
{
return -1;
}
char buf[2000] = {0};
for (;;)
{
int len = syslog.Recv(buf, sizeof(buf));
if (len <= 0)
{
continue;
}
buf[len] = '\0';
cout << buf << endl;
}
return 0;
}
XUdp.h
//#pragma once
#ifndef _XTCP_H_
#define _XTPC_H_
#include <string>
class XUdp
{
public:
XUdp();
~XUdp();
int CreateSocket();
vpid Close();
bool Bind(unsigned short port);
char ip[16];
unsigned short port = 0;
int Recv(char* buf, int bufSize);
protected:
int sock = 0