porchwatch 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- porchwatch-0.1.0/LICENSE +158 -0
- porchwatch-0.1.0/MANIFEST.in +3 -0
- porchwatch-0.1.0/PKG-INFO +229 -0
- porchwatch-0.1.0/README.md +216 -0
- porchwatch-0.1.0/examples/config.toml +21 -0
- porchwatch-0.1.0/porchwatch/__init__.py +2 -0
- porchwatch-0.1.0/porchwatch/__main__.py +3 -0
- porchwatch-0.1.0/porchwatch/alerts.py +115 -0
- porchwatch-0.1.0/porchwatch/cli.py +286 -0
- porchwatch-0.1.0/porchwatch/config.py +42 -0
- porchwatch-0.1.0/porchwatch/network.py +261 -0
- porchwatch-0.1.0/porchwatch/safety.py +217 -0
- porchwatch-0.1.0/porchwatch/state.py +113 -0
- porchwatch-0.1.0/porchwatch.egg-info/PKG-INFO +229 -0
- porchwatch-0.1.0/porchwatch.egg-info/SOURCES.txt +24 -0
- porchwatch-0.1.0/porchwatch.egg-info/dependency_links.txt +1 -0
- porchwatch-0.1.0/porchwatch.egg-info/entry_points.txt +2 -0
- porchwatch-0.1.0/porchwatch.egg-info/requires.txt +3 -0
- porchwatch-0.1.0/porchwatch.egg-info/top_level.txt +1 -0
- porchwatch-0.1.0/pyproject.toml +24 -0
- porchwatch-0.1.0/setup.cfg +4 -0
- porchwatch-0.1.0/tests/conftest.py +63 -0
- porchwatch-0.1.0/tests/test_alerts.py +45 -0
- porchwatch-0.1.0/tests/test_cli.py +311 -0
- porchwatch-0.1.0/tests/test_network.py +162 -0
- porchwatch-0.1.0/tests/test_safety.py +37 -0
porchwatch-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction, and
|
|
10
|
+
distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by the copyright
|
|
13
|
+
owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all other entities
|
|
16
|
+
that control, are controlled by, or are under common control with that entity.
|
|
17
|
+
For the purposes of this definition, "control" means (i) the power, direct or
|
|
18
|
+
indirect, to cause the direction or management of such entity, whether by
|
|
19
|
+
contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
20
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
21
|
+
|
|
22
|
+
"You" (or "Your") shall mean an individual or Legal Entity exercising
|
|
23
|
+
permissions granted by this License.
|
|
24
|
+
|
|
25
|
+
"Source" form shall mean the preferred form for making modifications, including
|
|
26
|
+
but not limited to software source code, documentation source, and configuration
|
|
27
|
+
files.
|
|
28
|
+
|
|
29
|
+
"Object" form shall mean any form resulting from mechanical transformation or
|
|
30
|
+
translation of a Source form, including but not limited to compiled object code,
|
|
31
|
+
generated documentation, and conversions to other media types.
|
|
32
|
+
|
|
33
|
+
"Work" shall mean the work of authorship, whether in Source or Object form,
|
|
34
|
+
made available under the License, as indicated by a copyright notice that is
|
|
35
|
+
included in or attached to the work.
|
|
36
|
+
|
|
37
|
+
"Derivative Works" shall mean any work, whether in Source or Object form, that
|
|
38
|
+
is based on (or derived from) the Work and for which the editorial revisions,
|
|
39
|
+
annotations, elaborations, or other modifications represent, as a whole, an
|
|
40
|
+
original work of authorship. For the purposes of this License, Derivative Works
|
|
41
|
+
shall not include works that remain separable from, or merely link (or bind by
|
|
42
|
+
name) to the interfaces of, the Work and Derivative Works thereof.
|
|
43
|
+
|
|
44
|
+
"Contribution" shall mean any work of authorship, including the original
|
|
45
|
+
version of the Work and any modifications or additions to that Work or
|
|
46
|
+
Derivative Works thereof, that is intentionally submitted to Licensor for
|
|
47
|
+
inclusion in the Work by the copyright owner or by an individual or Legal Entity
|
|
48
|
+
authorized to submit on behalf of the copyright owner. For the purposes of this
|
|
49
|
+
definition, "submitted" means any form of electronic, verbal, or written
|
|
50
|
+
communication sent to the Licensor or its representatives, including but not
|
|
51
|
+
limited to communication on electronic mailing lists, source code control
|
|
52
|
+
systems, and issue tracking systems that are managed by, or on behalf of, the
|
|
53
|
+
Licensor for the purpose of discussing and improving the Work, but excluding
|
|
54
|
+
communication that is conspicuously marked or otherwise designated in writing by
|
|
55
|
+
the copyright owner as "Not a Contribution."
|
|
56
|
+
|
|
57
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf
|
|
58
|
+
of whom a Contribution has been received by Licensor and subsequently
|
|
59
|
+
incorporated within the Work.
|
|
60
|
+
|
|
61
|
+
2. Grant of Copyright License. Subject to the terms and conditions of this
|
|
62
|
+
License, each Contributor hereby grants to You a perpetual, worldwide,
|
|
63
|
+
non-exclusive, no-charge, royalty-free, irrevocable copyright license to
|
|
64
|
+
reproduce, prepare Derivative Works of, publicly display, publicly perform,
|
|
65
|
+
sublicense, and distribute the Work and such Derivative Works in Source or
|
|
66
|
+
Object form.
|
|
67
|
+
|
|
68
|
+
3. Grant of Patent License. Subject to the terms and conditions of this License,
|
|
69
|
+
each Contributor hereby grants to You a perpetual, worldwide, non-exclusive,
|
|
70
|
+
no-charge, royalty-free, irrevocable patent license to make, have made, use,
|
|
71
|
+
offer to sell, sell, import, and otherwise transfer the Work, where such license
|
|
72
|
+
applies only to those patent claims licensable by such Contributor that are
|
|
73
|
+
necessarily infringed by their Contribution(s) alone or by combination of their
|
|
74
|
+
Contribution(s) with the Work to which such Contribution(s) was submitted. If
|
|
75
|
+
You institute patent litigation against any entity (including a cross-claim or
|
|
76
|
+
counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated
|
|
77
|
+
within the Work constitutes direct or contributory patent infringement, then any
|
|
78
|
+
patent licenses granted to You under this License for that Work shall terminate
|
|
79
|
+
as of the date such litigation is filed.
|
|
80
|
+
|
|
81
|
+
4. Redistribution. You may reproduce and distribute copies of the Work or
|
|
82
|
+
Derivative Works thereof in any medium, with or without modifications, and in
|
|
83
|
+
Source or Object form, provided that You meet the following conditions:
|
|
84
|
+
|
|
85
|
+
(a) You must give any other recipients of the Work or Derivative Works a copy of
|
|
86
|
+
this License; and
|
|
87
|
+
|
|
88
|
+
(b) You must cause any modified files to carry prominent notices stating that
|
|
89
|
+
You changed the files; and
|
|
90
|
+
|
|
91
|
+
(c) You must retain, in the Source form of any Derivative Works that You
|
|
92
|
+
distribute, all copyright, patent, trademark, and attribution notices from the
|
|
93
|
+
Source form of the Work, excluding those notices that do not pertain to any part
|
|
94
|
+
of the Derivative Works; and
|
|
95
|
+
|
|
96
|
+
(d) If the Work includes a "NOTICE" text file as part of its distribution, then
|
|
97
|
+
any Derivative Works that You distribute must include a readable copy of the
|
|
98
|
+
attribution notices contained within such NOTICE file, excluding those notices
|
|
99
|
+
that do not pertain to any part of the Derivative Works, in at least one of the
|
|
100
|
+
following places: within a NOTICE text file distributed as part of the
|
|
101
|
+
Derivative Works; within the Source form or documentation, if provided along
|
|
102
|
+
with the Derivative Works; or, within a display generated by the Derivative
|
|
103
|
+
Works, if and wherever such third-party notices normally appear. The contents of
|
|
104
|
+
the NOTICE file are for informational purposes only and do not modify the
|
|
105
|
+
License. You may add Your own attribution notices within Derivative Works that
|
|
106
|
+
You distribute, alongside or as an addendum to the NOTICE text from the Work,
|
|
107
|
+
provided that such additional attribution notices cannot be construed as
|
|
108
|
+
modifying the License.
|
|
109
|
+
|
|
110
|
+
You may add Your own copyright statement to Your modifications and may provide
|
|
111
|
+
additional or different license terms and conditions for use, reproduction, or
|
|
112
|
+
distribution of Your modifications, or for any such Derivative Works as a whole,
|
|
113
|
+
provided Your use, reproduction, and distribution of the Work otherwise complies
|
|
114
|
+
with the conditions stated in this License.
|
|
115
|
+
|
|
116
|
+
5. Submission of Contributions. Unless You explicitly state otherwise, any
|
|
117
|
+
Contribution intentionally submitted for inclusion in the Work by You to the
|
|
118
|
+
Licensor shall be under the terms and conditions of this License, without any
|
|
119
|
+
additional terms or conditions. Notwithstanding the above, nothing herein shall
|
|
120
|
+
supersede or modify the terms of any separate license agreement you may have
|
|
121
|
+
executed with Licensor regarding such Contributions.
|
|
122
|
+
|
|
123
|
+
6. Trademarks. This License does not grant permission to use the trade names,
|
|
124
|
+
trademarks, service marks, or product names of the Licensor, except as required
|
|
125
|
+
for reasonable and customary use in describing the origin of the Work and
|
|
126
|
+
reproducing the content of the NOTICE file.
|
|
127
|
+
|
|
128
|
+
7. Disclaimer of Warranty. Unless required by applicable law or agreed to in
|
|
129
|
+
writing, Licensor provides the Work (and each Contributor provides its
|
|
130
|
+
Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
131
|
+
KIND, either express or implied, including, without limitation, any warranties or
|
|
132
|
+
conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
133
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
134
|
+
appropriateness of using or redistributing the Work and assume any risks
|
|
135
|
+
associated with Your exercise of permissions under this License.
|
|
136
|
+
|
|
137
|
+
8. Limitation of Liability. In no event and under no legal theory, whether in
|
|
138
|
+
tort (including negligence), contract, or otherwise, unless required by
|
|
139
|
+
applicable law (such as deliberate and grossly negligent acts) or agreed to in
|
|
140
|
+
writing, shall any Contributor be liable to You for damages, including any
|
|
141
|
+
direct, indirect, special, incidental, or consequential damages of any character
|
|
142
|
+
arising as a result of this License or out of the use or inability to use the
|
|
143
|
+
Work (including but not limited to damages for loss of goodwill, work stoppage,
|
|
144
|
+
computer failure or malfunction, or any and all other commercial damages or
|
|
145
|
+
losses), even if such Contributor has been advised of the possibility of such
|
|
146
|
+
damages.
|
|
147
|
+
|
|
148
|
+
9. Accepting Warranty or Additional Liability. While redistributing the Work or
|
|
149
|
+
Derivative Works thereof, You may choose to offer, and charge a fee for,
|
|
150
|
+
acceptance of support, warranty, indemnity, or other liability obligations
|
|
151
|
+
and/or rights consistent with this License. However, in accepting such
|
|
152
|
+
obligations, You may act only on Your own behalf and on Your sole
|
|
153
|
+
responsibility, not on behalf of any other Contributor, and only if You agree to
|
|
154
|
+
indemnify, defend, and hold each Contributor harmless for any liability incurred
|
|
155
|
+
by, or claims asserted against, such Contributor by reason of your accepting any
|
|
156
|
+
such warranty or additional liability.
|
|
157
|
+
|
|
158
|
+
END OF TERMS AND CONDITIONS
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: porchwatch
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Private, passive home-LAN newcomer notices
|
|
5
|
+
License-Expression: Apache-2.0
|
|
6
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
7
|
+
Classifier: Programming Language :: Python :: 3
|
|
8
|
+
Requires-Python: >=3.10
|
|
9
|
+
Description-Content-Type: text/markdown
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Requires-Dist: tomli>=2; python_version < "3.11"
|
|
12
|
+
Dynamic: license-file
|
|
13
|
+
|
|
14
|
+
# Porch Watch
|
|
15
|
+
|
|
16
|
+
Porch Watch notices new MAC addresses in the existing home-LAN neighbor cache.
|
|
17
|
+
Initialize it once at home to mark current devices as known, then review newcomer
|
|
18
|
+
notices and add your own labels. A randomized MAC gets an informational notice:
|
|
19
|
+
phones often rotate private MACs, so a new address need not mean a new device.
|
|
20
|
+
|
|
21
|
+
Built and maintained by Dragon Lady — [GitHub](https://github.com/Dragon-Lady).
|
|
22
|
+
|
|
23
|
+
## Posture
|
|
24
|
+
|
|
25
|
+
- Linux first, Python 3.10 or newer. Apache-2.0.
|
|
26
|
+
- Passive by default: reads kernel neighbor/routing tables without sending
|
|
27
|
+
discovery packets. No telemetry, DNS lookups, hostnames, mDNS, DHCP scraping,
|
|
28
|
+
router login, blocking, port scans, OS fingerprinting, or service discovery.
|
|
29
|
+
- Only its own state and explicitly requested local reports are written.
|
|
30
|
+
Configuration and local vendor tables are read-only. There is no root use.
|
|
31
|
+
- Alert delivery is opt-in through `alert_channels`. Active host discovery is
|
|
32
|
+
separately opt-in with `scan --active`. Neither is enabled by a printed timer.
|
|
33
|
+
- Local state/report metadata includes MACs, last IPs, user labels, vendor,
|
|
34
|
+
randomized flag, and first/last observation rounded down to the UTC hour.
|
|
35
|
+
These reports are private. No packet contents or address history are kept.
|
|
36
|
+
- Off-box alerts contain only newcomer counts, rule ID, and severity. They never
|
|
37
|
+
contain MACs, IPs, labels, vendors, paths, hostnames, or machine identifiers.
|
|
38
|
+
- Recognized provider-token shapes in labels/vendor text and configured alert
|
|
39
|
+
credentials are replaced by keyed fingerprints. Never enter passwords or
|
|
40
|
+
arbitrary secrets as device labels: this is not a general secret detector.
|
|
41
|
+
- The home gateway uses an HMAC-SHA256 fingerprint (`fp:` plus 16 hex digits)
|
|
42
|
+
with a private random 32-byte key. No plain hash is used.
|
|
43
|
+
- State directory: 0700. Every state/report file: 0600 at creation. Unsafe
|
|
44
|
+
existing modes are refused; source permissions are never changed. Reports
|
|
45
|
+
are create-only and cannot overwrite an existing file or tool state.
|
|
46
|
+
|
|
47
|
+
## Install
|
|
48
|
+
|
|
49
|
+
Install the published package, or install from a source checkout:
|
|
50
|
+
|
|
51
|
+
```sh
|
|
52
|
+
python3 -m pip install porchwatch==0.1.0
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
```sh
|
|
56
|
+
python3 -m venv .venv
|
|
57
|
+
.venv/bin/python -m pip install .
|
|
58
|
+
.venv/bin/porchwatch --help
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Runtime uses the standard library and `tomli` only on Python 3.10. Building uses
|
|
62
|
+
setuptools; tests use pytest. No packages are installed during a scan. On Linux,
|
|
63
|
+
iproute2 supplies the passive `ip` commands; nmap is optional and is never
|
|
64
|
+
installed or elevated by Porch Watch.
|
|
65
|
+
|
|
66
|
+
## Commands
|
|
67
|
+
|
|
68
|
+
Run `init` only while connected to the home network you intend to monitor. It
|
|
69
|
+
trusts that network as home; it cannot determine that a network belongs to you.
|
|
70
|
+
|
|
71
|
+
```sh
|
|
72
|
+
porchwatch init
|
|
73
|
+
porchwatch scan
|
|
74
|
+
porchwatch scan --format html --output porchwatch-report.html
|
|
75
|
+
porchwatch list --unlabeled --since 7d
|
|
76
|
+
porchwatch label 00:11:22:33:44:66 "Living room TV"
|
|
77
|
+
porchwatch known 00:11:22:33:44:66
|
|
78
|
+
porchwatch report --since 7d
|
|
79
|
+
porchwatch report --send
|
|
80
|
+
porchwatch forget 00:11:22:33:44:66
|
|
81
|
+
porchwatch print-timer --interval 15m
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
All commands accept `--format text|json|md|html` and `--output FILE`. Output is
|
|
85
|
+
also printed to stdout. Labels are escaped in HTML/Markdown output; text output
|
|
86
|
+
removes control characters. `--since` filters by last observation, with UTC-hour
|
|
87
|
+
precision; it is not a scan-history view. `report --send` retries only pending
|
|
88
|
+
notices in that report's selected window.
|
|
89
|
+
|
|
90
|
+
`init` imports every current device as unlabeled-known and sends no alerts. It
|
|
91
|
+
will never overwrite existing initialization. Each subsequently discovered MAC
|
|
92
|
+
is alerted once per configured channel. Successful channel receipts persist;
|
|
93
|
+
failed channels retry on `scan` or `report --send`. Labeling or marking a device
|
|
94
|
+
known suppresses pending notices. Forgetting removes its record and delivery
|
|
95
|
+
receipts, allowing a fresh notice if it is observed again. Changing/rotating a
|
|
96
|
+
channel's destination does not replay already delivered notices for that channel.
|
|
97
|
+
|
|
98
|
+
For a first home baseline, keep remote alert channels disabled, run `init` while
|
|
99
|
+
present on the intended network, and review `list` before configuring delivery
|
|
100
|
+
or a timer. The operator decides which devices are normal; the tool cannot make
|
|
101
|
+
that judgment.
|
|
102
|
+
|
|
103
|
+
Exit status: `0` no newly observed MACs (or not home), `1` newcomer(s), `2`
|
|
104
|
+
usage/runtime/alert-delivery error. An alert failure does not drop the newcomer:
|
|
105
|
+
the next run retries it. A fresh scan with only already-notified devices exits 0.
|
|
106
|
+
|
|
107
|
+
## Home-network guard
|
|
108
|
+
|
|
109
|
+
Before writing state, a key, a report, or delivery receipts, and before sending
|
|
110
|
+
alerts, Porch Watch requires an existing neighbor-cache MAC for the IPv4 default
|
|
111
|
+
gateway. A unique default interface and connected gateway subnet must be present.
|
|
112
|
+
The gateway fingerprint and subnet must match the initialized home identity.
|
|
113
|
+
Missing, ambiguous, or mismatched identity yields `not home`, exit 0, no alert,
|
|
114
|
+
and no writes. `init` with insufficient evidence exits 2 and creates nothing.
|
|
115
|
+
It never probes a missing gateway to make the guard pass.
|
|
116
|
+
|
|
117
|
+
The guard also covers `label`, `known`, `forget`, and report file output. Lists
|
|
118
|
+
and local reports conservatively return `not home` when identity is unknown.
|
|
119
|
+
Printing a timer to stdout needs no network or initialization. An interrupted
|
|
120
|
+
initialization or missing key is not silently repaired; preserve the state for
|
|
121
|
+
inspection and recovery. Deliberately re-initializing on a different network
|
|
122
|
+
requires you to archive the old private state yourself.
|
|
123
|
+
|
|
124
|
+
Home identity is advisory: cached entries can be stale, MACs can be spoofed, and
|
|
125
|
+
a router replacement looks like a different home. Checks are snapshots, repeated
|
|
126
|
+
before active discovery, state writes, and alert delivery; no user-space tool can
|
|
127
|
+
atomically bind routing changes and an external delivery transaction. A crash
|
|
128
|
+
after remote acceptance but before saving a receipt can produce a retry. There
|
|
129
|
+
is no claim of exactly-once delivery across crashes or provider timeouts.
|
|
130
|
+
|
|
131
|
+
## Passive and active coverage
|
|
132
|
+
|
|
133
|
+
Passive mode runs only these read operations (actual executable path resolved
|
|
134
|
+
locally):
|
|
135
|
+
|
|
136
|
+
```text
|
|
137
|
+
ip -j -4 route show table all
|
|
138
|
+
ip -j neigh show
|
|
139
|
+
ip -j -4 rule show
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
Neighbor states REACHABLE, STALE, DELAY, and PERMANENT are accepted. FAILED,
|
|
143
|
+
INCOMPLETE, and other states are ignored. IPv4 and IPv6 cache entries on the
|
|
144
|
+
selected interface are deduplicated by MAC; one deterministic last IP is stored,
|
|
145
|
+
preferring IPv4. IPv6-only home-gateway initialization is not supported in v0.1.
|
|
146
|
+
Without `ip`, `/proc/net/route` and `/proc/net/arp` provide an IPv4-only passive
|
|
147
|
+
fallback; proc files are accessed through this process's numeric proc directory
|
|
148
|
+
to avoid following `/proc/net` symlinks. No root or nmap is needed for passive use.
|
|
149
|
+
Cache visibility is limited: a silent device may never appear, and a disappearing
|
|
150
|
+
device is not considered removed. This is not an exhaustive network inventory.
|
|
151
|
+
|
|
152
|
+
For an explicit local host-discovery run:
|
|
153
|
+
|
|
154
|
+
```sh
|
|
155
|
+
porchwatch scan --active
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
The only permitted discovery command is `nmap -sn -n <subnet>`. There is no
|
|
159
|
+
user-supplied target, additional flag, port scan, DNS, or privilege elevation.
|
|
160
|
+
Only an exact, directly connected RFC1918 IPv4 subnet on the default-route
|
|
161
|
+
interface, at /22 or smaller, passes. All-table route evidence and standard
|
|
162
|
+
IPv4 policy rules are required. Public, CGNAT, link-local, overly broad,
|
|
163
|
+
overlapping, other-interface, multipath, or policy-routing ambiguity fails closed.
|
|
164
|
+
The proc fallback cannot authorize active mode. If the subnet is safe but nmap
|
|
165
|
+
is missing, the command reports `nmap not installed; passive fallback`.
|
|
166
|
+
|
|
167
|
+
After discovery, Porch Watch rechecks home identity and reads the kernel cache;
|
|
168
|
+
it does not ingest nmap's output or hostnames. Unprivileged nmap host discovery
|
|
169
|
+
may use TCP connection probes and may find fewer devices than privileged ARP
|
|
170
|
+
discovery. `-sn` disables the port-scan phase; it does not mean no TCP packets.
|
|
171
|
+
See the [ip neighbor manual](https://man7.org/linux/man-pages/man8/ip-neighbour.8.html)
|
|
172
|
+
and [nmap host-discovery reference](https://nmap.org/book/man-host-discovery.html).
|
|
173
|
+
|
|
174
|
+
Vendor lookup uses only `/usr/share/ieee-data/oui.txt` or
|
|
175
|
+
`/usr/share/nmap/nmap-mac-prefixes` if present and under the 5 MB read limit.
|
|
176
|
+
Locally administered MACs do not receive an OUI vendor guess. Missing vendor
|
|
177
|
+
data is harmless; it is never downloaded.
|
|
178
|
+
|
|
179
|
+
## Configuration and state
|
|
180
|
+
|
|
181
|
+
Configuration defaults to `~/.config/porchwatch/config.toml`; state defaults to
|
|
182
|
+
`~/.local/state/porchwatch/`. `XDG_CONFIG_HOME` and `XDG_STATE_HOME` are respected.
|
|
183
|
+
An alternate config is selected before the command:
|
|
184
|
+
|
|
185
|
+
```sh
|
|
186
|
+
porchwatch --config ~/.config/porchwatch/config.toml scan
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
Configuration must be owned by the current user, 0600, and a regular file.
|
|
190
|
+
Porch Watch does not create or edit it. [examples/config.toml](examples/config.toml)
|
|
191
|
+
documents the accepted keys. An absent config, empty `alert_channels`, or
|
|
192
|
+
`["stdout"]` keeps alert handling local. There are no per-MAC remote payloads.
|
|
193
|
+
|
|
194
|
+
Slack webhooks, ntfy tokens, and SMTP passwords come from environment variable
|
|
195
|
+
**names**, never inline config credentials. HTTP endpoints require HTTPS except
|
|
196
|
+
on literal loopback/localhost; redirects are rejected. SMTP requires TLS except
|
|
197
|
+
on loopback. Delivery has a 5-second timeout per channel. Error messages do not
|
|
198
|
+
echo provider errors, URLs, labels, or credential values.
|
|
199
|
+
|
|
200
|
+
Private state consists of:
|
|
201
|
+
|
|
202
|
+
| File | Contents |
|
|
203
|
+
| --- | --- |
|
|
204
|
+
| `devices.json` | Only MAC, first_seen, last_seen, label, vendor, randomized, last_ip per device |
|
|
205
|
+
| `home.json` | Gateway MAC HMAC and initialized subnet |
|
|
206
|
+
| `fp.key` | Random 32-byte HMAC key |
|
|
207
|
+
| `alerts.json` | HMAC identities of known devices and permanent channel delivery receipts |
|
|
208
|
+
| `lock` | Empty advisory lock, preventing overlapping local state updates |
|
|
209
|
+
|
|
210
|
+
The extra receipt state is necessary to keep the specified device schema intact
|
|
211
|
+
while supporting known devices, once-per-channel notices, and failure retries.
|
|
212
|
+
No report/history file is automatically accumulated.
|
|
213
|
+
|
|
214
|
+
## Scheduling and verification
|
|
215
|
+
|
|
216
|
+
`print-timer` prints a systemd **user** service and timer; it installs or enables
|
|
217
|
+
nothing. The printed service expects a `~/.local/bin/porchwatch` executable:
|
|
218
|
+
adjust its path to your chosen environment before a separate manual installation.
|
|
219
|
+
It treats finding exit code 1 as success and runs passive scans only. Configure
|
|
220
|
+
remote channels and their environment separately before scheduling if desired.
|
|
221
|
+
|
|
222
|
+
```sh
|
|
223
|
+
python -m pytest
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
Tests use a fake HOME/XDG tree, fixture routes/neighbors, mocked commands and
|
|
227
|
+
alert endpoints. They do not initialize a real network, execute nmap, install
|
|
228
|
+
timers, send alerts, or touch the real home. Installing the package does not
|
|
229
|
+
enable monitoring.
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
# Porch Watch
|
|
2
|
+
|
|
3
|
+
Porch Watch notices new MAC addresses in the existing home-LAN neighbor cache.
|
|
4
|
+
Initialize it once at home to mark current devices as known, then review newcomer
|
|
5
|
+
notices and add your own labels. A randomized MAC gets an informational notice:
|
|
6
|
+
phones often rotate private MACs, so a new address need not mean a new device.
|
|
7
|
+
|
|
8
|
+
Built and maintained by Dragon Lady — [GitHub](https://github.com/Dragon-Lady).
|
|
9
|
+
|
|
10
|
+
## Posture
|
|
11
|
+
|
|
12
|
+
- Linux first, Python 3.10 or newer. Apache-2.0.
|
|
13
|
+
- Passive by default: reads kernel neighbor/routing tables without sending
|
|
14
|
+
discovery packets. No telemetry, DNS lookups, hostnames, mDNS, DHCP scraping,
|
|
15
|
+
router login, blocking, port scans, OS fingerprinting, or service discovery.
|
|
16
|
+
- Only its own state and explicitly requested local reports are written.
|
|
17
|
+
Configuration and local vendor tables are read-only. There is no root use.
|
|
18
|
+
- Alert delivery is opt-in through `alert_channels`. Active host discovery is
|
|
19
|
+
separately opt-in with `scan --active`. Neither is enabled by a printed timer.
|
|
20
|
+
- Local state/report metadata includes MACs, last IPs, user labels, vendor,
|
|
21
|
+
randomized flag, and first/last observation rounded down to the UTC hour.
|
|
22
|
+
These reports are private. No packet contents or address history are kept.
|
|
23
|
+
- Off-box alerts contain only newcomer counts, rule ID, and severity. They never
|
|
24
|
+
contain MACs, IPs, labels, vendors, paths, hostnames, or machine identifiers.
|
|
25
|
+
- Recognized provider-token shapes in labels/vendor text and configured alert
|
|
26
|
+
credentials are replaced by keyed fingerprints. Never enter passwords or
|
|
27
|
+
arbitrary secrets as device labels: this is not a general secret detector.
|
|
28
|
+
- The home gateway uses an HMAC-SHA256 fingerprint (`fp:` plus 16 hex digits)
|
|
29
|
+
with a private random 32-byte key. No plain hash is used.
|
|
30
|
+
- State directory: 0700. Every state/report file: 0600 at creation. Unsafe
|
|
31
|
+
existing modes are refused; source permissions are never changed. Reports
|
|
32
|
+
are create-only and cannot overwrite an existing file or tool state.
|
|
33
|
+
|
|
34
|
+
## Install
|
|
35
|
+
|
|
36
|
+
Install the published package, or install from a source checkout:
|
|
37
|
+
|
|
38
|
+
```sh
|
|
39
|
+
python3 -m pip install porchwatch==0.1.0
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
```sh
|
|
43
|
+
python3 -m venv .venv
|
|
44
|
+
.venv/bin/python -m pip install .
|
|
45
|
+
.venv/bin/porchwatch --help
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Runtime uses the standard library and `tomli` only on Python 3.10. Building uses
|
|
49
|
+
setuptools; tests use pytest. No packages are installed during a scan. On Linux,
|
|
50
|
+
iproute2 supplies the passive `ip` commands; nmap is optional and is never
|
|
51
|
+
installed or elevated by Porch Watch.
|
|
52
|
+
|
|
53
|
+
## Commands
|
|
54
|
+
|
|
55
|
+
Run `init` only while connected to the home network you intend to monitor. It
|
|
56
|
+
trusts that network as home; it cannot determine that a network belongs to you.
|
|
57
|
+
|
|
58
|
+
```sh
|
|
59
|
+
porchwatch init
|
|
60
|
+
porchwatch scan
|
|
61
|
+
porchwatch scan --format html --output porchwatch-report.html
|
|
62
|
+
porchwatch list --unlabeled --since 7d
|
|
63
|
+
porchwatch label 00:11:22:33:44:66 "Living room TV"
|
|
64
|
+
porchwatch known 00:11:22:33:44:66
|
|
65
|
+
porchwatch report --since 7d
|
|
66
|
+
porchwatch report --send
|
|
67
|
+
porchwatch forget 00:11:22:33:44:66
|
|
68
|
+
porchwatch print-timer --interval 15m
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
All commands accept `--format text|json|md|html` and `--output FILE`. Output is
|
|
72
|
+
also printed to stdout. Labels are escaped in HTML/Markdown output; text output
|
|
73
|
+
removes control characters. `--since` filters by last observation, with UTC-hour
|
|
74
|
+
precision; it is not a scan-history view. `report --send` retries only pending
|
|
75
|
+
notices in that report's selected window.
|
|
76
|
+
|
|
77
|
+
`init` imports every current device as unlabeled-known and sends no alerts. It
|
|
78
|
+
will never overwrite existing initialization. Each subsequently discovered MAC
|
|
79
|
+
is alerted once per configured channel. Successful channel receipts persist;
|
|
80
|
+
failed channels retry on `scan` or `report --send`. Labeling or marking a device
|
|
81
|
+
known suppresses pending notices. Forgetting removes its record and delivery
|
|
82
|
+
receipts, allowing a fresh notice if it is observed again. Changing/rotating a
|
|
83
|
+
channel's destination does not replay already delivered notices for that channel.
|
|
84
|
+
|
|
85
|
+
For a first home baseline, keep remote alert channels disabled, run `init` while
|
|
86
|
+
present on the intended network, and review `list` before configuring delivery
|
|
87
|
+
or a timer. The operator decides which devices are normal; the tool cannot make
|
|
88
|
+
that judgment.
|
|
89
|
+
|
|
90
|
+
Exit status: `0` no newly observed MACs (or not home), `1` newcomer(s), `2`
|
|
91
|
+
usage/runtime/alert-delivery error. An alert failure does not drop the newcomer:
|
|
92
|
+
the next run retries it. A fresh scan with only already-notified devices exits 0.
|
|
93
|
+
|
|
94
|
+
## Home-network guard
|
|
95
|
+
|
|
96
|
+
Before writing state, a key, a report, or delivery receipts, and before sending
|
|
97
|
+
alerts, Porch Watch requires an existing neighbor-cache MAC for the IPv4 default
|
|
98
|
+
gateway. A unique default interface and connected gateway subnet must be present.
|
|
99
|
+
The gateway fingerprint and subnet must match the initialized home identity.
|
|
100
|
+
Missing, ambiguous, or mismatched identity yields `not home`, exit 0, no alert,
|
|
101
|
+
and no writes. `init` with insufficient evidence exits 2 and creates nothing.
|
|
102
|
+
It never probes a missing gateway to make the guard pass.
|
|
103
|
+
|
|
104
|
+
The guard also covers `label`, `known`, `forget`, and report file output. Lists
|
|
105
|
+
and local reports conservatively return `not home` when identity is unknown.
|
|
106
|
+
Printing a timer to stdout needs no network or initialization. An interrupted
|
|
107
|
+
initialization or missing key is not silently repaired; preserve the state for
|
|
108
|
+
inspection and recovery. Deliberately re-initializing on a different network
|
|
109
|
+
requires you to archive the old private state yourself.
|
|
110
|
+
|
|
111
|
+
Home identity is advisory: cached entries can be stale, MACs can be spoofed, and
|
|
112
|
+
a router replacement looks like a different home. Checks are snapshots, repeated
|
|
113
|
+
before active discovery, state writes, and alert delivery; no user-space tool can
|
|
114
|
+
atomically bind routing changes and an external delivery transaction. A crash
|
|
115
|
+
after remote acceptance but before saving a receipt can produce a retry. There
|
|
116
|
+
is no claim of exactly-once delivery across crashes or provider timeouts.
|
|
117
|
+
|
|
118
|
+
## Passive and active coverage
|
|
119
|
+
|
|
120
|
+
Passive mode runs only these read operations (actual executable path resolved
|
|
121
|
+
locally):
|
|
122
|
+
|
|
123
|
+
```text
|
|
124
|
+
ip -j -4 route show table all
|
|
125
|
+
ip -j neigh show
|
|
126
|
+
ip -j -4 rule show
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
Neighbor states REACHABLE, STALE, DELAY, and PERMANENT are accepted. FAILED,
|
|
130
|
+
INCOMPLETE, and other states are ignored. IPv4 and IPv6 cache entries on the
|
|
131
|
+
selected interface are deduplicated by MAC; one deterministic last IP is stored,
|
|
132
|
+
preferring IPv4. IPv6-only home-gateway initialization is not supported in v0.1.
|
|
133
|
+
Without `ip`, `/proc/net/route` and `/proc/net/arp` provide an IPv4-only passive
|
|
134
|
+
fallback; proc files are accessed through this process's numeric proc directory
|
|
135
|
+
to avoid following `/proc/net` symlinks. No root or nmap is needed for passive use.
|
|
136
|
+
Cache visibility is limited: a silent device may never appear, and a disappearing
|
|
137
|
+
device is not considered removed. This is not an exhaustive network inventory.
|
|
138
|
+
|
|
139
|
+
For an explicit local host-discovery run:
|
|
140
|
+
|
|
141
|
+
```sh
|
|
142
|
+
porchwatch scan --active
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
The only permitted discovery command is `nmap -sn -n <subnet>`. There is no
|
|
146
|
+
user-supplied target, additional flag, port scan, DNS, or privilege elevation.
|
|
147
|
+
Only an exact, directly connected RFC1918 IPv4 subnet on the default-route
|
|
148
|
+
interface, at /22 or smaller, passes. All-table route evidence and standard
|
|
149
|
+
IPv4 policy rules are required. Public, CGNAT, link-local, overly broad,
|
|
150
|
+
overlapping, other-interface, multipath, or policy-routing ambiguity fails closed.
|
|
151
|
+
The proc fallback cannot authorize active mode. If the subnet is safe but nmap
|
|
152
|
+
is missing, the command reports `nmap not installed; passive fallback`.
|
|
153
|
+
|
|
154
|
+
After discovery, Porch Watch rechecks home identity and reads the kernel cache;
|
|
155
|
+
it does not ingest nmap's output or hostnames. Unprivileged nmap host discovery
|
|
156
|
+
may use TCP connection probes and may find fewer devices than privileged ARP
|
|
157
|
+
discovery. `-sn` disables the port-scan phase; it does not mean no TCP packets.
|
|
158
|
+
See the [ip neighbor manual](https://man7.org/linux/man-pages/man8/ip-neighbour.8.html)
|
|
159
|
+
and [nmap host-discovery reference](https://nmap.org/book/man-host-discovery.html).
|
|
160
|
+
|
|
161
|
+
Vendor lookup uses only `/usr/share/ieee-data/oui.txt` or
|
|
162
|
+
`/usr/share/nmap/nmap-mac-prefixes` if present and under the 5 MB read limit.
|
|
163
|
+
Locally administered MACs do not receive an OUI vendor guess. Missing vendor
|
|
164
|
+
data is harmless; it is never downloaded.
|
|
165
|
+
|
|
166
|
+
## Configuration and state
|
|
167
|
+
|
|
168
|
+
Configuration defaults to `~/.config/porchwatch/config.toml`; state defaults to
|
|
169
|
+
`~/.local/state/porchwatch/`. `XDG_CONFIG_HOME` and `XDG_STATE_HOME` are respected.
|
|
170
|
+
An alternate config is selected before the command:
|
|
171
|
+
|
|
172
|
+
```sh
|
|
173
|
+
porchwatch --config ~/.config/porchwatch/config.toml scan
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
Configuration must be owned by the current user, 0600, and a regular file.
|
|
177
|
+
Porch Watch does not create or edit it. [examples/config.toml](examples/config.toml)
|
|
178
|
+
documents the accepted keys. An absent config, empty `alert_channels`, or
|
|
179
|
+
`["stdout"]` keeps alert handling local. There are no per-MAC remote payloads.
|
|
180
|
+
|
|
181
|
+
Slack webhooks, ntfy tokens, and SMTP passwords come from environment variable
|
|
182
|
+
**names**, never inline config credentials. HTTP endpoints require HTTPS except
|
|
183
|
+
on literal loopback/localhost; redirects are rejected. SMTP requires TLS except
|
|
184
|
+
on loopback. Delivery has a 5-second timeout per channel. Error messages do not
|
|
185
|
+
echo provider errors, URLs, labels, or credential values.
|
|
186
|
+
|
|
187
|
+
Private state consists of:
|
|
188
|
+
|
|
189
|
+
| File | Contents |
|
|
190
|
+
| --- | --- |
|
|
191
|
+
| `devices.json` | Only MAC, first_seen, last_seen, label, vendor, randomized, last_ip per device |
|
|
192
|
+
| `home.json` | Gateway MAC HMAC and initialized subnet |
|
|
193
|
+
| `fp.key` | Random 32-byte HMAC key |
|
|
194
|
+
| `alerts.json` | HMAC identities of known devices and permanent channel delivery receipts |
|
|
195
|
+
| `lock` | Empty advisory lock, preventing overlapping local state updates |
|
|
196
|
+
|
|
197
|
+
The extra receipt state is necessary to keep the specified device schema intact
|
|
198
|
+
while supporting known devices, once-per-channel notices, and failure retries.
|
|
199
|
+
No report/history file is automatically accumulated.
|
|
200
|
+
|
|
201
|
+
## Scheduling and verification
|
|
202
|
+
|
|
203
|
+
`print-timer` prints a systemd **user** service and timer; it installs or enables
|
|
204
|
+
nothing. The printed service expects a `~/.local/bin/porchwatch` executable:
|
|
205
|
+
adjust its path to your chosen environment before a separate manual installation.
|
|
206
|
+
It treats finding exit code 1 as success and runs passive scans only. Configure
|
|
207
|
+
remote channels and their environment separately before scheduling if desired.
|
|
208
|
+
|
|
209
|
+
```sh
|
|
210
|
+
python -m pytest
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
Tests use a fake HOME/XDG tree, fixture routes/neighbors, mocked commands and
|
|
214
|
+
alert endpoints. They do not initialize a real network, execute nmap, install
|
|
215
|
+
timers, send alerts, or touch the real home. Installing the package does not
|
|
216
|
+
enable monitoring.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# Example only. Create your private config at 0600 before using it.
|
|
2
|
+
# An absent config or empty list means local stdout only.
|
|
3
|
+
alert_channels = ["stdout"]
|
|
4
|
+
|
|
5
|
+
# Opt-in channels: stdout, slack, ntfy, email. Configure before scheduling.
|
|
6
|
+
# alert_channels = ["stdout", "slack"]
|
|
7
|
+
# alert_slack_webhook_env = "PORCHWATCH_SLACK_WEBHOOK"
|
|
8
|
+
|
|
9
|
+
# alert_ntfy_topic = "https://ntfy.example.invalid/topic"
|
|
10
|
+
# alert_ntfy_token_env = "PORCHWATCH_NTFY_TOKEN"
|
|
11
|
+
|
|
12
|
+
# alert_smtp_host = "smtp.example.invalid"
|
|
13
|
+
# alert_smtp_port = 587
|
|
14
|
+
# alert_smtp_security = "starttls" # ssl or starttls; none only on loopback
|
|
15
|
+
# alert_smtp_from = "monitor@example.invalid"
|
|
16
|
+
# alert_email = "operator@example.invalid"
|
|
17
|
+
# alert_smtp_username = "monitor"
|
|
18
|
+
# alert_smtp_password_env = "PW_SMTP_PASSWORD"
|
|
19
|
+
|
|
20
|
+
# Active discovery has no persistent config switch: use scan --active explicitly.
|
|
21
|
+
# Off-box payloads are aggregate counts/rule/severity only.
|