win32 changes and split exempt code into seperate files
This commit is contained in:
parent
d4a0ac2624
commit
b8d5e23925
10 changed files with 123 additions and 83 deletions
|
@ -1,5 +1,10 @@
|
|||
Open Proxy Scanning Bot Module for NeoStats Changelog.
|
||||
==============================================================================
|
||||
* Version 3.0 * * Mark (M)
|
||||
- Changes for Win32 compatibility. (M)
|
||||
- Split exempt code into seperate files. (M)
|
||||
- Port to 3.0 API (M)
|
||||
|
||||
* Version 2.3 * 25/7/2004 * Fish (F)
|
||||
- Fix a problem with "OPSB is not configured" messages
|
||||
- Make sure we are using the correct config type for serval set variables
|
||||
|
|
49
exempts.c
49
exempts.c
|
@ -25,6 +25,9 @@
|
|||
#include "opsb.h"
|
||||
#include "exempts.h"
|
||||
|
||||
/* this is the list of exempted hosts/servers */
|
||||
list_t *exempt;
|
||||
|
||||
int opsb_cmd_exclude (CmdParams* cmdparams)
|
||||
{
|
||||
char *buf;
|
||||
|
@ -134,6 +137,7 @@ void LoadExempts (void)
|
|||
char datapath[BUFSIZE];
|
||||
exemptinfo *exempts;
|
||||
|
||||
exempt = list_create(MAX_EXEMPTS);
|
||||
if (GetDir ("Exempt", &data) > 0) {
|
||||
/* try */
|
||||
for (i = 0; data[i] != NULL; i++) {
|
||||
|
@ -168,3 +172,48 @@ void LoadExempts (void)
|
|||
}
|
||||
free(data);
|
||||
}
|
||||
|
||||
int IsServerExempt (char *nick, char *host)
|
||||
{
|
||||
lnode_t *node;
|
||||
exemptinfo *exempts;
|
||||
|
||||
node = list_first(exempt);
|
||||
while (node) {
|
||||
exempts = lnode_get(node);
|
||||
if (exempts->server == 1) {
|
||||
/* match a server */
|
||||
if (match(exempts->host, host)) {
|
||||
dlog (DEBUG1, "OPSB: User %s exempt. Matched host entry %s in Exemptions", nick, exempts->host);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
node = list_next(exempt, node);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int IsUserExempt (char *nick, char *host)
|
||||
{
|
||||
lnode_t *node;
|
||||
exemptinfo *exempts;
|
||||
|
||||
node = list_first(exempt);
|
||||
while (node) {
|
||||
exempts = lnode_get(node);
|
||||
if (exempts->server == 1) {
|
||||
/* match a server */
|
||||
if (match(exempts->host, host)) {
|
||||
dlog (DEBUG1, "OPSB: User %s exempt. Matched server entry %s in Exemptions", nick, exempts->host);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
node = list_next(exempt, node);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int GetExemptCount (void)
|
||||
{
|
||||
return list_count(exempt);
|
||||
}
|
|
@ -13,5 +13,8 @@
|
|||
void LoadExempts (void);
|
||||
void SaveExempts (exemptinfo *exempts);
|
||||
int opsb_cmd_exclude (CmdParams* cmdparams);
|
||||
int IsServerExempt (char *nick, char *host);
|
||||
int IsUserExempt (char *nick, char *host);
|
||||
int GetExemptCount (void);
|
||||
|
||||
#endif /* EXEMPTS_H */
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
|
||||
#ifdef WIN32
|
||||
#include "win32modconfig.h"
|
||||
#include <winsock2.h>
|
||||
#else
|
||||
#include "modconfig.h"
|
||||
#endif
|
||||
|
@ -34,8 +35,10 @@
|
|||
#endif
|
||||
|
||||
#ifndef HAVE_INET_ATON
|
||||
#ifndef WIN32
|
||||
# include <netinet/in.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include "compat.h"
|
||||
#include "opm.h"
|
||||
|
|
|
@ -42,9 +42,13 @@ along with this program; if not, write to
|
|||
# include <strings.h>
|
||||
#endif
|
||||
#include <sys/types.h>
|
||||
#ifdef WIN32
|
||||
#include <winsock2.h>
|
||||
#else
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <netdb.h>
|
||||
#endif
|
||||
|
||||
#include "inet.h"
|
||||
#include "opm.h"
|
||||
|
|
|
@ -2,10 +2,14 @@
|
|||
#define INET_H
|
||||
|
||||
#include <sys/types.h>
|
||||
#ifdef WIN32
|
||||
#include <winsock2.h>
|
||||
#else
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <netdb.h>
|
||||
#endif
|
||||
#ifdef HAVE_FCNTL_H
|
||||
# include <fcntl.h>
|
||||
#endif
|
||||
|
|
|
@ -49,7 +49,9 @@
|
|||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STRING_H
|
||||
# include <string.h>
|
||||
|
@ -1066,8 +1068,14 @@ static void libopm_do_connect(OPM_T * scanner, OPM_SCAN_T *scan, OPM_CONNECTION_
|
|||
}
|
||||
|
||||
/* Set socket non blocking */
|
||||
#ifdef WIN32
|
||||
{
|
||||
int flags = 1;
|
||||
ioctlsocket(conn->fd, FIONBIO, &flags);
|
||||
}
|
||||
#else
|
||||
fcntl(conn->fd, F_SETFL, O_NONBLOCK);
|
||||
|
||||
#endif
|
||||
connect(conn->fd, (struct sockaddr *) addr, sizeof(*addr));
|
||||
|
||||
conn->state = OPM_STATE_ESTABLISHED;
|
||||
|
|
76
opsb.c
76
opsb.c
|
@ -155,17 +155,17 @@ int opsb_cmd_check (CmdParams* cmdparams)
|
|||
}
|
||||
scandata = malloc(sizeof(scaninfo));
|
||||
scandata->doneban = 0;
|
||||
scandata->u = cmdparams->source;
|
||||
scandata->reqclient = cmdparams->source;
|
||||
if ((u2 = find_user(cmdparams->av[0])) != NULL) {
|
||||
/* don't scan users from my server */
|
||||
if (!strcasecmp(u2->user->server->name, me.name)) {
|
||||
if (!strcasecmp(u2->uplink->name, me.name)) {
|
||||
irc_prefmsg (opsb_bot, cmdparams->source, "Error, Can not scan NeoStats Bots");
|
||||
free(scandata);
|
||||
return -1;
|
||||
}
|
||||
strlcpy(scandata->who, u2->name, MAXHOST);
|
||||
strlcpy(scandata->lookup, u2->user->hostname, MAXHOST);
|
||||
strlcpy(scandata->server, u2->user->server->name, MAXHOST);
|
||||
strlcpy(scandata->server, u2->uplink->name, MAXHOST);
|
||||
scandata->ip.s_addr = u2->ip.s_addr;
|
||||
if (scandata->ip.s_addr > 0) {
|
||||
scandata->dnsstate = DO_OPM_LOOKUP;
|
||||
|
@ -460,29 +460,12 @@ int checkcache(scaninfo *scandata)
|
|||
{
|
||||
lnode_t *node, *node2;
|
||||
cache_entry *ce;
|
||||
exemptinfo *exempts;
|
||||
|
||||
SET_SEGV_LOCATION();
|
||||
|
||||
node = list_first(exempt);
|
||||
while (node) {
|
||||
exempts = lnode_get(node);
|
||||
if ((exempts->server == 1) && (scandata->server)) {
|
||||
/* match a server */
|
||||
if (match(exempts->host, scandata->server)) {
|
||||
dlog (DEBUG1, "OPSB: User %s exempt. Matched server entry %s in Exemptions", scandata->who, exempts->host);
|
||||
if (scandata->u) irc_prefmsg (opsb_bot, scandata->u,"%s Matches a Server Exception %s", scandata->who, exempts->host);
|
||||
return 1;
|
||||
}
|
||||
} else {
|
||||
if (match(exempts->host, scandata->lookup)) {
|
||||
dlog (DEBUG1, "OPSB: User %s exempt. Matched host entry %s in exemptions", scandata->who, exempts->host);
|
||||
if (scandata->u) irc_prefmsg (opsb_bot, scandata->u, "%s Matches a Host Exception %s", scandata->who, exempts->host);
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
node = list_next(exempt, node);
|
||||
}
|
||||
if (scandata->server && IsServerExempt (scandata->who, scandata->server))
|
||||
return 1;
|
||||
if (IsUserExempt (scandata->who, scandata->lookup))
|
||||
return 2;
|
||||
node = list_first(cache);
|
||||
while (node) {
|
||||
ce = lnode_get(node);
|
||||
|
@ -501,7 +484,7 @@ int checkcache(scaninfo *scandata)
|
|||
if (ce->ip == scandata->ip.s_addr) {
|
||||
dlog (DEBUG1, "OPSB: user %s is already in Cache", scandata->who);
|
||||
opsb.cachehits++;
|
||||
if (scandata->u) irc_prefmsg (opsb_bot, scandata->u, "User %s is already in Cache", scandata->who);
|
||||
if (scandata->reqclient) irc_prefmsg (opsb_bot, scandata->reqclient, "User %s is already in Cache", scandata->who);
|
||||
return 3;
|
||||
}
|
||||
node = list_next(cache, node);
|
||||
|
@ -520,30 +503,18 @@ static int ScanNick (CmdParams* cmdparams)
|
|||
{
|
||||
scaninfo *scandata;
|
||||
lnode_t *scannode;
|
||||
lnode_t *node;
|
||||
exemptinfo *exempts;
|
||||
|
||||
SET_SEGV_LOCATION();
|
||||
|
||||
/* don't scan users from a server that is excluded */
|
||||
node = list_first(exempt);
|
||||
while (node) {
|
||||
exempts = lnode_get(node);
|
||||
if (exempts->server == 1) {
|
||||
/* match a server */
|
||||
if (match(exempts->host, cmdparams->source->user->server->name)) {
|
||||
dlog (DEBUG1, "OPSB: User %s exempt. Matched server entry %s in Exemptions", cmdparams->source->name, exempts->host);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
node = list_next(exempt, node);
|
||||
if (IsServerExempt (cmdparams->source->name, cmdparams->source->uplink->name))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (time(NULL) - cmdparams->source->tsconnect > opsb.timedif) {
|
||||
dlog (DEBUG1, "Netsplit Nick %s, Not Scanning", cmdparams->source->name);
|
||||
return -1;
|
||||
}
|
||||
|
||||
scannode = list_find(opsbl, cmdparams->source->name, findscan);
|
||||
if (!scannode) scannode = list_find(opsbq, cmdparams->source->name, findscan);
|
||||
if (scannode) {
|
||||
|
@ -552,11 +523,11 @@ static int ScanNick (CmdParams* cmdparams)
|
|||
}
|
||||
irc_prefmsg (opsb_bot, cmdparams->source, "%s", opsb.scanmsg);
|
||||
scandata = malloc(sizeof(scaninfo));
|
||||
scandata->u = NULL;
|
||||
scandata->reqclient = NULL;
|
||||
scandata->doneban = 0;
|
||||
strlcpy(scandata->who, cmdparams->source->name, MAXHOST);
|
||||
strlcpy(scandata->lookup, cmdparams->source->user->hostname, MAXHOST);
|
||||
strlcpy(scandata->server, cmdparams->source->user->server->name, MAXHOST);
|
||||
strlcpy(scandata->server, cmdparams->source->uplink->name, MAXHOST);
|
||||
strlcpy(scandata->connectstring, recbuf, BUFSIZE);
|
||||
scandata->ip.s_addr = cmdparams->source->ip.s_addr;
|
||||
if (scandata->ip.s_addr > 0) {
|
||||
|
@ -590,7 +561,7 @@ int startscan(scaninfo *scandata)
|
|||
/* only check the cache when we have IP addy */
|
||||
if (scandata->dnsstate == DO_OPM_LOOKUP) {
|
||||
i = checkcache(scandata);
|
||||
if ((i > 0) && (scandata->u == NULL)) {
|
||||
if ((i > 0) && (scandata->reqclient == NULL)) {
|
||||
free(scandata);
|
||||
return 1;
|
||||
}
|
||||
|
@ -601,14 +572,14 @@ int startscan(scaninfo *scandata)
|
|||
if (list_isfull(opsbq)) {
|
||||
irc_chanalert (opsb_bot, "Warning, Both Current and queue lists are full. Not Adding additional scans");
|
||||
dlog (DEBUG1, "OPSB: dropped scaning of %s, as queue is full", scandata->who);
|
||||
if (scandata->u) irc_prefmsg (opsb_bot, scandata->u, "To Busy. Try again later");
|
||||
if (scandata->reqclient) irc_prefmsg (opsb_bot, scandata->reqclient, "To Busy. Try again later");
|
||||
free(scandata);
|
||||
return 0;
|
||||
}
|
||||
scannode = lnode_create(scandata);
|
||||
list_append(opsbq, scannode);
|
||||
dlog (DEBUG1, "DNS: Added %s to dns queue", scandata->who);
|
||||
if (scandata->u) irc_prefmsg (opsb_bot, scandata->u, "Your Request has been added to the Queue");
|
||||
if (scandata->reqclient) irc_prefmsg (opsb_bot, scandata->reqclient, "Your Request has been added to the Queue");
|
||||
return 1;
|
||||
}
|
||||
if (dns_lookup(scandata->lookup, adns_r_a, dnsblscan, scandata->who) != 1) {
|
||||
|
@ -627,7 +598,7 @@ int startscan(scaninfo *scandata)
|
|||
if (list_isfull(opsbl)) {
|
||||
if(list_isfull(opsbq)) {
|
||||
irc_chanalert (opsb_bot, "Warning, Both Current and Queue lists are full, Not adding Scan");
|
||||
if (scandata->u) irc_prefmsg (opsb_bot, scandata->u, "Too Busy. Try again Later");
|
||||
if (scandata->reqclient) irc_prefmsg (opsb_bot, scandata->reqclient, "Too Busy. Try again Later");
|
||||
free(scandata);
|
||||
return 0;
|
||||
}
|
||||
|
@ -657,7 +628,7 @@ int startscan(scaninfo *scandata)
|
|||
list_append(opsbl, scannode);
|
||||
dlog (DEBUG1, "DNS: Added OPM %s lookup to DNS active list", buf);
|
||||
free(buf);
|
||||
start_proxy_scan(scannode);
|
||||
start_proxy_scan(lnode_get(scannode));
|
||||
++opsb.scanned;
|
||||
return 1;
|
||||
break;
|
||||
|
@ -690,7 +661,7 @@ void dnsblscan(char *data, adns_answer *a)
|
|||
case DO_DNS_HOST_LOOKUP:
|
||||
if (a->nrrs < 1) {
|
||||
irc_chanalert (opsb_bot, "No Record for %s. Aborting Scan", scandata->lookup);
|
||||
if (scandata->u) irc_prefmsg (opsb_bot, scandata->u, "No A record for %s. Aborting Scan", scandata->lookup);
|
||||
if (scandata->reqclient) irc_prefmsg (opsb_bot, scandata->reqclient, "No A record for %s. Aborting Scan", scandata->lookup);
|
||||
list_delete(opsbl, scannode);
|
||||
lnode_destroy(scannode);
|
||||
free(scandata);
|
||||
|
@ -703,7 +674,7 @@ void dnsblscan(char *data, adns_answer *a)
|
|||
dlog (DEBUG1, "DNS: Got IP for %s -> %s", scandata->who, show);
|
||||
if (a->nrrs > 1) {
|
||||
irc_chanalert (opsb_bot, "Warning, More than one IP address for %s. Using %s only", scandata->lookup, show);
|
||||
if (scandata->u) irc_prefmsg (opsb_bot, scandata->u, "Warning, More than one IP address for %s. Using %s only", scandata->lookup, show);
|
||||
if (scandata->reqclient) irc_prefmsg (opsb_bot, scandata->reqclient, "Warning, More than one IP address for %s. Using %s only", scandata->lookup, show);
|
||||
}
|
||||
if (inet_aton(show, &scandata->ip) > 0) {
|
||||
scandata->dnsstate = DO_OPM_LOOKUP;
|
||||
|
@ -737,11 +708,11 @@ void dnsblscan(char *data, adns_answer *a)
|
|||
opsb.opmhits++;
|
||||
irc_chanalert (opsb_bot, "Banning %s (%s) as its listed in %s", scandata->who, inet_ntoa(scandata->ip), opsb.opmdomain);
|
||||
irc_globops (opsb_bot, "Banning %s (%s) as its listed in %s", scandata->who, inet_ntoa(scandata->ip), opsb.opmdomain);
|
||||
if (scandata->u) irc_prefmsg (opsb_bot, scandata->u, "Banning %s (%s) as its listed in %s", scandata->who, inet_ntoa(scandata->ip), opsb.opmdomain);
|
||||
if (scandata->reqclient) irc_prefmsg (opsb_bot, scandata->reqclient, "Banning %s (%s) as its listed in %s", scandata->who, inet_ntoa(scandata->ip), opsb.opmdomain);
|
||||
irc_akill (opsb_bot, inet_ntoa(scandata->ip), "*", opsb.bantime, "Your host is listed as an Open Proxy. Please visit the following website for more info: www.blitzed.org/proxy?ip=%s", inet_ntoa(scandata->ip));
|
||||
checkqueue();
|
||||
} else {
|
||||
if (scandata->u) irc_prefmsg (opsb_bot, scandata->u, "%s does not appear in DNS black list", scandata->lookup);
|
||||
if (scandata->reqclient) irc_prefmsg (opsb_bot, scandata->reqclient, "%s does not appear in DNS black list", scandata->lookup);
|
||||
dlog (DEBUG1, "Got Negative OPM lookup for %s (%s)", scandata->who, scandata->lookup);
|
||||
scandata->dnsstate = NOOPMLIST;
|
||||
}
|
||||
|
@ -824,7 +795,6 @@ int ModInit (Module *mod_ptr)
|
|||
opsbq = list_create(MAX_QUEUE);
|
||||
/* scan cache is MAX_QUEUE size (why not?) */
|
||||
cache = list_create(MAX_QUEUE);
|
||||
exempt = list_create(MAX_EXEMPTS);
|
||||
opsb.ports = list_create(MAX_PORTS);
|
||||
LoadExempts();
|
||||
opsb.open = 0;
|
||||
|
@ -843,4 +813,4 @@ int ModInit (Module *mod_ptr)
|
|||
|
||||
void ModFini()
|
||||
{
|
||||
};
|
||||
}
|
||||
|
|
8
opsb.h
8
opsb.h
|
@ -45,7 +45,7 @@ typedef struct scaninfo{
|
|||
char lookup[MAXHOST];
|
||||
char server[MAXHOST];
|
||||
struct in_addr ip;
|
||||
Client *u;
|
||||
Client *reqclient;
|
||||
int doreport;
|
||||
time_t started;
|
||||
int doneban;
|
||||
|
@ -101,10 +101,6 @@ typedef struct proxy_type {
|
|||
char name[MAXNICK];
|
||||
} proxy_type;
|
||||
|
||||
/* this is the list of exempted hosts/servers */
|
||||
|
||||
list_t *exempt;
|
||||
|
||||
/* these are some state flags */
|
||||
#define REPORT_DNS 0x0001
|
||||
#define DO_DNS_HOST_LOOKUP 0x0002
|
||||
|
@ -124,7 +120,7 @@ void addtocache(unsigned long ip);
|
|||
|
||||
|
||||
/* proxy.c */
|
||||
void start_proxy_scan(lnode_t *scannode);
|
||||
void start_proxy_scan(scaninfo *scandata);
|
||||
int opsb_cmd_status (CmdParams* cmdparams) ;
|
||||
void check_scan_free(scaninfo *scandata);
|
||||
int init_libopm();
|
||||
|
|
44
proxy.c
44
proxy.c
|
@ -34,6 +34,7 @@
|
|||
#endif
|
||||
#include "neostats.h"
|
||||
#include "opsb.h"
|
||||
#include "exempts.h"
|
||||
#include "opm.h"
|
||||
#include "opm_types.h"
|
||||
#include "opm_error.h"
|
||||
|
@ -178,7 +179,7 @@ void open_proxy(OPM_T *scanner, OPM_REMOTE_T *remote, int notused, void *unused)
|
|||
nlog (LOG_CRITICAL, "OPSB: Banning %s (%s) for Open Proxy - %s(%d)", scandata->who, remote->ip, type_of_proxy(remote->protocol), remote->port);
|
||||
irc_chanalert (opsb_bot, "Banning %s (%s) for Open Proxy - %s(%d)", scandata->who, remote->ip, type_of_proxy(remote->protocol), remote->port);
|
||||
irc_globops (opsb_bot, "Banning %s (%s) for Open Proxy - %s(%d)", scandata->who, remote->ip, type_of_proxy(remote->protocol), remote->port);
|
||||
if (scandata->u) irc_prefmsg (opsb_bot, scandata->u, "Banning %s (%s) for Open Proxy - %s(%d)", scandata->who, remote->ip, type_of_proxy(remote->protocol), remote->port);
|
||||
if (scandata->reqclient) irc_prefmsg (opsb_bot, scandata->reqclient, "Banning %s (%s) for Open Proxy - %s(%d)", scandata->who, remote->ip, type_of_proxy(remote->protocol), remote->port);
|
||||
if (opsb.doban)
|
||||
irc_akill (opsb_bot, remote->ip, "*", opsb.bantime, "Open Proxy found on your host. %s(%d)", type_of_proxy(remote->protocol), remote->port);
|
||||
#if 0
|
||||
|
@ -198,7 +199,7 @@ void open_proxy(OPM_T *scanner, OPM_REMOTE_T *remote, int notused, void *unused)
|
|||
nlog (LOG_CRITICAL, "OPSB: Banning %s (%s) as its listed in %s", scandata->who, inet_ntoa(scandata->ip), opsb.opmdomain);
|
||||
irc_chanalert (opsb_bot, "Banning %s (%s) as its listed in %s", scandata->who, inet_ntoa(scandata->ip), opsb.opmdomain);
|
||||
irc_globops (opsb_bot, "Banning %s (%s) as its listed in %s", scandata->who, inet_ntoa(scandata->ip), opsb.opmdomain);
|
||||
if (scandata->u) irc_prefmsg (opsb_bot, scandata->u, "Banning %s (%s) as its listed in %s", scandata->who, inet_ntoa(scandata->ip), opsb.opmdomain);
|
||||
if (scandata->reqclient) irc_prefmsg (opsb_bot, scandata->reqclient, "Banning %s (%s) as its listed in %s", scandata->who, inet_ntoa(scandata->ip), opsb.opmdomain);
|
||||
irc_akill (opsb_bot, inet_ntoa(scandata->ip), "*", opsb.bantime, "Your host is listed as an Open Proxy. Please visit the following website for more info: www.blitzed.org/proxy?ip=%s", inet_ntoa(scandata->ip));
|
||||
}
|
||||
#endif
|
||||
|
@ -211,8 +212,8 @@ void negfailed(OPM_T *scanner, OPM_REMOTE_T *remote, int notused, void *unused)
|
|||
|
||||
scandata = remote->data;
|
||||
|
||||
if (scandata->u) {
|
||||
irc_prefmsg (opsb_bot, scandata->u, "Negitiation failed for protocol %s(%d)", type_of_proxy(remote->protocol), remote->port);
|
||||
if (scandata->reqclient) {
|
||||
irc_prefmsg (opsb_bot, scandata->reqclient, "Negitiation failed for protocol %s(%d)", type_of_proxy(remote->protocol), remote->port);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -222,8 +223,8 @@ void timeout(OPM_T *scanner, OPM_REMOTE_T *remote, int notused, void *unused) {
|
|||
SET_SEGV_LOCATION();
|
||||
|
||||
scandata = remote->data;
|
||||
if (scandata->u) {
|
||||
irc_prefmsg (opsb_bot, scandata->u, "Timeout on Protocol %s(%d)", type_of_proxy(remote->protocol), remote->port);
|
||||
if (scandata->reqclient) {
|
||||
irc_prefmsg (opsb_bot, scandata->reqclient, "Timeout on Protocol %s(%d)", type_of_proxy(remote->protocol), remote->port);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -233,8 +234,8 @@ void scan_end(OPM_T *scanner, OPM_REMOTE_T *remote, int notused, void *unused) {
|
|||
SET_SEGV_LOCATION();
|
||||
|
||||
scandata = remote->data;
|
||||
if (scandata->u) {
|
||||
irc_prefmsg (opsb_bot, scandata->u, "scan finished on %s", scandata->who);
|
||||
if (scandata->reqclient) {
|
||||
irc_prefmsg (opsb_bot, scandata->reqclient, "scan finished on %s", scandata->who);
|
||||
}
|
||||
opm_remote_free(remote);
|
||||
if (scandata->state != GOTOPENPROXY) scandata->state = FIN_SCAN;
|
||||
|
@ -246,11 +247,11 @@ void scan_error(OPM_T *scanner, OPM_REMOTE_T *remote, int opmerr, void *unused)
|
|||
|
||||
SET_SEGV_LOCATION();
|
||||
scandata = remote->data;
|
||||
if (scandata->u) {
|
||||
if (scandata->reqclient) {
|
||||
if (opmerr == 5) {
|
||||
irc_prefmsg (opsb_bot, scandata->u, "Closed Proxy on Protocol %s (%d)", type_of_proxy(remote->protocol), remote->port);
|
||||
irc_prefmsg (opsb_bot, scandata->reqclient, "Closed Proxy on Protocol %s (%d)", type_of_proxy(remote->protocol), remote->port);
|
||||
} else {
|
||||
irc_prefmsg (opsb_bot, scandata->u, "scan error on Protocol %s (%d) - %d", type_of_proxy(remote->protocol), remote->port, opmerr);
|
||||
irc_prefmsg (opsb_bot, scandata->reqclient, "scan error on Protocol %s (%d) - %d", type_of_proxy(remote->protocol), remote->port, opmerr);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -266,7 +267,7 @@ int opsb_cmd_status (CmdParams* cmdparams)
|
|||
SET_SEGV_LOCATION();
|
||||
|
||||
irc_prefmsg (opsb_bot, cmdparams->source, "Proxy Results:");
|
||||
irc_prefmsg (opsb_bot, cmdparams->source, "Hosts Scanned: %d Hosts found Open: %d Exceptions %d", opsb.scanned, opsb.open, (int)list_count(exempt));
|
||||
irc_prefmsg (opsb_bot, cmdparams->source, "Hosts Scanned: %d Hosts found Open: %d Exceptions %d", opsb.scanned, opsb.open, GetExemptCount ());
|
||||
irc_prefmsg (opsb_bot, cmdparams->source, "Cache Entries: %d", (int)list_count(cache));
|
||||
irc_prefmsg (opsb_bot, cmdparams->source, "Cache Hits: %d", opsb.cachehits);
|
||||
irc_prefmsg (opsb_bot, cmdparams->source, "Blacklist Hits: %d", opsb.opmhits);
|
||||
|
@ -279,8 +280,8 @@ int opsb_cmd_status (CmdParams* cmdparams)
|
|||
node = list_first(opsbl);
|
||||
while (node) {
|
||||
scandata = lnode_get(node);
|
||||
if (scandata->u)
|
||||
irc_prefmsg (opsb_bot, cmdparams->source, "Scanning %s by request of %s", scandata->lookup, scandata->u->name);
|
||||
if (scandata->reqclient)
|
||||
irc_prefmsg (opsb_bot, cmdparams->source, "Scanning %s by request of %s", scandata->lookup, scandata->reqclient->name);
|
||||
else
|
||||
irc_prefmsg (opsb_bot, cmdparams->source, "Scanning %s (%s) - %s", scandata->lookup, inet_ntoa(scandata->ip), scandata->who);
|
||||
|
||||
|
@ -319,28 +320,25 @@ int opsb_cmd_status (CmdParams* cmdparams)
|
|||
}
|
||||
|
||||
|
||||
void start_proxy_scan(lnode_t *scannode) {
|
||||
scaninfo *scandata;
|
||||
void start_proxy_scan(scaninfo *scandata)
|
||||
{
|
||||
OPM_REMOTE_T *remote;
|
||||
int i;
|
||||
|
||||
SET_SEGV_LOCATION();
|
||||
|
||||
|
||||
scandata = lnode_get(scannode);
|
||||
/* if we are configured not to scan, and its not a request, bail out */
|
||||
if ((opsb.doscan == 0) && (!scandata->u)) {
|
||||
if ((opsb.doscan == 0) && (!scandata->reqclient)) {
|
||||
scandata->state = FIN_SCAN;
|
||||
check_scan_free(scandata);
|
||||
return;
|
||||
}
|
||||
|
||||
if (scandata->u) irc_chanalert (opsb_bot, "Starting proxy scan on %s (%s) by Request of %s", scandata->who, scandata->lookup, scandata->u->name);
|
||||
if (scandata->reqclient) irc_chanalert (opsb_bot, "Starting proxy scan on %s (%s) by Request of %s", scandata->who, scandata->lookup, scandata->reqclient->name);
|
||||
scandata->state = DOING_SCAN;
|
||||
/* this is so we can timeout scans */
|
||||
scandata->started = time(NULL);
|
||||
|
||||
if ((opsb.doscan == 1) || (scandata->u)) {
|
||||
if ((opsb.doscan == 1) || (scandata->reqclient)) {
|
||||
remote = opm_remote_create(inet_ntoa(scandata->ip));
|
||||
remote->data = scandata;
|
||||
switch(i = opm_scan(scanner, remote))
|
||||
|
@ -372,7 +370,7 @@ void check_scan_free(scaninfo *scandata) {
|
|||
dlog (DEBUG1, "%s scan finished. Cleaning up", scandata->who);
|
||||
list_delete(opsbl, scannode);
|
||||
lnode_destroy(scannode);
|
||||
scandata->u = NULL;
|
||||
scandata->reqclient = NULL;
|
||||
free(scandata);
|
||||
} else {
|
||||
nlog (LOG_WARNING, "Damn, Can't find ScanNode %s. Something is fubar", scandata->who);
|
||||
|
|
Reference in a new issue