/* Default scan types */
proxyscan_addscantype(STYPE_HTTP, 8080);
+ proxyscan_addscantype(STYPE_HTTP, 8118);
proxyscan_addscantype(STYPE_HTTP, 80);
proxyscan_addscantype(STYPE_HTTP, 6588);
proxyscan_addscantype(STYPE_HTTP, 8000);
proxyscan_addscantype(STYPE_DIRECT_IRC, 6668);
proxyscan_addscantype(STYPE_DIRECT_IRC, 6669);
proxyscan_addscantype(STYPE_DIRECT_IRC, 6670);
+ proxyscan_addscantype(STYPE_ROUTER, 3128);
/* Schedule saves */
schedulerecurring(time(NULL)+3600,0,3600,&dumpcachehosts,NULL);
int i;
cachehost *chp;
foundproxy *fpp;
+ time_t now;
scansdone++;
scansbyclass[sp->class]++;
fpp->next=chp->proxies;
chp->proxies=fpp;
}
-
- if (!chp->glineid) {
+
+ now=time(NULL);
+ /* the purpose of this lastgline stuff is to stop gline spam from one scan */
+ if (!chp->glineid || (now>=chp->lastgline+SCANTIMEOUT)) {
+ chp->lastgline=now;
glinedhosts++;
- loggline(chp, sp->node);
+ loggline(chp, sp->node);
irc_send("%s GL * +*@%s 1800 %jd :Open Proxy, see http://www.quakenet.org/openproxies.html - ID: %d",
mynumeric->content,IPtostr(((patricia_node_t *)sp->node)->prefix->sin),(intmax_t)getnettime(), chp->glineid);
Error("proxyscan",ERR_DEBUG,"Found open proxy on host %s",IPtostr(((patricia_node_t *)sp->node)->prefix->sin));
}
}
+ /* deref prefix (referenced in queuescan) */
+ derefnode(iptree,sp->node);
freescan(sp);
/* kick the queue.. */
return;
}
+ /* Do nothing */
+ break;
+
+ case STYPE_ROUTER:
+ sprintf(buf,"GET /nonexistent HTTP/1.0\r\n\r\n");
+ if ((write(fd,buf,strlen(buf)))<strlen(buf)) {
+ killsock(sp, SOUTCOME_CLOSED);
+ return;
+ }
+
/* Do nothing */
break;
}
char *magicstring;
int magicstringlength;
- if(sp->type != STYPE_DIRECT_IRC) {
- magicstring = MAGICSTRING;
- magicstringlength = MAGICSTRINGLENGTH;
- } else {
+ if(sp->type == STYPE_DIRECT_IRC) {
magicstring = MAGICIRCSTRING;
magicstringlength = MAGICIRCSTRINGLENGTH;
+ } else if(sp->type == STYPE_ROUTER) {
+ magicstring = MAGICROUTERSTRING;
+ magicstringlength = MAGICROUTERSTRINGLENGTH;
+ } else {
+ magicstring = MAGICSTRING;
+ magicstringlength = MAGICSTRINGLENGTH;
}
for (i=0;i<sp->bytesread - magicstringlength;i++) {
return CMD_OK;
}
+void startnickscan(nick *np) {
+ time_t t = time(NULL);
+ int i;
+ for(i=0;i<numscans;i++) {
+ /* @@@TODO: we allow a forced scan to scan the same IP multiple times atm */
+ queuescan(np->ipnode,thescans[i].type,thescans[i].port,SCLASS_NORMAL,t);
+ }
+}
+
int proxyscandoscan(void *sender, int cargc, char **cargv) {
nick *np = (nick *)sender;
patricia_node_t *node;
if (0 == ipmask_parse(cargv[0],&sin, &bits)) {
sendnoticetouser(proxyscannick,np,"Usage: scan <ip>");
} else {
+ if (bits != 128 || !irc_in_addr_is_ipv4(&sin) || irc_in_addr_is_loopback(&sin)) {
+ sendnoticetouser(proxyscannick,np,"You may only scan single IPv4 IP's");
+ return CMD_OK;
+ }
+
+ time_t t;
sendnoticetouser(proxyscannick,np,"Forcing scan of %s",IPtostr(sin));
// * Just queue the scans directly here.. plonk them on the priority queue * /
node = refnode(iptree, &sin, bits); /* node leaks node here - should only allow to scan a nick? */
+ t = time(NULL);
for(i=0;i<numscans;i++) {
/* @@@TODO: we allow a forced scan to scan the same IP multiple times atm */
- queuescan(node,thescans[i].type,thescans[i].port,SCLASS_NORMAL,time(NULL));
+ queuescan(node,thescans[i].type,thescans[i].port,SCLASS_NORMAL,t);
}
}
return CMD_OK;