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:
136:be1d42268b5d
Amalgamated Reply into Poll function

Who changed what in which revision?

UserRevisionLine numberNew contents of line
andrewboyson 96:eb2eb75bad0f 1 "//Net4 script\n"
andrewboyson 86:f3c9beec4ee7 2 "'use strict';\n"
andrewboyson 86:f3c9beec4ee7 3 "\n"
andrewboyson 95:8c9dda8a0caf 4 "let localIp = '';\n"
andrewboyson 95:8c9dda8a0caf 5 "let domainName = '';\n"
andrewboyson 95:8c9dda8a0caf 6 "let hostName = '';\n"
andrewboyson 95:8c9dda8a0caf 7 "let ntpIp = '';\n"
andrewboyson 95:8c9dda8a0caf 8 "let dnsIp = '';\n"
andrewboyson 95:8c9dda8a0caf 9 "let dhcpIp = '';\n"
andrewboyson 95:8c9dda8a0caf 10 "let routerIp = '';\n"
andrewboyson 95:8c9dda8a0caf 11 "let subnetMask = '';\n"
andrewboyson 95:8c9dda8a0caf 12 "let broadcastIp = '';\n"
andrewboyson 95:8c9dda8a0caf 13 "let leaseTime = '';\n"
andrewboyson 95:8c9dda8a0caf 14 "let renewalT1 = '';\n"
andrewboyson 95:8c9dda8a0caf 15 "let renewalt2 = '';\n"
andrewboyson 95:8c9dda8a0caf 16 "let elapsed = '';\n"
andrewboyson 95:8c9dda8a0caf 17 "let arp = '';\n"
andrewboyson 95:8c9dda8a0caf 18 "let dns = '';\n"
andrewboyson 86:f3c9beec4ee7 19 "\n"
andrewboyson 88:2857259fc2b4 20 "function parseArpLine(line)\n"
andrewboyson 88:2857259fc2b4 21 "{\n"
andrewboyson 88:2857259fc2b4 22 " if (line.length == 0) return;\n"
andrewboyson 95:8c9dda8a0caf 23 " let minutes = parseInt(line.substr(0, 8), 16) / 1000 / 60;\n"
andrewboyson 88:2857259fc2b4 24 " arp += Math.floor(minutes).toString().padStart(4, ' ');\n"
andrewboyson 88:2857259fc2b4 25 " arp += ' ';\n"
andrewboyson 96:eb2eb75bad0f 26 " arp += Net.makeIp4(line.substr(8, 8)).padEnd(15, ' ');\n"
andrewboyson 88:2857259fc2b4 27 " arp += ' ';\n"
andrewboyson 96:eb2eb75bad0f 28 " arp += Net.makeMac(line.substr(16, 12));\n"
andrewboyson 88:2857259fc2b4 29 " arp += '\\r\\n';\n"
andrewboyson 88:2857259fc2b4 30 "}\n"
andrewboyson 88:2857259fc2b4 31 "function parseDnsLine(line)\n"
andrewboyson 88:2857259fc2b4 32 "{\n"
andrewboyson 88:2857259fc2b4 33 " if (line.length == 0) return;\n"
andrewboyson 95:8c9dda8a0caf 34 " let minutes = parseInt(line.substr(0, 8), 16) / 1000 / 60;\n"
andrewboyson 88:2857259fc2b4 35 " dns += Math.floor(minutes).toString().padStart(4, ' ');\n"
andrewboyson 88:2857259fc2b4 36 " dns += ' ';\n"
andrewboyson 96:eb2eb75bad0f 37 " dns += Net.makeIp4(line.substr(8, 8)).padEnd(15, ' ');\n"
andrewboyson 88:2857259fc2b4 38 " dns += ' ';\n"
andrewboyson 88:2857259fc2b4 39 " dns += line.substr(16, 1);\n"
andrewboyson 88:2857259fc2b4 40 " dns += ' ';\n"
andrewboyson 88:2857259fc2b4 41 " dns += line.substr(17);\n"
andrewboyson 88:2857259fc2b4 42 " dns += '\\r\\n';\n"
andrewboyson 88:2857259fc2b4 43 "}\n"
andrewboyson 88:2857259fc2b4 44 "function parseArpLines(text)\n"
andrewboyson 88:2857259fc2b4 45 "{\n"
andrewboyson 88:2857259fc2b4 46 " arp = '';\n"
andrewboyson 88:2857259fc2b4 47 " text.split('\\n').forEach(parseArpLine);\n"
andrewboyson 88:2857259fc2b4 48 "}\n"
andrewboyson 95:8c9dda8a0caf 49 "function parseDnsLines(text)\n"
andrewboyson 95:8c9dda8a0caf 50 "{\n"
andrewboyson 95:8c9dda8a0caf 51 " dns = '';\n"
andrewboyson 95:8c9dda8a0caf 52 " text.split('\\n').forEach(parseDnsLine);\n"
andrewboyson 95:8c9dda8a0caf 53 "}\n"
andrewboyson 89:615fb951df69 54 "function parseGenLines(text)\n"
andrewboyson 89:615fb951df69 55 "{\n"
andrewboyson 95:8c9dda8a0caf 56 " let lines = text.split('\\n');\n"
andrewboyson 96:eb2eb75bad0f 57 " localIp = Net.makeIp4(lines[ 0]) ;\n"
andrewboyson 96:eb2eb75bad0f 58 " domainName = lines[ 1] ;\n"
andrewboyson 96:eb2eb75bad0f 59 " hostName = lines[ 2] ;\n"
andrewboyson 96:eb2eb75bad0f 60 " ntpIp = Net.makeIp4(lines[ 3]) ;\n"
andrewboyson 96:eb2eb75bad0f 61 " dnsIp = Net.makeIp4(lines[ 4]) ;\n"
andrewboyson 96:eb2eb75bad0f 62 " dhcpIp = Net.makeIp4(lines[ 5]) ;\n"
andrewboyson 96:eb2eb75bad0f 63 " routerIp = Net.makeIp4(lines[ 6]) ;\n"
andrewboyson 96:eb2eb75bad0f 64 " subnetMask = Net.makeIp4(lines[ 7]) ;\n"
andrewboyson 96:eb2eb75bad0f 65 " broadcastIp = Net.makeIp4(lines[ 8]) ;\n"
andrewboyson 96:eb2eb75bad0f 66 " leaseTime = parseInt(lines[ 9], 16);\n"
andrewboyson 96:eb2eb75bad0f 67 " renewalT1 = parseInt(lines[10], 16);\n"
andrewboyson 96:eb2eb75bad0f 68 " renewalt2 = parseInt(lines[11], 16);\n"
andrewboyson 96:eb2eb75bad0f 69 " elapsed = parseInt(lines[12], 16);\n"
andrewboyson 89:615fb951df69 70 "}\n"
andrewboyson 95:8c9dda8a0caf 71 "function parse()\n"
andrewboyson 88:2857259fc2b4 72 "{\n"
andrewboyson 95:8c9dda8a0caf 73 " let topics = Ajax.response.split('\\f');\n"
andrewboyson 89:615fb951df69 74 " parseGenLines(topics[0]);\n"
andrewboyson 89:615fb951df69 75 " parseArpLines(topics[1]);\n"
andrewboyson 89:615fb951df69 76 " parseDnsLines(topics[2]);\n"
andrewboyson 86:f3c9beec4ee7 77 "}\n"
andrewboyson 95:8c9dda8a0caf 78 "function display()\n"
andrewboyson 86:f3c9beec4ee7 79 "{\n"
andrewboyson 95:8c9dda8a0caf 80 " let elem;\n"
andrewboyson 86:f3c9beec4ee7 81 "\n"
andrewboyson 95:8c9dda8a0caf 82 " elem = Ajax.getElementOrNull('ajax-local-ip' ); if (elem) elem.textContent = localIp;\n"
andrewboyson 95:8c9dda8a0caf 83 " elem = Ajax.getElementOrNull('ajax-domain-name' ); if (elem) elem.textContent = domainName;\n"
andrewboyson 95:8c9dda8a0caf 84 " elem = Ajax.getElementOrNull('ajax-host-name' ); if (elem) elem.textContent = hostName;\n"
andrewboyson 95:8c9dda8a0caf 85 " elem = Ajax.getElementOrNull('ajax-ntp-ip' ); if (elem) elem.textContent = ntpIp;\n"
andrewboyson 95:8c9dda8a0caf 86 " elem = Ajax.getElementOrNull('ajax-dns-ip' ); if (elem) elem.textContent = dnsIp;\n"
andrewboyson 95:8c9dda8a0caf 87 " elem = Ajax.getElementOrNull('ajax-dhcp-ip' ); if (elem) elem.textContent = dhcpIp;\n"
andrewboyson 95:8c9dda8a0caf 88 " elem = Ajax.getElementOrNull('ajax-router-ip' ); if (elem) elem.textContent = routerIp;\n"
andrewboyson 95:8c9dda8a0caf 89 " elem = Ajax.getElementOrNull('ajax-subnet-mask' ); if (elem) elem.textContent = subnetMask;\n"
andrewboyson 95:8c9dda8a0caf 90 " elem = Ajax.getElementOrNull('ajax-broadcast-ip'); if (elem) elem.textContent = broadcastIp;\n"
andrewboyson 95:8c9dda8a0caf 91 " elem = Ajax.getElementOrNull('ajax-lease-time' ); if (elem) elem.textContent = leaseTime;\n"
andrewboyson 95:8c9dda8a0caf 92 " elem = Ajax.getElementOrNull('ajax-renewal-t1' ); if (elem) elem.textContent = renewalT1;\n"
andrewboyson 95:8c9dda8a0caf 93 " elem = Ajax.getElementOrNull('ajax-renewal-t2' ); if (elem) elem.textContent = renewalt2;\n"
andrewboyson 95:8c9dda8a0caf 94 " elem = Ajax.getElementOrNull('ajax-elapsed' ); if (elem) elem.textContent = elapsed;\n"
andrewboyson 95:8c9dda8a0caf 95 " elem = Ajax.getElementOrNull('ajax-arp' ); if (elem) elem.textContent = arp;\n"
andrewboyson 95:8c9dda8a0caf 96 " elem = Ajax.getElementOrNull('ajax-dns' ); if (elem) elem.textContent = dns;\n"
andrewboyson 86:f3c9beec4ee7 97 "}\n"
andrewboyson 86:f3c9beec4ee7 98 "\n"
andrewboyson 95:8c9dda8a0caf 99 "Ajax.server = '/net4-ajax';\n"
andrewboyson 95:8c9dda8a0caf 100 "Ajax.onResponse = function() { parse(); display(); };\n"
andrewboyson 95:8c9dda8a0caf 101 "Ajax.init();\n"
andrewboyson 86:f3c9beec4ee7 102 ""