honeyd/honeyd.patch

Thu, 04 Oct 2012 20:30:05 +0200

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 04 Oct 2012 20:30:05 +0200
changeset 715
c10fb90893b9
parent 575
6e491d7671a4
permissions
-rw-r--r--

Correct out of date build configuration, porting to Solaris 11 network
link infrastructure and new libpcap logic. This additionally allows for
device drivers in subdirectories of /dev. Correct packaged nmap
personalities and signatures to work out of the box. Finally, hack
arpd logic to properly close sockets and quit on TERM by repeating
signaling in the run command script. Sadly, all this fails to correct
the run time behaviour of honeyd which fails to bind to the IP layer.

michael@574 1 Index: command.c
michael@574 2 --- command.c.orig 2006-08-19 09:10:40 +0200
michael@574 3 +++ command.c 2006-08-24 12:14:21 +0200
michael@574 4 @@ -72,6 +72,9 @@
michael@574 5 #include "pyextend.h"
michael@574 6 #include "honeyd_overload.h"
michael@574 7 #include "util.h"
michael@574 8 +#ifndef HAVE_SETENV
michael@574 9 +#include "setenv.h"
michael@574 10 +#endif
michael@574 11
michael@574 12 ssize_t atomicio(ssize_t (*)(), int, void *, size_t);
michael@574 13
michael@574 14 Index: compat/getopt.h
michael@574 15 --- compat/getopt.h.orig 2006-08-19 09:10:40 +0200
michael@574 16 +++ compat/getopt.h 2006-08-24 12:14:21 +0200
michael@574 17 @@ -40,7 +40,11 @@
michael@574 18 #ifndef _GETOPT_H_
michael@574 19 #define _GETOPT_H_
michael@574 20
michael@574 21 +#ifdef HAVE_SYS_CDEFS_H
michael@574 22 #include <sys/cdefs.h>
michael@574 23 +#else
michael@574 24 +#include "cdefs.h"
michael@574 25 +#endif
michael@574 26
michael@574 27 /*
michael@574 28 * GNU-like getopt_long() and 4.4BSD getsubopt()/optreset extensions
michael@574 29 Index: compat/sha1.h
michael@574 30 --- compat/sha1.h.orig 2006-08-19 09:10:40 +0200
michael@574 31 +++ compat/sha1.h 2006-08-24 12:14:21 +0200
michael@574 32 @@ -15,7 +15,11 @@
michael@574 33 unsigned char buffer[64];
michael@574 34 } SHA1_CTX;
michael@574 35
michael@574 36 +#ifdef HAVE_SYS_CDEFS_H
michael@574 37 #include <sys/cdefs.h>
michael@574 38 +#else
michael@574 39 +#include "cdefs.h"
michael@574 40 +#endif
michael@574 41
michael@574 42 __BEGIN_DECLS
michael@574 43 void SHA1Transform(u_int32_t [5], const unsigned char [64])
michael@574 44 Index: config.h.in
michael@574 45 --- config.h.in.orig 2006-01-17 18:11:44 +0100
michael@574 46 +++ config.h.in 2006-08-24 12:14:21 +0200
michael@574 47 @@ -222,6 +222,9 @@
michael@574 48 /* Define to 1 if you have the `strtoul' function. */
michael@574 49 #undef HAVE_STRTOUL
michael@574 50
michael@574 51 +/* Define to 1 if you have the `setenv' function. */
michael@574 52 +#undef HAVE_SETENV
michael@574 53 +
michael@574 54 /* Define if your system defines struct sockaddr_storage */
michael@574 55 #undef HAVE_STRUCT_SOCKADDR_STORAGE
michael@574 56
michael@574 57 @@ -255,6 +258,9 @@
michael@574 58 /* Define to 1 if you have the <sys/types.h> header file. */
michael@574 59 #undef HAVE_SYS_TYPES_H
michael@574 60
michael@574 61 +/* Define to 1 if you have the <sys/cdefs.h> header file. */
michael@574 62 +#undef HAVE_SYS_CDEFS_H
michael@574 63 +
michael@574 64 /* Define to 1 if you have <sys/wait.h> that is POSIX.1 compatible. */
michael@574 65 #undef HAVE_SYS_WAIT_H
michael@574 66
michael@574 67 Index: dhcpclient.c
michael@574 68 --- dhcpclient.c.orig 2006-08-19 09:10:41 +0200
michael@574 69 +++ dhcpclient.c 2006-08-24 12:14:21 +0200
michael@574 70 @@ -94,6 +94,13 @@
michael@574 71
michael@574 72 #define NTRIES 10
michael@574 73
michael@574 74 +#ifndef MIN
michael@574 75 +# define MIN(a,b) (((a) < (b)) ? (a) : (b))
michael@574 76 +#endif /* MIN */
michael@574 77 +#ifndef MAX
michael@574 78 +# define MAX(a,b) (((a) > (b)) ? (a) : (b))
michael@574 79 +#endif /* MAX */
michael@574 80 +
michael@574 81 static int _pack_request(struct dhcpclient_req *, void *, size_t *);
michael@574 82 static int _pack_release(struct dhcpclient_req *, void *, size_t *);
michael@574 83 static int _bcast(struct template *,
michael@574 84 Index: honeyd.c
michael@574 85 --- honeyd.c.orig 2006-08-19 09:14:36 +0200
michael@574 86 +++ honeyd.c 2006-08-24 12:14:21 +0200
michael@574 87 @@ -101,6 +101,9 @@
michael@574 88 #include "histogram.h"
michael@574 89 #include "update.h"
michael@574 90 #include "util.h"
michael@574 91 +#ifndef HAVE_SETENV
michael@574 92 +#include "setenv.h"
michael@574 93 +#endif
michael@574 94
michael@574 95 #ifdef HAVE_PYTHON
michael@574 96 #include <Python.h>
michael@574 97 Index: honeyd_overload.c
michael@574 98 --- honeyd_overload.c.orig 2006-08-19 09:10:41 +0200
michael@574 99 +++ honeyd_overload.c 2006-08-24 12:14:21 +0200
michael@574 100 @@ -295,7 +295,7 @@
michael@574 101 struct fd *nfd;
michael@574 102 int pair[2];
michael@574 103
michael@574 104 - if (socketpair(AF_LOCAL, type, 0, pair) == -1) {
michael@574 105 + if (socketpair(AF_UNIX, type, 0, pair) == -1) {
michael@574 106 warn("%s: socketpair", __func__);
michael@574 107 return (NULL);
michael@574 108 }
michael@574 109 @@ -625,7 +625,7 @@
michael@574 110 }
michael@574 111
michael@574 112 /* Get another socketpair */
michael@574 113 - if (socketpair(AF_LOCAL, SOCK_STREAM, 0, pair) == -1) {
michael@574 114 + if (socketpair(AF_UNIX, SOCK_STREAM, 0, pair) == -1) {
michael@574 115 DPRINTF((stderr, "%s: socketpair failed", __func__));
michael@574 116 errno = ETIMEDOUT; /* XXX */
michael@574 117 return (-1);
michael@574 118 @@ -732,6 +732,7 @@
michael@574 119 }
michael@574 120 #endif /* !__FreeBSD__ */
michael@574 121
michael@574 122 +#ifndef sun
michael@574 123 ssize_t
michael@574 124 recvfrom(int sock, void *buf, size_t len, int flags, struct sockaddr *from,
michael@574 125 socklen_t *fromlen)
michael@574 126 @@ -759,6 +760,7 @@
michael@574 127 out:
michael@574 128 return (ret);
michael@574 129 }
michael@574 130 +#endif /* !sun */
michael@574 131
michael@574 132 ssize_t
michael@574 133 sendto(int sock, const void *buf, size_t len, int flags,
michael@574 134 @@ -795,6 +797,7 @@
michael@574 135 return (ret);
michael@574 136 }
michael@574 137
michael@574 138 +#ifndef sun
michael@574 139 int
michael@574 140 getsockname(int sock, struct sockaddr *to, socklen_t *tolen)
michael@574 141 {
michael@574 142 @@ -832,6 +835,7 @@
michael@574 143
michael@574 144 return (0);
michael@574 145 }
michael@574 146 +#endif /* !sun */
michael@574 147
michael@574 148 ssize_t
michael@574 149 recvmsg(int sock, struct msghdr *msg, int flags)
michael@574 150 @@ -1120,6 +1124,7 @@
michael@574 151 return (ret);
michael@574 152 }
michael@574 153
michael@574 154 +#ifndef sun
michael@574 155 int
michael@574 156 accept(int sock, struct sockaddr *addr, socklen_t *addrlen)
michael@574 157 {
michael@574 158 @@ -1169,6 +1174,7 @@
michael@574 159
michael@574 160 return (fd);
michael@574 161 }
michael@574 162 +#endif /* !sun */
michael@574 163
michael@574 164 #if 0
michael@574 165
michael@574 166 Index: personality.c
michael@574 167 --- personality.c.orig 2006-08-19 09:10:40 +0200
michael@574 168 +++ personality.c 2006-08-24 12:14:21 +0200
michael@574 169 @@ -32,6 +32,9 @@
michael@574 170
michael@574 171 #include <sys/param.h>
michael@574 172 #include <sys/types.h>
michael@574 173 +#ifndef UINT_MAX
michael@574 174 +#define UINT_MAX 4294967295U
michael@574 175 +#endif
michael@574 176
michael@574 177 #include "config.h"
michael@574 178
michael@574 179 Index: pf_osfp.c
michael@574 180 --- pf_osfp.c.orig 2006-08-19 09:10:40 +0200
michael@574 181 +++ pf_osfp.c 2006-08-24 12:14:21 +0200
michael@574 182 @@ -50,6 +50,10 @@
michael@574 183 # define DPFPRINTF(format, x...) ((void)0)
michael@574 184 # endif /* PFDEBUG */
michael@574 185
michael@574 186 +#ifndef MAX
michael@574 187 +# define MAX(a,b) (((a) > (b)) ? (a) : (b))
michael@574 188 +#endif
michael@574 189 +
michael@574 190 SLIST_HEAD(pf_osfp_list, pf_os_fingerprint) pf_osfp_list;
michael@574 191 pool_t pf_osfp_entry_pl;
michael@574 192 pool_t pf_osfp_pl;
michael@715 193 Index: nmap.prints
michael@715 194 --- nmap.prints.orig 2007-05-28 08:05:05.000000000 +0200
michael@715 195 +++ nmap.prints 2012-10-02 20:41:53.110772932 +0200
michael@715 196 @@ -662,18 +662,6 @@
michael@715 197 T7(DF=N%W=0%ACK=S%Flags=AR%Ops=)
michael@715 198 PU(DF=N%TOS=0%IPLEN=38%RIPTL=15C%RID=E%RIPCK=0%UCK=0%ULEN=134%DAT=E)
michael@715 199
michael@715 200 -Fingerprint IBM OS/400 V4R2M0
michael@715 201 -Class IBM | OS/400 | V4 | general purpose
michael@715 202 -TSeq(Class=TD|RI%gcd=<6%SI=<285DC&>206%IPID=I%TS=U)
michael@715 203 -T1(DF=N%W=8000%ACK=S++%Flags=AS%Ops=M)
michael@715 204 -T2(Resp=Y%DF=N%W=0%ACK=S%Flags=AR%Ops=)
michael@715 205 -T3(Resp=Y%DF=N%W=8000%ACK=S++%Flags=AS%Ops=M)
michael@715 206 -T4(DF=N%W=0%ACK=S%Flags=R%Ops=)
michael@715 207 -T5(DF=N%W=0%ACK=S++%Flags=AR%Ops=)
michael@715 208 -T6(DF=N%W=0%ACK=S%Flags=R%Ops=)
michael@715 209 -T7(DF=N%W=0%ACK=S++%Flags=AR%Ops=)
michael@715 210 -PU(DF=N%TOS=0%IPLEN=38%RIPTL=148%RID=E%RIPCK=E%UCK=E%ULEN=134%DAT=E)
michael@715 211 -
michael@715 212 Fingerprint IBM OS/400 V4R5M0
michael@715 213 Class IBM | OS/400 | V4 | general purpose
michael@715 214 T1(DF=N%W=2000%ACK=S++%Flags=AS%Ops=MNWNNT)
michael@715 215 @@ -11085,18 +11073,6 @@
michael@715 216
michael@715 217 Fingerprint Microsoft Windows NT 4.0 SP3
michael@715 218 Class Microsoft | Windows | NT/2K/XP | general purpose
michael@715 219 -TSeq(Class=TD|RI%gcd=<18%SI=<2A00DA&>6B73)
michael@715 220 -T1(DF=Y%W=7FFF|2017%ACK=S++%Flags=AS%Ops=M|MNWNNT)
michael@715 221 -T2(Resp=Y%DF=N%W=0%ACK=S%Flags=AR%Ops=)
michael@715 222 -T3(Resp=Y%DF=Y%W=7FFF|2017%ACK=S++|O%Flags=AS|A%Ops=M|NNT)
michael@715 223 -T4(DF=N%W=0%ACK=O|S%Flags=R%Ops=)
michael@715 224 -T5(DF=N%W=0%ACK=S++%Flags=AR%Ops=)
michael@715 225 -T6(DF=N%W=0%ACK=O|S++%Flags=R%Ops=)
michael@715 226 -T7(DF=N%W=0%ACK=S++%Flags=AR%Ops=)
michael@715 227 -PU(TOS=0%IPLEN=38%RIPTL=148%RID=E%RIPCK=E%UCK=E%ULEN=134%DAT=E)
michael@715 228 -
michael@715 229 -Fingerprint Microsoft Windows NT 4.0 SP3
michael@715 230 -Class Microsoft | Windows | NT/2K/XP | general purpose
michael@715 231 TSeq(Class=TD%gcd=<F4%SI=<3C%IPID=BI%TS=U)
michael@715 232 T1(DF=Y%W=2017%ACK=S++%Flags=AS%Ops=M)
michael@715 233 T2(Resp=Y%DF=N%W=0%ACK=S%Flags=AR%Ops=)
michael@715 234 Index: interface.c
michael@715 235 --- interface.c.orig 2007-05-28 08:12:52.000000000 +0200
michael@715 236 +++ interface.c 2012-10-02 21:16:53.229492754 +0200
michael@715 237 @@ -114,6 +114,7 @@
michael@715 238 {
michael@715 239 char ebuf[PCAP_ERRBUF_SIZE];
michael@715 240 struct interface *inter;
michael@715 241 + char *iface = 0;
michael@715 242
michael@715 243 if ((inter = calloc(1, sizeof(struct interface))) == NULL)
michael@715 244 err(1, "%s: calloc", __func__);
michael@715 245 @@ -126,14 +127,23 @@
michael@715 246 TAILQ_INSERT_TAIL(&interfaces, inter, next);
michael@715 247
michael@715 248 inter->if_ent.intf_len = sizeof(struct intf_entry);
michael@715 249 - strlcpy(inter->if_ent.intf_name, dev, sizeof(inter->if_ent.intf_name));
michael@715 250 +
michael@715 251 + /* mitigate slash paths in OS that provide */
michael@715 252 + /* network devices in subdirectories of /dev */
michael@715 253 + iface = strrchr(dev, '/');
michael@715 254 + if (iface)
michael@715 255 + iface += sizeof(char);
michael@715 256 + else
michael@715 257 + iface = dev;
michael@715 258 +
michael@715 259 + strlcpy(inter->if_ent.intf_name, iface, sizeof(inter->if_ent.intf_name));
michael@715 260
michael@715 261 if (intf_get(intf, &inter->if_ent) < 0)
michael@715 262 err(1, "%s: intf_get", __func__);
michael@715 263
michael@715 264 if (inter->if_ent.intf_addr.addr_type != ADDR_TYPE_IP)
michael@715 265 errx(1, "%s: bad interface configuration: %s is not IP",
michael@715 266 - __func__, dev);
michael@715 267 + __func__, iface);
michael@715 268
michael@715 269 return (inter);
michael@715 270 }
michael@715 271 @@ -244,7 +254,7 @@
michael@715 272 }
michael@715 273
michael@715 274 void
michael@715 275 -interface_ether_filter(struct interface *inter,
michael@715 276 +interface_ether_filter(char *dev, struct interface *inter,
michael@715 277 int naddresses, char **addresses)
michael@715 278 {
michael@715 279 char line[48];
michael@715 280 @@ -259,7 +269,7 @@
michael@715 281 sizeof(inter->if_filter))
michael@715 282 errx(1, "%s: pcap filter exceeds maximum length", __func__);
michael@715 283
michael@715 284 - inter->if_eth = eth_open(inter->if_ent.intf_name);
michael@715 285 + inter->if_eth = eth_open(dev);
michael@715 286 if (inter->if_eth == NULL)
michael@715 287 errx(1, "%s: eth_open: %s", inter->if_ent.intf_name);
michael@715 288
michael@715 289 @@ -307,7 +317,7 @@
michael@715 290 * ignore our own packets.
michael@715 291 */
michael@715 292 if (inter->if_ent.intf_link_addr.addr_type == ADDR_TYPE_ETH) {
michael@715 293 - interface_ether_filter(inter, naddresses, addresses);
michael@715 294 + interface_ether_filter(dev, inter, naddresses, addresses);
michael@715 295
michael@715 296 /*
michael@715 297 * We open all interfaces before parsing the

mercurial