最近、イギリスのグラスゴー大学(UofG)心理学部に所属するパブロ・アリアス・サラ氏ら研究チームは、使用者たちが気づかないレベルでリアルタイムに画面上の顔を操作するAI顔フィルターを開発しました。
⇧「AI顔フィルター」を検出する機能も合わせて提供してくれれば、
『この人は「AI顔フィルター」を使うような人なんやな、さいなら』みたいな感じになりそうですけどね。
信用の無い人とは、長続きしない気がするんですけどね。
Ruby製のライブラリOxidizedの各modelクラスのコマンドの数を把握したかったが...
このブログで何回か話に出てきてる、
Oxidized is a network device configuration backup tool. It's a RANCID replacement!
It is light and extensible and supports over 130 operating system types.
⇧「Oxidized」という「Ruby」製のライブラリがあるのだけど、
⇧ modelクラスが用意されており、「OS(Operation System)」毎にクラスが用意されており、コマンドも異なりますと。
2024年11月8日(金)時点で、176ファイル用意されておりました。
で、流石に、1ファイルずつ確認したくなくて、何とか抽出できないかJavaで試してみたのだけど、「Oxidized」のコーディングが無法地帯なだけのか、「Ruby」のコーディングが無法地帯なのかが分からんのだが、書きっぷりのパターンに統一感が無く、結局のところの目視で確認するしか無さそうなんよね...
Javaで試してみた。
■/poc-search-cmd/src/CmdExtractor.java
import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.nio.file.StandardOpenOption; import java.util.LinkedHashSet; import java.util.Set; public class CmdExtractor { public static void main(String[] args) { // 対象ディレクトリのパスを指定 Path dirPath = Paths.get("E:\\soft_work\\oxidized\\lib\\oxidized\\model"); // 出力ファイルのパスを指定(例:output.csv) Path outputPath = Paths.get("output.tsv"); try (BufferedWriter writer = Files.newBufferedWriter(outputPath, StandardOpenOption.CREATE)) { // TSVヘッダを書き込む writer.write("番号\tファイル名\tコマンド数\tコマンド\n"); // 番号を付けるカウンター(ファイルに対して番号を付ける) // 番号をカウントするための配列 final int[] counter = { 1 }; // ディレクトリ内のすべてのファイルを再帰的に探索 Files.walk(dirPath) .filter(Files::isRegularFile) // ファイルのみ対象 .forEach(filePath -> processFile(filePath, writer, counter)); // 各ファイルを処理 } catch (IOException e) { e.printStackTrace(); } } // ファイルを処理するメソッド private static void processFile(Path filePath, BufferedWriter writer, int[] counter) { try (BufferedReader reader = Files.newBufferedReader(filePath)) { String line; // シングルクォーテーションまたはダブルクォーテーションで囲まれた部分を抽出するパターン // Pattern pattern = Pattern.compile("\"([^\"]*)\"|'([^']*)'"); // ダブルクォートとシングルクォートを両方サポート Set<String> commands = new LinkedHashSet<>(); while ((line = reader.readLine()) != null) { line = line.trim(); if (line.startsWith("cmd")) { int cmdStartPosition = "cmd".length() + 1; int cmdEndPosition = line.lastIndexOf("do"); System.out.println("文字数:" + line.length()); System.out.println("文字列:" + line); System.out.println("コマンド開始位置:" + cmdStartPosition); System.out.println("コマンド終了位置:" + cmdEndPosition); // ブロックが無いパターン if (cmdEndPosition == -1) { commands.add(line.substring(cmdStartPosition, line.length())); } else { commands.add(line.substring(cmdStartPosition, cmdEndPosition)); } } } // コマンドが1つ以上見つかった場合、または見つからない場合でもファイル名とコマンド数を出力 String fileName = filePath.getFileName().toString(); int commandCount = commands.size(); // コマンド数 // コマンドがあればカンマ区切りで出力、なければ空欄 String commandsStr = commandCount > 0 ? String.join("\t", commands) : ""; // 書き込み writer.write(counter[0] + "\t" + fileName + "\t" + commandCount + "\t" + commandsStr + "\n"); // 番号をインクリメント counter[0]++; } catch (IOException e) { e.printStackTrace(); } } }
で、実行すると、TSV形式のファイルが出力される。
■/poc-search-cmd/output.tsv
番号 ファイル名 コマンド数 コマンド 1 acmepacket.rb 6 :all 'show version' 'show running-config' "enable" "enable", /^[pP]assword:/ vars(:enable) 2 acos.rb 10 :secret 'show version' 'show bootimage' 'show license' 'show partition-config all' 'show running-config all-partitions' 'show aflex all-partitions' :all "show aflex #{name} partition #{partition}") pw 3 acsw.rb 6 :all :secret 'show version' 'show inventory' 'show running-config' vars(:enable) 4 addpack.rb 2 'enable' 'show running-config' 5 adtran.rb 4 :all :secret 'show running-config' vars(:enable) 6 adva.rb 7 :secret :all 'show running-config delta' 'show system' 'network-element ne-1' 'show shelf-info' 'show ports' 7 aen.rb 2 'configuration generate-script module all' :all 8 aireos.rb 4 :all 'show udi' 'show boot' 'show run-config commands' 9 airfiber.rb 2 :all 'cat /tmp/system.cfg' 10 airos.rb 4 'cat /etc/board.info' 'cat /etc/version' 'sort /tmp/system.cfg' :secret 11 alteonos.rb 2 :secret 'cfg/dump' 12 alvarion.rb 1 "#{node.auth[:password]}.cfg" 13 aos.rb 7 :all 'show system' 'show chassis' 'show hardware info' 'show license info' 'show license file' 'show configuration snapshot' 14 aos7.rb 6 :all 'show system' 'show chassis' 'show hardware-info' 'show running-directory' 'show configuration snapshot' 15 aoscx.rb 9 :all :secret 'show version' 'show environment' 'show module' 'show interface transceiver' 'show system | exclude "Up Time" | exclude "CPU" | exclude "Memory" | exclude "Pkts .x" | exclude "Lowest" | exclude "Missed"' 'show running-config' vars(:enable) 16 aosw.rb 9 :all :secret 'show version' 'show inventory' 'show slots' 'show license' 'show license passphrase' 'show running-config' vars(:enable) 17 apc_aos.rb 1 'config.ini' 18 arbos.rb 3 'system hardware' 'system version' 'config show' 19 aricentiss.rb 4 :all :secret 'show system information' 'show running-config' 20 asa.rb 12 :all :secret 'show mode' 'show version' 'show inventory' vars(:enable) 'more system:running-config' "more" + profile) "more disk0:/dap.xml" 'changeto system' 'show running-config' "more " + files[i].join(" ") 21 asternos.rb 3 :all 'show version' "show runningconfiguration all" 22 asyncos.rb 2 'version' 'showconfig' 23 audiocodes.rb 1 "show running-config\r\n" 24 audiocodesmp.rb 2 'conf' 'cf get' 25 awplus.rb 6 :all :secret 'Show System' 'show running-config' vars(:enable) + "\r\n" 'enable' # Required for Priv-Exec users without enable PW to be put into "enable mode". 26 axos.rb 2 'show running-config | nomore' :all 27 bdcom.rb 9 :secret :all 'show running-config' 'show version' 'show power-status' 'show fan-status' "enable" "enable", /^[pP]assword:/ vars(:enable) 28 boss.rb 4 '') { |cfg| comment "#{cfg}\n" } 'show sys-info' 'show stack-info' 'show running-config' 29 br6910.rb 4 :all 'show version' 'dir' 'show running-config' 30 c4cmts.rb 5 :all :secret 'show factory-eeprom' 'show version' 'show running-config' 31 cambium.rb 1 cfg_cb 32 cambiumepmp.rb 2 :all 'config show json' 33 casa.rb 6 :secret :all 'show system' 'show version' 'show run' vars(:enable) 34 catos.rb 5 :all 'show system' 'show version' 'show conf all' vars(:enable) 35 ciscoce.rb 1 "/level/15/exec/-/show/startup-config" 36 cisconga.rb 2 'show version' 'show configuration' 37 ciscosma.rb 2 'version' 'showconfig' 38 ciscosmb.rb 8 :all :secret 'show version' 'show bootvar' 'show running-config' 'enable' 'enable', /^\r?Password:$/ vars(:enable) 39 ciscovpn3k.rb 1 'CONFIG' 40 cnos.rb 5 :secret :all 'show version' 'show transceiver' 'show running-config' 41 comnetms.rb 4 :all 'show running-config' 'show version' vars(:enable) 42 comtrol.rb 2 'show version' 'show running-config' 43 comware.rb 15 :all :secret "super" "super", /^\s?[pP]assword:/ vars(:enable) '_cmdline-mode on', /(#{@node.prompt}|Continue)/ 'y', /(#{@node.prompt}|input password)/ vars(:comware_cmdline) 'xtd-cli-mode on', /(#{@node.prompt}|Continue)/ 'xtd-cli-mode', /(#{@node.prompt}|Continue|Switch)/ 'y', /(#{@node.prompt}|input password|Password:)/ 'display version' 'display device' 'display device manuinfo' 'display current-configuration' 44 coriant8600.rb 3 'show hw-inventory' 'show flash' 'show run' 45 coriantgroove.rb 4 :all 'show inventory' 'show softwareload' 'show config | display commands' 46 corianttmos.rb 2 'show node extensive' 'show run' 47 cumulus.rb 7 :all :secret "sudo su -", /^\[su @node.auth[:password] "su -", /^Password:/ vars(:enable) "exit" if vars(:enable) 48 datacom.rb 4 :all 'show firmware' 'show system' 'show running-config' 49 dcnos.rb 6 :all 'show version' 'show boot-files' 'show flash' 'show running-config' vars(:enable) 50 dellx.rb 6 :all :secret 'show version' 'show system' 'show running-config' vars(:enable) 51 dlink.rb 5 :secret :all 'show switch' 'show vlan' 'show config current' 52 dlinknextgen.rb 6 :all :secret 'show switch' 'show version' 'show vlan' 'show running-config' 53 dnos.rb 7 :all :secret 'show inventory' 'show inventory media' 'show version' 'show running-config' vars(:enable) 54 eciapollo.rb 7 :all :secret 'show version') { |cfg| comment cfg } 'show system licenses') { |cfg| comment cfg } 'show configuration') { |cfg| comment cfg } 'show configuration | display-set') { |cfg| cfg } 'show chassis inventory') { |cfg| comment cfg } 55 edgecos.rb 7 :secret :all 'show running-config' 'show system' 'show version' 'show watchdog' 'show interfaces transceiver' 56 edgeos.rb 4 :all :secret 'show version | no-more' 'show configuration commands | no-more' 57 edgeswitch.rb 5 'show running-config' "enable" "enable", /^[pP]assword:/ vars(:enable) 'terminal length 0' 58 eltex.rb 6 :all :secret 'show running-config' "enable" "enable", /^[pP]assword:/ vars(:enable) 59 enterasys.rb 4 :all 'show system hardware' 'show version' 'show config' 60 enterasys800.rb 2 :all 'show config effective' 61 eos.rb 4 :all :secret 'show inventory | no-more' 'show running-config | no-more | exclude ! Time:' 62 f5os.rb 2 'show running-config' 'paginate false' 63 fabricos.rb 2 'chassisShow' 'configShow -all' 64 fastiron.rb 10 :all 'show version' 'show module' 'show media | exclude EMPTY' 'show hardware-info' 'show stack' 'show running-config' "enable" "enable", /[pP]assword:/ vars(:enable) 65 fiberdriver.rb 3 :all 'show inventory' "show running-config" 66 firebrick.rb 3 :all 'show status' 'show configuration' 67 firelinuxos.rb 5 :all :secret 'show version system' 'show inventory' 'show running-config all' 68 firewareos.rb 3 :all 'show sysinfo' 'export config to console' 69 fortios.rb 3 :all :secret 'get system status' 70 fortiwlc.rb 4 :all 'show controller' 'show ap' 'show running-config' 71 fsos.rb 3 :secret 'show version' 'show running-config' 72 ftos.rb 5 :all :secret 'show inventory' 'show inventory media' 'show running-config' 73 fujitsupy.rb 4 :all 'show version' 'show system information' 'show running-config' 74 gaiaos.rb 8 :all :secret 'show vsx' 'show asset all' 'show version all' 'show configuration' 'show virtual-system all' "set virtual-system #{item[0]}" 75 garderos.rb 5 :all 'show system version' 'show system serial' 'show hardware wwan wwan0 sim' 'show configuration running' 76 gcombnps.rb 6 :all :secret 'show running-config' 'show interface sfp' 'show version' 'show system' 77 grandstream.rb 2 "/cgi-bin/dologin?password=%<password>s" "/cgi-bin/ 78 h3c.rb 5 :secret :all 'display version' 'display device' 'display current-configuration' 79 hatteras.rb 6 :secret :all "show switch\r" "show card\r" "show sfp *\r" "show config run\r" 80 hios.rb 3 :all 'show system info' 'show running-config script' 81 hirschmann.rb 3 :all 'show sysinfo' 'show running-config' 82 hpebladesystem.rb 15 :all :secret 'show oa info' 'show oa network' 'show oa certificate' 'show sshfingerprint' 'show fru' 'show network' 'show vlan' 'show rack name' 'show server list' 'show server names' 'show server port map all' 'show server info all' 'show config' 83 hpemsa.rb 1 'show configuration' 84 hpmsm.rb 10 :all :secret 'show system info' 'show ip' 'show ip route' 'show certificate' 'show certificate binding' 'show satellites' 'show web content' 'show all config' 85 ibos.rb 7 :all :secret 'show version' 'show running-config' "enable" "enable", /^[pP]assword:/ vars(:enable) 86 icotera.rb 3 :all 'show management' 'copy progress screen' 87 ios.rb 11 :all :secret 'show version' 'show vtp status' 'show inventory' line = 'show running-config' line += ' view full' if vars(:ios_rbac) cmd_line "enable" "enable", /^[pP]assword:/ vars(:enable) 88 iosxe.rb 0 89 iosxr.rb 5 :all :secret 'show inventory all' 'show platform' 'show running-config' 90 ipos.rb 6 'show chassis' 'show hardware' 'show release' 'show configuration' "enable" vars(:enable) 91 ironware.rb 7 :all 'show version' 'show chassis' 'show flash' 'show module' 'show running-config' vars(:enable) 92 isam.rb 4 :all 'show software-mngt oswp detail' 'show equipment slot detail' 'info configure flat' 93 junos.rb 7 :all :secret 'show version' 'show chassis hardware') { |cfg| comment cfg } 'show system license') 'show system license keys') { |cfg| comment cfg } 'show configuration | display omit' 94 lancom.rb 2 "sysinfo\r" "readscript\r" 95 lenovonos.rb 10 :all :secret 'show version' 'show boot' 'show transceiver' 'show software-key' 'show running-config' "enable" "enable", /^[pP]assword:/ vars(:enable) 96 linksyssrw.rb 5 :all :secret 'show startup-config' 'show version' 'show system' 97 linuxgeneric.rb 6 :all "sudo su -", /^\[su @node.auth[:password] "su -", /^Password:/ vars(:enable) "exit" if vars(:enable) 98 masteros.rb 6 :secret :all 'show inventory' 'show plugins' 'show hw-config' 'show running-config' 99 mimosab11.rb 1 cfg_cb 100 ml66.rb 5 'show version' 'show inventory hw all' 'show inventory sw all' 'show license status all' 'show running-config' 101 mlnxos.rb 6 :all :secret 'show version' 'show inventory' 'enable' 'show running-config' 102 model.rb 0 103 mtrlrfs.rb 4 :all 'show version' 'show licenses' 'show running-config' 104 ndms.rb 2 'show version' 'show running-config' 105 necix.rb 1 'show running-config' 106 netgear.rb 8 :secret "enable" "enable", /[pP]assword:\s?$/ vars(:enable) :all 'show version' 'show bootvar' 'show running-config' 107 netonix.rb 2 :all 'cat config.json;echo' 108 netscaler.rb 7 :all 'show version' 'show hardware' 'show partition' :secret 'show ns ns.conf' "switch ns partition " + part.join(" ") + "; show ns ns.conf; switch ns partition default" 109 nodegrid.rb 3 'show system/about/' 'show settings/license/' 'export_settings settings/ --plain-password' 110 nos.rb 6 :all 'show version' 'show inventory' 'show license' 'show chassis' 'show running-config | nomore' 111 nsxconfig.rb 1 "/api/4.0/edges/" 112 nsxdfw.rb 1 "/policy/api/v1/infra/domains/" 113 nsxfirewall.rb 1 "/api/4.0/edges/" 114 nxos.rb 4 :secret 'show version' 'show inventory' 'show running-config' 115 ocnos.rb 7 :all 'show version' 'show system fru' 'show system-information board-info' 'show forwarding profile limit' 'show license' 'show running-config' 116 onefinity.rb 2 :all 'show configuration | display set | nomore' 117 oneos.rb 7 :all :secret 'show version' 'show system hardware' 'show product-info-area' 'show running-config' vars(:enable) 118 openbsd.rb 1 :all 119 opengear.rb 6 :secret 'cat /etc/version') { |cfg| comment cfg } 'ogdeviceinfo -r' 'config export' 'showserial' 'config -g config' 120 openwrt.rb 5 'cat /etc/banner' 'cat /proc/cpuinfo' 'cat /etc/openwrt_release' 'sysupgrade -l' 'cat /proc/mtd' 121 opnsense.rb 2 'cat /conf/config.xml' 'opnsense-version || echo "OPNsense "`cat /usr/local/opnsense/version/opnsense`' 122 os10.rb 6 :all :secret 'show inventory' 'show inventory media' 'show running-configuration' vars(:enable) 123 os6.rb 6 :all :secret 'show version' 'show interfaces transceiver properties' 'show running-config' vars(:enable) 124 outputs.rb 0 125 panos.rb 3 :all 'show system info' 'show config running' 126 panos_api.rb 1 cfg_cb 127 pfsense.rb 3 :secret 'cat /cf/conf/config.xml' 'cat /etc/version' 128 planet.rb 5 :all :secret 'show version' 'show running-config' vars(:enable) 129 powerconnect.rb 8 :all :secret 'show version' 'show system' 'show running-config' "enable" "enable", /[pP]assword:/ vars(:enable) 130 procurve.rb 10 :all :secret 'show version' 'show modules' 'show interfaces transceiver' 'show flash' 'show system-information' 'show system information' 'show running-config' vars(:enable) 131 purityos.rb 1 'pureconfig list' 132 qtech.rb 8 :all :secret 'show version' 'show running-config' "enable" "enable", /^[pP]assword:/ vars(:enable) 'terminal length 0' 133 quantaos.rb 2 'show run' vars(:enable) || "" 134 raisecom.rb 2 'show version' 'show running-config' 135 rgos.rb 3 :secret 'show version' 'show running-config' 136 routeros.rb 5 :all '/system resource print' '/system package update print' '/system history print without-paging' run_cmd 137 saos.rb 5 :all 'chassis show device-id power' 'software show' 'port xcvr show' 'configuration show' 138 screenos.rb 4 :all :secret 'get system' 'get config' 139 sgos.rb 6 :all 'show licenses' 'show general' :secret 'show configuration expanded noprompts with-keyrings unencrypted' vars(:enable) 140 siklu.rb 2 'copy startup-configuration display' 'copy running-configuration display' 141 siklumhtg.rb 1 'show startup' 142 slxos.rb 6 'show version' 'show chassis' 'show system' 'show slots' 'show running-config' vars(:enable) 143 smartax.rb 1 'display current-configuration' 144 smartcs.rb 4 :all 'show version' 'show config' pw 145 sonicos.rb 4 :all :secret 'show version' 'show current-config' 146 speedtouch.rb 2 ':env list' ':config dump' 147 sros.rb 10 :all 'show bof' 'show system information' 'show card state' 'show chassis' 'file type bootlog.txt' 'show debug' 'file type config.dbg' "admin display-config index\n" "admin display-config\n" 148 srosmd.rb 10 :all 'show system information' 'show card state' 'show chassis' 'file show bootlog.txt' 'admin show configuration debug full-context' 'file show config.dbg' 'admin show configuration configure | match persistent-indices post-lines 10000' 'admin show configuration bof full-context' 'admin show configuration configure full-context' 149 stoneos.rb 3 :all 'show configuration running' 'show version' 150 supermicro.rb 0 151 swos.rb 1 '/backup.swb' 152 tdre.rb 2 "get -f" :all 153 telco.rb 2 :all 'show running-config' 154 timos.rb 0 155 tmos.rb 12 :secret 'tmsh -q show sys version') { |cfg| comment cfg } 'tmsh -q show sys software') { |cfg| comment cfg } 'tmsh -q show sys hardware field-fmt' 'cat /config/bigip.license') { |cfg| comment cfg } 'tmsh -q list' 'tmsh -q list net route all') { |cfg| comment cfg } '/bin/ls --full-time --color=never /config/ssl/ssl.crt') { |cfg| comment cfg } '/bin/ls --full-time --color=never /config/ssl/ssl.key') { |cfg| comment cfg } 'tmsh -q show running-config sys db all-properties' '[ -d "/config/zebos" ] && cat /config/zebos/*/ZebOS.conf') { |cfg| comment cfg } 'cat /config/partitions/*/bigip*.conf') { |cfg| comment cfg } 156 tplink.rb 6 :all :secret 'show system-info' 'show running-config' "enable" vars(:enable) 157 trango.rb 1 'sysinfo' 158 truenas.rb 3 'uname -a') { |cfg| comment cfg } 'cat /etc/version') { |cfg| comment cfg } 'sqlite3 "file:///data/freenas-v1.db?mode=ro&immutable=1" .dump') 159 ucs.rb 4 'show version brief' 'show chassis detail' 'show fabric-interconnect detail' 'show configuration all | no-more' 160 uplinkolt.rb 7 :all 'configure terminal' 'show version' 'show running-config' "enable" "enable", /^[pP]assword:/ vars(:enable) 161 viptela.rb 4 :all :secret 'show running-config' 'show version' 162 voltaire.rb 7 :all :secret 'version show' 'firmware-version show' 'remote show' 'sm-info show' ' show' 163 voss.rb 3 '') { |cfg| comment "#{cfg}\n" } 'show sys-info' 'more config.cfg' 164 vrp.rb 5 :secret :all 'display version' 'display device' 'display current-configuration all' 165 vyatta.rb 4 :all :secret 'show version' 'show configuration commands | no-more' 166 weos.rb 2 :all 'show running-config' 167 xos.rb 9 :all :secret 'show version' 'show diagnostics' 'show licenses' 'show switch' 'show configuration' 'show policy detail' 'disable clipaging' 168 yamaha.rb 6 :all 'show config' "administrator" "administrator", /^[pP]assword:/ vars(:enable) 'exit' 169 zhoneolt.rb 7 :secret :all 'swversion' 'slots' 'eeshow card' 'ethrpshow' 'dump console' 170 zteolt.rb 8 :all :secret 'show version-running' 'show patch-running' 'show running-config' "enable" "enable", /^[pP]assword:/ vars(:enable) 171 zy1308.rb 1 '/config_OLT-1308S-22.log' 172 zynos.rb 8 :all :secret 'show version' 'show system-information' 'show running-config' "enable" "enable", /^[pP]assword:/ vars(:enable) 173 zynosadsl.rb 1 'config show all nopause' 174 zynoscli.rb 4 :all 'show stacking' 'show version' 'show running-config' 175 zynosgs.rb 1 'show running-config' 176 zynosmgs.rb 2 'show version' 'show running-config'
何と言うか、「Oxidized」がイケてないのか、「Ruby」がイケてないのか分からんのだけど、なかなかの地獄ですな...
毎度モヤモヤ感が半端ない…
今回はこのへんで。