[gopher] Capability files are dangerous
Kim Holviala
kim at holviala.com
Mon May 14 16:30:13 UTC 2012
On May 14, 2012, at 19:27 , Kim Holviala wrote:
> And related to the above; I can determine with 100% reliability all of the existing gopher servers. Got code too to prove it.
Still one more before I go see teh ladies.
/*
* Figure out gopher server software
*/
char *get_gopherd(char *host, int port)
{
static char result[128];
char page[BUFSIZE];
char *c;
/* Try fingerprinting hURL reply */
if (tcp_request(host, port, "URL:http://www.google.com/" CRLF,
page, sizeof(page)) == ERROR) return NA;
if (strstr(page, "pygopherd")) return "PyGopherd";
if (strstr(page, "bucktooth")) return "Bucktooth";
if (strstr(page, "Gophernicus")) return "Gophernicus";
if (strstr(page, "GopherBlock")) return "GopherBlock";
if (strstr(page, "You'll be redirected")) return "mgod";
if (strstr(page, "This page is for redirecting you")) return "Geomyidae";
if (strstr(page, "It appears that you clicked on a")) return "Grumpy";
if (strstr(page, "refresh\" content=\"0;URL=") &&
!strstr(page, "</HTML>")) return "Gophserv";
if (sstrncmp(page, "3Server error: Sorry, access denied") == MATCH &&
strstr(page, "\terror.host")) return "GN";
/* Synchronet? */
if (page[0] == '.') {
if (tcp_request(host, port, "ver" CRLF,
page, sizeof(page)) == ERROR) return NA;
if (strstr(page, "Synchronet")) return "Synchronet";
}
/* VenVen */
if (page[0] == '\0') {
if (tcp_request(host, port, CRLF,
page, sizeof(page)) == ERROR) return NA;
if (strstr(page, "0./") || strstr(page, "1./")) return "VenVen";
}
/* Do one more detection test */
if (tcp_request(host, port, "lkjsdflkjsadlflksjdflkjasdfklj" CRLF,
page, sizeof(page)) == ERROR) return NA;
if (strstr(page, "no handler found")) return "PyGopherd";
if (strstr(page, "[pselect]")) return "GN";
if (strstr(page, "<html") || strstr(page, "<HTML")) return "g2httpd";
/* Try /server-status */
if (tcp_request(host, port, "/server-status" CRLF,
page, sizeof(page)) == ERROR) return NA;
if ((c = strstr(page, "Server: "))) {
sstrlcpy(result, c + 8);
if ((c = strchr(result, '/'))) *c = '\0';
if ((c = strchr(result, '('))) *c = '\0';
return result;
}
/* Damn */
return "Unknown";
}
More information about the Gopher-Project
mailing list