Пример #1
0
static void
telnet_parse(  const struct Banner1 *banner1,
        void *banner1_private,
        struct ProtocolState *pstate,
        const unsigned char *px, size_t length,
        struct BannerOutput *banout,
        struct InteractiveData *more)
{
    unsigned state = pstate->state;
    unsigned i;

    UNUSEDPARM(banner1_private);
    UNUSEDPARM(banner1);
    UNUSEDPARM(more);

    for (i=0; i<length; i++)
    switch (state) {
    case 0:
        if (px[i] == '\r')
            continue;
        if (px[i] == '\n' || px[i] == '\0' || !isprint(px[i])) {
            state++;
            tcp_close(more);
            continue;
        }
        banout_append_char(banout, PROTO_SSH2, px[i]);
        break;
    default:
        i = (unsigned)length;
        break;
    }
    pstate->state = state;
}
Пример #2
0
/*************************************** *************************************
 ****************************************************************************/
static void
text_out_banner(struct Output *out, FILE *fp, time_t timestamp,
        unsigned ip, unsigned ip_proto, unsigned port,
        enum ApplicationProtocol proto, unsigned ttl,
        const unsigned char *px, unsigned length)
{
    char banner_buffer[4096];


    UNUSEDPARM(out);
    UNUSEDPARM(ttl);

    fprintf(fp, "%s %s %u %u.%u.%u.%u %u %s %s\n",
        "banner",
        name_from_ip_proto(ip_proto),
        port,
        (ip>>24)&0xFF,
        (ip>>16)&0xFF,
        (ip>> 8)&0xFF,
        (ip>> 0)&0xFF,
        (unsigned)timestamp,
        masscan_app_to_string(proto),
        normalize_string(px, length, banner_buffer, sizeof(banner_buffer))
        );
}
Пример #3
0
static void
ssh_parse(  const struct Banner1 *banner1,
        void *banner1_private,
        struct Banner1State *pstate,
        const unsigned char *px, size_t length,
        char *banner, unsigned *banner_offset, size_t banner_max)
{
    unsigned state = pstate->state;
    unsigned i;

    UNUSEDPARM(banner1_private);
    UNUSEDPARM(banner1);

    for (i=0; i<length; i++)
    switch (state) {
    case 0:
        if (px[i] == '\r')
            continue;
        if (px[i] == '\n' || px[i] == '\0' || !isprint(px[i])) {
            state = STATE_DONE;
            continue;
        }
        if (*banner_offset < banner_max)
            banner[(*banner_offset)++] = px[i];
        break;
    default:
        i = (unsigned)length;
        break;
    }
    pstate->state = state;
}
Пример #4
0
static unsigned null_PCAP_DISPATCH(void *hPcap, unsigned how_many_packets, PCAP_HANDLE_PACKET handler, void *handle_data)
{
#ifdef STATICPCAP
	return pcap_dispatch(hPcap, how_many_packets, handler, handle_data);
#endif
	UNUSEDPARM(hPcap);UNUSEDPARM(how_many_packets);UNUSEDPARM(handler);UNUSEDPARM(handle_data);
	return 0;
}
Пример #5
0
static void * null_PCAP_OPEN_LIVE(const char *devicename, unsigned snap_length, unsigned is_promiscuous, unsigned read_timeout, char *errbuf)
{
#ifdef STATICPCAP
	return pcap_open_live(devicename, snap_length, is_promiscuous, read_timeout, errbuf);
#endif
	seterr(errbuf, "libpcap not loaded");
	UNUSEDPARM(devicename);UNUSEDPARM(snap_length);UNUSEDPARM(is_promiscuous);UNUSEDPARM(read_timeout);
	return NULL;
}
Пример #6
0
void
perftest_server_to_client_response(struct Adapter *adapter,
                                   struct Thread *thread, struct Packet *pkt)
{
    struct TestAdapter *testadapter = (struct TestAdapter *)adapter->userdata;
    struct PerfTest *perftest = testadapter->parent;
    
    UNUSEDPARM(thread);
    UNUSEDPARM(perftest);
    
    
    
}
Пример #7
0
void extract_item(struct Ferret *ferret, struct NetFrame *frame, const unsigned char *px, 
				  unsigned length, unsigned *r_offset, 
				  const unsigned char **r_object, unsigned *r_object_len)
{
	unsigned len;

	UNUSEDPARM(ferret);

	if (*r_offset + 1 > length) {
		FRAMERR(frame, "truncated\n");
		*r_offset = length+1;
		return;
	}

	len = px[*r_offset];
	(*r_offset)++;

	if (*r_offset + len > length)
		len = length-*r_offset;

	*r_object = px + *r_offset;
	*r_object_len = len;

	*r_offset += len;
}
Пример #8
0
static void
unicornscan_out_open(struct Output *out, FILE *fp)
{
    UNUSEDPARM(out);
    fprintf(fp, "#masscan\n");
    init_tcp_services();
}
Пример #9
0
/*************************************** *************************************
 ****************************************************************************/
static void
text_out_banner(struct Output *out, FILE *fp, time_t timestamp,
        unsigned ip, unsigned ip_proto, unsigned port,
        enum ApplicationProtocol proto, const unsigned char *px, unsigned length)
{
    char banner_buffer[4096];
    char ip_proto_sz[64];

    switch (ip_proto) {
    case 1: strcpy_s(ip_proto_sz, sizeof(ip_proto_sz), "icmp"); break;
    case 6: strcpy_s(ip_proto_sz, sizeof(ip_proto_sz), "tcp"); break;
    case 17: strcpy_s(ip_proto_sz, sizeof(ip_proto_sz), "udp"); break;
    default: sprintf_s(ip_proto_sz, sizeof(ip_proto_sz), "(%u)", ip_proto); break;
    }

    UNUSEDPARM(out);

    fprintf(fp, "%s %s %u %u.%u.%u.%u %u %s %s\n",
        "banner",
        ip_proto_sz,
        port,
        (ip>>24)&0xFF,
        (ip>>16)&0xFF,
        (ip>> 8)&0xFF,
        (ip>> 0)&0xFF,
        (unsigned)timestamp,
        masscan_app_to_string(proto),
        normalize_string(px, length, banner_buffer, sizeof(banner_buffer))
        );
}
Пример #10
0
unsigned
banner_ssh(  struct Banner1 *banner1,
        unsigned state,
        const unsigned char *px, size_t length,
        char *banner, unsigned *banner_offset, size_t banner_max)
{
    unsigned i;

    UNUSEDPARM(banner1);

    for (i=0; i<length; i++)
    switch (state) {
    case 0:
        if (px[i] == '\r')
            continue;
        if (px[i] == '\n' || px[i] == '\0' || !isprint(px[i])) {
            state = STATE_DONE;
            continue;
        }
        if (*banner_offset < banner_max)
            banner[(*banner_offset)++] = px[i];
        break;
    default:
        i = (unsigned)length;
        break;
    }
    return state;
}
Пример #11
0
static void
xml_out_status(struct Output *out, FILE *fp, time_t timestamp, int status,
               unsigned ip, unsigned ip_proto, unsigned port, unsigned reason, unsigned ttl)
{
    char reason_buffer[128];
    UNUSEDPARM(out);
    fprintf(fp, "<host endtime=\"%u\">"
                    "<address addr=\"%u.%u.%u.%u\" addrtype=\"ipv4\"/>"
                    "<ports>"
                    "<port protocol=\"%s\" portid=\"%u\">"
                    "<state state=\"%s\" reason=\"%s\" reason_ttl=\"%u\"/>"
                    "</port>"
                    "</ports>"
                "</host>"
                "\r\n",
        (unsigned)timestamp,
        (ip>>24)&0xFF,
        (ip>>16)&0xFF,
        (ip>> 8)&0xFF,
        (ip>> 0)&0xFF,
        name_from_ip_proto(ip_proto),
        port,
        status_string(status),
        reason_string(reason, reason_buffer, sizeof(reason_buffer)),
        ttl
        );
}
Пример #12
0
static void
xml_out_banner(struct Output *out, FILE *fp, time_t timestamp,
        unsigned ip, unsigned ip_proto, unsigned port,
        enum ApplicationProtocol proto, const unsigned char *px, unsigned length)
{
    char banner_buffer[4096];

    UNUSEDPARM(out);

    fprintf(fp, "<host endtime=\"%u\">"
                    "<address addr=\"%u.%u.%u.%u\" addrtype=\"ipv4\"/>"
                    "<ports>"
                    "<port protocol=\"%s\" portid=\"%u\">"
                    "<service name=\"%s\" banner=\"%s\">"
                    "</service>"
                    "</port>"
                    "</ports>"
                "</host>"
                "\r\n",
        (unsigned)timestamp,
        (ip>>24)&0xFF,
        (ip>>16)&0xFF,
        (ip>> 8)&0xFF,
        (ip>> 0)&0xFF,
        name_from_ip_proto(ip_proto),
        port,
        masscan_app_to_string(proto),
        normalize_string(px, length, banner_buffer, sizeof(banner_buffer))
        );
}
Пример #13
0
void
status_finish(struct Status *status)
{
    UNUSEDPARM(status);
    fprintf(stderr, 
"                                                                             \r");
}
Пример #14
0
static int null_PCAP_MINOR_VERSION(void *p)
{
#ifdef STATICPCAP
	return pcap_minor_version(p);
#endif
	UNUSEDPARM(p);
	return 0;
}
Пример #15
0
static void null_PCAP_CLOSE(void *hPcap)
{
#ifdef STATICPCAP
	pcap_close(hPcap);
	return;
#endif
	UNUSEDPARM(hPcap);
}
Пример #16
0
static void null_PCAP_FREEALLDEVS(pcap_if_t *alldevs)
{
#ifdef STATICPCAP
	return pcap_freealldevs(alldevs);
#endif
	UNUSEDPARM(alldevs);
	return;
}
Пример #17
0
static unsigned null_PCAP_DATALINK(void *hPcap)
{
#ifdef STATICPCAP
	return pcap_datalink(hPcap);
#endif
	UNUSEDPARM(hPcap);
	return 0;
}
Пример #18
0
/****************************************************************************
 * Prints out "banner" information for a port. This is done when there is
 * a protocol defined for a port, and we do some interaction to find out
 * more information about which protocol is running on a port, it's version,
 * and other useful information.
 ****************************************************************************/
