first pass 3.0 conversion
This commit is contained in:
parent
a1051b1882
commit
d4a0ac2624
18 changed files with 545 additions and 548 deletions
2
.gitattributes
vendored
2
.gitattributes
vendored
|
@ -8,6 +8,8 @@
|
|||
/aclocal.m4 -text
|
||||
/configure -text
|
||||
/configure.in -text
|
||||
/exempts.c -text
|
||||
/exempts.h -text
|
||||
/html.css -text
|
||||
/install-sh -text
|
||||
libopm/.cvsignore -text
|
||||
|
|
|
@ -8,7 +8,7 @@ INSTALL_DATA = @INSTALL_DATA@
|
|||
DIRECTORY = @DIRINST@/dl/
|
||||
INCLUDES = -I@DIRINST@/include/ -I. -Ilibopm
|
||||
|
||||
SRCS= opsb.c proxy.c opsb_help.c
|
||||
SRCS= opsb.c proxy.c opsb_help.c exempts.c
|
||||
OBJS= ${SRCS:.c=.o}
|
||||
TARGET= opsb.so
|
||||
DOCS=README.opsb README.opsb.html opsb.Settings
|
||||
|
@ -57,4 +57,5 @@ $(OBJS): Makefile
|
|||
opsb.o: opsb.h opsb.c modconfig.h
|
||||
proxy.o: opsb.h proxy.c modconfig.h
|
||||
opsb_help.o: opsb.h
|
||||
exempts.o: opsb.h exempts.c exempts.h
|
||||
|
||||
|
|
170
exempts.c
Normal file
170
exempts.c
Normal file
|
@ -0,0 +1,170 @@
|
|||
/* NeoStats - IRC Statistical Services Copyright (c) 1999-2004 NeoStats Group Inc.
|
||||
** Copyright (c) 1999-2004 Adam Rutter, Justin Hammond
|
||||
** http://www.neostats.net/
|
||||
**
|
||||
** This program is free software; you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
** the Free Software Foundation; either version 2 of the License, or
|
||||
** (at your option) any later version.
|
||||
**
|
||||
** This program is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with this program; if not, write to the Free Software
|
||||
** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
** USA
|
||||
**
|
||||
** NeoStats CVS Identification
|
||||
** $Id$
|
||||
*/
|
||||
|
||||
#include "neostats.h"
|
||||
#include "opsb.h"
|
||||
#include "exempts.h"
|
||||
|
||||
int opsb_cmd_exclude (CmdParams* cmdparams)
|
||||
{
|
||||
char *buf;
|
||||
exemptinfo *exempts;
|
||||
int i;
|
||||
lnode_t *lnode;
|
||||
|
||||
if (!strcasecmp(cmdparams->av[0], "LIST")) {
|
||||
lnode = list_first(exempt);
|
||||
i = 1;
|
||||
irc_prefmsg (opsb_bot, cmdparams->source, "Exception List:");
|
||||
while (lnode) {
|
||||
exempts = lnode_get(lnode);
|
||||
irc_prefmsg (opsb_bot, cmdparams->source, "%d) %s %s Added by %s for %s", i, exempts->host, (exempts->server ? "(Server)" : "(Client)"), exempts->who, exempts->reason);
|
||||
++i;
|
||||
lnode = list_next(exempt, lnode);
|
||||
}
|
||||
irc_prefmsg (opsb_bot, cmdparams->source, "End of List.");
|
||||
irc_chanalert (opsb_bot, "%s requested Exception List", cmdparams->source->name);
|
||||
} else if (!strcasecmp(cmdparams->av[0], "ADD")) {
|
||||
if (cmdparams->ac < 6) {
|
||||
irc_prefmsg (opsb_bot, cmdparams->source, "Syntax Error. /msg %s help exclude", opsb_bot);
|
||||
return 0;
|
||||
}
|
||||
if (list_isfull(exempt)) {
|
||||
irc_prefmsg (opsb_bot, cmdparams->source, "Error, Exception list is full");
|
||||
return 0;
|
||||
}
|
||||
if (!index(cmdparams->av[1], '.')) {
|
||||
irc_prefmsg (opsb_bot, cmdparams->source, "Host field does not contain a vaild host");
|
||||
return 0;
|
||||
}
|
||||
exempts = malloc(sizeof(exemptinfo));
|
||||
strlcpy(exempts->host, cmdparams->av[1], MAXHOST);
|
||||
if (atoi(cmdparams->av[2]) > 0)
|
||||
exempts->server = 1;
|
||||
else
|
||||
exempts->server = 0;
|
||||
strlcpy(exempts->who, cmdparams->source->name, MAXNICK);
|
||||
buf = joinbuf(cmdparams->av, cmdparams->ac, 3);
|
||||
strlcpy(exempts->reason, buf, MAXHOST);
|
||||
free(buf);
|
||||
lnode = lnode_create(exempts);
|
||||
list_append(exempt, lnode);
|
||||
SaveExempts(exempts);
|
||||
|
||||
irc_prefmsg (opsb_bot, cmdparams->source, "Added %s (%s) exception to list", exempts->host, (exempts->server ? "(Server)" : "(Client)"));
|
||||
irc_chanalert (opsb_bot, "%s added %s (%s) exception to list", cmdparams->source->name, exempts->host, (exempts->server ? "(Server)" : "(Client)"));
|
||||
} else if (!strcasecmp(cmdparams->av[0], "DEL")) {
|
||||
if (cmdparams->ac < 1) {
|
||||
irc_prefmsg (opsb_bot, cmdparams->source, "Syntax Error. /msg %s help exclude", opsb_bot);
|
||||
return 0;
|
||||
}
|
||||
if (atoi(cmdparams->av[1]) != 0) {
|
||||
lnode = list_first(exempt);
|
||||
i = 1;
|
||||
while (lnode) {
|
||||
if (i == atoi(cmdparams->av[1])) {
|
||||
/* delete the entry */
|
||||
exempts = lnode_get(lnode);
|
||||
buf = malloc(BUFSIZE);
|
||||
ircsnprintf(buf, BUFSIZE, "Exempt/%s", exempts->host);
|
||||
DelConf(buf);
|
||||
free(buf);
|
||||
list_delete(exempt, lnode);
|
||||
irc_prefmsg (opsb_bot, cmdparams->source, "Deleted %s %s out of exception list", exempts->host, (exempts->server ? "(Server)" : "(Client)"));
|
||||
irc_chanalert (opsb_bot, "%s deleted %s %s out of exception list", cmdparams->source->name, exempts->host, (exempts->server ? "(Server)" : "(Client)"));
|
||||
free(exempts);
|
||||
return 1;
|
||||
}
|
||||
++i;
|
||||
lnode = list_next(exempt, lnode);
|
||||
}
|
||||
/* if we get here, then we can't find the entry */
|
||||
irc_prefmsg (opsb_bot, cmdparams->source, "Error, Can't find entry %d. /msg %s exclude list", atoi(cmdparams->av[1]), opsb_bot);
|
||||
return 0;
|
||||
} else {
|
||||
irc_prefmsg (opsb_bot, cmdparams->source, "Error, Out of Range");
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
irc_prefmsg (opsb_bot, cmdparams->source, "Syntax Error. /msg %s help exclude", opsb_bot);
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void SaveExempts (exemptinfo *exempts)
|
||||
{
|
||||
char path[255];
|
||||
|
||||
dlog (DEBUG1, "Saving Exempt List %s", exempts->host);
|
||||
ircsnprintf (path, 255, "Exempt/%s/Who", exempts->host);
|
||||
SetConf ((void *)exempts->who, CFGSTR, path);
|
||||
ircsnprintf (path, 255, "Exempt/%s/Reason", exempts->host);
|
||||
SetConf ((void *)exempts->reason, CFGSTR, path);
|
||||
ircsnprintf (path, 255, "Exempt/%s/Server", exempts->host);
|
||||
SetConf ((void *)exempts->server, CFGINT, path);
|
||||
}
|
||||
|
||||
void LoadExempts (void)
|
||||
{
|
||||
int i;
|
||||
lnode_t *node;
|
||||
char **data;
|
||||
char *tmp;
|
||||
char datapath[BUFSIZE];
|
||||
exemptinfo *exempts;
|
||||
|
||||
if (GetDir ("Exempt", &data) > 0) {
|
||||
/* try */
|
||||
for (i = 0; data[i] != NULL; i++) {
|
||||
exempts = malloc(sizeof(exemptinfo));
|
||||
strlcpy(exempts->host, data[i], MAXHOST);
|
||||
|
||||
ircsnprintf(datapath, CONFBUFSIZE, "Exempt/%s/Who", data[i]);
|
||||
if (GetConf((void *)&tmp, CFGSTR, datapath) <= 0) {
|
||||
free(exempts);
|
||||
continue;
|
||||
} else {
|
||||
strlcpy(exempts->who, tmp, MAXNICK);
|
||||
free(tmp);
|
||||
}
|
||||
ircsnprintf(datapath, CONFBUFSIZE, "Exempt/%s/Reason", data[i]);
|
||||
if (GetConf((void *)&tmp, CFGSTR, datapath) <= 0) {
|
||||
free(exempts);
|
||||
continue;
|
||||
} else {
|
||||
strlcpy(exempts->reason, tmp, MAXREASON);
|
||||
free(tmp);
|
||||
}
|
||||
ircsnprintf(datapath, CONFBUFSIZE, "Exempt/%s/Server", data[i]);
|
||||
if (GetConf((void *)&exempts->server, CFGINT, datapath) <= 0) {
|
||||
free(exempts);
|
||||
continue;
|
||||
}
|
||||
dlog (DEBUG2, "Adding %s (%d) Set by %s for %s to Exempt List", exempts->host, exempts->server, exempts->who, exempts->reason);
|
||||
node = lnode_create(exempts);
|
||||
list_prepend(exempt, node);
|
||||
}
|
||||
}
|
||||
free(data);
|
||||
}
|
17
exempts.h
Normal file
17
exempts.h
Normal file
|
@ -0,0 +1,17 @@
|
|||
/* NetStats - IRC Statistical Services Copyright (c) 1999 Adam Rutter,
|
||||
** Justin Hammond http://codeworks.kamserve.com
|
||||
*
|
||||
** Based from GeoStats 1.1.0 by Johnathan George net@lite.net
|
||||
*
|
||||
** NetStats CVS Identification
|
||||
** $Id$
|
||||
*/
|
||||
|
||||
#ifndef EXEMPTS_H
|
||||
#define EXEMPTS_H
|
||||
|
||||
void LoadExempts (void);
|
||||
void SaveExempts (exemptinfo *exempts);
|
||||
int opsb_cmd_exclude (CmdParams* cmdparams);
|
||||
|
||||
#endif /* EXEMPTS_H */
|
|
@ -21,7 +21,11 @@
|
|||
* Boston, MA 02111-1307, USA
|
||||
*/
|
||||
|
||||
#ifdef WIN32
|
||||
#include "win32modconfig.h"
|
||||
#else
|
||||
#include "modconfig.h"
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
|
|
|
@ -21,7 +21,11 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#ifdef WIN32
|
||||
#include "win32modconfig.h"
|
||||
#else
|
||||
#include "modconfig.h"
|
||||
#endif
|
||||
|
||||
#include "malloc.h"
|
||||
#include "config.h"
|
||||
|
|
|
@ -25,7 +25,11 @@ along with this program; if not, write to
|
|||
* -TimeMr14C
|
||||
*/
|
||||
|
||||
#ifdef WIN32
|
||||
#include "win32modconfig.h"
|
||||
#else
|
||||
#include "modconfig.h"
|
||||
#endif
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
|
|
|
@ -21,7 +21,11 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#ifdef WIN32
|
||||
#include "win32modconfig.h"
|
||||
#else
|
||||
#include "modconfig.h"
|
||||
#endif
|
||||
|
||||
#include "config.h"
|
||||
#include "libopm.h"
|
||||
|
|
|
@ -21,7 +21,11 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#ifdef WIN32
|
||||
#include "win32modconfig.h"
|
||||
#else
|
||||
#include "modconfig.h"
|
||||
#endif
|
||||
|
||||
#include "opm_common.h"
|
||||
#include "list.h"
|
||||
|
|
|
@ -22,7 +22,11 @@
|
|||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#ifdef WIN32
|
||||
#include "win32modconfig.h"
|
||||
#else
|
||||
#include "modconfig.h"
|
||||
#endif
|
||||
|
||||
#include "malloc.h"
|
||||
#include "opm.h"
|
||||
|
|
|
@ -1,7 +1,11 @@
|
|||
#ifndef MALLOC_H
|
||||
#define MALLOC_H
|
||||
|
||||
#ifdef WIN32
|
||||
#include "win32modconfig.h"
|
||||
#else
|
||||
#include "modconfig.h"
|
||||
#endif
|
||||
|
||||
#ifdef STDC_HEADERS
|
||||
# include <stdlib.h>
|
||||
|
|
|
@ -10,7 +10,9 @@
|
|||
#define OPM_H
|
||||
|
||||
#include "opm_common.h"
|
||||
#ifndef WIN32
|
||||
#include <sys/poll.h>
|
||||
#endif
|
||||
|
||||
/* Stuff to shut up warnings about rcsid being unused. */
|
||||
#define USE_VAR(var) static char sizeof##var = sizeof(sizeof##var) + sizeof(var)
|
||||
|
|
|
@ -22,7 +22,11 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#ifdef WIN32
|
||||
#include "win32modconfig.h"
|
||||
#else
|
||||
#include "modconfig.h"
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
|
|
|
@ -21,7 +21,11 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#ifdef WIN32
|
||||
#include "win32modconfig.h"
|
||||
#else
|
||||
#include "modconfig.h"
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include "opm.h"
|
||||
|
|
50
opsb.h
50
opsb.h
|
@ -11,7 +11,11 @@
|
|||
#ifndef OPSB_H
|
||||
#define OPSB_H
|
||||
|
||||
#ifdef WIN32
|
||||
#include "win32modconfig.h"
|
||||
#else
|
||||
#include "modconfig.h"
|
||||
#endif
|
||||
#include "opm_types.h"
|
||||
|
||||
typedef struct port_list {
|
||||
|
@ -21,9 +25,7 @@ typedef struct port_list {
|
|||
int noopen;
|
||||
} port_list;
|
||||
|
||||
|
||||
extern char s_opsb[MAXNICK];
|
||||
|
||||
extern Bot *opsb_bot;
|
||||
|
||||
/* max scans in the max concurrent scans at any one time */
|
||||
#define MAX_SCANS 100
|
||||
|
@ -36,26 +38,21 @@ extern char s_opsb[MAXNICK];
|
|||
|
||||
#define MAXREASON 128
|
||||
|
||||
struct scanq {
|
||||
typedef struct scaninfo{
|
||||
char who[MAXHOST];
|
||||
int state;
|
||||
int dnsstate;
|
||||
char lookup[MAXHOST];
|
||||
char server[MAXHOST];
|
||||
struct in_addr ipaddr;
|
||||
User *u;
|
||||
struct in_addr ip;
|
||||
Client *u;
|
||||
int doreport;
|
||||
time_t started;
|
||||
int doneban;
|
||||
char connectstring[BUFSIZE];
|
||||
};
|
||||
|
||||
typedef struct scanq scaninfo;
|
||||
} scaninfo;
|
||||
|
||||
struct opsb {
|
||||
char user[MAXUSER];
|
||||
char host[MAXHOST];
|
||||
char realname[MAXREALNAME];
|
||||
char opmdomain[MAXHOST];
|
||||
int init;
|
||||
char targethost[MAXHOST];
|
||||
|
@ -79,45 +76,31 @@ struct opsb {
|
|||
list_t *ports;
|
||||
} opsb;
|
||||
|
||||
|
||||
typedef struct sockinfo socklist;
|
||||
|
||||
|
||||
/* this is the list of items to be queued */
|
||||
list_t *opsbq;
|
||||
/* this is the list of currently active scans */
|
||||
list_t *opsbl;
|
||||
|
||||
|
||||
struct cache_entry {
|
||||
typedef struct cache_entry {
|
||||
unsigned long ip;
|
||||
time_t when;
|
||||
};
|
||||
|
||||
typedef struct cache_entry C_entry;
|
||||
|
||||
} cache_entry;
|
||||
|
||||
/* this is a list of cached scans */
|
||||
list_t *cache;
|
||||
|
||||
struct exempts {
|
||||
typedef struct exemptinfo {
|
||||
char host[MAXHOST];
|
||||
int server;
|
||||
char who[MAXNICK];
|
||||
char reason[MAXREASON];
|
||||
};
|
||||
|
||||
typedef struct exempts exemptinfo;
|
||||
|
||||
}exemptinfo;
|
||||
|
||||
typedef struct proxy_type {
|
||||
int type;
|
||||
char name[MAXNICK];
|
||||
} proxy_type;
|
||||
|
||||
|
||||
|
||||
|
||||
/* this is the list of exempted hosts/servers */
|
||||
|
||||
list_t *exempt;
|
||||
|
@ -137,12 +120,12 @@ list_t *exempt;
|
|||
int findscan(const void *key1, const void *key2);
|
||||
void do_ban(scaninfo *scandata);
|
||||
void checkqueue();
|
||||
void addtocache(unsigned long ipaddr);
|
||||
void addtocache(unsigned long ip);
|
||||
|
||||
|
||||
/* proxy.c */
|
||||
void start_proxy_scan(lnode_t *scannode);
|
||||
int do_status(User *u, char **av, int ac);
|
||||
int opsb_cmd_status (CmdParams* cmdparams) ;
|
||||
void check_scan_free(scaninfo *scandata);
|
||||
int init_libopm();
|
||||
char *type_of_proxy(int type);
|
||||
|
@ -152,14 +135,13 @@ int load_ports();
|
|||
|
||||
/* help text */
|
||||
extern const char *opsb_help_lookup[];
|
||||
extern const char *opsb_help_info[];
|
||||
extern const char *opsb_about[];
|
||||
extern const char *opsb_help_check[];
|
||||
extern const char *opsb_help_status[];
|
||||
extern const char *opsb_help_exclude[];
|
||||
extern const char *opsb_help_remove[];
|
||||
extern const char *opsb_help_ports[];
|
||||
|
||||
extern const char opsb_help_info_oneline[];
|
||||
extern const char opsb_help_status_oneline[];
|
||||
extern const char opsb_help_lookup_oneline[];
|
||||
extern const char opsb_help_remove_oneline[];
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
|
||||
#include "neostats.h"
|
||||
|
||||
const char opsb_help_info_oneline[] = "Information about opsb";
|
||||
const char opsb_help_status_oneline[] = "View opsb state information";
|
||||
const char opsb_help_lookup_oneline[] = "Lookup DNS record";
|
||||
const char opsb_help_remove_oneline[] = "Remove an akill set by opsb";
|
||||
|
@ -51,7 +50,7 @@ const char *opsb_help_lookup[] = {
|
|||
NULL
|
||||
};
|
||||
|
||||
const char *opsb_help_info[] = {
|
||||
const char *opsb_about[] = {
|
||||
"\2Open Proxy Scanning Bot Information\2",
|
||||
"",
|
||||
"This bot is intended to scan clients connecting to this",
|
||||
|
|
101
proxy.c
101
proxy.c
|
@ -26,17 +26,19 @@
|
|||
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#ifndef WIN32
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <arpa/nameser.h>
|
||||
#endif
|
||||
#include "neostats.h"
|
||||
#include "opsb.h"
|
||||
#include "opm.h"
|
||||
#include "opm_types.h"
|
||||
#include "opm_error.h"
|
||||
|
||||
int proxy_connect(unsigned long ipaddr, int port, char *who);
|
||||
int proxy_connect(unsigned long ip, int port, char *who);
|
||||
void open_proxy(OPM_T *scanner, OPM_REMOTE_T *remote, int notused, void *unused);
|
||||
void negfailed(OPM_T *scanner, OPM_REMOTE_T *remote, int notused, void *unused);
|
||||
void timeout(OPM_T *scanner, OPM_REMOTE_T *remote, int notused, void *unused);
|
||||
|
@ -85,16 +87,16 @@ int load_ports() {
|
|||
ok = 0;
|
||||
for (i = 0; proxy_list[i].type != 0; i++) {
|
||||
if (GetConf((void *)&portname, CFGSTR, proxy_list[i].name) <= 0) {
|
||||
nlog(LOG_WARNING, LOG_MOD, "Warning, No Ports defined for Protocol %s", proxy_list[i].name);
|
||||
nlog (LOG_WARNING, "Warning, No Ports defined for Protocol %s", proxy_list[i].name);
|
||||
} else {
|
||||
ac = split_buf(portname, &av, 0);
|
||||
for (j = 0; j < ac; j++) {
|
||||
if (atoi(av[j]) == 0) {
|
||||
nlog(LOG_WARNING, LOG_MOD, "Invalid Port %s for Proxy Type %s", av[j], proxy_list[i].name);
|
||||
nlog (LOG_WARNING, "Invalid Port %s for Proxy Type %s", av[j], proxy_list[i].name);
|
||||
continue;
|
||||
}
|
||||
if (list_isfull(opsb.ports)) {
|
||||
nlog(LOG_MOD, LOG_WARNING, "Ports List is Full.");
|
||||
nlog (LOG_WARNING, "Ports List is Full.");
|
||||
break;
|
||||
}
|
||||
prtlst = malloc(sizeof(port_list));
|
||||
|
@ -103,7 +105,7 @@ int load_ports() {
|
|||
prtlst->noopen = 0;
|
||||
pn = lnode_create(prtlst);
|
||||
list_append(opsb.ports, pn);
|
||||
nlog(LOG_DEBUG1, LOG_MOD, "Added Port %d for Protocol %s", prtlst->port, proxy_list[i].name);
|
||||
dlog (DEBUG1, "Added Port %d for Protocol %s", prtlst->port, proxy_list[i].name);
|
||||
ok = 1;
|
||||
}
|
||||
free(av);
|
||||
|
@ -152,7 +154,7 @@ int init_libopm() {
|
|||
|
||||
|
||||
/* add the sock poll interface into neo */
|
||||
add_sockpoll("libopm_before_poll", "libopm_after_poll", "opsb", "opsb", scanner);
|
||||
add_sockpoll("opsb", scanner, libopm_before_poll, libopm_after_poll);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
@ -173,11 +175,12 @@ void open_proxy(OPM_T *scanner, OPM_REMOTE_T *remote, int notused, void *unused)
|
|||
|
||||
++opsb.open;
|
||||
|
||||
nlog(LOG_CRITICAL, LOG_MOD, "OPSB: Banning %s (%s) for Open Proxy - %s(%d)", scandata->who, remote->ip, type_of_proxy(remote->protocol), remote->port);
|
||||
chanalert(s_opsb, "Banning %s (%s) for Open Proxy - %s(%d)", scandata->who, remote->ip, type_of_proxy(remote->protocol), remote->port);
|
||||
globops(s_opsb, "Banning %s (%s) for Open Proxy - %s(%d)", scandata->who, remote->ip, type_of_proxy(remote->protocol), remote->port);
|
||||
if (scandata->u) prefmsg(scandata->u->nick, s_opsb, "Banning %s (%s) for Open Proxy - %s(%d)", scandata->who, remote->ip, type_of_proxy(remote->protocol), remote->port);
|
||||
if (opsb.doban) sakill_cmd(remote->ip, "*", s_opsb, opsb.bantime, "Open Proxy found on your host. %s(%d)", type_of_proxy(remote->protocol), remote->port);
|
||||
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 (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
|
||||
/* write out to a logfile */
|
||||
if ((fp = fopen("logs/openproxies.log", "a")) == NULL) return;
|
||||
|
@ -192,11 +195,11 @@ void open_proxy(OPM_T *scanner, OPM_REMOTE_T *remote, int notused, void *unused)
|
|||
#if 0
|
||||
if (scandata->dnsstate == OPMLIST) {
|
||||
scandata->doneban = 1;
|
||||
nlog(LOG_CRITICAL, LOG_MOD, "OPSB: Banning %s (%s) as its listed in %s", scandata->who, inet_ntoa(scandata->ipaddr), opsb.opmdomain);
|
||||
chanalert(s_opsb, "Banning %s (%s) as its listed in %s", scandata->who, inet_ntoa(scandata->ipaddr), opsb.opmdomain);
|
||||
globops(s_opsb, "Banning %s (%s) as its listed in %s", scandata->who, inet_ntoa(scandata->ipaddr), opsb.opmdomain);
|
||||
if (scandata->u) prefmsg(scandata->u->nick, s_opsb, "Banning %s (%s) as its listed in %s", scandata->who, inet_ntoa(scandata->ipaddr), opsb.opmdomain);
|
||||
sakill_cmd(inet_ntoa(scandata->ipaddr), "*", s_opsb, 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->ipaddr));
|
||||
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);
|
||||
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
|
||||
}
|
||||
|
@ -209,7 +212,7 @@ void negfailed(OPM_T *scanner, OPM_REMOTE_T *remote, int notused, void *unused)
|
|||
scandata = remote->data;
|
||||
|
||||
if (scandata->u) {
|
||||
prefmsg(scandata->u->nick, s_opsb, "Negitiation failed for protocol %s(%d)", type_of_proxy(remote->protocol), remote->port);
|
||||
irc_prefmsg (opsb_bot, scandata->u, "Negitiation failed for protocol %s(%d)", type_of_proxy(remote->protocol), remote->port);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -220,7 +223,7 @@ void timeout(OPM_T *scanner, OPM_REMOTE_T *remote, int notused, void *unused) {
|
|||
|
||||
scandata = remote->data;
|
||||
if (scandata->u) {
|
||||
prefmsg(scandata->u->nick, s_opsb, "Timeout on Protocol %s(%d)", type_of_proxy(remote->protocol), remote->port);
|
||||
irc_prefmsg (opsb_bot, scandata->u, "Timeout on Protocol %s(%d)", type_of_proxy(remote->protocol), remote->port);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -231,7 +234,7 @@ void scan_end(OPM_T *scanner, OPM_REMOTE_T *remote, int notused, void *unused) {
|
|||
|
||||
scandata = remote->data;
|
||||
if (scandata->u) {
|
||||
prefmsg(scandata->u->nick, s_opsb, "scan finished on %s", scandata->who);
|
||||
irc_prefmsg (opsb_bot, scandata->u, "scan finished on %s", scandata->who);
|
||||
}
|
||||
opm_remote_free(remote);
|
||||
if (scandata->state != GOTOPENPROXY) scandata->state = FIN_SCAN;
|
||||
|
@ -245,9 +248,9 @@ void scan_error(OPM_T *scanner, OPM_REMOTE_T *remote, int opmerr, void *unused)
|
|||
scandata = remote->data;
|
||||
if (scandata->u) {
|
||||
if (opmerr == 5) {
|
||||
prefmsg(scandata->u->nick, s_opsb, "Closed Proxy on Protocol %s (%d)", type_of_proxy(remote->protocol), remote->port);
|
||||
irc_prefmsg (opsb_bot, scandata->u, "Closed Proxy on Protocol %s (%d)", type_of_proxy(remote->protocol), remote->port);
|
||||
} else {
|
||||
prefmsg(scandata->u->nick, s_opsb, "scan error on Protocol %s (%d) - %d", type_of_proxy(remote->protocol), remote->port, opmerr);
|
||||
irc_prefmsg (opsb_bot, scandata->u, "scan error on Protocol %s (%d) - %d", type_of_proxy(remote->protocol), remote->port, opmerr);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -255,60 +258,60 @@ void scan_error(OPM_T *scanner, OPM_REMOTE_T *remote, int opmerr, void *unused)
|
|||
|
||||
|
||||
|
||||
int do_status(User *u, char **av, int ac)
|
||||
int opsb_cmd_status (CmdParams* cmdparams)
|
||||
{
|
||||
lnode_t *node;
|
||||
scaninfo *scandata;
|
||||
|
||||
SET_SEGV_LOCATION();
|
||||
|
||||
prefmsg(u->nick, s_opsb, "Proxy Results:");
|
||||
prefmsg(u->nick, s_opsb, "Hosts Scanned: %d Hosts found Open: %d Exceptions %d", opsb.scanned, opsb.open, (int)list_count(exempt));
|
||||
prefmsg(u->nick, s_opsb, "Cache Entries: %d", (int)list_count(cache));
|
||||
prefmsg(u->nick, s_opsb, "Cache Hits: %d", opsb.cachehits);
|
||||
prefmsg(u->nick, s_opsb, "Blacklist Hits: %d", opsb.opmhits);
|
||||
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, "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);
|
||||
#if 0
|
||||
for (i = 0; i < NUM_PROXIES; i++) {
|
||||
prefmsg(u->nick, s_opsb, "Proxy %s (%d) Found %d Open %d", proxy_list[i].type, proxy_list[i].port, proxy_list[i].nofound, proxy_list[i].noopen);
|
||||
irc_prefmsg (opsb_bot, cmdparams->source, "Proxy %s (%d) Found %d Open %d", proxy_list[i].type, proxy_list[i].port, proxy_list[i].nofound, proxy_list[i].noopen);
|
||||
}
|
||||
#endif
|
||||
prefmsg(u->nick, s_opsb, "Currently Scanning %d Proxies (%d in queue):", (int)list_count(opsbl), (int)list_count(opsbq));
|
||||
irc_prefmsg (opsb_bot, cmdparams->source, "Currently Scanning %d Proxies (%d in queue):", (int)list_count(opsbl), (int)list_count(opsbq));
|
||||
node = list_first(opsbl);
|
||||
while (node) {
|
||||
scandata = lnode_get(node);
|
||||
if (scandata->u)
|
||||
prefmsg(u->nick, s_opsb, "Scanning %s by request of %s", scandata->lookup, scandata->u->nick);
|
||||
irc_prefmsg (opsb_bot, cmdparams->source, "Scanning %s by request of %s", scandata->lookup, scandata->u->name);
|
||||
else
|
||||
prefmsg(u->nick, s_opsb, "Scanning %s (%s) - %s", scandata->lookup, inet_ntoa(scandata->ipaddr), scandata->who);
|
||||
irc_prefmsg (opsb_bot, cmdparams->source, "Scanning %s (%s) - %s", scandata->lookup, inet_ntoa(scandata->ip), scandata->who);
|
||||
|
||||
switch(scandata->dnsstate) {
|
||||
case REPORT_DNS:
|
||||
prefmsg(u->nick, s_opsb, "Looking up IP Address");
|
||||
irc_prefmsg (opsb_bot, cmdparams->source, "Looking up IP Address");
|
||||
break;
|
||||
case DO_DNS_HOST_LOOKUP:
|
||||
prefmsg(u->nick, s_opsb, "Looking up IP address for Scan");
|
||||
irc_prefmsg (opsb_bot, cmdparams->source, "Looking up IP address for Scan");
|
||||
break;
|
||||
case DO_OPM_LOOKUP:
|
||||
prefmsg(u->nick, s_opsb, "Looking up DNS blacklist");
|
||||
irc_prefmsg (opsb_bot, cmdparams->source, "Looking up DNS blacklist");
|
||||
break;
|
||||
case OPMLIST:
|
||||
prefmsg(u->nick, s_opsb, "Host is listed in %s", opsb.opmdomain);
|
||||
irc_prefmsg (opsb_bot, cmdparams->source, "Host is listed in %s", opsb.opmdomain);
|
||||
break;
|
||||
case NOOPMLIST:
|
||||
prefmsg(u->nick, s_opsb, "Host is Not listed in %s", opsb.opmdomain);
|
||||
irc_prefmsg (opsb_bot, cmdparams->source, "Host is Not listed in %s", opsb.opmdomain);
|
||||
break;
|
||||
default:
|
||||
prefmsg(u->nick, s_opsb, "Unknown State (DNS)");
|
||||
irc_prefmsg (opsb_bot, cmdparams->source, "Unknown State (DNS)");
|
||||
}
|
||||
switch(scandata->state) {
|
||||
case DOING_SCAN:
|
||||
prefmsg(u->nick, s_opsb, "Scanning for Open Proxies");
|
||||
irc_prefmsg (opsb_bot, cmdparams->source, "Scanning for Open Proxies");
|
||||
break;
|
||||
case GOTOPENPROXY:
|
||||
prefmsg(u->nick, s_opsb, "Contains an Open Proxy");
|
||||
irc_prefmsg (opsb_bot, cmdparams->source, "Contains an Open Proxy");
|
||||
break;
|
||||
default:
|
||||
prefmsg(u->nick, s_opsb, "Unknown State (Scan)");
|
||||
irc_prefmsg (opsb_bot, cmdparams->source, "Unknown State (Scan)");
|
||||
}
|
||||
node = list_next(opsbl, node);
|
||||
}
|
||||
|
@ -332,21 +335,21 @@ void start_proxy_scan(lnode_t *scannode) {
|
|||
return;
|
||||
}
|
||||
|
||||
if (scandata->u) chanalert(s_opsb, "Starting proxy scan on %s (%s) by Request of %s", scandata->who, scandata->lookup, scandata->u->nick);
|
||||
if (scandata->u) irc_chanalert (opsb_bot, "Starting proxy scan on %s (%s) by Request of %s", scandata->who, scandata->lookup, scandata->u->name);
|
||||
scandata->state = DOING_SCAN;
|
||||
/* this is so we can timeout scans */
|
||||
scandata->started = time(NULL);
|
||||
|
||||
if ((opsb.doscan == 1) || (scandata->u)) {
|
||||
remote = opm_remote_create(inet_ntoa(scandata->ipaddr));
|
||||
remote = opm_remote_create(inet_ntoa(scandata->ip));
|
||||
remote->data = scandata;
|
||||
switch(i = opm_scan(scanner, remote))
|
||||
{
|
||||
case OPM_SUCCESS:
|
||||
nlog(LOG_DEBUG2, LOG_MOD, "Starting Scan on %s", inet_ntoa(scandata->ipaddr));
|
||||
dlog (DEBUG2, "Starting Scan on %s", inet_ntoa(scandata->ip));
|
||||
break;
|
||||
case OPM_ERR_BADADDR:
|
||||
nlog(LOG_WARNING, LOG_MOD, "Scan of %s %s Failed. Bad Address?", scandata->who, inet_ntoa(scandata->ipaddr));
|
||||
nlog (LOG_WARNING, "Scan of %s %s Failed. Bad Address?", scandata->who, inet_ntoa(scandata->ip));
|
||||
opm_remote_free(remote);
|
||||
scandata->state = FIN_SCAN;
|
||||
check_scan_free(scandata);
|
||||
|
@ -357,22 +360,22 @@ void start_proxy_scan(lnode_t *scannode) {
|
|||
void check_scan_free(scaninfo *scandata) {
|
||||
lnode_t *scannode;
|
||||
if ((scandata->dnsstate == DO_OPM_LOOKUP) || (scandata->dnsstate == DO_DNS_HOST_LOOKUP) || (scandata->state == DOING_SCAN)) {
|
||||
nlog(LOG_DEBUG2, LOG_MOD, "Not Cleaning up Scaninfo for %s yet. Scan hasn't completed", scandata->who);
|
||||
dlog (DEBUG2, "Not Cleaning up Scaninfo for %s yet. Scan hasn't completed", scandata->who);
|
||||
return;
|
||||
}
|
||||
if ((scandata->dnsstate != OPMLIST) && (scandata->state != GOTOPENPROXY)) {
|
||||
addtocache(scandata->ipaddr.s_addr);
|
||||
nlog(LOG_DEBUG1, LOG_MOD, "%s's Host is clean. Adding to Cache", scandata->who);
|
||||
addtocache(scandata->ip.s_addr);
|
||||
dlog (DEBUG1, "%s's Host is clean. Adding to Cache", scandata->who);
|
||||
}
|
||||
scannode = list_find(opsbl, scandata->who, findscan);
|
||||
if (scannode) {
|
||||
nlog(LOG_DEBUG1, LOG_MOD, "%s scan finished. Cleaning up", scandata->who);
|
||||
dlog (DEBUG1, "%s scan finished. Cleaning up", scandata->who);
|
||||
list_delete(opsbl, scannode);
|
||||
lnode_destroy(scannode);
|
||||
scandata->u = NULL;
|
||||
free(scandata);
|
||||
} else {
|
||||
nlog(LOG_WARNING, LOG_MOD, "Damn, Can't find ScanNode %s. Something is fubar", scandata->who);
|
||||
nlog (LOG_WARNING, "Damn, Can't find ScanNode %s. Something is fubar", scandata->who);
|
||||
}
|
||||
checkqueue();
|
||||
}
|
||||
|
|
Reference in a new issue