From 0e1795363e53da0162751b8c92e856bccde879da Mon Sep 17 00:00:00 2001 From: Robert Graham Date: Wed, 8 May 2019 17:02:11 -0400 Subject: [PATCH] telnet windows fixes --- src/proto-coap.c | 23 ++++++++++++++--------- src/proto-tcp-telnet.c | 12 ++++++------ src/util-bool.h | 9 +++++++++ vs10/masscan.vcxproj | 3 +++ vs10/masscan.vcxproj.filters | 9 +++++++++ 5 files changed, 41 insertions(+), 15 deletions(-) create mode 100644 src/util-bool.h diff --git a/src/proto-coap.c b/src/proto-coap.c index af2d7bf1..04845020 100644 --- a/src/proto-coap.c +++ b/src/proto-coap.c @@ -41,10 +41,10 @@ #include "templ-port.h" #include "util-malloc.h" #include "string_s.h" +#include "util-bool.h" #include #include #include -#include struct CoapLink { @@ -294,6 +294,10 @@ coap_parse(const unsigned char *px, size_t length, struct BannerOutput *banout, unsigned code = 0; unsigned token_length = 0; unsigned long long token = 0; + unsigned offset; + unsigned optnum; + unsigned content_format; + size_t i; /* All coap responses will be at least 8 bytes */ if (length < 4) { @@ -339,7 +343,7 @@ coap_parse(const unsigned char *px, size_t length, struct BannerOutput *banout, } token = 0; - for (size_t i=0; i;if=\"se\\\"\\;\\,\\<\\>\\\\nsor\","; - links = parse_links(input, 0, (~0), &count); + links = parse_links(input, 0, (unsigned)(~0), &count); if (!test_is_link("/success", input, links, count, __LINE__)) return 1; } @@ -665,7 +670,7 @@ proto_coap_selftest(void) { static const unsigned char *input = (const unsigned char *) ";if=\"sensor\""; - links = parse_links(input, 0, (~0), &count); + links = parse_links(input, 0, (unsigned)(~0), &count); if (!test_is_link("/sensors/temp", input, links, count, __LINE__)) return 1; } @@ -688,7 +693,7 @@ proto_coap_selftest(void) ";anchor=\"/sensors/temp\";rel=\"alternate\"," ";rt=\"firmware\";sz=262144" ; - links = parse_links(input, 0, (~0), &count); + links = parse_links(input, 0, (unsigned)(~0), &count); if (!test_is_link("/firmware/v2.1", input, links, count, __LINE__)) return 1; } diff --git a/src/proto-tcp-telnet.c b/src/proto-tcp-telnet.c index f4b42761..d4d619e0 100644 --- a/src/proto-tcp-telnet.c +++ b/src/proto-tcp-telnet.c @@ -262,7 +262,7 @@ telnet_parse( const struct Banner1 *banner1, } { - const size_t r_length = 256*3*4; +#define r_length (256*3*4) unsigned char reply[r_length]; size_t r_offset = 0; size_t i; @@ -270,22 +270,22 @@ telnet_parse( const struct Banner1 *banner1, if (nego[i] & FLAG_WILL) { reply[r_offset++] = 0xFF; /* IAC */ reply[r_offset++] = 0xFB; /* WILL */ - reply[r_offset++] = i; + reply[r_offset++] = (unsigned char)i; } if (nego[i] & FLAG_WONT) { reply[r_offset++] = 0xFF; /* IAC */ reply[r_offset++] = 0xFC; /* WONT */ - reply[r_offset++] = i; + reply[r_offset++] = (unsigned char)i; } if (nego[i] & FLAG_DO) { reply[r_offset++] = 0xFF; /* IAC */ reply[r_offset++] = 0xFD; /* DO */ - reply[r_offset++] = i; + reply[r_offset++] = (unsigned char)i; } if (nego[i] & FLAG_DONT) { reply[r_offset++] = 0xFF; /* IAC */ reply[r_offset++] = 0xFE; /* DONT */ - reply[r_offset++] = i; + reply[r_offset++] = (unsigned char)i; } } if (r_offset) { @@ -336,7 +336,7 @@ telnet_selftest_item(const char *input, const char *output) banout1, &more ); - fprintf(stderr, "%.*s\n", (int)banout_string_length(banout1, PROTO_TELNET), banout_string(banout1, PROTO_TELNET)); + //fprintf(stderr, "%.*s\n", (int)banout_string_length(banout1, PROTO_TELNET), banout_string(banout1, PROTO_TELNET)); /* * Verify that somewhere in the output is the string * we are looking for diff --git a/src/util-bool.h b/src/util-bool.h new file mode 100644 index 00000000..cbe6816e --- /dev/null +++ b/src/util-bool.h @@ -0,0 +1,9 @@ +#ifndef UTIL_BOOL_H +#define UTIL_BOOL_H + +#if _MSC_VER && _MSC_VER < 1800 +typedef enum {false=0, true=1} bool; +#else +#include +#endif +#endif \ No newline at end of file diff --git a/vs10/masscan.vcxproj b/vs10/masscan.vcxproj index 67718673..1959f001 100644 --- a/vs10/masscan.vcxproj +++ b/vs10/masscan.vcxproj @@ -46,6 +46,7 @@ + @@ -145,6 +146,7 @@ + @@ -190,6 +192,7 @@ + diff --git a/vs10/masscan.vcxproj.filters b/vs10/masscan.vcxproj.filters index 204e0f8f..a518c551 100644 --- a/vs10/masscan.vcxproj.filters +++ b/vs10/masscan.vcxproj.filters @@ -333,6 +333,9 @@ Source Files\misc + + Source Files\proto + @@ -566,6 +569,12 @@ Source Files\misc + + Source Files\proto + + + Source Files\proto +