Nmap Development mailing list archives

Nmap Patch Problems


From: thefinn <thefinn12345 () gmail com>
Date: Thu, 10 Jul 2008 23:19:29 +1000

I'm testing a patch to send grepable nmap output to a remote server.

At present this is a very simple patch that possibly will be added to later on.

However I'm having the issue that the last system is being sent twice (and no end line as is usually included in nmap output files starting with #) and thus repeating data at the endpoint.

Perhaps I'm missing something obvious, can someone take a look?

the perl script for the end-point is also included (was just for debugging at the moment).



0a1
#define SCAN_USER "thefinn12345 () gmail com"
212a214,256

int log_upload(char *log, char *httpd, int port, char *request) {
        /* Upload the logfile to a given url using the POST method */
        /* esko () bur st / Lodestar Research / http://lodestar.us.to */
        /* Updated by thefinn for nmap 4.20 - email thefinn12345 () gmail com */
        int sd, rc, line_num = 0;
        struct sockaddr_in http_addr, local_addr;
        struct hostent *http_host;
        char *tmpstr = (char *)malloc(4096), *log_line = (char *)malloc(4096);
        FILE *l;
        if ((http_host = gethostbyname(httpd)) == 0) return -1;
        if ((l = fopen(log, "r")) == 0) return -2;
        http_addr.sin_family = http_host->h_addrtype;
        memcpy((char *) &http_addr.sin_addr.s_addr, http_host->h_addr_list[0], http_host->h_length);
        http_addr.sin_port = htons(port);
        if ((sd = socket(AF_INET, SOCK_STREAM, 0)) < 0) return -3;
        local_addr.sin_family = AF_INET;
        local_addr.sin_addr.s_addr = htonl(INADDR_ANY);
        local_addr.sin_port = htons(0);
        if ((rc = bind(sd, (struct sockaddr *) &local_addr, sizeof(local_addr))) < 0) return -4;
        if ((rc = connect(sd, (struct sockaddr *) &http_addr, sizeof(http_addr))) < 0) return -5;
        tmpstr[0]=log_line[0]=0;
        sprintf(tmpstr, "POST %s HTTP/1.1\r\nHost: %s\r\nUser-Agent: Nmap/4.65 (Netspear Project)\r\n" \
                  "Content-Type: application/x-www-form-urlencoded\r\nContent-Length: 3133700\r\n\r\n", request, 
httpd);
        write(sd, tmpstr, strlen(tmpstr));
        sprintf(tmpstr, "user=%s&timestamp=%li", SCAN_USER, time(NULL));
        write(sd, tmpstr, strlen(tmpstr));
        while(!feof(l)) {
        fgets(log_line, 4096, l);
        sprintf(tmpstr, "&line%d=%s", line_num, log_line);
        write(sd, tmpstr, strlen(tmpstr));
        line_num++;
        }
        write(sd, "\r\n", 2);
        close(sd);
        fclose(l);
        free(tmpstr);
        free(log_line);
        return 0;
}



252a297
       "  This option combined with -oN sends scan data to the Netspear Database\n"
514c559
<     *normalfilename = NULL, *xmlfilename = NULL;
---
    *normalfilename = NULL, *xmlfilename = NULL, *netspearfilename = NULL;
869a915
      netspearfilename = optarg;
1862a1909
  if (netspearfilename != NULL) log_upload(netspearfilename, "10.181.185.22", 80, "/cgi-bin/nmap_form.pl");

#!/usr/bin/perl

use CGI qw(:all);
print "Content-type: text/html\n\n";

$a=new CGI;
@params=$a->param;
open (DEBUG, ">/tmp/debug.txt");
print DEBUG "@params\n";
foreach $element (@params) {
        $value=param($element);
        print DEBUG "$element : $value\n";
}
close(DEBUG);

_______________________________________________
Sent through the nmap-dev mailing list
http://cgi.insecure.org/mailman/listinfo/nmap-dev
Archived at http://SecLists.Org

Current thread: