[ufp v2] ufp: write oui info to ieee-oui.txt
Christian Korber
ckorber at tdt.de
Thu Apr 23 01:52:33 PDT 2026
This commit writes connected device's information (oui and vendor) to
ieee-oui.txt for arp-scan if export is set to true.
This way there is no unneccessary big file on the target.
CHANGE to v1: corrected the patch for upstream and included an option
`export` to choose if it is activated.
Signed-off-by: Christian Korber <ckorber at tdt.de>
---
ufpd | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 52 insertions(+), 2 deletions(-)
diff --git a/ufpd b/ufpd
index c41ab8c..da988ac 100755
--- a/ufpd
+++ b/ufpd
@@ -3,7 +3,7 @@
import * as uloop from "uloop";
import * as libubus from "ubus";
import * as unetmsg from "unetmsg.client";
-import { readfile, glob, basename } from "fs";
+import { readfile, glob, basename, open, stat, mkdir } from "fs";
let uht = require("uht");
push(REQUIRE_SEARCH_PATH, "/usr/share/ufp/*.uc");
@@ -365,7 +365,8 @@ global.ubus_object = {
macaddr: "",
ubus_rpc_session: "",
weight: false,
- local: false
+ local: false,
+ export: false
},
call: function(req) {
refresh_plugins();
@@ -373,6 +374,7 @@ global.ubus_object = {
let cur_devices = network_devices(req.args.local);
let mac_list = req.args.macaddr ? [ req.args.macaddr ] : keys(cur_devices);
let ret = {};
+ let to_file = req.args.export;
for (let mac in mac_list) {
let match_list = device_match_list(mac, cur_devices);
@@ -398,6 +400,54 @@ global.ubus_object = {
}
}
+ /*
+ * We want to populate ieee-oui.txt in order to
+ * use it for arp-scan. This way we don't need a
+ * large file too big in size, but rather rely on
+ * found data via ubus call 'fingerprint'.
+ * ieee-oui.txt will be updated on every call to:
+ * `ubus call fingerprint fingerprint`.
+ */
+
+ if(to_file) {
+ const tmp_dir = '/tmp/arp-scan';
+ const ieee_file = sprintf('%s/ieee-oui.txt', tmp_dir);
+ let ouis_added = [];
+
+ if (!stat(tmp_dir))
+ mkdir(tmp_dir);
+
+ const fd = open(ieee_file, 'a+');
+
+ /*
+ * check for duplicate ouis
+ */
+ for (let line = fd.read('line'); length(line); line = fd.read('line')) {
+ let oui = split(line, '\t')[0];
+ oui = uc(oui);
+
+ if (index(ouis_added, oui) < 0)
+ push(ouis_added, oui);
+ }
+
+ /*
+ * write to ieee-oui.txt
+ */
+ for (let entry in ret) {
+ let vendor = ret[entry].vendor;
+ let oui = split(entry, ':');
+ oui = join('', slice(oui, 0,3));
+ oui = uc(oui);
+
+ if (index(ouis_added, oui) < 0) {
+ let line = sprintf('%s\t%s\n', oui, vendor);
+ fd.write(line);
+ }
+ }
+
+ fd.close();
+ }
+
return req.args.macaddr ? ret[req.args.macaddr] : ret;
}
},
--
2.47.3
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 6005 bytes
Desc: not available
URL: <http://lists.openwrt.org/pipermail/openwrt-devel/attachments/20260423/bd90d362/attachment.bin>
More information about the openwrt-devel
mailing list