Author: Fish
Date: Sun Apr 3 21:46:49 2005
New Revision: 158
Added:
branches/3.0/libopm/opmlist.c
- copied, changed from r157, branches/3.0/libopm/list.c
branches/3.0/libopm/opmlist.h
- copied, changed from r157, branches/3.0/libopm/list.h
Removed:
branches/3.0/libopm/list.c
branches/3.0/libopm/list.h
Modified:
branches/3.0/Makefile.in
branches/3.0/configure
branches/3.0/configure.in
branches/3.0/libopm/Makefile.in
branches/3.0/libopm/config.c
branches/3.0/libopm/libopm.c
branches/3.0/libopm/libopm.h
branches/3.0/opsb.c
branches/3.0/opsb.h
branches/3.0/proxy.c
Log:
round one of porting OPSB to new socket code and remove old libopm implementation
Modified: branches/3.0/Makefile.in
==============================================================================
--- branches/3.0/Makefile.in (original)
+++ branches/3.0/Makefile.in Sun Apr 3 21:46:49 2005
@@ -6,7 +6,7 @@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_DATA = @INSTALL_DATA@
DIRECTORY = @DIRINST@/modules/
-INCLUDES = -I@DIRINST@/include/ -I. -Ilibopm
+INCLUDES = -I@DIRINST@/include/ -I.
SRCS = opsb.c proxy.c opsb_help.c
OBJS = ${SRCS:.c=.o}
@@ -14,7 +14,7 @@
DOCS = README.opsb README.opsb.html
DATA =
SCRIPTS =
-DISTFILES = $(SRCS) $(DOCS) modconfig.h.in configure install-sh ChangeLog Makefile.in opsb.h libopm/*.c libopm/*.h libopm/README libopm/LICENSE LICENSE libopm/*.in libopm/*.vcproj RELNOTES opsb.vcproj modconfigwin32.h
+DISTFILES = $(SRCS) $(DOCS) modconfig.h.in configure install-sh ChangeLog Makefile.in opsb.h LICENSE RELNOTES opsb.vcproj modconfigwin32.h
DISTDIR = @PACKAGE@-@VERSION@
all: module
@@ -29,14 +29,11 @@
$(CC) -c $(CFLAGS) $(INCLUDES) $<
$(CC) -MM $(INCLUDES) -c $< > $*.d
-libopm.a:
- (cd libopm; $(MAKE) $@)
-module: libopm.a $(OBJS)
- $(LD) -shared -o $(TARGET) $(LDFLAGS) $(OBJS) libopm/libopm.a
+module: $(OBJS)
+ $(LD) -shared -o $(TARGET) $(LDFLAGS) $(OBJS)
clean:
- (cd libopm; $(MAKE) $@)
/bin/rm -rf $(TARGET) *.o Makefile *.log modconfig.h
install: module
Modified: branches/3.0/configure
==============================================================================
--- branches/3.0/configure (original)
+++ branches/3.0/configure Sun Apr 3 21:46:49 2005
@@ -1321,7 +1321,7 @@
DIRINST=~/NeoStats3.0/
-CFLAGS="$CFLAGS -O2 -Wall"
+CFLAGS="$CFLAGS -O2 -Wall -fno-strict-aliasing"
case "$host_os" in
*openbsd*)
Modified: branches/3.0/configure.in
==============================================================================
--- branches/3.0/configure.in (original)
+++ branches/3.0/configure.in Sun Apr 3 21:46:49 2005
@@ -13,7 +13,7 @@
AC_DEFINE_UNQUOTED(MODULE_REV, "$MODULE_REV")
DIRINST=~/NeoStats3.0/
AC_PREFIX_DEFAULT(~/NeoStats3.0/)
-CFLAGS="$CFLAGS -O2 -Wall"
+CFLAGS="$CFLAGS -O2 -Wall -fno-strict-aliasing"
case "$host_os" in
*openbsd*)
Modified: branches/3.0/libopm/Makefile.in
==============================================================================
--- branches/3.0/libopm/Makefile.in (original)
+++ branches/3.0/libopm/Makefile.in Sun Apr 3 21:46:49 2005
@@ -6,9 +6,9 @@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_DATA = @INSTALL_DATA@
DIRECTORY = @DIRINST@/dl/
-INCLUDES = -I. -I..
+INCLUDES = -I. -I.. -I@DIRINST@/include/
-SRCS= compat.c config.c inet.c libopm.c list.c malloc.c proxy.c
+SRCS= compat.c config.c inet.c libopm.c opmlist.c malloc.c proxy.c
OBJS= ${SRCS:.c=.o}
TARGET= libopm.a
@@ -34,11 +34,11 @@
$(OBJS): Makefile
compat.o: compat.c ../modconfig.h compat.h opm.h opm_common.h
config.o: config.c ../modconfig.h malloc.h config.h libopm.h inet.h \
- opm_common.h opm.h opm_error.h opm_types.h list.h
+ opm_common.h opm.h opm_error.h opm_types.h opmlist.h
inet.o: inet.c ../modconfig.h inet.h opm.h opm_common.h
libopm.o: libopm.c ../modconfig.h config.h libopm.h inet.h opm_common.h \
- opm.h malloc.h opm_error.h opm_types.h list.h proxy.h
-list.o: list.c ../modconfig.h opm_common.h list.h malloc.h opm.h
+ opm.h malloc.h opm_error.h opm_types.h opmlist.h proxy.h
+list.o: opmlist.c ../modconfig.h opm_common.h opmlist.h malloc.h opm.h
malloc.o: malloc.c ../modconfig.h malloc.h opm.h opm_common.h
proxy.o: proxy.c ../modconfig.h inet.h compat.h config.h libopm.h \
opm_common.h opm.h proxy.h opm_types.h opm_error.h
Modified: branches/3.0/libopm/config.c
==============================================================================
--- branches/3.0/libopm/config.c (original)
+++ branches/3.0/libopm/config.c Sun Apr 3 21:46:49 2005
@@ -33,7 +33,7 @@
#include "opm_error.h"
#include "opm_types.h"
#include "opm_common.h"
-#include "list.h"
+#include "opmlist.h"
#ifdef STDC_HEADERS
# include <string.h>
Modified: branches/3.0/libopm/libopm.c
==============================================================================
--- branches/3.0/libopm/libopm.c (original)
+++ branches/3.0/libopm/libopm.c Sun Apr 3 21:46:49 2005
@@ -27,13 +27,15 @@
#include "modconfig.h"
#endif
+#include <neostats.h>
+#include <event.h>
#include "config.h"
#include "libopm.h"
#include "malloc.h"
#include "opm_error.h"
#include "opm_types.h"
#include "opm_common.h"
-#include "list.h"
+#include "opmlist.h"
#include "inet.h"
#include "proxy.h"
@@ -57,6 +59,8 @@
# include <string.h>
#endif
+
+
RCSID("$Id$");
static OPM_PROTOCOL_CONFIG_T *libopm_protocol_config_create(void);
@@ -1030,10 +1034,12 @@
static void libopm_do_connect(OPM_T * scanner, OPM_SCAN_T *scan, OPM_CONNECTION_T *conn)
{
opm_sockaddr *bind_ip;
-
+ struct timeval timeout;
struct sockaddr_in *addr; /* Outgoing host */
+ char tmpbuf[BUFSIZE];
+#if 0
struct sockaddr_in local_addr; /* For binding */
-
+#endif
addr = (struct sockaddr_in *) &(scan->addr.sa4); /* Already have the IP in byte format from opm_scan */
addr->sin_family = AF_INET;
@@ -1041,7 +1047,21 @@
bind_ip = (opm_sockaddr *) libopm_config(scanner->config, OPM_CONFIG_BIND_IP);
+
+ conn->fd = sock_connect(SOCK_STREAM, scan->addr.sa4.sin_addr, conn->port);
+ if (conn->fd == -1)
+ {
+ libopm_do_callback(scanner, libopm_setup_remote(scan->remote, conn), OPM_CALLBACK_ERROR, OPM_ERR_NOFD);
+ conn->state = OPM_STATE_CLOSED;
+ return;
+ }
+ ircsnprintf(tmpbuf, BUFSIZE, "OPSB-%d-%d", conn->fd, conn->port);
+ timeout.tv_sec = *(int *) libopm_config(scanner->config, OPM_CONFIG_TIMEOUT);
+ timeout.tv_usec = 0;
+ conn->Sock = AddSock(SOCK_NATIVE, tmpbuf, conn->fd, libopm_do_readready, libopm_do_writeready, EV_WRITE|EV_TIMEOUT, (void *)conn, &timeout);
+
+#if 0
conn->fd = socket(PF_INET, SOCK_STREAM, 0);
scanner->fd_use++; /* Increase file descriptor use */
@@ -1077,12 +1097,15 @@
fcntl(conn->fd, F_SETFL, O_NONBLOCK);
#endif
connect(conn->fd, (struct sockaddr *) addr, sizeof(*addr));
+#endif /* new sock code */
conn->state = OPM_STATE_ESTABLISHED;
time(&(conn->creation)); /* Stamp creation time, for timeout */
}
+#if 0
+
/* check_poll
*
* Check sockets for ready read/write
@@ -1299,7 +1322,7 @@
}
-
+#endif
/* do_readready
*
Modified: branches/3.0/libopm/libopm.h
==============================================================================
--- branches/3.0/libopm/libopm.h (original)
+++ branches/3.0/libopm/libopm.h Sun Apr 3 21:46:49 2005
@@ -1,6 +1,7 @@
#ifndef LIBOPM_H
#define LIBOPM_H
+#include <neostats.h>
#include "config.h"
#include "inet.h"
#include "opm_common.h"
@@ -31,7 +32,7 @@
OPM_PROTOCOL_T *protocol; /* Pointer to specific protocol this connection handles */
unsigned short int port; /* Some protocols have multiple ports, eg. HTTP */
-
+ Sock *Sock;
int fd; /* Allocated file descriptor, 0 if not yet allocated */
unsigned short int bytes_read; /* Bytes read so far in this connection */
char readbuf[READBUFLEN + 1]; /* 128 byte read buffer, anything over 128 is probably not of use */
Copied: branches/3.0/libopm/opmlist.c (from r157, branches/3.0/libopm/list.c)
==============================================================================
--- branches/3.0/libopm/list.c (original)
+++ branches/3.0/libopm/opmlist.c Sun Apr 3 21:46:49 2005
@@ -28,7 +28,7 @@
#endif
#include "opm_common.h"
-#include "list.h"
+#include "opmlist.h"
#include "malloc.h"
#include "opm.h"
Copied: branches/3.0/libopm/opmlist.h (from r157, branches/3.0/libopm/list.h)
==============================================================================
--- branches/3.0/libopm/list.h (original)
+++ branches/3.0/libopm/opmlist.h Sun Apr 3 21:46:49 2005
@@ -1,5 +1,5 @@
-#ifndef LIST_H
-#define LIST_H
+#ifndef OPMLIST_H
+#define OPMLIST_H
/* Copyright (C) 2002 by the past and present ircd coders, and others.
Modified: branches/3.0/opsb.c
==============================================================================
--- branches/3.0/opsb.c (original)
+++ branches/3.0/opsb.c Sun Apr 3 21:46:49 2005
@@ -30,8 +30,7 @@
#endif
#include "opsb.h"
-void reportdns(char *data, adns_answer *a);
-void dnsblscan(char *data, adns_answer *a);
+void dnsblscan(void *scandata, adns_answer *a);
static int ss_event_signon (CmdParams* cmdparams);
int startscan(scaninfo *scandata);
void save_ports();
@@ -85,51 +84,6 @@
return -1;
}
-int opsb_cmd_lookup (CmdParams* cmdparams)
-{
- scaninfo *scandata;
- int lookuptype;
-
- scandata = malloc(sizeof(scaninfo));
- scandata->dnsstate = REPORT_DNS;
- strlcpy(scandata->who, cmdparams->source->name, MAXNICK);
- strlcpy(scandata->lookup, cmdparams->av[0], MAXHOST);
- /* if the lists are full, don't add it, and alert the user */
- if (list_isfull(opsbl)) {
- if (list_isfull(opsbq)) {
- irc_prefmsg (opsb_bot, cmdparams->source, "Too Busy. Try again Later");
- ns_free(scandata);
- return NS_SUCCESS;
- }
- irc_prefmsg (opsb_bot, cmdparams->source, "OPSB list is full, queuing your request");
- lnode_create_append(opsbq, scandata);
- }
- if (inet_aton(scandata->lookup, NULL) > 0) {
- lookuptype = adns_r_ptr;
- } else {
- if (cmdparams->ac == 2) {
- if (!ircstrcasecmp (cmdparams->av[1], "txt"))
- lookuptype = adns_r_txt;
- else if (!ircstrcasecmp (cmdparams->av[1], "rp"))
- lookuptype = adns_r_rp;
- else if (!ircstrcasecmp (cmdparams->av[1], "ns"))
- lookuptype = adns_r_ns;
- else if (!ircstrcasecmp (cmdparams->av[1], "soa"))
- lookuptype = adns_r_soa;
- else
- lookuptype = adns_r_a;
- } else {
- lookuptype = adns_r_a;
- }
- }
- if (dns_lookup(scandata->lookup, lookuptype, reportdns, scandata->who) != 1) {
- irc_prefmsg (opsb_bot, cmdparams->source, "DnsLookup Failed.");
- ns_free(scandata);
- return NS_FAILURE;
- }
- lnode_create_append(opsbl, scandata);
- return NS_SUCCESS;
-}
int opsb_cmd_remove (CmdParams* cmdparams)
{
@@ -158,29 +112,30 @@
ns_free(scandata);
return NS_SUCCESS;
}
- strlcpy(scandata->who, scanuser->name, MAXHOST);
- strlcpy(scandata->lookup, scanuser->user->hostname, MAXHOST);
- strlcpy(scandata->server, scanuser->uplink->name, MAXHOST);
- scandata->ip.s_addr = scanuser->ip.s_addr;
- if (scandata->ip.s_addr > 0) {
- scandata->dnsstate = DO_OPM_LOOKUP;
- } else {
+ if (scanuser->ip.s_addr <= 0) {
/* if its here, we don't have the IP address yet */
- irc_prefmsg (opsb_bot, cmdparams->source, "Error: We don't have a IP address for %s yet. Try again soon", scanuser->name);
+ irc_prefmsg (opsb_bot, cmdparams->source, "Error: We don't have a IP address for %s.", scanuser->name);
ns_free(scandata);
return NS_SUCCESS;
}
+ strlcpy(scandata->who, scanuser->name, MAXHOST);
+ strlcpy(scandata->lookup, scanuser->user->hostname, MAXHOST);
+ strlcpy(scandata->server, scanuser->uplink->name, MAXHOST);
+ scandata->ip.s_addr = scanuser->ip.s_addr;
} else {
strlcpy(scandata->who, cmdparams->av[0], MAXHOST);
strlcpy(scandata->lookup, cmdparams->av[0], MAXHOST);
memset (scandata->server, 0, MAXHOST);
/* is it a ip address or host */
- if (inet_aton(cmdparams->av[0], &scandata->ip) > 0) {
- scandata->dnsstate = DO_OPM_LOOKUP;
- } else {
- scandata->dnsstate = DO_DNS_HOST_LOOKUP;
+ if (inet_aton(cmdparams->av[0], &scandata->ip) <= 0) {
scandata->ip.s_addr = 0;
}
+ if (dns_lookup(scandata->lookup, adns_r_a, dnsblscan, (void *)scandata) != 1) {
+ nlog (LOG_WARNING, "DNS: startscan() DO_DNS_HOST_LOOKUP dns_lookup() failed");
+ ns_free(scandata);
+ return 0;
+ }
+ return 0;
}
irc_prefmsg (opsb_bot, cmdparams->source, "Checking %s for open Proxies", cmdparams->av[0]);
if (!startscan(scandata))
@@ -323,30 +278,27 @@
static bot_cmd opsb_commands[]=
{
- {"STATUS", opsb_cmd_status, 0, NS_ULEVEL_OPER, opsb_help_status, opsb_help_status_oneline},
- {"LOOKUP", opsb_cmd_lookup, 1, NS_ULEVEL_OPER, opsb_help_lookup, opsb_help_lookup_oneline},
- {"REMOVE", opsb_cmd_remove, 1, NS_ULEVEL_OPER, opsb_help_remove, opsb_help_remove_oneline},
+ {"STATUS", opsb_cmd_status, 0, NS_ULEVEL_OPER, opsb_help_status, opsb_help_status_oneline},
+ {"REMOVE", opsb_cmd_remove, 1, NS_ULEVEL_OPER, opsb_help_remove, opsb_help_remove_oneline},
{"CHECK", opsb_cmd_check, 1, NS_ULEVEL_OPER, opsb_help_check, opsb_help_check_oneline},
- {"PORTS", opsb_cmd_ports, 1, NS_ULEVEL_ADMIN,opsb_help_ports, opsb_help_ports_oneline},
- {NULL, NULL, 0, 0, NULL, NULL}
+ {"PORTS", opsb_cmd_ports, 1, NS_ULEVEL_ADMIN, opsb_help_ports, opsb_help_ports_oneline},
+ {NULL, NULL, 0, 0, NULL, NULL}
};
static bot_setting opsb_settings[]=
{
- {"SCAN", &opsb.doscan, SET_TYPE_BOOLEAN, 0, 0, NS_ULEVEL_ADMIN, NULL, opsb_help_set_doscan, do_set_cb, (void*)1 },
- {"TARGETIP", &opsb.targetip, SET_TYPE_IPV4, 0, 0, NS_ULEVEL_ADMIN, NULL, opsb_help_set_targetip, do_set_cb },
- {"TARGETPORT", &opsb.targetport, SET_TYPE_INT, 0, 65535, NS_ULEVEL_ADMIN, NULL, opsb_help_set_targetport, do_set_cb },
- {"OPMDOMAIN", &opsb.opmdomain, SET_TYPE_HOST, 0, MAXHOST, NS_ULEVEL_ADMIN, NULL, opsb_help_set_opmdomain, do_set_cb, (void*)"opm.blitzed.org" },
- {"AKILL", &opsb.doakill, SET_TYPE_BOOLEAN, 0, 0, NS_ULEVEL_ADMIN, NULL, opsb_help_set_akill, do_set_cb, (void*)1 },
- {"AKILLTIME", &opsb.akilltime, SET_TYPE_INT, 0, 20736000, NS_ULEVEL_ADMIN, NULL, opsb_help_set_akilltime, do_set_cb, (void*)86400 },
- {"MAXBYTES", &opsb.maxbytes, SET_TYPE_INT, 0, 100000, NS_ULEVEL_ADMIN, NULL, opsb_help_set_maxbytes, do_set_cb, (void*)500 },
- {"TIMEOUT", &opsb.timeout, SET_TYPE_INT, 0, 120, NS_ULEVEL_ADMIN, NULL, opsb_help_set_timeout, do_set_cb, (void*)30 },
- {"OPENSTRING", &opsb.openstring, SET_TYPE_MSG, 0, BUFSIZE, NS_ULEVEL_ADMIN, NULL, opsb_help_set_openstring, do_set_cb, (void*)"*** Looking up your hostname..." },
- {"SCANMSG", &opsb.scanmsg, SET_TYPE_MSG, 0, BUFSIZE, NS_ULEVEL_ADMIN, NULL, opsb_help_set_scanmsg, do_set_cb, (void*)"Your Host is being Scanned for Open Proxies" },
- {"CACHETIME", &opsb.cachetime, SET_TYPE_INT, 0, 86400, NS_ULEVEL_ADMIN, NULL, opsb_help_set_cachetime, do_set_cb, (void*)3600 },
- {"VERBOSE", &opsb.verbose, SET_TYPE_BOOLEAN, 0, 0, NS_ULEVEL_ADMIN, NULL, opsb_help_set_verbose, do_set_cb, (void*)1 },
- {"EXCLUSIONS", &opsb.exclusions, SET_TYPE_BOOLEAN, 0, 0, NS_ULEVEL_ADMIN,NULL, opsb_help_set_exclusions, opsb_set_exclusions_cb, (void *)0 },
- {NULL, NULL, 0, 0, 0, 0, NULL, NULL, NULL },
+ {"TARGETIP", &opsb.targetip, SET_TYPE_IPV4, 0, 0, NS_ULEVEL_ADMIN, NULL, opsb_help_set_targetip, do_set_cb },
+ {"TARGETPORT", &opsb.targetport, SET_TYPE_INT, 0, 65535, NS_ULEVEL_ADMIN, NULL, opsb_help_set_targetport, do_set_cb },
+ {"AKILL", &opsb.doakill, SET_TYPE_BOOLEAN, 0, 0, NS_ULEVEL_ADMIN, NULL, opsb_help_set_akill, do_set_cb, (void*)1 },
+ {"AKILLTIME", &opsb.akilltime, SET_TYPE_INT, 0, 20736000,NS_ULEVEL_ADMIN, NULL, opsb_help_set_akilltime, do_set_cb, (void*)86400 },
+ {"MAXBYTES", &opsb.maxbytes, SET_TYPE_INT, 0, 100000, NS_ULEVEL_ADMIN, NULL, opsb_help_set_maxbytes, do_set_cb, (void*)500 },
+ {"TIMEOUT", &opsb.timeout, SET_TYPE_INT, 0, 120, NS_ULEVEL_ADMIN, NULL, opsb_help_set_timeout, do_set_cb, (void*)30 },
+ {"OPENSTRING", &opsb.openstring, SET_TYPE_MSG, 0, BUFSIZE, NS_ULEVEL_ADMIN, NULL, opsb_help_set_openstring, do_set_cb, (void*)"*** Looking up your hostname..." },
+ {"SCANMSG", &opsb.scanmsg, SET_TYPE_MSG, 0, BUFSIZE, NS_ULEVEL_ADMIN, NULL, opsb_help_set_scanmsg, do_set_cb, (void*)"Your Host is being Scanned for Open Proxies" },
+ {"CACHETIME", &opsb.cachetime, SET_TYPE_INT, 0, 86400, NS_ULEVEL_ADMIN, NULL, opsb_help_set_cachetime, do_set_cb, (void*)3600 },
+ {"VERBOSE", &opsb.verbose, SET_TYPE_BOOLEAN, 0, 0, NS_ULEVEL_ADMIN, NULL, opsb_help_set_verbose, do_set_cb, (void*)1 },
+ {"EXCLUSIONS", &opsb.exclusions, SET_TYPE_BOOLEAN, 0, 0, NS_ULEVEL_ADMIN, NULL, opsb_help_set_exclusions, opsb_set_exclusions_cb, (void *)0 },
+ {NULL, NULL, 0, 0, 0, 0, NULL, NULL, NULL },
};
/** BotInfo */
@@ -381,11 +333,7 @@
strlcpy(opsb.targetip, me.uplink, MAXHOST);
}
if(opsb.verbose) {
- if (opsb.doscan) {
- irc_chanalert (opsb_bot, "Open Proxy Scanning bot has started (Concurrent Scans: %d Sockets %d)", opsb.socks, opsb.socks *7);
- } else {
- irc_chanalert (opsb_bot, "DNS Blacklist Lookup is only Enabled!! (No Open Proxy Scans)");
- }
+ irc_chanalert (opsb_bot, "Open Proxy Scanning bot has started (Concurrent Scans: %d Sockets %d)", opsb.socks, opsb.socks *7);
}
return NS_SUCCESS;
};
@@ -538,7 +486,6 @@
strlcpy(scandata->server, cmdparams->source->uplink->name, MAXHOST);
/*strlcpy(scandata->connectstring, recbuf, BUFSIZE);*/
scandata->ip.s_addr = cmdparams->source->ip.s_addr;
- scandata->dnsstate = DO_OPM_LOOKUP;
if (!startscan(scandata)) {
irc_chanalert (opsb_bot, "Warning Can't scan %s", cmdparams->source->name);
nlog (LOG_WARNING, "OBSB ss_event_signon(): Can't scan %s. Check logs for possible errors", cmdparams->source->name);
@@ -551,223 +498,92 @@
int startscan(scaninfo *scandata)
{
- unsigned char a, b, c, d;
- char *buf;
- int buflen;
int i;
SET_SEGV_LOCATION();
/* only check the cache when we have IP addy */
- if (scandata->dnsstate == DO_OPM_LOOKUP) {
+ if (scandata->ip.s_addr > 0) {
+ printf("check cache\n");
i = checkcache(scandata);
if ((i > 0) && (scandata->reqclient == NULL)) {
ns_free(scandata);
return 1;
}
}
- switch(scandata->dnsstate) {
- case DO_DNS_HOST_LOOKUP:
- if (list_isfull(opsbl)) {
- 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->reqclient) irc_prefmsg (opsb_bot, scandata->reqclient, "To Busy. Try again later");
- ns_free(scandata);
- return 0;
- }
- lnode_create_append(opsbq, scandata);
- dlog (DEBUG1, "DNS: Added %s to dns queue", scandata->who);
- 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) {
- nlog (LOG_WARNING, "DNS: startscan() DO_DNS_HOST_LOOKUP dns_lookup() failed");
- ns_free(scandata);
- checkqueue();
- return 0;
- }
-
- lnode_create_append(opsbl, scandata);
- dlog (DEBUG1, "DNS: Added getnickip to DNS active list");
- return 1;
- break;
- case DO_OPM_LOOKUP:
- 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->reqclient) irc_prefmsg (opsb_bot, scandata->reqclient, "Too Busy. Try again Later");
- ns_free(scandata);
- return 0;
- }
- lnode_create_append(opsbq, scandata);
- dlog (DEBUG1, "DNS: Added OPM lookup to queue: %s", scandata->who);
- return 1;
- }
- d = (unsigned char) (scandata->ip.s_addr >> 24) & 0xFF;
- c = (unsigned char) (scandata->ip.s_addr >> 16) & 0xFF;
- b = (unsigned char) (scandata->ip.s_addr >> 8) & 0xFF;
- a = (unsigned char) scandata->ip.s_addr & 0xFF;
-
- /* Enough for a reversed IP and the zone. */
- buflen = 18 + strlen(opsb.opmdomain);
- buf = malloc(buflen * sizeof(*buf));
-
- ircsnprintf(buf, buflen, "%d.%d.%d.%d.%s", d, c, b, a, opsb.opmdomain);
- if (dns_lookup(buf, adns_r_a, dnsblscan, scandata->who) != 1) {
- nlog (LOG_WARNING, "DNS: startscan() DO_OPM_LOOKUP dns_lookup() failed");
- ns_free(scandata);
- ns_free(buf);
- checkqueue();
- return 0;
- }
- lnode_create_append(opsbl, scandata);
- dlog (DEBUG1, "DNS: Added OPM %s lookup to DNS active list", buf);
- ns_free(buf);
- start_proxy_scan(scandata);
- ++opsb.scanned;
- return 1;
- break;
- default:
- nlog (LOG_WARNING, "Warning, Unknown Status in startscan()");
- ns_free(scandata);
- return -1;
+ if (list_isfull(opsbl)) {
+ 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->reqclient) irc_prefmsg (opsb_bot, scandata->reqclient, "To Busy. Try again later");
+ ns_free(scandata);
+ return 0;
+ }
+ lnode_create_append(opsbq, scandata);
+ dlog (DEBUG1, "OPSB: Added %s to dns queue", scandata->who);
+ if (scandata->reqclient) irc_prefmsg (opsb_bot, scandata->reqclient, "Your Request has been added to the Queue");
+ return 1;
+ }
+ start_proxy_scan(scandata);
+#if 0
+ if (dns_lookup(scandata->lookup, adns_r_a, dnsblscan, scandata) != 1) {
+ nlog (LOG_WARNING, "OPSB: startscan() DO_DNS_HOST_LOOKUP dns_lookup() failed");
+ ns_free(scandata);
+ checkqueue();
+ return 0;
}
+#endif
+ lnode_create_append(opsbl, scandata);
+ dlog (DEBUG1, "OPSB: Added %s to Scan active list", scandata->who);
+ return 1;
}
/* this function is called when either checking the opm list, or when we are trying to resolve the hostname */
-void dnsblscan(char *data, adns_answer *a)
+void dnsblscan(void *data, adns_answer *a)
{
- lnode_t *scannode;
- scaninfo *scandata;
+ scaninfo *scandata = (scaninfo *)data;
char *show;
int len, ri;
SET_SEGV_LOCATION();
- scannode = list_find(opsbl, data, findscan);
- if (!scannode) {
- nlog (LOG_CRITICAL, "dnsblscan(): Ehhh, Something is wrong here - Can't find %s", data);
- return;
- }
- scandata = lnode_get(scannode);
if (a) {
- switch(scandata->dnsstate) {
- case DO_DNS_HOST_LOOKUP:
- if (a->nrrs < 1) {
- irc_chanalert (opsb_bot, "No 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);
- ns_free(scandata);
- checkqueue();
- break;
- }
- adns_rr_info(a->type, 0, 0, &len, 0, 0);
- ri = adns_rr_info(a->type, 0, 0, 0, a->rrs.bytes, &show);
- if (!ri) {
- 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->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;
- list_delete(opsbl, scannode);
- lnode_destroy(scannode);
- startscan(scandata);
- } else {
- nlog (LOG_CRITICAL, "DNS: dnsblscan() GETNICKIP failed-> %s", show);
- irc_chanalert (opsb_bot, "Warning, Couldn't get the address for %s", scandata->who);
- list_delete(opsbl, scannode);
- lnode_destroy(scannode);
- ns_free(scandata);
- checkqueue();
- }
-
- } else {
- nlog (LOG_CRITICAL, "DNS: dnsblscan GETNICKIP rr_info failed");
- irc_chanalert (opsb_bot, "Warning, Couldnt get the address for %s. rr_info failed", scandata->who);
- list_delete(opsbl, scannode);
- lnode_destroy(scannode);
- ns_free(scandata);
- checkqueue();
- }
- ns_free(show);
- break;
- case DO_OPM_LOOKUP:
- if (a->nrrs > 0) {
- /* TODO: print out what type of open proxy it is based on IP address returned */
- nlog (LOG_NOTICE, "Got Positive OPM lookup for %s (%s)", scandata->who, scandata->lookup);
- scandata->dnsstate = OPMLIST;
- 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->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.akilltime, "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->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;
- }
- check_scan_free(scandata);
- break;
- default:
- nlog (LOG_WARNING, "Warning, Unknown Status in dnsblscan()");
- list_delete(opsbl, scannode);
- lnode_destroy(scannode);
- ns_free(scandata);
- return;
+ if (a->nrrs < 1) {
+ irc_chanalert (opsb_bot, "No 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);
+ ns_free(scandata);
+ checkqueue();
+ return;
}
- return;
- } else {
- nlog (LOG_CRITICAL, "OPSP() Answer is Empty!");
- list_delete(opsbl, scannode);
- lnode_destroy(scannode);
- ns_free(scandata);
- }
-}
-
-/* this function is to send the results to the user after a lookup command */
-
-void reportdns(char *data, adns_answer *a) {
- lnode_t *dnslookup;
- scaninfo *dnsinfo;
- char *show;
- int i, len, ri;
-
- SET_SEGV_LOCATION();
-
- dnslookup = list_find(opsbl, data, findscan);
- if (!dnslookup) {
- nlog (LOG_CRITICAL, "reportdns(): Ehhh, something wrong here %s", data);
- return;
- }
- dnsinfo = lnode_get(dnslookup);
- if (a) {
adns_rr_info(a->type, 0, 0, &len, 0, 0);
- for(i = 0; i < a->nrrs; i++) {
- ri = adns_rr_info(a->type, 0, 0, 0, a->rrs.bytes +i*len, &show);
- if (!ri) {
- irc_prefmsg (opsb_bot, FindUser (data), "%s resolves to %s", dnsinfo->lookup, show);
+ ri = adns_rr_info(a->type, 0, 0, 0, a->rrs.bytes, &show);
+ if (!ri) {
+ dlog (DEBUG1, "OPSB: 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->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) {
+ startscan(scandata);
} else {
- irc_prefmsg (opsb_bot, FindUser (data), "DNS error %s", adns_strerror(ri));
+ nlog (LOG_CRITICAL, "OPSB: dnsblscan() GETNICKIP failed-> %s", show);
+ irc_chanalert (opsb_bot, "Warning, Couldn't get the address for %s", scandata->who);
+ ns_free(scandata);
+ checkqueue();
}
- ns_free(show);
- }
- if (a->nrrs < 1) {
- irc_prefmsg (opsb_bot, FindUser (data), "%s Does not resolve", dnsinfo->lookup);
+ } else {
+ nlog (LOG_CRITICAL, "OPSB: dnsblscan GETNICKIP rr_info failed");
+ irc_chanalert (opsb_bot, "Warning, Couldnt get the address for %s. rr_info failed", scandata->who);
+ ns_free(scandata);
+ checkqueue();
}
+ ns_free(show);
+ return;
} else {
- irc_prefmsg (opsb_bot, FindUser (data), "An unknown error occured");
- }
-
- list_delete(opsbl, dnslookup);
- lnode_destroy(dnslookup);
- ns_free(dnsinfo);
- checkqueue();
+ nlog (LOG_CRITICAL, "OPSP() Answer is Empty!");
+ ns_free(scandata);
+ }
}
int ModInit( void )
@@ -818,4 +634,4 @@
{
return 0;
}
-#endif
\ No newline at end of file
+#endif
Modified: branches/3.0/opsb.h
==============================================================================
--- branches/3.0/opsb.h (original)
+++ branches/3.0/opsb.h Sun Apr 3 21:46:49 2005
@@ -51,7 +51,6 @@
typedef struct scaninfo{
char who[MAXHOST];
int state;
- int dnsstate;
char lookup[MAXHOST];
char server[MAXHOST];
struct in_addr ip;
@@ -106,13 +105,13 @@
/* these are some state flags */
#define REPORT_DNS 0x0001
-#define DO_DNS_HOST_LOOKUP 0x0002
-#define DO_OPM_LOOKUP 0x0004
+#define DO_DNS_HOST_LOOKUP 0x0002
+/* #define DO_OPM_LOOKUP 0x0004 */
#define DOING_SCAN 0x0008
#define GOTOPENPROXY 0x0010
#define OPMLIST 0x0020
-#define NOOPMLIST 0x0040
-#define FIN_SCAN 0x0080
+#define NOOPMLIST 0x0040
+#define FIN_SCAN 0x0080
/* opsb.c */
Modified: branches/3.0/proxy.c
==============================================================================
--- branches/3.0/proxy.c (original)
+++ branches/3.0/proxy.c Sun Apr 3 21:46:49 2005
@@ -31,23 +31,33 @@
#include <arpa/nameser.h>
#endif
#include "opsb.h"
-#include "opm.h"
-#include "opm_types.h"
-#include "opm_error.h"
int proxy_connect(unsigned long ip, int port, char *who);
+#if 0
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);
void scan_end(OPM_T *scanner, OPM_REMOTE_T *remote, int notused, void *unused);
void scan_error(OPM_T *scanner, OPM_REMOTE_T *remote, int opmerr, void *unused);
+#endif
#ifndef MSG_NOSIGNAL
#define MSG_NOSIGNAL 0
#endif
+
+typedef struct conninfo {
+ int type;
+ int port;
+ scaninfo *scandata;
+ int status;
+};
-
-OPM_T *scanner;
+#define PTYPE_HTTP 0
+#define PTYPE_SOCKS4 1
+#define PTYPE_SOCKS5 2
+#define PTYPE_WINGATE 3
+#define PTYPE_ROUTER 4
+#define PTYPE_HTTPPOST 5
char *defaultports[] = {
"80 8080 8000 3128",
@@ -59,12 +69,12 @@
};
proxy_type proxy_list[] = {
- { OPM_TYPE_HTTP, "HTTP" },
- { OPM_TYPE_SOCKS4, "SOCKS4" },
- { OPM_TYPE_SOCKS5, "SOCKS5" },
- { OPM_TYPE_WINGATE, "WINGATE" },
- { OPM_TYPE_ROUTER, "ROUTER"},
- { OPM_TYPE_HTTPPOST, "HTTPPOST" },
+ { PTYPE_HTTP, "HTTP" },
+ { PTYPE_SOCKS4, "SOCKS4" },
+ { PTYPE_SOCKS5, "SOCKS5" },
+ { PTYPE_WINGATE, "WINGATE" },
+ { PTYPE_ROUTER, "ROUTER"},
+ { PTYPE_HTTPPOST, "HTTPPOST" },
{ 0, "" }
};
@@ -80,9 +90,6 @@
}
return 0;
}
-void add_port(int type, int port) {
- opm_addtype(scanner, type, port);
-}
void save_ports()
{
@@ -158,147 +165,88 @@
}
int init_libopm() {
- lnode_t *pn;
- port_list *pl;
-
- scanner = opm_create();
- /* setup the callbacks to our code */
- opm_callback(scanner, OPM_CALLBACK_OPENPROXY, &open_proxy, NULL);
- opm_callback(scanner, OPM_CALLBACK_NEGFAIL, &negfailed, NULL);
- opm_callback(scanner, OPM_CALLBACK_TIMEOUT, &timeout, NULL);
- opm_callback(scanner, OPM_CALLBACK_END, &scan_end, NULL);
- opm_callback(scanner, OPM_CALLBACK_ERROR, &scan_error, NULL);
-
- /* max number of socks we allow */
- opm_config(scanner, OPM_CONFIG_FD_LIMIT, &opsb.socks);
- /* host to try to connect to */
- opm_config(scanner, OPM_CONFIG_SCAN_IP, opsb.targetip);
- /* port to try to connect to */
- opm_config(scanner, OPM_CONFIG_SCAN_PORT, &opsb.targetport);
- /* string to look for */
- opm_config(scanner, OPM_CONFIG_TARGET_STRING, opsb.openstring);
- /* also look for throttle messages */
- opm_config(scanner, OPM_CONFIG_TARGET_STRING, "ERROR :Trying to reconnect too fast");
- /* timeout */
- opm_config(scanner, OPM_CONFIG_TIMEOUT, &opsb.timeout);
- /* max bytes read */
- opm_config(scanner, OPM_CONFIG_MAX_READ, &opsb.maxbytes);
-
-
-
- /* read the proxy types directly from keeper :) */
- pn = list_first(opsb.ports);
- while (pn) {
- pl = lnode_get(pn);
- opm_addtype(scanner, pl->type, pl->port);
- pn = list_next(opsb.ports, pn);
- }
-
-
- /* add the sock poll interface into neo */
- add_sockpoll("opsb", scanner, libopm_before_poll, libopm_after_poll);
-
- return 1;
+ return NS_SUCCESS;
}
-void open_proxy(OPM_T *scanner, OPM_REMOTE_T *remote, int notused, void *unused)
- {
-#if 0
- FILE *fp;
-#endif
- scaninfo *scandata;
+void start_proxy_scan(scaninfo *scandata)
+{
+ int i;
SET_SEGV_LOCATION();
- scandata = remote->data;
-
- if (scandata->doneban == 1)
- return;
-
- ++opsb.open;
+ 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);
- 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->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.doakill)
- irc_akill (opsb_bot, remote->ip, "*", opsb.akilltime, "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;
- fprintf(fp, "%d:%s:%s\n", remote->protocol, remote->ip, "empty");
- fclose(fp);
-#endif
- /* no point continuing the scan if they are found open */
- scandata->state = GOTOPENPROXY;
- opm_end(scanner, remote);
-
+ if ((opsb.doscan == 1) || (scandata->reqclient)) {
-#if 0
- if (scandata->dnsstate == OPMLIST) {
- scandata->doneban = 1;
- 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->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.akilltime, "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));
- }
+ remote = opm_remote_create(inet_ntoa(scandata->ip));
+ remote->data = scandata;
+ switch(i = opm_scan(scanner, remote))
+ {
+ case OPM_SUCCESS:
+ dlog (DEBUG2, "Starting Scan on %s", inet_ntoa(scandata->ip));
+ break;
+ case OPM_ERR_BADADDR:
+ 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);
+ }
+ }
#endif
}
-
-void negfailed(OPM_T *scanner, OPM_REMOTE_T *remote, int notused, void *unused) {
- scaninfo *scandata;
-
- SET_SEGV_LOCATION();
-
- scandata = remote->data;
-
- if (scandata->reqclient) {
- irc_prefmsg (opsb_bot, scandata->reqclient, "Negitiation failed for protocol %s(%d)", type_of_proxy(remote->protocol), remote->port);
+void check_scan_free(scaninfo *scandata) {
+ lnode_t *scannode;
+ if (scandata->state == DOING_SCAN) {
+ dlog (DEBUG2, "Not Cleaning up Scaninfo for %s yet. Scan hasn't completed", scandata->who);
+ return;
}
-}
-
-void timeout(OPM_T *scanner, OPM_REMOTE_T *remote, int notused, void *unused) {
- scaninfo *scandata;
-
- SET_SEGV_LOCATION();
-
- scandata = remote->data;
- if (scandata->reqclient) {
- irc_prefmsg (opsb_bot, scandata->reqclient, "Timeout on Protocol %s(%d)", type_of_proxy(remote->protocol), remote->port);
+ if (scandata->state != GOTOPENPROXY) {
+ 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) {
+ dlog (DEBUG1, "%s scan finished. Cleaning up", scandata->who);
+ list_delete(opsbl, scannode);
+ lnode_destroy(scannode);
+ scandata->reqclient = NULL;
+ ns_free(scandata);
+ } else {
+ nlog (LOG_WARNING, "Damn, Can't find ScanNode %s. Something is fubar", scandata->who);
+ }
+ checkqueue();
}
-void scan_end(OPM_T *scanner, OPM_REMOTE_T *remote, int notused, void *unused) {
- scaninfo *scandata;
- SET_SEGV_LOCATION();
- scandata = remote->data;
- 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;
- check_scan_free(scandata);
-}
-
-void scan_error(OPM_T *scanner, OPM_REMOTE_T *remote, int opmerr, void *unused) {
- scaninfo *scandata;
+void open_proxy(conninfo *connection)
+ {
+ scaninfo *scandata = connection->scandata;
SET_SEGV_LOCATION();
- scandata = remote->data;
- if (scandata->reqclient) {
- if (opmerr == 5) {
- 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->reqclient, "scan error on Protocol %s (%d) - %d", type_of_proxy(remote->protocol), remote->port, opmerr);
- }
- }
-}
+ if (scandata->doneban == 1)
+ return;
+ ++opsb.open;
+ nlog (LOG_CRITICAL, "OPSB: Banning %s (%s) for Open Proxy - %s(%d)", scandata->who, scandata->ip, type_of_proxy(connection->type), connection->port);
+ irc_chanalert (opsb_bot, "Banning %s (%s) for Open Proxy - %s(%d)", scandata->who, scandata->ip, type_of_proxy(connection->type), connection->port);
+ irc_globops (opsb_bot, "Banning %s (%s) for Open Proxy - %s(%d)", scandata->who, scandata->ip, type_of_proxy(connection->type), connection->port);
+ if (scandata->reqclient) irc_prefmsg (opsb_bot, scandata->reqclient, "Banning %s (%s) for Open Proxy - %s(%d)", scandata->who, scandata->ip, type_of_proxy(connection->type), connection->port);
+ if (opsb.doakill)
+ irc_akill (opsb_bot, remote->ip, "*", opsb.akilltime, "Open Proxy found on your host. %s(%d)", type_of_proxy(connection->type), connection->port);
+
+ /* no point continuing the scan if they are found open */
+ scandata->state = GOTOPENPROXY;
+ /* XXX end scan */
+
+}
int opsb_cmd_status (CmdParams* cmdparams)
{
@@ -326,25 +274,6 @@
else
irc_prefmsg (opsb_bot, cmdparams->source, "Scanning %s (%s) - %s", scandata->lookup, inet_ntoa(scandata->ip), scandata->who);
- switch(scandata->dnsstate) {
- case REPORT_DNS:
- irc_prefmsg (opsb_bot, cmdparams->source, "Looking up IP Address");
- break;
- case DO_DNS_HOST_LOOKUP:
- irc_prefmsg (opsb_bot, cmdparams->source, "Looking up IP address for Scan");
- break;
- case DO_OPM_LOOKUP:
- irc_prefmsg (opsb_bot, cmdparams->source, "Looking up DNS blacklist");
- break;
- case OPMLIST:
- irc_prefmsg (opsb_bot, cmdparams->source, "Host is listed in %s", opsb.opmdomain);
- break;
- case NOOPMLIST:
- irc_prefmsg (opsb_bot, cmdparams->source, "Host is Not listed in %s", opsb.opmdomain);
- break;
- default:
- irc_prefmsg (opsb_bot, cmdparams->source, "Unknown State (DNS)");
- }
switch(scandata->state) {
case DOING_SCAN:
irc_prefmsg (opsb_bot, cmdparams->source, "Scanning for Open Proxies");
@@ -361,60 +290,3 @@
}
-void start_proxy_scan(scaninfo *scandata)
-{
- OPM_REMOTE_T *remote;
- int i;
-
- SET_SEGV_LOCATION();
- /* if we are configured not to scan, and its not a request, bail out */
- if ((opsb.doscan == 0) && (!scandata->reqclient)) {
- scandata->state = FIN_SCAN;
- check_scan_free(scandata);
- return;
- }
-
- 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->reqclient)) {
- remote = opm_remote_create(inet_ntoa(scandata->ip));
- remote->data = scandata;
- switch(i = opm_scan(scanner, remote))
- {
- case OPM_SUCCESS:
- dlog (DEBUG2, "Starting Scan on %s", inet_ntoa(scandata->ip));
- break;
- case OPM_ERR_BADADDR:
- 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);
- }
- }
-
-}
-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)) {
- 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->ip.s_addr);
- dlog (DEBUG1, "%s's Host is clean. Adding to Cache", scandata->who);
- }
- scannode = list_find(opsbl, scandata->who, findscan);
- if (scannode) {
- dlog (DEBUG1, "%s scan finished. Cleaning up", scandata->who);
- list_delete(opsbl, scannode);
- lnode_destroy(scannode);
- scandata->reqclient = NULL;
- ns_free(scandata);
- } else {
- nlog (LOG_WARNING, "Damn, Can't find ScanNode %s. Something is fubar", scandata->who);
- }
- checkqueue();
-}
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.