try to issolate the OPSB open_proxy crash
This commit is contained in:
parent
4279ef08e3
commit
8ebc6523d8
2 changed files with 56 additions and 5 deletions
24
opsb.c
24
opsb.c
|
@ -163,6 +163,8 @@ static int ports_sort( const void *key1, const void *key2 )
|
|||
port_list *pl1 = (port_list *)key1;
|
||||
port_list *pl2 = (port_list *)key2;
|
||||
|
||||
SET_SEGV_LOCATION();
|
||||
|
||||
if (pl1->type == pl2->type)
|
||||
{
|
||||
if (pl1->port == pl2->port)
|
||||
|
@ -188,6 +190,8 @@ static int ports_sort( const void *key1, const void *key2 )
|
|||
|
||||
int opsb_cmd_remove( const CmdParams *cmdparams )
|
||||
{
|
||||
SET_SEGV_LOCATION();
|
||||
|
||||
irc_rakill (opsb_bot, cmdparams->av[0], "*");
|
||||
irc_chanalert (opsb_bot, "%s attempted to remove an akill for *@%s", cmdparams->source->name, cmdparams->av[0]);
|
||||
return NS_SUCCESS;
|
||||
|
@ -207,6 +211,8 @@ int opsb_cmd_check( const CmdParams *cmdparams )
|
|||
Client *scanuser;
|
||||
scaninfo *scandata;
|
||||
|
||||
SET_SEGV_LOCATION();
|
||||
|
||||
if ((list_find(opsbl, cmdparams->av[0], findscan)) || (list_find(opsbq, cmdparams->av[0], findscan))) {
|
||||
irc_prefmsg (opsb_bot, cmdparams->source, "Already Scanning (or in queue) %s. Not Scanning again", cmdparams->av[0]);
|
||||
return NS_SUCCESS;
|
||||
|
@ -269,6 +275,8 @@ int opsb_cmd_list (const CmdParams *cmdparams)
|
|||
int i;
|
||||
lnode_t *lnode;
|
||||
|
||||
SET_SEGV_LOCATION();
|
||||
|
||||
lnode = list_first(opsb.ports);
|
||||
i = 1;
|
||||
irc_prefmsg (opsb_bot, cmdparams->source, "Port List:");
|
||||
|
@ -297,6 +305,8 @@ int opsb_cmd_add (const CmdParams *cmdparams)
|
|||
port_list *pl;
|
||||
lnode_t *lnode;
|
||||
|
||||
SET_SEGV_LOCATION();
|
||||
|
||||
if (list_isfull(opsb.ports)) {
|
||||
irc_prefmsg (opsb_bot, cmdparams->source, "Error, Ports list is full");
|
||||
return NS_SUCCESS;
|
||||
|
@ -347,6 +357,8 @@ int opsb_cmd_del (const CmdParams *cmdparams)
|
|||
int i;
|
||||
lnode_t *lnode;
|
||||
|
||||
SET_SEGV_LOCATION();
|
||||
|
||||
if (atoi(cmdparams->av[0]) != 0) {
|
||||
lnode = list_first(opsb.ports);
|
||||
i = 1;
|
||||
|
@ -389,6 +401,9 @@ int opsb_cmd_del (const CmdParams *cmdparams)
|
|||
|
||||
int opsb_set_cb( const CmdParams *cmdparams, SET_REASON reason )
|
||||
{
|
||||
|
||||
SET_SEGV_LOCATION();
|
||||
|
||||
if( reason == SET_CHANGE )
|
||||
{
|
||||
opsb.confed = 1;
|
||||
|
@ -411,6 +426,8 @@ int opsb_set_cb( const CmdParams *cmdparams, SET_REASON reason )
|
|||
|
||||
int opsb_set_target_cb( const CmdParams *cmdparams, SET_REASON reason )
|
||||
{
|
||||
SET_SEGV_LOCATION();
|
||||
|
||||
if( reason == SET_CHANGE )
|
||||
{
|
||||
(void)opsb_set_cb( cmdparams, reason );
|
||||
|
@ -432,6 +449,8 @@ int opsb_set_target_cb( const CmdParams *cmdparams, SET_REASON reason )
|
|||
|
||||
static int opsb_set_exclusions_cb( const CmdParams *cmdparams, SET_REASON reason )
|
||||
{
|
||||
SET_SEGV_LOCATION();
|
||||
|
||||
if( reason == SET_LOAD || reason == SET_CHANGE )
|
||||
{
|
||||
SetAllEventFlags( EVENT_FLAG_USE_EXCLUDE, opsb.exclusions );
|
||||
|
@ -450,6 +469,8 @@ static int opsb_set_exclusions_cb( const CmdParams *cmdparams, SET_REASON reason
|
|||
|
||||
static int unconf(void *userptr)
|
||||
{
|
||||
SET_SEGV_LOCATION();
|
||||
|
||||
if (opsb.confed != 1)
|
||||
{
|
||||
irc_chanalert (opsb_bot, "Warning, OPSB is configured with default Settings. Please Update this ASAP");
|
||||
|
@ -752,6 +773,9 @@ static void dns_callback(void *data, adns_answer *a)
|
|||
|
||||
int ModInit( void )
|
||||
{
|
||||
|
||||
SET_SEGV_LOCATION();
|
||||
|
||||
DBAFetchConfigInt ("Confed", &opsb.confed);
|
||||
ModuleConfig (opsb_settings);
|
||||
/* we have to be careful here. Currently, we have SCAN_SOCKET_COUNT sockets that get opened per connection. Soooo.
|
||||
|
|
37
proxy.c
37
proxy.c
|
@ -164,6 +164,7 @@ static void report_positive (const Client *u, const conninfo *connection)
|
|||
int32 *port;
|
||||
MByteBuffer **NeoVer;
|
||||
|
||||
SET_SEGV_LOCATION();
|
||||
|
||||
if (opsb.doreport) {
|
||||
/* get our template message */
|
||||
|
@ -213,13 +214,15 @@ static void open_proxy(const conninfo *connection)
|
|||
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);
|
||||
u = FindUser(scandata->who);
|
||||
if (u)
|
||||
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)
|
||||
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));
|
||||
#ifndef WIN32
|
||||
report_positive(u, connection);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (opsb.doakill)
|
||||
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));
|
||||
/* no point continuing the scan if they are found open */
|
||||
scandata->state = GOTOPENPROXY;
|
||||
/* XXX end scan */
|
||||
|
@ -241,11 +244,13 @@ static int proxy_read( void *data, void *recv, int size )
|
|||
scaninfo *si = ci->scandata;
|
||||
lnode_t *connode;
|
||||
int i;
|
||||
|
||||
SET_SEGV_LOCATION();
|
||||
|
||||
/* XXX delete CI */
|
||||
switch (size) {
|
||||
case -1: /* connect refused */
|
||||
case -2: /* timeout */
|
||||
/* XXX Close */
|
||||
connode = list_find(si->connections, ci, findconn);
|
||||
if (connode) {
|
||||
list_delete(si->connections, connode);
|
||||
|
@ -324,6 +329,8 @@ void save_ports( void )
|
|||
static char tmpports[512];
|
||||
int lasttype = -1;
|
||||
|
||||
SET_SEGV_LOCATION();
|
||||
|
||||
pn = list_first(opsb.ports);
|
||||
while (pn) {
|
||||
pl = lnode_get(pn);
|
||||
|
@ -359,6 +366,8 @@ static void load_port(int type, const char *portname)
|
|||
unsigned int j, ac;
|
||||
port_list *prtlst;
|
||||
|
||||
SET_SEGV_LOCATION();
|
||||
|
||||
strlcpy (portlist, portname, 512);
|
||||
ac = split_buf(portlist, &av);
|
||||
for (j = 0; j < ac; j++) {
|
||||
|
@ -395,6 +404,8 @@ int load_ports( void )
|
|||
int i;
|
||||
int ok = 0;
|
||||
|
||||
SET_SEGV_LOCATION();
|
||||
|
||||
for (i = 0; proxy_list[i].type != 0; i++) {
|
||||
if (DBAFetchConfigStr (proxy_list[i].name, portname, 512) != NS_SUCCESS) {
|
||||
nlog (LOG_WARNING, "Warning, no ports defined for protocol %s, using defaults", proxy_list[i].name);
|
||||
|
@ -423,6 +434,8 @@ int init_scanengine( void )
|
|||
struct in_addr addr;
|
||||
unsigned long laddr;
|
||||
|
||||
SET_SEGV_LOCATION();
|
||||
|
||||
/* set up our send buffers */
|
||||
http_send_buf_len = ircsnprintf(http_send_buf, BUFSIZE, "CONNECT %s:%d HTTP/1.0\r\n\r\nquit\r\n\r\n", opsb.targetip, opsb.targetport);
|
||||
httppost_send_buf_len = ircsnprintf(httppost_send_buf, BUFSIZE, "POST http://%s:%d/ HTTP/1.0\r\nContent-type: text/plain\r\nContent-length: 5\r\n\r\nquit\r\n\r\n", opsb.targetip, opsb.targetport);
|
||||
|
@ -523,6 +536,9 @@ static int http_send(int fd, void *data)
|
|||
{
|
||||
conninfo *ci = (conninfo *)data;
|
||||
struct timeval tv;
|
||||
|
||||
SET_SEGV_LOCATION();
|
||||
|
||||
if (send_to_sock(ci->sock, http_send_buf, http_send_buf_len) != NS_FAILURE) {
|
||||
/* our timeout */
|
||||
tv.tv_sec = opsb.timeout;
|
||||
|
@ -545,7 +561,9 @@ static int sock4_send(int fd, void *data)
|
|||
{
|
||||
conninfo *ci = (conninfo *)data;
|
||||
struct timeval tv;
|
||||
|
||||
|
||||
SET_SEGV_LOCATION();
|
||||
|
||||
if (send_to_sock(ci->sock, socks4_send_buf, socks4_send_buf_len) != NS_FAILURE) {
|
||||
/* our timeout */
|
||||
tv.tv_sec = opsb.timeout;
|
||||
|
@ -569,6 +587,8 @@ static int sock5_send(int fd, void *data)
|
|||
conninfo *ci = (conninfo *)data;
|
||||
struct timeval tv;
|
||||
|
||||
SET_SEGV_LOCATION();
|
||||
|
||||
if (send_to_sock(ci->sock, socks5_send_buf, socks5_send_buf_len) != NS_FAILURE) {
|
||||
/* our timeout */
|
||||
tv.tv_sec = opsb.timeout;
|
||||
|
@ -592,6 +612,8 @@ static int wingate_send(int fd, void *data)
|
|||
conninfo *ci = (conninfo *)data;
|
||||
struct timeval tv;
|
||||
|
||||
SET_SEGV_LOCATION();
|
||||
|
||||
if (send_to_sock(ci->sock, wingate_send_buf, wingate_send_buf_len) != NS_FAILURE) {
|
||||
/* our timeout */
|
||||
tv.tv_sec = opsb.timeout;
|
||||
|
@ -615,6 +637,8 @@ static int router_send(int fd, void *data)
|
|||
conninfo *ci = (conninfo *)data;
|
||||
struct timeval tv;
|
||||
|
||||
SET_SEGV_LOCATION();
|
||||
|
||||
if (send_to_sock(ci->sock, wingate_send_buf, wingate_send_buf_len) != NS_FAILURE) {
|
||||
/* our timeout */
|
||||
tv.tv_sec = opsb.timeout;
|
||||
|
@ -637,6 +661,9 @@ static int httppost_send(int fd, void *data)
|
|||
{
|
||||
conninfo *ci = (conninfo *)data;
|
||||
struct timeval tv;
|
||||
|
||||
SET_SEGV_LOCATION();
|
||||
|
||||
if (send_to_sock(ci->sock, httppost_send_buf, httppost_send_buf_len) != NS_FAILURE) {
|
||||
/* our timeout */
|
||||
tv.tv_sec = opsb.timeout;
|
||||
|
|
Reference in a new issue