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 "//Net6 script\n"
andrewboyson 86:f3c9beec4ee7 2 "'use strict';\n"
andrewboyson 86:f3c9beec4ee7 3 "\n"
andrewboyson 96:eb2eb75bad0f 4 "let arp = '';\n"
andrewboyson 96:eb2eb75bad0f 5 "let dns = '';\n"
andrewboyson 96:eb2eb75bad0f 6 "let hopLimit = '';\n"
andrewboyson 96:eb2eb75bad0f 7 "let managed = false;\n"
andrewboyson 96:eb2eb75bad0f 8 "let other = false;\n"
andrewboyson 96:eb2eb75bad0f 9 "let routerMac = '';\n"
andrewboyson 96:eb2eb75bad0f 10 "let prefixLength = '';\n"
andrewboyson 96:eb2eb75bad0f 11 "let prefixL = false;\n"
andrewboyson 96:eb2eb75bad0f 12 "let prefixA = false;\n"
andrewboyson 96:eb2eb75bad0f 13 "let prefixLimit = '';\n"
andrewboyson 96:eb2eb75bad0f 14 "let prefixPreferred = '';\n"
andrewboyson 96:eb2eb75bad0f 15 "let prefix = '';\n"
andrewboyson 96:eb2eb75bad0f 16 "let dnsLife = '';\n"
andrewboyson 96:eb2eb75bad0f 17 "let dnsIp = '';\n"
andrewboyson 96:eb2eb75bad0f 18 "let ndpLease = '';\n"
andrewboyson 96:eb2eb75bad0f 19 "let ndpElapsed = '';\n"
andrewboyson 96:eb2eb75bad0f 20 "let slaac = '';\n"
andrewboyson 96:eb2eb75bad0f 21 "let mtu = '';\n"
andrewboyson 86:f3c9beec4ee7 22 "\n"
andrewboyson 88:2857259fc2b4 23 "function parseArpLine(line)\n"
andrewboyson 88:2857259fc2b4 24 "{\n"
andrewboyson 88:2857259fc2b4 25 " if (line.length == 0) return;\n"
andrewboyson 96:eb2eb75bad0f 26 " let minutes = parseInt(line.substr(0, 8), 16) / 1000 / 60;\n"
andrewboyson 88:2857259fc2b4 27 " arp += Math.floor(minutes).toString().padStart(4, ' ');\n"
andrewboyson 88:2857259fc2b4 28 " arp += ' ';\n"
andrewboyson 96:eb2eb75bad0f 29 " arp += Net.makeIp6(line.substr(8, 32)).padEnd(40, ' ');\n"
andrewboyson 88:2857259fc2b4 30 " arp += ' ';\n"
andrewboyson 96:eb2eb75bad0f 31 " arp += Net.makeMac(line.substr(40, 12));\n"
andrewboyson 88:2857259fc2b4 32 " arp += '\\r\\n';\n"
andrewboyson 88:2857259fc2b4 33 "}\n"
andrewboyson 88:2857259fc2b4 34 "function parseDnsLine(line)\n"
andrewboyson 88:2857259fc2b4 35 "{\n"
andrewboyson 88:2857259fc2b4 36 " if (line.length == 0) return;\n"
andrewboyson 96:eb2eb75bad0f 37 " let minutes = parseInt(line.substr(0, 8), 16) / 1000 / 60;\n"
andrewboyson 88:2857259fc2b4 38 " dns += Math.floor(minutes).toString().padStart(4, ' ');\n"
andrewboyson 88:2857259fc2b4 39 " dns += ' ';\n"
andrewboyson 96:eb2eb75bad0f 40 " dns += Net.makeIp6(line.substr(8, 32)).padEnd(40, ' ');\n"
andrewboyson 88:2857259fc2b4 41 " dns += ' ';\n"
andrewboyson 88:2857259fc2b4 42 " dns += line.substr(40, 1);\n"
andrewboyson 88:2857259fc2b4 43 " dns += ' ';\n"
andrewboyson 88:2857259fc2b4 44 " dns += line.substr(41);\n"
andrewboyson 88:2857259fc2b4 45 " dns += '\\r\\n';\n"
andrewboyson 88:2857259fc2b4 46 "}\n"
andrewboyson 88:2857259fc2b4 47 "function parseArpLines(text)\n"
andrewboyson 88:2857259fc2b4 48 "{\n"
andrewboyson 88:2857259fc2b4 49 " arp = '';\n"
andrewboyson 88:2857259fc2b4 50 " text.split('\\n').forEach(parseArpLine);\n"
andrewboyson 88:2857259fc2b4 51 "}\n"
andrewboyson 88:2857259fc2b4 52 "function parseDnsLines(text)\n"
andrewboyson 88:2857259fc2b4 53 "{\n"
andrewboyson 88:2857259fc2b4 54 " dns = '';\n"
andrewboyson 88:2857259fc2b4 55 " text.split('\\n').forEach(parseDnsLine);\n"
andrewboyson 88:2857259fc2b4 56 "}\n"
andrewboyson 89:615fb951df69 57 "function parseGenLines(text)\n"
andrewboyson 89:615fb951df69 58 "{\n"
andrewboyson 96:eb2eb75bad0f 59 " let lines = text.split('\\n');\n"
andrewboyson 89:615fb951df69 60 " \n"
andrewboyson 96:eb2eb75bad0f 61 " hopLimit = parseInt(lines[ 1], 16);\n"
andrewboyson 96:eb2eb75bad0f 62 " managed = Net.hexToBit(lines[ 0], 0);\n"
andrewboyson 96:eb2eb75bad0f 63 " other = Net.hexToBit(lines[ 0], 1);\n"
andrewboyson 96:eb2eb75bad0f 64 " routerMac = Net.makeMac (lines[ 2], 16);\n"
andrewboyson 96:eb2eb75bad0f 65 " prefixLength = parseInt(lines[ 3], 16);\n"
andrewboyson 96:eb2eb75bad0f 66 " prefixL = Net.hexToBit(lines[ 0], 2);\n"
andrewboyson 96:eb2eb75bad0f 67 " prefixA = Net.hexToBit(lines[ 0], 3);\n"
andrewboyson 96:eb2eb75bad0f 68 " prefixLimit = parseInt(lines[ 4], 16);\n"
andrewboyson 96:eb2eb75bad0f 69 " prefixPreferred = parseInt(lines[ 5], 16);\n"
andrewboyson 96:eb2eb75bad0f 70 " prefix = Net.makeIp6 (lines[ 6] );\n"
andrewboyson 96:eb2eb75bad0f 71 " dnsLife = parseInt(lines[ 7], 16);\n"
andrewboyson 96:eb2eb75bad0f 72 " dnsIp = Net.makeIp6 (lines[ 8] );\n"
andrewboyson 96:eb2eb75bad0f 73 " ndpLease = parseInt(lines[ 9], 16);\n"
andrewboyson 96:eb2eb75bad0f 74 " ndpElapsed = parseInt(lines[10], 16);\n"
andrewboyson 96:eb2eb75bad0f 75 " slaac = Net.makeIp6 (lines[11] );\n"
andrewboyson 96:eb2eb75bad0f 76 " mtu = parseInt(lines[12], 16);\n"
andrewboyson 89:615fb951df69 77 "}\n"
andrewboyson 96:eb2eb75bad0f 78 "function parse()\n"
andrewboyson 86:f3c9beec4ee7 79 "{\n"
andrewboyson 96:eb2eb75bad0f 80 " let topics = Ajax.response.split('\\f');\n"
andrewboyson 89:615fb951df69 81 " parseGenLines(topics[0]);\n"
andrewboyson 89:615fb951df69 82 " parseArpLines(topics[1]);\n"
andrewboyson 89:615fb951df69 83 " parseDnsLines(topics[2]);\n"
andrewboyson 86:f3c9beec4ee7 84 "}\n"
andrewboyson 96:eb2eb75bad0f 85 "function display()\n"
andrewboyson 86:f3c9beec4ee7 86 "{\n"
andrewboyson 96:eb2eb75bad0f 87 " let elem;\n"
andrewboyson 89:615fb951df69 88 " \n"
andrewboyson 96:eb2eb75bad0f 89 " elem = Ajax.getElementOrNull('ajax-arp' ); if (elem) elem.textContent = arp;\n"
andrewboyson 96:eb2eb75bad0f 90 " elem = Ajax.getElementOrNull('ajax-dns' ); if (elem) elem.textContent = dns;\n"
andrewboyson 96:eb2eb75bad0f 91 " elem = Ajax.getElementOrNull('ajax-hop-limit' ); if (elem) elem.textContent = hopLimit;\n"
andrewboyson 96:eb2eb75bad0f 92 " elem = Ajax.getElementOrNull('ajax-managed' ); if (elem) elem.setAttribute('dir', managed ? 'rtl' : 'ltr');\n"
andrewboyson 96:eb2eb75bad0f 93 " elem = Ajax.getElementOrNull('ajax-other' ); if (elem) elem.setAttribute('dir', other ? 'rtl' : 'ltr');\n"
andrewboyson 96:eb2eb75bad0f 94 " elem = Ajax.getElementOrNull('ajax-router-mac' ); if (elem) elem.textContent = routerMac;\n"
andrewboyson 96:eb2eb75bad0f 95 " elem = Ajax.getElementOrNull('ajax-prefix-length' ); if (elem) elem.textContent = prefixLength;\n"
andrewboyson 96:eb2eb75bad0f 96 " elem = Ajax.getElementOrNull('ajax-prefix-l' ); if (elem) elem.setAttribute('dir', prefixL ? 'rtl' : 'ltr');\n"
andrewboyson 96:eb2eb75bad0f 97 " elem = Ajax.getElementOrNull('ajax-prefix-a' ); if (elem) elem.setAttribute('dir', prefixA ? 'rtl' : 'ltr');\n"
andrewboyson 96:eb2eb75bad0f 98 " elem = Ajax.getElementOrNull('ajax-prefix-limit' ); if (elem) elem.textContent = prefixLimit;\n"
andrewboyson 96:eb2eb75bad0f 99 " elem = Ajax.getElementOrNull('ajax-prefix-preferred'); if (elem) elem.textContent = prefixPreferred;\n"
andrewboyson 96:eb2eb75bad0f 100 " elem = Ajax.getElementOrNull('ajax-prefix' ); if (elem) elem.textContent = prefix;\n"
andrewboyson 96:eb2eb75bad0f 101 " elem = Ajax.getElementOrNull('ajax-dns-life' ); if (elem) elem.textContent = dnsLife;\n"
andrewboyson 96:eb2eb75bad0f 102 " elem = Ajax.getElementOrNull('ajax-dns-ip' ); if (elem) elem.textContent = dnsIp;\n"
andrewboyson 96:eb2eb75bad0f 103 " elem = Ajax.getElementOrNull('ajax-ndp-lease' ); if (elem) elem.textContent = ndpLease;\n"
andrewboyson 96:eb2eb75bad0f 104 " elem = Ajax.getElementOrNull('ajax-ndp-elapsed' ); if (elem) elem.textContent = ndpElapsed;\n"
andrewboyson 96:eb2eb75bad0f 105 " elem = Ajax.getElementOrNull('ajax-slaac' ); if (elem) elem.textContent = slaac;\n"
andrewboyson 96:eb2eb75bad0f 106 " elem = Ajax.getElementOrNull('ajax-mtu' ); if (elem) elem.textContent = mtu;\n"
andrewboyson 86:f3c9beec4ee7 107 "}\n"
andrewboyson 86:f3c9beec4ee7 108 "\n"
andrewboyson 96:eb2eb75bad0f 109 "Ajax.server = '/net6-ajax';\n"
andrewboyson 96:eb2eb75bad0f 110 "Ajax.onResponse = function() { parse(); display(); };\n"
andrewboyson 96:eb2eb75bad0f 111 "Ajax.init();"