2022-07-07 16:52:24 +08:00
|
|
|
#ifndef RHOST_H
|
|
|
|
#define RHOST_H
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <time.h>
|
|
|
|
#include <signal.h>
|
|
|
|
#include <sys/wait.h>
|
|
|
|
#include <curl/curl.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <arpa/inet.h>
|
2022-10-22 18:41:00 +08:00
|
|
|
#include <time.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/wait.h>
|
2022-10-25 23:07:47 +08:00
|
|
|
#include <assert.h>
|
|
|
|
|
|
|
|
|
2022-10-28 21:53:48 +08:00
|
|
|
typedef struct now_next_time
|
|
|
|
{
|
2022-10-25 23:07:47 +08:00
|
|
|
int now_year;
|
|
|
|
int now_mon;
|
|
|
|
int now_day;
|
|
|
|
int now_hour;
|
|
|
|
int now_min;
|
|
|
|
int now_sec;
|
|
|
|
int now_week;
|
|
|
|
|
|
|
|
int next_year;
|
|
|
|
int next_mon;
|
|
|
|
int next_day;
|
|
|
|
int next_hour;
|
|
|
|
int next_min;
|
|
|
|
int next_sec;
|
|
|
|
int next_week;
|
|
|
|
} now_next_time;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include <assert.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <limits.h>
|
|
|
|
|
|
|
|
#include "ccronexpr.h"
|
|
|
|
|
|
|
|
#define MAX_SECONDS 60
|
|
|
|
#define CRON_MAX_MINUTES 60
|
|
|
|
#define CRON_MAX_HOURS 24
|
|
|
|
#define CRON_MAX_DAYS_OF_WEEK 8
|
|
|
|
#define CRON_MAX_DAYS_OF_MONTH 32
|
|
|
|
#define CRON_MAX_MONTHS 12
|
|
|
|
|
|
|
|
#define INVALID_INSTANT ((time_t) -1)
|
|
|
|
|
|
|
|
#define DATE_FORMAT "%Y-%m-%d_%H:%M:%S"
|
|
|
|
|
|
|
|
#ifndef ARRAY_LEN
|
|
|
|
#define ARRAY_LEN(x) sizeof(x)/sizeof(x[0])
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef CRON_TEST_MALLOC
|
|
|
|
static int cronAllocations = 0;
|
|
|
|
static int cronTotalAllocations = 0;
|
|
|
|
static int maxAlloc = 0;
|
2022-10-28 21:53:48 +08:00
|
|
|
void* cron_malloc(size_t n)
|
|
|
|
{
|
2022-10-25 23:07:47 +08:00
|
|
|
cronAllocations++;
|
|
|
|
cronTotalAllocations++;
|
2022-10-28 21:53:48 +08:00
|
|
|
if (cronAllocations > maxAlloc)
|
|
|
|
{
|
2022-10-25 23:07:47 +08:00
|
|
|
maxAlloc = cronAllocations;
|
|
|
|
}
|
|
|
|
return malloc(n);
|
|
|
|
}
|
|
|
|
|
2022-10-28 21:53:48 +08:00
|
|
|
void cron_free(void* p)
|
|
|
|
{
|
2022-10-25 23:07:47 +08:00
|
|
|
cronAllocations--;
|
|
|
|
free(p);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2022-07-07 16:52:24 +08:00
|
|
|
|
|
|
|
#define CENTOS_SYSTEM 1
|
|
|
|
#define DEBISN_SYSTEM 2
|
|
|
|
#define UNKNOWN_SYSTEM 3
|
|
|
|
|
|
|
|
#define BUFFER 1024
|
|
|
|
#define LONG_BUFFER 1024*100
|
2022-10-28 21:53:48 +08:00
|
|
|
#define ARGS_NUM 20
|
2022-10-10 17:52:00 +08:00
|
|
|
#define WHITELIST_IP_NUM 1024
|
|
|
|
|
2022-07-07 16:52:24 +08:00
|
|
|
#define AWK " | awk -v num=%d '{a[$1]+=1;} END {for(i in a){if (a[i] >= num) {print i;}}}' "
|
|
|
|
#define GE_10 "grep -E \"^$(LC_ALL=\"C\" date \"+%h\").$(LC_ALL=\"C\" date \"+%d\")\" /var/log/auth.log | grep failure | grep rhost"
|
|
|
|
#define LE_10 "grep -E \"^$(LC_ALL=\"C\" date \"+%h\")..$(LC_ALL=\"C\" date | awk '{print $3}')\" /var/log/auth.log | grep failure | grep rhost"
|
|
|
|
|
|
|
|
#define CENTOS_GE_10 "grep -E \"^$(LC_ALL=\"C\" date \"+%h\").$(LC_ALL=\"C\" date \"+%d\")\" /var/log/secure | grep failure | grep rhost"
|
|
|
|
#define CENTOS_LE_10 "grep -E \"^$(LC_ALL=\"C\" date \"+%h\")..$(LC_ALL=\"C\" date | awk '{print $3}')\" /var/log/secure | grep failure | grep rhost"
|
|
|
|
|
2022-10-22 18:41:00 +08:00
|
|
|
#define QQMAIL "gomail -r %s -s \"System ban IP\" -t \"%s\""
|
2022-07-07 16:52:24 +08:00
|
|
|
|
2022-10-28 21:53:48 +08:00
|
|
|
|
2022-10-08 14:28:05 +08:00
|
|
|
extern void read_conf(char *filename, conf * configure);
|
2022-07-07 16:52:24 +08:00
|
|
|
extern void free_conf(conf * conf);
|
2022-10-08 14:28:05 +08:00
|
|
|
extern void ptintf_conf(conf * conf);
|
2022-07-07 16:52:24 +08:00
|
|
|
|
2022-10-08 14:28:05 +08:00
|
|
|
#endif
|