Compare commits
3 Commits
969927106e
...
15b093d3f6
Author | SHA1 | Date | |
---|---|---|---|
15b093d3f6 | |||
764491d70a | |||
9421d1f1eb |
48
conf.c
48
conf.c
@ -144,6 +144,12 @@ static void parse_global_module(char *content, conf * conf)
|
|||||||
if (copy_new_mem(val_begin, val_begin_len, &conf->RECV_MAIL) != 0)
|
if (copy_new_mem(val_begin, val_begin_len, &conf->RECV_MAIL) != 0)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (strcasecmp(var, "PUBLIC_IP") == 0) {
|
||||||
|
val_begin_len = val_end - val_begin;
|
||||||
|
if (copy_new_mem(val_begin, val_begin_len, &conf->PUBLIC_IP) != 0)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
content = strchr(lineEnd + 1, '\n');
|
content = strchr(lineEnd + 1, '\n');
|
||||||
}
|
}
|
||||||
@ -206,27 +212,43 @@ void read_conf(char *filename, conf * configure)
|
|||||||
|
|
||||||
void free_conf(conf * conf)
|
void free_conf(conf * conf)
|
||||||
{
|
{
|
||||||
free(conf->DAEMON);
|
if (conf->DAEMON)
|
||||||
free(conf->PHONE);
|
free(conf->DAEMON);
|
||||||
free(conf->DING_WEBHOOK);
|
if (conf->PHONE)
|
||||||
free(conf->SEND_QQ);
|
free(conf->PHONE);
|
||||||
free(conf->QQMAIL_KEY);
|
if (conf->DING_WEBHOOK)
|
||||||
free(conf->RECV_MAIL);
|
free(conf->DING_WEBHOOK);
|
||||||
|
if (conf->SEND_QQ)
|
||||||
|
free(conf->SEND_QQ);
|
||||||
|
if (conf->QQMAIL_KEY)
|
||||||
|
free(conf->QQMAIL_KEY);
|
||||||
|
if (conf->RECV_MAIL)
|
||||||
|
free(conf->RECV_MAIL);
|
||||||
|
if (conf->PUBLIC_IP)
|
||||||
|
free(conf->PUBLIC_IP);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ptintf_conf(conf * conf)
|
void ptintf_conf(conf * conf)
|
||||||
{
|
{
|
||||||
printf("%s\n", conf->DAEMON);
|
if (conf->DAEMON)
|
||||||
|
printf("%s\n", conf->DAEMON);
|
||||||
printf("%d\n", conf->TIME);
|
printf("%d\n", conf->TIME);
|
||||||
printf("%d\n", conf->REFUSE_NUMBER);
|
printf("%d\n", conf->REFUSE_NUMBER);
|
||||||
printf("%d\n", conf->IS_MAIL);
|
printf("%d\n", conf->IS_MAIL);
|
||||||
printf("%d\n", conf->IS_DING_WEBHOOK);
|
printf("%d\n", conf->IS_DING_WEBHOOK);
|
||||||
printf("%s\n", conf->PHONE);
|
if (conf->PHONE)
|
||||||
printf("%s\n", conf->DING_WEBHOOK);
|
printf("%s\n", conf->PHONE);
|
||||||
|
if (conf->DING_WEBHOOK)
|
||||||
|
printf("%s\n", conf->DING_WEBHOOK);
|
||||||
printf("%d\n", conf->IS_QQMAIL);
|
printf("%d\n", conf->IS_QQMAIL);
|
||||||
printf("%s\n", conf->SEND_QQ);
|
if (conf->SEND_QQ)
|
||||||
printf("%s\n", conf->QQMAIL_KEY);
|
printf("%s\n", conf->SEND_QQ);
|
||||||
printf("%s\n", conf->RECV_MAIL);
|
if (conf->QQMAIL_KEY)
|
||||||
|
printf("%s\n", conf->QQMAIL_KEY);
|
||||||
|
if (conf->RECV_MAIL)
|
||||||
|
printf("%s\n", conf->RECV_MAIL);
|
||||||
|
if (conf->PUBLIC_IP)
|
||||||
|
printf("%s\n", conf->PUBLIC_IP);
|
||||||
}
|
}
|
||||||
|
3
conf.h
3
conf.h
@ -12,6 +12,9 @@ typedef struct CONF {
|
|||||||
int TIME;
|
int TIME;
|
||||||
|
|
||||||
int REFUSE_NUMBER;
|
int REFUSE_NUMBER;
|
||||||
|
|
||||||
|
// 获取公网IP Url地址
|
||||||
|
char *PUBLIC_IP;
|
||||||
|
|
||||||
int IS_MAIL;
|
int IS_MAIL;
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ function run()
|
|||||||
free -hl &>> ${LOG_FILE}
|
free -hl &>> ${LOG_FILE}
|
||||||
|
|
||||||
echo "System process:" &>> ${LOG_FILE}
|
echo "System process:" &>> ${LOG_FILE}
|
||||||
ps -auxwwjf &>> ${LOG_FILE}
|
ps -auxwwf &>> ${LOG_FILE}
|
||||||
|
|
||||||
echo "Network Connections" &>> ${LOG_FILE}
|
echo "Network Connections" &>> ${LOG_FILE}
|
||||||
netstat -tnulp &>> ${LOG_FILE}
|
netstat -tnulp &>> ${LOG_FILE}
|
||||||
|
6
rhost.c
6
rhost.c
@ -62,7 +62,8 @@ static char *GET_PUBLIC_IP(char *URL)
|
|||||||
fprintf(stderr, "curl_easy_perform() failed: %s\n", curl_easy_strerror(res));
|
fprintf(stderr, "curl_easy_perform() failed: %s\n", curl_easy_strerror(res));
|
||||||
} else {
|
} else {
|
||||||
//printf("%lu bytes retrieved\n", (unsigned long)chunk.size);
|
//printf("%lu bytes retrieved\n", (unsigned long)chunk.size);
|
||||||
printf("%s", chunk.memory);
|
//printf("%s", chunk.memory);
|
||||||
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
curl_easy_cleanup(curl_handle);
|
curl_easy_cleanup(curl_handle);
|
||||||
@ -363,8 +364,7 @@ int main(int argc, char *argv[], char **env)
|
|||||||
//ptintf_conf(conf);
|
//ptintf_conf(conf);
|
||||||
|
|
||||||
// 新版本获取公网IP
|
// 新版本获取公网IP
|
||||||
public_ip = GET_PUBLIC_IP("http://ip.sb");
|
public_ip = GET_PUBLIC_IP(conf->PUBLIC_IP);
|
||||||
|
|
||||||
//printf("%s", public_ip);
|
//printf("%s", public_ip);
|
||||||
|
|
||||||
signal(SIGCHLD, sig_child); // 创建捕捉子进程退出信号
|
signal(SIGCHLD, sig_child); // 创建捕捉子进程退出信号
|
||||||
|
@ -2,7 +2,9 @@ global {
|
|||||||
DAEMON = "off"; // on开启后台运行,off不开启
|
DAEMON = "off"; // on开启后台运行,off不开启
|
||||||
TIME = "60"; // 睡眠时间
|
TIME = "60"; // 睡眠时间
|
||||||
|
|
||||||
REFUSE_NUMBER = 3; // 拒绝攻击次数
|
PUBLIC_IP = "http://inet-ip.info"; // 获取公网IP
|
||||||
|
|
||||||
|
REFUSE_NUMBER = 3; // 拒绝攻击次数
|
||||||
|
|
||||||
IS_MAIL = 0; // 开启邮件告警
|
IS_MAIL = 0; // 开启邮件告警
|
||||||
|
|
||||||
@ -10,6 +12,6 @@ global {
|
|||||||
PHONE = "15565979082"; // @的人手机号
|
PHONE = "15565979082"; // @的人手机号
|
||||||
DING_WEBHOOK = "https://oapi.dingtalk.com/robot/send?access_token=7f069c672cb878987aa6772cca336740eece4ce36bde12b51b45e9f440e0565a"; // 钉钉WEBHOOK
|
DING_WEBHOOK = "https://oapi.dingtalk.com/robot/send?access_token=7f069c672cb878987aa6772cca336740eece4ce36bde12b51b45e9f440e0565a"; // 钉钉WEBHOOK
|
||||||
|
|
||||||
IS_QQMAIL = 1; // 开启QQ邮箱告警
|
IS_QQMAIL = 0; // 开启QQ邮箱告警
|
||||||
RECV_MAIL = "1605227279@qq.com"; // 接收者QQ
|
RECV_MAIL = "1605227279@qq.com"; // 接收者QQ
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user