Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

## Unreleased

- **The Car Report no longer carries the unit's mobile-data address.** Its iptables dump only had
MAC addresses taken out, and Android's own chains (`st_mangle_EXEMPT`) hold the unit's
current mobile-data address and its carrier's servers. The rules are now scrubbed like the
routes: public and carrier-NAT addresses become `a.b.x.x`, private ones and everything else in
the rules stay.

- **A fresh install's Settings → Phone projection no longer shows an error.** The page read
`/data/hmgapi/public/state.json`, which HMG-API writes at the first mod change or Apply, so
before then it said "Can't read HMG-API's state: … ENOENT". With no file it now says no mod
Expand Down
8 changes: 5 additions & 3 deletions core/runtime/java/hmgapi/engine/NetReport.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,11 @@ static Map<String, Object> collect(Engine e) {
for (String v : new String[] { "4", "6" }) {
for (String t : new String[] { "filter", "nat", "mangle" }) {
if ("6".equals(v) && "nat".equals(t)) continue;
ipt.put(v + " " + t, macs(run(tool(v), "-t", t, "-S")));
// scrubbed like the routes: Android's own chains (netd's st_*, bw_*, natctrl_*) hold
// the unit's mobile-data address and its carrier's servers, filled in at runtime
ipt.put(v + " " + t, scrub(run(tool(v), "-t", t, "-S")));
}
ipt.put(v + " counters", macs(run(tool(v), "-L", "-n", "-v", "-x")));
ipt.put(v + " counters", scrub(run(tool(v), "-L", "-n", "-v", "-x")));
}
n.put("iptables", ipt);
n.put("interfaces", scrub(run("ip", "-o", "addr", "show")));
Expand Down Expand Up @@ -138,7 +140,7 @@ static List<Object> services(Engine e) {
static final Pattern V4 = Pattern.compile("(?<![\\d.])(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})(?![\\d.])");
static final Pattern V6 = Pattern.compile("(?i)(?<![0-9a-f:])([0-9a-f]{1,4}(?::[0-9a-f]{1,4}){7}|[0-9a-f]{0,4}(?::[0-9a-f]{0,4})*::(?:[0-9a-f]{1,4}(?::[0-9a-f]{1,4})*)?)(?![0-9a-f:])");

/** MAC addresses out (rules and scripts: the rest is the stock image's) */
/** MAC addresses out (the stock firewall script: the rest is the stock image's) */
static String macs(String s) {
return Report.SECRETS[0].matcher(MAC_FIELD.matcher(s).replaceAll("MAC=[removed]")).replaceAll("[removed]");
}
Expand Down
6 changes: 5 additions & 1 deletion core/runtime/net-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ printf '#!/system/bin/sh\niptables -P INPUT DROP\niptables -N WL_NCM0_IN\n' > "$
echo 0 > "$R/proc/sys/net/ipv4/ip_forward"
cat > "$B/iptables" <<'S'
#!/bin/sh
case "$*" in *-S*) printf -- '-P INPUT DROP\n-N WLIST_IN\n-N WL_NCM0_IN\n-A WL_NCM0_IN -p tcp --dport 7000 -j ACCEPT\n' ;; *) echo "Chain INPUT (policy DROP 12 packets, 3400 bytes)" ;; esac
case "$*" in *-S*) printf -- '-P INPUT DROP\n-N WLIST_IN\n-N WL_NCM0_IN\n-A WL_NCM0_IN -p tcp --dport 7000 -j ACCEPT\n-A st_mangle_EXEMPT -d 100.77.12.34/32 -j MARK --set-xmark 0x1/0xffffffff\n-A st_mangle_EXEMPT -d 198.51.100.7/32 -j MARK --set-xmark 0x1/0xffffffff\n-A st_mangle_EXEMPT -d 172.16.172.10/32 -j MARK --set-xmark 0x1/0xffffffff\n' ;; *) printf 'Chain INPUT (policy DROP 12 packets, 3400 bytes)\nChain st_mangle_EXEMPT (1 references)\n 0 0 MARK all -- * * 0.0.0.0/0 100.77.12.34 MARK set 0x1\n' ;; esac
S
cp "$B/iptables" "$B/ip6tables"
cat > "$B/ip" <<'S'
Expand Down Expand Up @@ -273,6 +273,10 @@ hasnt "report: no MAC from links" "00:1a:2b" "$j"
hasnt "report: no phone address (link-local from its MAC)" "1c2d" "$j"
has "report: link-local kept as such" "SRC=fe80::[removed]" "$j"
hasnt "report: no modem IPv4" "100.77.12.34" "$j"
has "report: Android's mobile-data chain kept, its addresses scrubbed" "-A st_mangle_EXEMPT -d 100.77.x.x/32 -j MARK" "$j"
hasnt "report: no carrier server IPv4 from the rules" "198.51.100.7" "$j"
has "report: private addresses in the rules kept" "172.16.172.10/32" "$j"
has "report: the rules' ports and policies kept" "-A WL_NCM0_IN -p tcp --dport 7000 -j ACCEPT" "$j"
has "report: ... cut to its network" "inet 100.77.x.x/30" "$j"
hasnt "report: no modem IPv6" "b04e" "$j"
has "report: hotspot address kept" "inet 192.168.0.1/24" "$j"
Expand Down
Loading