static void
null_out_banner(struct Output *out, FILE *fp, time_t timestamp,
        unsigned ip, unsigned ip_proto, unsigned port,
        enum ApplicationProtocol proto, unsigned ttl,
        const unsigned char *px, unsigned length)
{
    UNUSEDPARM(ttl);
    UNUSEDPARM(timestamp);
    UNUSEDPARM(out);
    UNUSEDPARM(fp);
    UNUSEDPARM(ip);
    UNUSEDPARM(ip_proto);
    UNUSEDPARM(port);
    UNUSEDPARM(proto);
    UNUSEDPARM(px);
    UNUSEDPARM(length);

}
Пример #19
0
static void
unicornscan_out_status(struct Output *out, FILE *fp, time_t timestamp,
    int status, unsigned ip, unsigned ip_proto, unsigned port, unsigned reason, unsigned ttl)
{
    UNUSEDPARM(reason);
    UNUSEDPARM(out);
    UNUSEDPARM(timestamp);

    if (ip_proto == 6) {
      fprintf(fp,"TCP open\t%16s[%5d]\t\tfrom %u.%u.%u.%u  ttl %-3d\n",
              tcp_services[port],
              port,
              (ip>>24)&0xFF,
              (ip>>16)&0xFF,
              (ip>> 8)&0xFF,
              (ip>> 0)&0xFF,
              ttl);
    }
Пример #20
0
/****************************************************************************
 * Prints out the status of a port, which is almost always just "open"
 * or "closed".
 ****************************************************************************/
static void
null_out_status(struct Output *out, FILE *fp, time_t timestamp,
    int status, unsigned ip, unsigned ip_proto, unsigned port, unsigned reason, unsigned ttl)
{
    UNUSEDPARM(timestamp);
    UNUSEDPARM(out);
    UNUSEDPARM(fp);
    UNUSEDPARM(status);
    UNUSEDPARM(ip_proto);
    UNUSEDPARM(ip);
    UNUSEDPARM(port);
    UNUSEDPARM(reason);
    UNUSEDPARM(ttl);

}
Пример #21
0
void process_icmp(struct Ferret *ferret, struct NetFrame *frame, const unsigned char *px, unsigned length)
{
    unsigned type = px[0];
    unsigned code = px[1];
    unsigned checksum = ex16be(px+2);

    UNUSEDPARM(length);
    UNUSEDPARM(frame);
    UNUSEDPARM(checksum);

    ferret->statistics.icmp++;
    frame->layer4_protocol = LAYER4_ICMP;

    JOTDOWN(ferret,
            JOT_SZ("TEST","icmp"),
            JOT_NUM("type",type),
            JOT_NUM("code",code),
            0);
}
Пример #22
0
static void
text_out_status(struct Output *out, FILE *fp, time_t timestamp,
    int status, unsigned ip, unsigned port, unsigned reason, unsigned ttl)
{
    UNUSEDPARM(ttl);
    UNUSEDPARM(reason);
    UNUSEDPARM(out);


    fprintf(fp, "%s tcp %u %u.%u.%u.%u %u\n",
        status_string(status),
        port,
        (ip>>24)&0xFF,
        (ip>>16)&0xFF,
        (ip>> 8)&0xFF,
        (ip>> 0)&0xFF,
        (unsigned)timestamp
        );
}
Пример #23
0
void
handle_arp(struct Output *out, const unsigned char *px, unsigned length, struct PreprocessedInfo *parsed)
{
    unsigned ip_them;

	UNUSEDPARM(length);
	UNUSEDPARM(px);

    ip_them = parsed->ip_src[0]<<24 | parsed->ip_src[1]<<16
            | parsed->ip_src[2]<< 8 | parsed->ip_src[3]<<0;

    output_report_status(
                    out,
                    Port_ArpOpen,
                    ip_them,
                    0,
                    0,
                    0);

}
Пример #24
0
static void
text_out_status(struct Output *out, FILE *fp, time_t timestamp,
    int status, unsigned ip, unsigned ip_proto, unsigned port, unsigned reason, unsigned ttl)
{
    const char *service = port_to_service(port, ip_proto);

    UNUSEDPARM(ttl);
    UNUSEDPARM(reason);
    UNUSEDPARM(out);

    fprintf(fp, "%s %s %u %u.%u.%u.%u %u %s\n",
        status_string(status),
        name_from_ip_proto(ip_proto),
        port,
        (ip>>24)&0xFF,
        (ip>>16)&0xFF,
        (ip>> 8)&0xFF,
        (ip>> 0)&0xFF,
        (unsigned)timestamp,
        service
        );
    fflush(fp);
}
Пример #25
0
int
main(int argc, char *argv[])
{
    unsigned cpu_count;
    
    UNUSEDPARM(argc);
    UNUSEDPARM(argv);
    
    /* Grab the number of CPUs. We want to run benchmarks on as many CPUs as
     * possible in order to test scaling */
    cpu_count = pixie_cpu_get_count();

    /* Print OS, version, CPU, etc. */
    print_version();

    /*
     * Print header information
     */
    printf("           ,CPUs,   Mm/sec,    Total,    nsecs\n");

    //alloc_all();

    bench_mainmem(cpu_count, MemBench_MaxRateHuge);
    bench_mainmem(cpu_count, MemBench_PointerChaseHuge);
    //bench_mainmem(cpu_count, MemBench_CmovChase);
    bench_mainmem(cpu_count, MemBench_MaxRate);
    bench_mainmem(cpu_count, MemBench_PointerChase);
    bench_cache_bounce(cpu_count, CacheBench_Add);
    bench_cache_bounce(cpu_count, CacheBench_LockedAdd);
    bench_cache_bounce(cpu_count, CacheBench_MutexAdd);
    bench_syscall(cpu_count);
    bench_funcall(cpu_count, add_two_numbers);
    bench_msgrate_pipe(cpu_count);
    bench_msgrate_ring(cpu_count);
    return 1;
}
Пример #26
0
void process_icmpv6(struct Ferret *ferret, struct NetFrame *frame, const unsigned char *px, unsigned length)
{
    unsigned type = px[0];
    unsigned code = px[1];
    unsigned checksum = ex16be(px+2);

    UNUSEDPARM(length);
    UNUSEDPARM(frame);
    UNUSEDPARM(checksum);

    frame->layer4_protocol = LAYER4_ICMP;

    JOTDOWN(ferret,
            JOT_SZ("TEST","icmp"),
            JOT_NUM("type",type),
            JOT_NUM("code",code),
            0);

    if (frame->dst_ipv6[0] == 0xFF)
        JOTDOWN(ferret,
                JOT_MACADDR("ID-MAC", frame->src_mac),
                JOT_IPv6("ipv6", frame->src_ipv6, 16),
                0);
}
Пример #27
0
static void process_ldap_search_request(struct Ferret *ferret, struct NetFrame *frame, const unsigned char *px, unsigned length, struct LDAP *ldap)
{
	unsigned offset = 0;

	UNUSEDPARM(ferret);


	asn1_string(frame, px, length, &offset, &ldap->basedn, &ldap->basedn_length);
	ldap->scope = asn1_enumerated(frame, px, length, &offset);
	ldap->dereference = asn1_enumerated(frame, px, length, &offset);
	ldap->size_limit = asn1_integer(frame, px, length, &offset);
	ldap->time_limit = asn1_integer(frame, px, length, &offset);
	ldap->attribute_only = asn1_boolean(frame, px, length, &offset);

	process_ldap_filter(frame, px, length, &offset, &ldap->filter);
}
Пример #28
0
static struct Packet 
selftest_alloc_packet(struct Adapter *adapter, struct Thread *thread)
{
    struct TestAdapter *testadapter = (struct TestAdapter *)adapter->userdata;
    struct Packet pkt;

    UNUSEDPARM(thread);

    pkt.buf = testadapter->buf;
    pkt.max = sizeof(testadapter->buf);
    pkt.offset = 0;
    pkt.fixup.network = 0;
    pkt.fixup.transport = 0;

    return pkt;
}
Пример #29
0
const struct AdapterListItem *
adapter_list(unsigned *r_count)
{
    static struct AdapterListItem list[64];
    static unsigned count;
    unsigned i;

    UNUSEDPARM(r_count);

    /* Free the old list */
    for (i=0; i<count; i++) {
        free(list[i].adapter_name);
        free(list[i].driver);
    }

    return 0;
}
Пример #30
0
static void
xml_out_banner(struct Output *out, FILE *fp, unsigned ip, unsigned ip_proto, unsigned port,
        unsigned proto, const unsigned char *px, unsigned length)
{
    char banner_buffer[1024];
    char ip_proto_sz[64];

    UNUSEDPARM(out);

    switch (ip_proto) {
    case 1: strcpy_s(ip_proto_sz, sizeof(ip_proto_sz), "icmp"); break;
    case 6: strcpy_s(ip_proto_sz, sizeof(ip_proto_sz), "tcp"); break;
    case 17: strcpy_s(ip_proto_sz, sizeof(ip_proto_sz), "udp"); break;
    default: sprintf_s(ip_proto_sz, sizeof(ip_proto_sz), "(%u)", ip_proto); break;
    }

    fprintf(fp, "<host endtime=\"%u\">"
                    "<address addr=\"%u.%u.%u.%u\" addrtype=\"ipv4\"/>"
                    "<ports>"
                    "<port protocol=\"%s\" portid=\"%u\">"
                    "<service name=\"%s\">"
                    "<banner>%s</banner>"
                    "</service>"
                    "</port>"
                    "</ports>"
                "</host>"
                "\r\n",
        (unsigned)global_now,
        (ip>>24)&0xFF,
        (ip>>16)&0xFF,
        (ip>> 8)&0xFF,
        (ip>> 0)&0xFF,
        ip_proto_sz,
        port,
        proto_string(proto),
        normalize_string(px, length, banner_buffer, sizeof(banner_buffer))
        );
}