Common stuff for all my devices' web server pages: css, login, log, ipv4, ipv6, firmware update, clock, reset info etc.

Dependents:   oldheating gps motorhome heating

Security

A password has to be set whenever there has been a software reset. Resets following faults or power on do not require a new password as the hash is restored from the RTC GPREG register.

The password is not saved on the device; instead a 32 bit hash of the password is saved. It would take 2^31 attempts to brute force the password: this could be done in under a month if an attempt were possible every millisecond. To prevent this a 200 ms delay is introduced in the reply to the login form, that gives a more reasonable 13 years to brute force the password.

Once the password is accepted a random session id is created. This is 36 bit to give six base 64 characters but without an extra delay. If an attempt could be made every ms then this would still take over a year to brute force.

The most likely attack would to use a dictionary with, say, 10 million entries against the password which would still take 20 days to do.

Committer:
andrewboyson
Date:
Wed Jul 31 15:09:15 2019 +0000
Revision:
127:bd6dd135009d
Parent:
110:8ab752842d25
Child:
130:9a5b8fe308f1
Amalgamated Reply into Poll function

Who changed what in which revision?

UserRevisionLine numberNew contents of line
andrewboyson 103:91194cc19bbb 1 #include <stdint.h>
andrewboyson 103:91194cc19bbb 2
andrewboyson 103:91194cc19bbb 3 #include "http.h"
andrewboyson 103:91194cc19bbb 4 #include "log.h"
andrewboyson 103:91194cc19bbb 5 #include "net.h"
andrewboyson 103:91194cc19bbb 6 #include "link.h"
andrewboyson 103:91194cc19bbb 7 #include "dns.h"
andrewboyson 103:91194cc19bbb 8 #include "dnsname.h"
andrewboyson 103:91194cc19bbb 9 #include "dnsquery.h"
andrewboyson 103:91194cc19bbb 10 #include "dnsreply.h"
andrewboyson 103:91194cc19bbb 11 #include "dnsserver.h"
andrewboyson 103:91194cc19bbb 12 #include "ntp.h"
andrewboyson 103:91194cc19bbb 13 #include "dhcp.h"
andrewboyson 103:91194cc19bbb 14 #include "ns.h"
andrewboyson 103:91194cc19bbb 15 #include "nr4.h"
andrewboyson 103:91194cc19bbb 16 #include "nr6.h"
andrewboyson 103:91194cc19bbb 17 #include "echo4.h"
andrewboyson 103:91194cc19bbb 18 #include "echo6.h"
andrewboyson 103:91194cc19bbb 19 #include "dest6.h"
andrewboyson 103:91194cc19bbb 20 #include "ra.h"
andrewboyson 103:91194cc19bbb 21 #include "rs.h"
andrewboyson 103:91194cc19bbb 22 #include "ar4.h"
andrewboyson 103:91194cc19bbb 23 #include "ar6.h"
andrewboyson 103:91194cc19bbb 24 #include "arp.h"
andrewboyson 103:91194cc19bbb 25 #include "ip4.h"
andrewboyson 103:91194cc19bbb 26 #include "ip6.h"
andrewboyson 103:91194cc19bbb 27 #include "udp.h"
andrewboyson 103:91194cc19bbb 28 #include "tcp.h"
andrewboyson 103:91194cc19bbb 29 #include "http.h"
andrewboyson 103:91194cc19bbb 30 #include "tftp.h"
andrewboyson 103:91194cc19bbb 31 #include "ntpclient.h"
andrewboyson 103:91194cc19bbb 32
andrewboyson 103:91194cc19bbb 33 void WebTraceAjax()
andrewboyson 103:91194cc19bbb 34 {
andrewboyson 103:91194cc19bbb 35 HttpOk("text/plain; charset=UTF-8", "no-cache", NULL, NULL);
andrewboyson 103:91194cc19bbb 36 char nibble;
andrewboyson 103:91194cc19bbb 37
andrewboyson 103:91194cc19bbb 38 nibble = 0; //0
andrewboyson 103:91194cc19bbb 39 if ( DnsSendRequestsViaIp4) nibble |= 2;
andrewboyson 103:91194cc19bbb 40 if ( NtpClientQuerySendRequestsViaIp4) nibble |= 4;
andrewboyson 103:91194cc19bbb 41 if (TftpSendRequestsViaIp4) nibble |= 8;
andrewboyson 103:91194cc19bbb 42 HttpAddNibbleAsHex(nibble);
andrewboyson 103:91194cc19bbb 43
andrewboyson 103:91194cc19bbb 44 HttpAddByteAsHex(NetTraceHost[0]); //1, 2
andrewboyson 103:91194cc19bbb 45 HttpAddByteAsHex(NetTraceHost[1]); //3, 4
andrewboyson 103:91194cc19bbb 46
andrewboyson 103:91194cc19bbb 47 nibble = 0; //5
andrewboyson 103:91194cc19bbb 48 if (NetTraceStack ) nibble |= 1;
andrewboyson 103:91194cc19bbb 49 if (NetTraceNewLine ) nibble |= 2;
andrewboyson 103:91194cc19bbb 50 if (NetTraceVerbose ) nibble |= 4;
andrewboyson 103:91194cc19bbb 51 if (LinkTrace ) nibble |= 8;
andrewboyson 103:91194cc19bbb 52 HttpAddNibbleAsHex(nibble);
andrewboyson 103:91194cc19bbb 53
andrewboyson 103:91194cc19bbb 54 nibble = 0; //6
andrewboyson 103:91194cc19bbb 55 if (DnsNameTrace ) nibble |= 1;
andrewboyson 103:91194cc19bbb 56 if (DnsQueryTrace ) nibble |= 2;
andrewboyson 103:91194cc19bbb 57 if (DnsReplyTrace ) nibble |= 4;
andrewboyson 103:91194cc19bbb 58 if (DnsServerTrace ) nibble |= 8;
andrewboyson 103:91194cc19bbb 59 HttpAddNibbleAsHex(nibble);
andrewboyson 103:91194cc19bbb 60
andrewboyson 103:91194cc19bbb 61 nibble = 0; //7
andrewboyson 103:91194cc19bbb 62 if (NtpTrace ) nibble |= 1;
andrewboyson 103:91194cc19bbb 63 if (DhcpTrace ) nibble |= 2;
andrewboyson 103:91194cc19bbb 64 if (NsTraceRecvSol ) nibble |= 4;
andrewboyson 103:91194cc19bbb 65 if (NsTraceRecvAdv ) nibble |= 8;
andrewboyson 103:91194cc19bbb 66 HttpAddNibbleAsHex(nibble);
andrewboyson 103:91194cc19bbb 67
andrewboyson 103:91194cc19bbb 68 nibble = 0; //8
andrewboyson 103:91194cc19bbb 69 if (NsTraceSendSol ) nibble |= 1;
andrewboyson 103:91194cc19bbb 70 if (Nr4Trace ) nibble |= 2;
andrewboyson 103:91194cc19bbb 71 if (Nr6Trace ) nibble |= 4;
andrewboyson 103:91194cc19bbb 72 if (NtpClientTrace ) nibble |= 8;
andrewboyson 103:91194cc19bbb 73 HttpAddNibbleAsHex(nibble);
andrewboyson 103:91194cc19bbb 74
andrewboyson 103:91194cc19bbb 75 nibble = 0; //9
andrewboyson 103:91194cc19bbb 76 if (Echo4Trace ) nibble |= 4;
andrewboyson 103:91194cc19bbb 77 if (Echo6Trace ) nibble |= 8;
andrewboyson 103:91194cc19bbb 78 HttpAddNibbleAsHex(nibble);
andrewboyson 103:91194cc19bbb 79
andrewboyson 103:91194cc19bbb 80 nibble = 0; //10
andrewboyson 103:91194cc19bbb 81 if (Dest6Trace ) nibble |= 1;
andrewboyson 103:91194cc19bbb 82 if (RaTrace ) nibble |= 2;
andrewboyson 103:91194cc19bbb 83 if (RsTrace ) nibble |= 4;
andrewboyson 103:91194cc19bbb 84 if (Ar4Trace ) nibble |= 8;
andrewboyson 103:91194cc19bbb 85 HttpAddNibbleAsHex(nibble);
andrewboyson 103:91194cc19bbb 86
andrewboyson 103:91194cc19bbb 87 nibble = 0; //11
andrewboyson 103:91194cc19bbb 88 if (Ar6Trace ) nibble |= 1;
andrewboyson 103:91194cc19bbb 89 if (ArpTrace ) nibble |= 2;
andrewboyson 103:91194cc19bbb 90 if (Ip4Trace ) nibble |= 4;
andrewboyson 103:91194cc19bbb 91 if (Ip6Trace ) nibble |= 8;
andrewboyson 103:91194cc19bbb 92 HttpAddNibbleAsHex(nibble);
andrewboyson 103:91194cc19bbb 93
andrewboyson 103:91194cc19bbb 94 nibble = 0; //12
andrewboyson 103:91194cc19bbb 95 if (UdpTrace ) nibble |= 1;
andrewboyson 103:91194cc19bbb 96 if (TcpTrace ) nibble |= 2;
andrewboyson 103:91194cc19bbb 97 if (HttpTrace ) nibble |= 4;
andrewboyson 103:91194cc19bbb 98 if (TftpTrace ) nibble |= 8;
andrewboyson 103:91194cc19bbb 99 HttpAddNibbleAsHex(nibble);
andrewboyson 103:91194cc19bbb 100 }
andrewboyson 103:91194cc19bbb 101