Commit 8005c628 authored by Robert David Graham's avatar Robert David Graham
Browse files

ntp monlist

parent 7997a4ef
Loading
Loading
Loading
Loading
+18 −2
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@
#include "templ-payloads.h"
#include "templ-port.h"
#include "crypto-base64.h"
#include "script.h"

#include <ctype.h>
#include <limits.h>
@@ -1207,8 +1208,23 @@ masscan_set_parameter(struct Masscan *masscan,
        while (*p && (p[strlen(p)-1] == '/' || p[strlen(p)-1] == '/'))
            p[strlen(p)-1] = '\0';
    } else if (EQUALS("script", name)) {
        fprintf(stderr, "nmap(%s): unsupported, it's too complex for this simple scanner\n", name);
        if (!script_lookup(value)) {
            fprintf(stderr, "FAIL: script '%s' does not exist\n", value);
            fprintf(stderr, "  hint: most nmap scripts aren't supported\n");
            fprintf(stderr, "  hint: use '--script list' to list available scripts\n");
            exit(1);
        }
        if (masscan->script.name != NULL) {
            if (strcmp(masscan->script.name, value) == 0)
                return; /* ok */
            else {
                fprintf(stderr, "FAIL: only one script supported at a time\n");
                fprintf(stderr, "  hint: '%s' is existing script, '%s' is new script\n",
                        masscan->script.name, value);
                exit(1);
            }
            masscan->script.name = script_lookup(value)->name;
        }
    } else if (EQUALS("scan-delay", name) || EQUALS("max-scan-delay", name)) {
        fprintf(stderr, "nmap(%s): unsupported: we do timing VASTLY differently!\n", name);
        exit(1);
+23 −0
Original line number Diff line number Diff line
@@ -42,6 +42,7 @@
#include "pixie-threads.h"      /* portable threads */
#include "templ-payloads.h"     /* UDP packet payloads */
#include "proto-snmp.h"         /* parse SNMP responses */
#include "proto-ntp.h"          /* parse NTP responses */
#include "templ-port.h"
#include "in-binary.h"          /* covert binary output to XML/JSON */
#include "main-globals.h"       /* all the global variables in the program */
@@ -51,6 +52,7 @@
#include "crypto-base64.h"      /* base64 encode/decode */
#include "pixie-backtrace.h"
#include "proto-sctp.h"
#include "script.h"

#include <assert.h>
#include <limits.h>
@@ -1003,9 +1005,28 @@ main_scan(struct Masscan *masscan)
    time_t now = time(0);
    struct Status status;
    uint64_t min_index = UINT64_MAX;
    struct MassScript *script = NULL;

    memset(parms_array, 0, sizeof(parms_array));

    /*
     * Script initialization
     */
    if (masscan->script.name) {
        unsigned i;
        script = script_lookup(masscan->script.name);
        
        /* If no ports specified on command-line, grab default ports */
        if (rangelist_count(&masscan->ports) == 0)
            rangelist_parse_ports(&masscan->ports, script->ports, 0);
        
        /* Kludge: change normal port range to script range */
        for (i=0; i<masscan->ports.count; i++) {
            struct Range *r = &masscan->ports.list[i];
            r->begin = (r->begin&0xFFFF) | Templ_Script;
        }
    }
    
    /*
     * Initialize the task size
     */
@@ -1105,6 +1126,7 @@ main_scan(struct Masscan *masscan)
         * scanning. Then, we adjust the template with additional features,
         * such as the IP address and so on.
         */
        parms->tmplset->script = script;
        template_packet_init(
                    parms->tmplset,
                    parms->adapter_mac,
@@ -1499,6 +1521,7 @@ int main(int argc, char *argv[])
            x += banner1_selftest();
            x += output_selftest();
            x += siphash24_selftest();
            x += ntp_selftest();
            x += snmp_selftest();
            x += payloads_selftest();
            x += blackrock_selftest();
+1 −1
Original line number Diff line number Diff line
@@ -27,7 +27,7 @@ masscan_app_to_string(enum ApplicationProtocol proto)
    case PROTO_X509_CERT: return "X509";
    case PROTO_HTML_TITLE: return "title";
    case PROTO_HTML_FULL: return "html";

    case PROTO_NTP:     return "ntp";
    default:
        sprintf_s(tmp, sizeof(tmp), "(%u)", proto);
        return tmp;
+7 −2
Original line number Diff line number Diff line
#ifndef MASSCAN_APP_H
#define MASSCAN_APP_H

/*
 * WARNING: these constants are used in files, so don't change the values.
 * Add new ones onto the end
 */
enum ApplicationProtocol {
    PROTO_NONE,
    PROTO_HEUR,
@@ -10,8 +14,8 @@ enum ApplicationProtocol {
    PROTO_FTP1,
    PROTO_FTP2,
    PROTO_DNS_VERSIONBIND,
    PROTO_SNMP,
    PROTO_NBTSTAT,
    PROTO_SNMP,             /* simple network management protocol, udp/161 */
    PROTO_NBTSTAT,          /* netbios, udp/137 */
    PROTO_SSL3,
    PROTO_SMTP,
    PROTO_POP3,
@@ -20,6 +24,7 @@ enum ApplicationProtocol {
    PROTO_X509_CERT,
    PROTO_HTML_TITLE,
    PROTO_HTML_FULL,
    PROTO_NTP,              /* network time protocol, udp/123 */
};

const char *
+10 −0
Original line number Diff line number Diff line
@@ -212,6 +212,16 @@ struct Masscan
     * --min-packet
     */
    unsigned min_packet_size;
    
    /**
     * --script <name>
     * The name of the internal script that we are going to use during the
     * scan. The script is responsible for crafting packets and parsing
     * the results
     */
    struct {
        const char *name;
    } script;
};


Loading