static void dns_tcl_iporhostres(sockname_t *ip, char *hostn, int ok, void *other) { devent_tclinfo_t *tclinfo = (devent_tclinfo_t *) other; Tcl_DString list; Tcl_DStringInit(&list); Tcl_DStringAppendElement(&list, tclinfo->proc); Tcl_DStringAppendElement(&list, iptostr(&ip->addr.sa)); Tcl_DStringAppendElement(&list, hostn); Tcl_DStringAppendElement(&list, ok ? "1" : "0"); if (tclinfo->paras) { EGG_CONST char *argv[2]; char *output; argv[0] = Tcl_DStringValue(&list); argv[1] = tclinfo->paras; output = Tcl_Concat(2, argv); if (Tcl_Eval(interp, output) == TCL_ERROR) { putlog(LOG_MISC, "*", DCC_TCLERROR, tclinfo->proc, tcl_resultstring()); Tcl_BackgroundError(interp); } Tcl_Free(output); } else if (Tcl_Eval(interp, Tcl_DStringValue(&list)) == TCL_ERROR) { putlog(LOG_MISC, "*", DCC_TCLERROR, tclinfo->proc, tcl_resultstring()); Tcl_BackgroundError(interp); } Tcl_DStringFree(&list); nfree(tclinfo->proc); if (tclinfo->paras) nfree(tclinfo->paras); nfree(tclinfo); }
/* Dump status info out to dcc */ void tell_verbose_status(int idx) { char s[256], s1[121], s2[81]; char *vers_t, *uni_t; int i; time_t now2 = now - online_since, hr, min; float cputime; #ifdef HAVE_UNAME struct utsname un; if (uname(&un) < 0) { #endif vers_t = " "; uni_t = "*unknown*"; #ifdef HAVE_UNAME } else { vers_t = un.release; uni_t = un.sysname; } #endif i = count_users(userlist); dprintf(idx, "I am %s, running %s: %d user%s (mem: %uk).\n", botnetnick, ver, i, i == 1 ? "" : "s", (int) (expected_memory() / 1024)); s[0] = 0; if (now2 > 86400) { /* days */ sprintf(s, "%d day", (int) (now2 / 86400)); if ((int) (now2 / 86400) >= 2) strcat(s, "s"); strcat(s, ", "); now2 -= (((int) (now2 / 86400)) * 86400); } hr = (time_t) ((int) now2 / 3600); now2 -= (hr * 3600); min = (time_t) ((int) now2 / 60); sprintf(&s[strlen(s)], "%02d:%02d", (int) hr, (int) min); s1[0] = 0; if (backgrd) strcpy(s1, MISC_BACKGROUND); else { if (term_z) strcpy(s1, MISC_TERMMODE); else if (con_chan) strcpy(s1, MISC_STATMODE); else strcpy(s1, MISC_LOGMODE); } cputime = getcputime(); if (cputime < 0) sprintf(s2, "CPU: unknown"); else { hr = cputime / 60; cputime -= hr * 60; sprintf(s2, "CPU: %02d:%05.2f", (int) hr, cputime); /* Actally min/sec */ } dprintf(idx, "%s %s (%s) - %s - %s: %4.1f%%\n", MISC_ONLINEFOR, s, s1, s2, MISC_CACHEHIT, 100.0 * ((float) cache_hit) / ((float) (cache_hit + cache_miss))); dprintf(idx, "Configured with: " EGG_AC_ARGS "\n"); if (admin[0]) dprintf(idx, "Admin: %s\n", admin); dprintf(idx, "Config file: %s\n", configfile); dprintf(idx, "OS: %s %s\n", uni_t, vers_t); dprintf(idx, "Process ID: %d (parent %d)\n", getpid(), getppid()); /* info library */ dprintf(idx, "%s %s\n", MISC_TCLLIBRARY, ((interp) && (Tcl_Eval(interp, "info library") == TCL_OK)) ? tcl_resultstring() : "*unknown*"); /* info tclversion/patchlevel */ dprintf(idx, "%s %s (%s %s)\n", MISC_TCLVERSION, ((interp) && (Tcl_Eval(interp, "info patchlevel") == TCL_OK)) ? tcl_resultstring() : (Tcl_Eval(interp, "info tclversion") == TCL_OK) ? tcl_resultstring() : "*unknown*", MISC_TCLHVERSION, TCL_PATCH_LEVEL ? TCL_PATCH_LEVEL : "*unknown*"); if (tcl_threaded()) dprintf(idx, "Tcl is threaded.\n"); #ifdef TLS dprintf(idx, "TLS support is enabled.\n"); dprintf(idx, "TLS library: %s\n", SSLeay_version(SSLEAY_VERSION)); #else dprintf(idx, "TLS support is not available.\n"); #endif #ifdef IPV6 dprintf(idx, "IPv6 support is enabled.\n"); #else dprintf(idx, "IPv6 support is not available.\n"); #endif dprintf(idx, "Socket table: %d/%d\n", threaddata()->MAXSOCKS, max_socks); }
static void write_debug() { int x; char s[25]; int y; if (nested_debug) { /* Yoicks, if we have this there's serious trouble! * All of these are pretty reliable, so we'll try these. * * NOTE: dont try and display context-notes in here, it's * _not_ safe <cybah> */ x = creat("DEBUG.DEBUG", 0644); setsock(x, SOCK_NONSOCK); if (x >= 0) { strncpyz(s, ctime(&now), sizeof s); dprintf(-x, "Debug (%s) written %s\n", ver, s); dprintf(-x, "Please report problem to [email protected]\n"); dprintf(-x, "after a visit to http://www.eggheads.org/bugzilla/\n"); dprintf(-x, "Full Patch List: %s\n", egg_xtra); dprintf(-x, "Context: "); cx_ptr = cx_ptr & 15; for (y = ((cx_ptr + 1) & 15); y != cx_ptr; y = ((y + 1) & 15)) dprintf(-x, "%s/%d,\n ", cx_file[y], cx_line[y]); dprintf(-x, "%s/%d\n\n", cx_file[y], cx_line[y]); killsock(x); close(x); } bg_send_quit(BG_ABORT); exit(1); /* Dont even try & tell people about, that may * have caused the fault last time. */ } else nested_debug = 1; putlog(LOG_MISC, "*", "* Last context: %s/%d [%s]", cx_file[cx_ptr], cx_line[cx_ptr], cx_note[cx_ptr][0] ? cx_note[cx_ptr] : ""); putlog(LOG_MISC, "*", "* Please REPORT this BUG!"); putlog(LOG_MISC, "*", "* Check doc/BUG-REPORT on how to do so."); x = creat("DEBUG", 0644); setsock(x, SOCK_NONSOCK); if (x < 0) { putlog(LOG_MISC, "*", "* Failed to write DEBUG"); } else { strncpyz(s, ctime(&now), sizeof s); dprintf(-x, "Debug (%s) written %s\n", ver, s); dprintf(-x, "Full Patch List: %s\n", egg_xtra); #ifdef STATIC dprintf(-x, "STATICALLY LINKED\n"); #endif /* info library */ dprintf(-x, "Tcl library: %s\n", ((interp) && (Tcl_Eval(interp, "info library") == TCL_OK)) ? tcl_resultstring() : "*unknown*"); /* info tclversion/patchlevel */ dprintf(-x, "Tcl version: %s (header version %s)\n", ((interp) && (Tcl_Eval(interp, "info patchlevel") == TCL_OK)) ? tcl_resultstring() : (Tcl_Eval(interp, "info tclversion") == TCL_OK) ? tcl_resultstring() : "*unknown*", TCL_PATCH_LEVEL ? TCL_PATCH_LEVEL : "*unknown*"); if (tcl_threaded()) dprintf(-x, "Tcl is threaded\n"); #ifdef IPV6 dprintf(-x, "Compiled with IPv6 support\n"); #else dprintf(-x, "Compiled without IPv6 support\n"); #endif #ifdef TLS dprintf(-x, "Compiled with TLS support\n"); #else dprintf(-x, "Compiled without TLS support\n"); #endif dprintf(-x, "Configure flags: %s\n", EGG_AC_ARGS); #ifdef CCFLAGS dprintf(-x, "Compile flags: %s\n", CCFLAGS); #endif #ifdef LDFLAGS dprintf(-x, "Link flags: %s\n", LDFLAGS); #endif #ifdef STRIPFLAGS dprintf(-x, "Strip flags: %s\n", STRIPFLAGS); #endif dprintf(-x, "Context: "); cx_ptr = cx_ptr & 15; for (y = ((cx_ptr + 1) & 15); y != cx_ptr; y = ((y + 1) & 15)) dprintf(-x, "%s/%d, [%s]\n ", cx_file[y], cx_line[y], (cx_note[y][0]) ? cx_note[y] : ""); dprintf(-x, "%s/%d [%s]\n\n", cx_file[cx_ptr], cx_line[cx_ptr], (cx_note[cx_ptr][0]) ? cx_note[cx_ptr] : ""); tell_dcc(-x); dprintf(-x, "\n"); debug_mem_to_dcc(-x); killsock(x); close(x); putlog(LOG_MISC, "*", "* Wrote DEBUG"); } }
/* Dump status info out to dcc */ void tell_verbose_status(int idx) { char s[256], s1[121], s2[81]; char *vers_t, *uni_t; int i; time_t now2 = now - online_since, hr, min; #ifdef HAVE_GETRUSAGE struct rusage ru; #else # ifdef HAVE_CLOCK clock_t cl; # endif #endif #ifdef HAVE_UNAME struct utsname un; if (!uname(&un) < 0) { #endif vers_t = " "; uni_t = "*unknown*"; #ifdef HAVE_UNAME } else { vers_t = un.release; uni_t = un.sysname; } #endif i = count_users(userlist); dprintf(idx, "I am %s, running %s: %d user%s (mem: %uk).\n", botnetnick, ver, i, i == 1 ? "" : "s", (int) (expected_memory() / 1024)); #ifdef IPV6 dprintf(idx, "Unofficial IPv6 patch for v1.6.21 based on the v1.6.18 IPv6 patch \n"); #endif s[0] = 0; if (now2 > 86400) { /* days */ sprintf(s, "%d day", (int) (now2 / 86400)); if ((int) (now2 / 86400) >= 2) strcat(s, "s"); strcat(s, ", "); now2 -= (((int) (now2 / 86400)) * 86400); } hr = (time_t) ((int) now2 / 3600); now2 -= (hr * 3600); min = (time_t) ((int) now2 / 60); sprintf(&s[strlen(s)], "%02d:%02d", (int) hr, (int) min); s1[0] = 0; if (backgrd) strcpy(s1, MISC_BACKGROUND); else { if (term_z) strcpy(s1, MISC_TERMMODE); else if (con_chan) strcpy(s1, MISC_STATMODE); else strcpy(s1, MISC_LOGMODE); } #ifdef HAVE_GETRUSAGE getrusage(RUSAGE_SELF, &ru); hr = (int) ((ru.ru_utime.tv_sec + ru.ru_stime.tv_sec) / 60); min = (int) ((ru.ru_utime.tv_sec + ru.ru_stime.tv_sec) - (hr * 60)); sprintf(s2, "CPU: %02d:%02d", (int) hr, (int) min); /* Actally min/sec */ #else # ifdef HAVE_CLOCK cl = (clock() / CLOCKS_PER_SEC); hr = (int) (cl / 60); min = (int) (cl - (hr * 60)); sprintf(s2, "CPU: %02d:%02d", (int) hr, (int) min); /* Actually min/sec */ # else sprintf(s2, "CPU: unknown"); # endif #endif dprintf(idx, "%s %s (%s) - %s - %s: %4.1f%%\n", MISC_ONLINEFOR, s, s1, s2, MISC_CACHEHIT, 100.0 * ((float) cache_hit) / ((float) (cache_hit + cache_miss))); dprintf(idx, "Configured with: " EGG_AC_ARGS "\n"); if (admin[0]) dprintf(idx, "Admin: %s\n", admin); dprintf(idx, "Config file: %s\n", configfile); dprintf(idx, "OS: %s %s\n", uni_t, vers_t); /* info library */ dprintf(idx, "%s %s\n", MISC_TCLLIBRARY, ((interp) && (Tcl_Eval(interp, "info library") == TCL_OK)) ? tcl_resultstring() : "*unknown*"); /* info tclversion/patchlevel */ dprintf(idx, "%s %s (%s %s)\n", MISC_TCLVERSION, ((interp) && (Tcl_Eval(interp, "info patchlevel") == TCL_OK)) ? tcl_resultstring() : (Tcl_Eval(interp, "info tclversion") == TCL_OK) ? tcl_resultstring() : "*unknown*", MISC_TCLHVERSION, TCL_PATCH_LEVEL ? TCL_PATCH_LEVEL : "*unknown*"); if (tcl_threaded()) dprintf(idx, "Tcl is threaded.\n"); dprintf(idx, "Socket table: %d/%d\n", threaddata()->MAXSOCKS, max_socks); }