diff --git a/.gitattributes b/.gitattributes index 251020b..1c5a8c3 100644 --- a/.gitattributes +++ b/.gitattributes @@ -14,8 +14,4 @@ /modconfig.h.in -text /modconfigwin32.h -text /opsb.Settings -text -/opsb.c -text -/opsb.h -text /opsb.vcproj -text -/opsb_help.c -text -/proxy.c -text diff --git a/ChangeLog b/ChangeLog index 0a9b76e..320e9ff 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,8 @@ Open Proxy Scanning Bot Module for NeoStats Changelog. ============================================================================== 3.0.a3-dev - Mark (M) & Fish (F) + - AKILL support and open proxy reporting (F) + - Get default targetip when starting up correctly (F) - Simplify command path. (M) - Fix event and command return values. (M) - Clean up config.h entries. (M) @@ -90,4 +92,4 @@ Open Proxy Scanning Bot Module for NeoStats Changelog. - added to exclusion list who added the exclusion, and the reason * Version 1.0Beta1 * 31/8/2002 * Fish -- Initial Release \ No newline at end of file +- Initial Release diff --git a/opsb.c b/opsb.c index 19082c4..c4be57a 100644 --- a/opsb.c +++ b/opsb.c @@ -86,7 +86,7 @@ static bot_cmd opsb_commands[]= static bot_setting opsb_settings[]= { - {"TARGETIP", opsb.targetip, SET_TYPE_IPV4, 0, MAXHOST,NS_ULEVEL_ADMIN, NULL, opsb_help_set_targetip, opsb_set_cb, (void*)"10.1.1.24" }, + {"TARGETIP", opsb.targetip, SET_TYPE_IPV4, 0, MAXHOST,NS_ULEVEL_ADMIN, NULL, opsb_help_set_targetip, opsb_set_cb, (void*)0 }, {"TARGETPORT", &opsb.targetport, SET_TYPE_INT, 0, 65535, NS_ULEVEL_ADMIN, NULL, opsb_help_set_targetport, opsb_set_cb, (void*)6667 }, {"AKILL", &opsb.doakill, SET_TYPE_BOOLEAN, 0, 0, NS_ULEVEL_ADMIN, NULL, opsb_help_set_akill, opsb_set_cb, (void*)1 }, {"AKILLTIME", &opsb.akilltime, SET_TYPE_INT, 0, 20736000,NS_ULEVEL_ADMIN, NULL, opsb_help_set_akilltime, opsb_set_cb, (void*)TS_ONE_DAY }, @@ -98,6 +98,7 @@ static bot_setting opsb_settings[]= {"CACHESIZE", &opsb.cachesize, SET_TYPE_INT, 0, 10000, NS_ULEVEL_ADMIN, NULL, opsb_help_set_cachesize, opsb_set_cb, (void*)1000 }, {"VERBOSE", &opsb.verbose, SET_TYPE_BOOLEAN, 0, 0, NS_ULEVEL_ADMIN, NULL, opsb_help_set_verbose, opsb_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 }, + {"DOREPORT", &opsb.doreport, SET_TYPE_BOOLEAN, 0, 0, NS_ULEVEL_ADMIN, NULL, opsb_help_set_doreport, opsb_set_cb, (void *)1}, {NULL, NULL, 0, 0, 0, 0, NULL, NULL, NULL }, }; @@ -745,13 +746,6 @@ int ModInit( void ) nlog (LOG_WARNING, "Can't Load opsb. No Ports Defined for Scanner. Did you install Correctly?"); return NS_FAILURE; } - /* XXX needs work */ - if (strlen(opsb.targetip) <= 0) { - strlcpy(opsb.targetip, me.uplink, MAXHOST); - } - if (init_scanengine() != NS_SUCCESS) { - return NS_FAILURE; - } return NS_SUCCESS; } @@ -767,6 +761,12 @@ int ModInit( void ) int ModSynch (void) { SET_SEGV_LOCATION(); + if (strlen(opsb.targetip) <= 0) { + strlcpy(opsb.targetip, inet_ntoa(me.srvip.sin_addr), MAXHOST); + } + if (init_scanengine() != NS_SUCCESS) { + return NS_FAILURE; + } opsb_bot = AddBot (&opsb_botinfo); if (opsb.confed == 0) { AddTimer (TIMER_TYPE_INTERVAL, unconf, "unconf", TS_ONE_MINUTE); @@ -789,5 +789,5 @@ int ModSynch (void) int ModFini( void ) { - return NS_SUCCESS; + return NS_SUCCESS; } diff --git a/opsb.h b/opsb.h index ac4cf98..d6fa12a 100644 --- a/opsb.h +++ b/opsb.h @@ -71,6 +71,7 @@ struct opsb { int cachesize; int cachehits; int doakill; + int doreport; int verbose; int exclusions; list_t *ports; @@ -144,5 +145,5 @@ extern const char *opsb_help_set_cachetime []; extern const char *opsb_help_set_verbose []; extern const char *opsb_help_set_exclusions[]; extern const char *opsb_help_set_cachesize[]; - +extern const char *opsb_help_set_doreport[]; #endif /* OPSB_H */ diff --git a/opsb_help.c b/opsb_help.c index 15b2752..8febd07 100644 --- a/opsb_help.c +++ b/opsb_help.c @@ -175,3 +175,9 @@ const char *opsb_help_set_exclusions[] = { "Use global exclusion list in addition to local exclusion list", NULL }; +const char *opsb_help_set_doreport[] = { + "Enable Open Proxy Reporting", + "\2DOREPORT \2", + "Enable OPSB reporting of Open Proxies back to Secure.irc-chat.net", + NULL +}; diff --git a/proxy.c b/proxy.c index 551ccae..199f0ee 100644 --- a/proxy.c +++ b/proxy.c @@ -269,7 +269,7 @@ int init_scanengine( void ) if (inet_aton(opsb.targetip, &addr) != 0) { laddr = htonl(addr.s_addr); } else { - nlog(LOG_ERROR, "Couldn't Setup connect address for init_scan_engine"); + nlog(LOG_ERROR, "Couldn't Setup connect address for init_scan_engine: %s", opsb.targetip); return NS_FAILURE; } /* taken from libopm */ @@ -588,7 +588,9 @@ void check_scan_free(scaninfo *scandata) { void open_proxy(conninfo *connection) { scaninfo *scandata = connection->scandata; - + Client *u; + char buf[1400]; + SET_SEGV_LOCATION(); if (scandata->doneban == 1) @@ -599,11 +601,16 @@ void open_proxy(conninfo *connection) irc_chanalert (opsb_bot, "Banning %s (%s) for Open Proxy - %s(%d)", scandata->who, scandata->lookup, type_of_proxy(connection->type), connection->port); irc_globops (opsb_bot, "Banning %s (%s) for Open Proxy - %s(%d)", scandata->who, scandata->lookup, 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->lookup, type_of_proxy(connection->type), connection->port); -#if 0 + u = FindUser(scandata->who); + if (u) + irc_prefmsg(opsb_bot, u, "An %s open proxy was found on port %d from your host. Please see http://secure.irc-chat.net/op.php?f=opsb&t=%d&p=%d&ip=%s", type_of_proxy(connection->type), connection->port, connection->type, connection->port, inet_ntoa(scandata->ip)); if (opsb.doakill) - /* XXX IP */ - irc_akill (opsb_bot, "", "*", opsb.akilltime, "Open Proxy found on your host. %s(%d)", type_of_proxy(connection->type), connection->port); -#endif + irc_akill (opsb_bot, inet_ntoa(scandata->ip), "*", opsb.akilltime, "An %s open proxy was found on port %d from your host. Please see http://secure.irc-chat.net/op.php?f=opsb&t=%d&p=%d&ip=%s", type_of_proxy(connection->type), connection->port, connection->type, connection->port, inet_ntoa(scandata->ip)); + if (opsb.doreport) { + /* type\nport\nip\nnetwork\n */ + ircsnprintf(buf, 1400, "%d\n%d\n%s\n%s\n", connection->type, connection->port, inet_ntoa(scandata->ip), me.name); + sendtoMQ(UPDATE_OPSBREPORT, buf, strlen(buf)); + } /* no point continuing the scan if they are found open */ scandata->state = GOTOPENPROXY; /* XXX end scan */