phronesis-nse 0.3.0__py3-none-any.whl

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.
Files changed (1001) hide show
  1. nmap_select.py +801 -0
  2. nse-library/EXCLUDED.md +4 -0
  3. nse-library/LICENSES/hackertarget-LICENSE +340 -0
  4. nse-library/LICENSES/nmap-NPSL.txt +583 -0
  5. nse-library/LICENSES/vulners-LICENSE +583 -0
  6. nse-library/README.md +15 -0
  7. nse-library/THIRD_PARTY_NOTICES.md +20 -0
  8. nse-library/catalog.jsonl +649 -0
  9. nse-library/community/cldrn/scripts/dns-cname-dangling.nse +504 -0
  10. nse-library/community/cldrn/scripts/dns-openresolvers-check.nse +84 -0
  11. nse-library/community/cldrn/scripts/google-people-enum.nse +213 -0
  12. nse-library/community/cldrn/scripts/hostmap-ip2hosts.nse +131 -0
  13. nse-library/community/cldrn/scripts/hostmap.nse +207 -0
  14. nse-library/community/cldrn/scripts/http-email-harvest.nse +59 -0
  15. nse-library/community/cldrn/scripts/http-httpoxy.nse +151 -0
  16. nse-library/community/cldrn/scripts/http-iis-shortname-dos.nse +53 -0
  17. nse-library/community/cldrn/scripts/http-phpselfxss-scan.nse +81 -0
  18. nse-library/community/cldrn/scripts/http-shellshock-spider.nse +74 -0
  19. nse-library/community/cldrn/scripts/http-sitemap-dump.nse +335 -0
  20. nse-library/community/cldrn/scripts/http-sitemap.nse +42 -0
  21. nse-library/community/cldrn/scripts/http-tomcat-brute.nse +116 -0
  22. nse-library/community/cldrn/scripts/http-trendnet-tvip110w.nse +39 -0
  23. nse-library/community/cldrn/scripts/http-wp-enum.nse +137 -0
  24. nse-library/community/cldrn/scripts/huawei5xx-udp-info.nse +103 -0
  25. nse-library/community/cldrn/scripts/nse-script-template.nse +21 -0
  26. nse-library/community/cldrn/scripts/smtp-dovecot-exim-exec.nse +110 -0
  27. nse-library/community/cldrn/scripts/vulscan.nse +538 -0
  28. nse-library/community/hackertarget/scripts/hostmap-hackertarget.nse +83 -0
  29. nse-library/community/hackertarget/scripts/http-wordpress-info.nse +227 -0
  30. nse-library/community/hackertarget/scripts/http-wordpress-plugins.nse +197 -0
  31. nse-library/community/hackertarget/scripts/http-wordpress-themes.nse +192 -0
  32. nse-library/community/personal/scripts/exploit-xunlei-rce.nse +6 -0
  33. nse-library/community/personal/scripts/my-dokuwiki-audit.nse +17 -0
  34. nse-library/community/psc4re/scripts/CVE-2021-21972.nse +89 -0
  35. nse-library/community/psc4re/scripts/cve-2020-0796.nse +101 -0
  36. nse-library/community/psc4re/scripts/cve-2020-1350.nse +89 -0
  37. nse-library/community/psc4re/scripts/http-custom-title.nse +99 -0
  38. nse-library/community/psc4re/scripts/proxyshell.nse +41 -0
  39. nse-library/manifest.json +4386 -0
  40. nse-library/nselib/afp.lua +2219 -0
  41. nse-library/nselib/ajp.lua +546 -0
  42. nse-library/nselib/amqp.lua +333 -0
  43. nse-library/nselib/anyconnect.lua +136 -0
  44. nse-library/nselib/asn1.lua +527 -0
  45. nse-library/nselib/base32.lua +245 -0
  46. nse-library/nselib/base64.lua +203 -0
  47. nse-library/nselib/bin.lua +367 -0
  48. nse-library/nselib/bitcoin.lua +628 -0
  49. nse-library/nselib/bits.lua +79 -0
  50. nse-library/nselib/bittorrent.lua +1053 -0
  51. nse-library/nselib/bjnp.lua +363 -0
  52. nse-library/nselib/brute.lua +1551 -0
  53. nse-library/nselib/cassandra.lua +190 -0
  54. nse-library/nselib/citrixxml.lua +528 -0
  55. nse-library/nselib/coap.lua +2675 -0
  56. nse-library/nselib/comm.lua +305 -0
  57. nse-library/nselib/creds.lua +541 -0
  58. nse-library/nselib/cvs.lua +96 -0
  59. nse-library/nselib/data/dns-srv-names +74 -0
  60. nse-library/nselib/data/drupal-modules.lst +17447 -0
  61. nse-library/nselib/data/drupal-themes.lst +1333 -0
  62. nse-library/nselib/data/enterprise_numbers.txt +59209 -0
  63. nse-library/nselib/data/favicon-db +133 -0
  64. nse-library/nselib/data/http-default-accounts-fingerprints.lua +1738 -0
  65. nse-library/nselib/data/http-devframework-fingerprints.lua +440 -0
  66. nse-library/nselib/data/http-fingerprints.lua +12859 -0
  67. nse-library/nselib/data/http-folders.txt +910 -0
  68. nse-library/nselib/data/http-sql-errors.lst +112 -0
  69. nse-library/nselib/data/http-web-files-extensions.lst +214 -0
  70. nse-library/nselib/data/idnaMappings.lua +13307 -0
  71. nse-library/nselib/data/ike-fingerprints.lua +2473 -0
  72. nse-library/nselib/data/jdwp-class/JDWPExecCmd.class +0 -0
  73. nse-library/nselib/data/jdwp-class/JDWPExecCmd.java +31 -0
  74. nse-library/nselib/data/jdwp-class/JDWPSystemInfo.class +0 -0
  75. nse-library/nselib/data/jdwp-class/JDWPSystemInfo.java +41 -0
  76. nse-library/nselib/data/jdwp-class/README.txt +26 -0
  77. nse-library/nselib/data/mgroupnames.db +485 -0
  78. nse-library/nselib/data/mysql-cis.audit +228 -0
  79. nse-library/nselib/data/oracle-default-accounts.lst +687 -0
  80. nse-library/nselib/data/oracle-sids +735 -0
  81. nse-library/nselib/data/packetdecoders.lua +951 -0
  82. nse-library/nselib/data/passwords.lst +5007 -0
  83. nse-library/nselib/data/pixel.gif +0 -0
  84. nse-library/nselib/data/psexec/README +15 -0
  85. nse-library/nselib/data/psexec/backdoor.lua +25 -0
  86. nse-library/nselib/data/psexec/default.lua +144 -0
  87. nse-library/nselib/data/psexec/drives.lua +47 -0
  88. nse-library/nselib/data/psexec/examples.lua +67 -0
  89. nse-library/nselib/data/psexec/experimental.lua +24 -0
  90. nse-library/nselib/data/psexec/network.lua +111 -0
  91. nse-library/nselib/data/psexec/nmap_service.c +380 -0
  92. nse-library/nselib/data/psexec/nmap_service.vcproj +194 -0
  93. nse-library/nselib/data/psexec/pwdump.lua +50 -0
  94. nse-library/nselib/data/publickeydb +3 -0
  95. nse-library/nselib/data/rtsp-urls.txt +178 -0
  96. nse-library/nselib/data/snmpcommunities.lst +27 -0
  97. nse-library/nselib/data/ssl-fingerprints +2077 -0
  98. nse-library/nselib/data/targets-ipv6-wordlist +2651 -0
  99. nse-library/nselib/data/tftp-fingerprints.lua +146 -0
  100. nse-library/nselib/data/tftplist.txt +255 -0
  101. nse-library/nselib/data/usernames.lst +10 -0
  102. nse-library/nselib/data/vhosts-default.lst +128 -0
  103. nse-library/nselib/data/vhosts-full.lst +498 -0
  104. nse-library/nselib/data/wp-plugins.lst +80377 -0
  105. nse-library/nselib/data/wp-themes.lst +14247 -0
  106. nse-library/nselib/datafiles.lua +342 -0
  107. nse-library/nselib/datetime.lua +252 -0
  108. nse-library/nselib/dhcp.lua +649 -0
  109. nse-library/nselib/dhcp6.lua +661 -0
  110. nse-library/nselib/dicom.lua +1558 -0
  111. nse-library/nselib/dns.lua +1634 -0
  112. nse-library/nselib/dnsbl.lua +624 -0
  113. nse-library/nselib/dnssd.lua +402 -0
  114. nse-library/nselib/drda.lua +778 -0
  115. nse-library/nselib/eap.lua +289 -0
  116. nse-library/nselib/eigrp.lua +355 -0
  117. nse-library/nselib/formulas.lua +220 -0
  118. nse-library/nselib/ftp.lua +284 -0
  119. nse-library/nselib/geoip.lua +138 -0
  120. nse-library/nselib/giop.lua +633 -0
  121. nse-library/nselib/gps.lua +126 -0
  122. nse-library/nselib/http.lua +3326 -0
  123. nse-library/nselib/httpspider.lua +1071 -0
  124. nse-library/nselib/iax2.lua +340 -0
  125. nse-library/nselib/idna.lua +565 -0
  126. nse-library/nselib/iec61850mms.lua +1187 -0
  127. nse-library/nselib/ike.lua +550 -0
  128. nse-library/nselib/imap.lua +280 -0
  129. nse-library/nselib/informix.lua +1333 -0
  130. nse-library/nselib/ipOps.lua +891 -0
  131. nse-library/nselib/ipmi.lua +306 -0
  132. nse-library/nselib/ipp.lua +411 -0
  133. nse-library/nselib/irc.lua +37 -0
  134. nse-library/nselib/iscsi.lua +729 -0
  135. nse-library/nselib/isns.lua +556 -0
  136. nse-library/nselib/jdwp.lua +1079 -0
  137. nse-library/nselib/json.lua +443 -0
  138. nse-library/nselib/knx.lua +87 -0
  139. nse-library/nselib/ldap.lua +917 -0
  140. nse-library/nselib/lfs.luadoc +48 -0
  141. nse-library/nselib/libssh2-utility.lua +285 -0
  142. nse-library/nselib/libssh2.luadoc +169 -0
  143. nse-library/nselib/listop.lua +184 -0
  144. nse-library/nselib/lpeg-utility.lua +170 -0
  145. nse-library/nselib/lpeg.luadoc +10 -0
  146. nse-library/nselib/ls.lua +368 -0
  147. nse-library/nselib/match.lua +62 -0
  148. nse-library/nselib/membase.lua +337 -0
  149. nse-library/nselib/mobileme.lua +242 -0
  150. nse-library/nselib/mongodb.lua +973 -0
  151. nse-library/nselib/mqtt.lua +1016 -0
  152. nse-library/nselib/msrpc.lua +5309 -0
  153. nse-library/nselib/msrpcperformance.lua +620 -0
  154. nse-library/nselib/msrpctypes.lua +4654 -0
  155. nse-library/nselib/mssql.lua +3491 -0
  156. nse-library/nselib/multicast.lua +178 -0
  157. nse-library/nselib/mysql.lua +570 -0
  158. nse-library/nselib/natpmp.lua +222 -0
  159. nse-library/nselib/nbd.lua +596 -0
  160. nse-library/nselib/ncp.lua +1116 -0
  161. nse-library/nselib/ndmp.lua +423 -0
  162. nse-library/nselib/netbios.lua +489 -0
  163. nse-library/nselib/nmap.luadoc +846 -0
  164. nse-library/nselib/nrpc.lua +164 -0
  165. nse-library/nselib/nsedebug.lua +131 -0
  166. nse-library/nselib/omp2.lua +178 -0
  167. nse-library/nselib/oops.lua +131 -0
  168. nse-library/nselib/openssl.luadoc +212 -0
  169. nse-library/nselib/ospf.lua +535 -0
  170. nse-library/nselib/outlib.lua +79 -0
  171. nse-library/nselib/packet.lua +1151 -0
  172. nse-library/nselib/pgsql.lua +620 -0
  173. nse-library/nselib/pop3.lua +235 -0
  174. nse-library/nselib/pppoe.lua +1005 -0
  175. nse-library/nselib/proxy.lua +314 -0
  176. nse-library/nselib/punycode.lua +473 -0
  177. nse-library/nselib/rand.lua +94 -0
  178. nse-library/nselib/rdp.lua +454 -0
  179. nse-library/nselib/re.lua +321 -0
  180. nse-library/nselib/redis.lua +217 -0
  181. nse-library/nselib/rmi.lua +1552 -0
  182. nse-library/nselib/rpc.lua +3474 -0
  183. nse-library/nselib/rpcap.lua +435 -0
  184. nse-library/nselib/rsync.lua +171 -0
  185. nse-library/nselib/rtsp.lua +291 -0
  186. nse-library/nselib/sasl.lua +510 -0
  187. nse-library/nselib/shortport.lua +423 -0
  188. nse-library/nselib/sip.lua +894 -0
  189. nse-library/nselib/slaxml.lua +449 -0
  190. nse-library/nselib/smb.lua +4461 -0
  191. nse-library/nselib/smb2.lua +393 -0
  192. nse-library/nselib/smbauth.lua +988 -0
  193. nse-library/nselib/smtp.lua +655 -0
  194. nse-library/nselib/snmp.lua +589 -0
  195. nse-library/nselib/socks.lua +283 -0
  196. nse-library/nselib/srvloc.lua +345 -0
  197. nse-library/nselib/ssh1.lua +275 -0
  198. nse-library/nselib/ssh2.lua +403 -0
  199. nse-library/nselib/sslcert.lua +1099 -0
  200. nse-library/nselib/sslv2.lua +366 -0
  201. nse-library/nselib/stdnse.lua +1100 -0
  202. nse-library/nselib/strbuf.lua +141 -0
  203. nse-library/nselib/strict.lua +88 -0
  204. nse-library/nselib/stringaux.lua +139 -0
  205. nse-library/nselib/stun.lua +388 -0
  206. nse-library/nselib/tab.lua +129 -0
  207. nse-library/nselib/tableaux.lua +90 -0
  208. nse-library/nselib/target.lua +115 -0
  209. nse-library/nselib/tftp.lua +347 -0
  210. nse-library/nselib/tls.lua +2073 -0
  211. nse-library/nselib/tn3270.lua +1406 -0
  212. nse-library/nselib/tns.lua +1798 -0
  213. nse-library/nselib/unicode.lua +469 -0
  214. nse-library/nselib/unittest.lua +524 -0
  215. nse-library/nselib/unpwdb.lua +338 -0
  216. nse-library/nselib/upnp.lua +397 -0
  217. nse-library/nselib/url.lua +550 -0
  218. nse-library/nselib/versant.lua +284 -0
  219. nse-library/nselib/vnc.lua +828 -0
  220. nse-library/nselib/vulns.lua +2317 -0
  221. nse-library/nselib/vuzedht.lua +548 -0
  222. nse-library/nselib/wsdd.lua +382 -0
  223. nse-library/nselib/xdmcp.lua +407 -0
  224. nse-library/nselib/xmpp.lua +456 -0
  225. nse-library/nselib/zlib.luadoc +112 -0
  226. nse-library/script.db +620 -0
  227. nse-library/scripts/acarsd-info.nse +115 -0
  228. nse-library/scripts/address-info.nse +299 -0
  229. nse-library/scripts/afp-brute.nse +111 -0
  230. nse-library/scripts/afp-ls.nse +187 -0
  231. nse-library/scripts/afp-path-vuln.nse +220 -0
  232. nse-library/scripts/afp-serverinfo.nse +175 -0
  233. nse-library/scripts/afp-showmount.nse +101 -0
  234. nse-library/scripts/ajp-auth.nse +72 -0
  235. nse-library/scripts/ajp-brute.nse +113 -0
  236. nse-library/scripts/ajp-headers.nse +46 -0
  237. nse-library/scripts/ajp-methods.nse +81 -0
  238. nse-library/scripts/ajp-request.nse +103 -0
  239. nse-library/scripts/allseeingeye-info.nse +219 -0
  240. nse-library/scripts/amqp-info.nse +60 -0
  241. nse-library/scripts/asn-query.nse +466 -0
  242. nse-library/scripts/auth-owners.nse +80 -0
  243. nse-library/scripts/auth-spoof.nse +37 -0
  244. nse-library/scripts/backorifice-brute.nse +291 -0
  245. nse-library/scripts/backorifice-info.nse +325 -0
  246. nse-library/scripts/bacnet-info.nse +1569 -0
  247. nse-library/scripts/banner.nse +198 -0
  248. nse-library/scripts/bitcoin-getaddr.nse +76 -0
  249. nse-library/scripts/bitcoin-info.nse +75 -0
  250. nse-library/scripts/bitcoinrpc-info.nse +165 -0
  251. nse-library/scripts/bittorrent-discovery.nse +139 -0
  252. nse-library/scripts/bjnp-discover.nse +50 -0
  253. nse-library/scripts/broadcast-ataoe-discover.nse +167 -0
  254. nse-library/scripts/broadcast-avahi-dos.nse +108 -0
  255. nse-library/scripts/broadcast-bjnp-discover.nse +174 -0
  256. nse-library/scripts/broadcast-db2-discover.nse +86 -0
  257. nse-library/scripts/broadcast-dhcp-discover.nse +285 -0
  258. nse-library/scripts/broadcast-dhcp6-discover.nse +102 -0
  259. nse-library/scripts/broadcast-dns-service-discovery.nse +55 -0
  260. nse-library/scripts/broadcast-dropbox-listener.nse +140 -0
  261. nse-library/scripts/broadcast-eigrp-discovery.nse +330 -0
  262. nse-library/scripts/broadcast-hid-discoveryd.nse +100 -0
  263. nse-library/scripts/broadcast-igmp-discovery.nse +397 -0
  264. nse-library/scripts/broadcast-jenkins-discover.nse +94 -0
  265. nse-library/scripts/broadcast-listener.nse +259 -0
  266. nse-library/scripts/broadcast-ms-sql-discover.nse +114 -0
  267. nse-library/scripts/broadcast-netbios-master-browser.nse +67 -0
  268. nse-library/scripts/broadcast-networker-discover.nse +104 -0
  269. nse-library/scripts/broadcast-novell-locate.nse +78 -0
  270. nse-library/scripts/broadcast-ospf2-discover.nse +422 -0
  271. nse-library/scripts/broadcast-pc-anywhere.nse +72 -0
  272. nse-library/scripts/broadcast-pc-duo.nse +132 -0
  273. nse-library/scripts/broadcast-pim-discovery.nse +197 -0
  274. nse-library/scripts/broadcast-ping.nse +274 -0
  275. nse-library/scripts/broadcast-pppoe-discover.nse +103 -0
  276. nse-library/scripts/broadcast-rip-discover.nse +181 -0
  277. nse-library/scripts/broadcast-ripng-discover.nse +222 -0
  278. nse-library/scripts/broadcast-sonicwall-discover.nse +131 -0
  279. nse-library/scripts/broadcast-sybase-asa-discover.nse +188 -0
  280. nse-library/scripts/broadcast-tellstick-discover.nse +69 -0
  281. nse-library/scripts/broadcast-upnp-info.nse +51 -0
  282. nse-library/scripts/broadcast-versant-locate.nse +41 -0
  283. nse-library/scripts/broadcast-wake-on-lan.nse +68 -0
  284. nse-library/scripts/broadcast-wpad-discover.nse +222 -0
  285. nse-library/scripts/broadcast-wsdd-discover.nse +102 -0
  286. nse-library/scripts/broadcast-xdmcp-discover.nse +73 -0
  287. nse-library/scripts/cassandra-brute.nse +132 -0
  288. nse-library/scripts/cassandra-info.nse +94 -0
  289. nse-library/scripts/cccam-version.nse +63 -0
  290. nse-library/scripts/cics-enum.nse +430 -0
  291. nse-library/scripts/cics-info.nse +409 -0
  292. nse-library/scripts/cics-user-brute.nse +299 -0
  293. nse-library/scripts/cics-user-enum.nse +255 -0
  294. nse-library/scripts/citrix-brute-xml.nse +163 -0
  295. nse-library/scripts/citrix-enum-apps-xml.nse +154 -0
  296. nse-library/scripts/citrix-enum-apps.nse +159 -0
  297. nse-library/scripts/citrix-enum-servers-xml.nse +47 -0
  298. nse-library/scripts/citrix-enum-servers.nse +145 -0
  299. nse-library/scripts/clamav-exec.nse +220 -0
  300. nse-library/scripts/clock-skew.nse +179 -0
  301. nse-library/scripts/coap-resources.nse +316 -0
  302. nse-library/scripts/couchdb-databases.nse +97 -0
  303. nse-library/scripts/couchdb-stats.nse +225 -0
  304. nse-library/scripts/creds-summary.nse +41 -0
  305. nse-library/scripts/cups-info.nse +73 -0
  306. nse-library/scripts/cups-queue-info.nse +42 -0
  307. nse-library/scripts/cvs-brute-repository.nse +129 -0
  308. nse-library/scripts/cvs-brute.nse +106 -0
  309. nse-library/scripts/daap-get-library.nse +332 -0
  310. nse-library/scripts/daytime.nse +26 -0
  311. nse-library/scripts/db2-das-info.nse +440 -0
  312. nse-library/scripts/deluge-rpc-brute.nse +167 -0
  313. nse-library/scripts/dhcp-discover.nse +228 -0
  314. nse-library/scripts/dicom-brute.nse +80 -0
  315. nse-library/scripts/dicom-cfind-ls.nse +801 -0
  316. nse-library/scripts/dicom-cmove.nse +583 -0
  317. nse-library/scripts/dicom-get.nse +656 -0
  318. nse-library/scripts/dicom-info.nse +743 -0
  319. nse-library/scripts/dicom-ping.nse +70 -0
  320. nse-library/scripts/dicom-slowloris.nse +495 -0
  321. nse-library/scripts/dicom-store-fuzzer.nse +790 -0
  322. nse-library/scripts/dicom-store-inject.nse +279 -0
  323. nse-library/scripts/dicom-web-enum.nse +497 -0
  324. nse-library/scripts/dict-info.nse +79 -0
  325. nse-library/scripts/distcc-cve2004-2687.nse +108 -0
  326. nse-library/scripts/dns-blacklist.nse +176 -0
  327. nse-library/scripts/dns-brute.nse +328 -0
  328. nse-library/scripts/dns-cache-snoop.nse +233 -0
  329. nse-library/scripts/dns-check-zone.nse +449 -0
  330. nse-library/scripts/dns-client-subnet-scan.nse +359 -0
  331. nse-library/scripts/dns-fuzz.nse +306 -0
  332. nse-library/scripts/dns-ip6-arpa-scan.nse +131 -0
  333. nse-library/scripts/dns-nsec-enum.nse +393 -0
  334. nse-library/scripts/dns-nsec3-enum.nse +427 -0
  335. nse-library/scripts/dns-nsid.nse +117 -0
  336. nse-library/scripts/dns-random-srcport.nse +153 -0
  337. nse-library/scripts/dns-random-txid.nse +153 -0
  338. nse-library/scripts/dns-recursion.nse +58 -0
  339. nse-library/scripts/dns-service-discovery.nse +67 -0
  340. nse-library/scripts/dns-srv-enum.nse +179 -0
  341. nse-library/scripts/dns-update.nse +118 -0
  342. nse-library/scripts/dns-zeustracker.nse +61 -0
  343. nse-library/scripts/dns-zone-transfer.nse +621 -0
  344. nse-library/scripts/docker-version.nse +46 -0
  345. nse-library/scripts/domcon-brute.nse +168 -0
  346. nse-library/scripts/domcon-cmd.nse +141 -0
  347. nse-library/scripts/domino-enum-users.nse +135 -0
  348. nse-library/scripts/dpap-brute.nse +127 -0
  349. nse-library/scripts/drda-brute.nse +173 -0
  350. nse-library/scripts/drda-info.nse +114 -0
  351. nse-library/scripts/duplicates.nse +243 -0
  352. nse-library/scripts/eap-info.nse +186 -0
  353. nse-library/scripts/enip-info.nse +1765 -0
  354. nse-library/scripts/epmd-info.nse +69 -0
  355. nse-library/scripts/eppc-enum-processes.nse +105 -0
  356. nse-library/scripts/fcrdns.nse +141 -0
  357. nse-library/scripts/finger.nse +37 -0
  358. nse-library/scripts/fingerprint-strings.nse +136 -0
  359. nse-library/scripts/firewalk.nse +1062 -0
  360. nse-library/scripts/firewall-bypass.nse +274 -0
  361. nse-library/scripts/flume-master-info.nse +296 -0
  362. nse-library/scripts/fox-info.nse +139 -0
  363. nse-library/scripts/freelancer-info.nse +107 -0
  364. nse-library/scripts/ftp-anon.nse +143 -0
  365. nse-library/scripts/ftp-bounce.nse +112 -0
  366. nse-library/scripts/ftp-brute.nse +112 -0
  367. nse-library/scripts/ftp-libopie.nse +101 -0
  368. nse-library/scripts/ftp-proftpd-backdoor.nse +127 -0
  369. nse-library/scripts/ftp-syst.nse +144 -0
  370. nse-library/scripts/ftp-vsftpd-backdoor.nse +192 -0
  371. nse-library/scripts/ftp-vuln-cve2010-4221.nse +198 -0
  372. nse-library/scripts/ganglia-info.nse +244 -0
  373. nse-library/scripts/giop-info.nse +81 -0
  374. nse-library/scripts/gkrellm-info.nse +205 -0
  375. nse-library/scripts/gopher-ls.nse +92 -0
  376. nse-library/scripts/gpsd-info.nse +105 -0
  377. nse-library/scripts/hadoop-datanode-info.nse +61 -0
  378. nse-library/scripts/hadoop-jobtracker-info.nse +181 -0
  379. nse-library/scripts/hadoop-namenode-info.nse +180 -0
  380. nse-library/scripts/hadoop-secondary-namenode-info.nse +122 -0
  381. nse-library/scripts/hadoop-tasktracker-info.nse +80 -0
  382. nse-library/scripts/hartip-info.nse +302 -0
  383. nse-library/scripts/hbase-master-info.nse +145 -0
  384. nse-library/scripts/hbase-region-info.nse +94 -0
  385. nse-library/scripts/hddtemp-info.nse +69 -0
  386. nse-library/scripts/hnap-info.nse +130 -0
  387. nse-library/scripts/hostmap-crtsh.nse +168 -0
  388. nse-library/scripts/hostmap-robtex.nse +85 -0
  389. nse-library/scripts/http-adobe-coldfusion-apsa1301.nse +66 -0
  390. nse-library/scripts/http-affiliate-id.nse +167 -0
  391. nse-library/scripts/http-apache-negotiation.nse +66 -0
  392. nse-library/scripts/http-apache-server-status.nse +126 -0
  393. nse-library/scripts/http-aspnet-debug.nse +60 -0
  394. nse-library/scripts/http-auth-finder.nse +119 -0
  395. nse-library/scripts/http-auth.nse +106 -0
  396. nse-library/scripts/http-avaya-ipoffice-users.nse +77 -0
  397. nse-library/scripts/http-awstatstotals-exec.nse +136 -0
  398. nse-library/scripts/http-axis2-dir-traversal.nse +197 -0
  399. nse-library/scripts/http-backup-finder.nse +157 -0
  400. nse-library/scripts/http-barracuda-dir-traversal.nse +184 -0
  401. nse-library/scripts/http-bigip-cookie.nse +83 -0
  402. nse-library/scripts/http-brute.nse +165 -0
  403. nse-library/scripts/http-cakephp-version.nse +113 -0
  404. nse-library/scripts/http-chrono.nse +136 -0
  405. nse-library/scripts/http-cisco-anyconnect.nse +60 -0
  406. nse-library/scripts/http-coldfusion-subzero.nse +147 -0
  407. nse-library/scripts/http-comments-displayer.nse +156 -0
  408. nse-library/scripts/http-config-backup.nse +245 -0
  409. nse-library/scripts/http-cookie-flags.nse +173 -0
  410. nse-library/scripts/http-cors.nse +100 -0
  411. nse-library/scripts/http-cross-domain-policy.nse +306 -0
  412. nse-library/scripts/http-csrf.nse +187 -0
  413. nse-library/scripts/http-date.nse +58 -0
  414. nse-library/scripts/http-default-accounts.nse +558 -0
  415. nse-library/scripts/http-devframework.nse +152 -0
  416. nse-library/scripts/http-dlink-backdoor.nse +70 -0
  417. nse-library/scripts/http-dombased-xss.nse +154 -0
  418. nse-library/scripts/http-domino-enum-passwords.nse +354 -0
  419. nse-library/scripts/http-drupal-enum-users.nse +82 -0
  420. nse-library/scripts/http-drupal-enum.nse +233 -0
  421. nse-library/scripts/http-enum.nse +512 -0
  422. nse-library/scripts/http-errors.nse +130 -0
  423. nse-library/scripts/http-exif-spider.nse +539 -0
  424. nse-library/scripts/http-favicon.nse +175 -0
  425. nse-library/scripts/http-feed.nse +159 -0
  426. nse-library/scripts/http-fetch.nse +251 -0
  427. nse-library/scripts/http-fileupload-exploiter.nse +342 -0
  428. nse-library/scripts/http-form-brute.nse +588 -0
  429. nse-library/scripts/http-form-fuzzer.nse +205 -0
  430. nse-library/scripts/http-frontpage-login.nse +84 -0
  431. nse-library/scripts/http-generator.nse +62 -0
  432. nse-library/scripts/http-git.nse +309 -0
  433. nse-library/scripts/http-gitweb-projects-enum.nse +106 -0
  434. nse-library/scripts/http-google-malware.nse +109 -0
  435. nse-library/scripts/http-grep.nse +326 -0
  436. nse-library/scripts/http-headers.nse +66 -0
  437. nse-library/scripts/http-hp-ilo-info.nse +120 -0
  438. nse-library/scripts/http-huawei-hg5xx-vuln.nse +131 -0
  439. nse-library/scripts/http-icloud-findmyiphone.nse +87 -0
  440. nse-library/scripts/http-icloud-sendmsg.nse +113 -0
  441. nse-library/scripts/http-iis-short-name-brute.nse +181 -0
  442. nse-library/scripts/http-iis-webdav-vuln.nse +220 -0
  443. nse-library/scripts/http-internal-ip-disclosure.nse +89 -0
  444. nse-library/scripts/http-joomla-brute.nse +147 -0
  445. nse-library/scripts/http-jsonp-detection.nse +190 -0
  446. nse-library/scripts/http-litespeed-sourcecode-download.nse +75 -0
  447. nse-library/scripts/http-ls.nse +193 -0
  448. nse-library/scripts/http-majordomo2-dir-traversal.nse +96 -0
  449. nse-library/scripts/http-malware-host.nse +81 -0
  450. nse-library/scripts/http-mcmp.nse +70 -0
  451. nse-library/scripts/http-method-tamper.nse +176 -0
  452. nse-library/scripts/http-methods.nse +235 -0
  453. nse-library/scripts/http-mobileversion-checker.nse +87 -0
  454. nse-library/scripts/http-ntlm-info.nse +131 -0
  455. nse-library/scripts/http-open-proxy.nse +213 -0
  456. nse-library/scripts/http-open-redirect.nse +136 -0
  457. nse-library/scripts/http-passwd.nse +198 -0
  458. nse-library/scripts/http-php-version.nse +166 -0
  459. nse-library/scripts/http-phpmyadmin-dir-traversal.nse +149 -0
  460. nse-library/scripts/http-phpself-xss.nse +168 -0
  461. nse-library/scripts/http-proxy-brute.nse +115 -0
  462. nse-library/scripts/http-put.nse +61 -0
  463. nse-library/scripts/http-qnap-nas-info.nse +118 -0
  464. nse-library/scripts/http-referer-checker.nse +89 -0
  465. nse-library/scripts/http-rfi-spider.nse +283 -0
  466. nse-library/scripts/http-robots.txt.nse +111 -0
  467. nse-library/scripts/http-robtex-reverse-ip.nse +81 -0
  468. nse-library/scripts/http-robtex-shared-ns.nse +111 -0
  469. nse-library/scripts/http-sap-netweaver-leak.nse +138 -0
  470. nse-library/scripts/http-security-headers.nse +315 -0
  471. nse-library/scripts/http-server-header.nse +106 -0
  472. nse-library/scripts/http-shellshock.nse +144 -0
  473. nse-library/scripts/http-sitemap-generator.nse +179 -0
  474. nse-library/scripts/http-slowloris-check.nse +164 -0
  475. nse-library/scripts/http-slowloris.nse +364 -0
  476. nse-library/scripts/http-sql-injection.nse +285 -0
  477. nse-library/scripts/http-stored-xss.nse +283 -0
  478. nse-library/scripts/http-svn-enum.nse +132 -0
  479. nse-library/scripts/http-svn-info.nse +130 -0
  480. nse-library/scripts/http-title.nse +82 -0
  481. nse-library/scripts/http-tplink-dir-traversal.nse +158 -0
  482. nse-library/scripts/http-trace.nse +72 -0
  483. nse-library/scripts/http-traceroute.nse +180 -0
  484. nse-library/scripts/http-trane-info.nse +167 -0
  485. nse-library/scripts/http-unsafe-output-escaping.nse +160 -0
  486. nse-library/scripts/http-useragent-tester.nse +193 -0
  487. nse-library/scripts/http-userdir-enum.nse +133 -0
  488. nse-library/scripts/http-vhosts.nse +179 -0
  489. nse-library/scripts/http-virustotal.nse +254 -0
  490. nse-library/scripts/http-vlcstreamer-ls.nse +86 -0
  491. nse-library/scripts/http-vmware-path-vuln.nse +141 -0
  492. nse-library/scripts/http-vuln-cve2006-3392.nse +79 -0
  493. nse-library/scripts/http-vuln-cve2009-3960.nse +163 -0
  494. nse-library/scripts/http-vuln-cve2010-0738.nse +79 -0
  495. nse-library/scripts/http-vuln-cve2010-2861.nse +143 -0
  496. nse-library/scripts/http-vuln-cve2011-3192.nse +128 -0
  497. nse-library/scripts/http-vuln-cve2011-3368.nse +160 -0
  498. nse-library/scripts/http-vuln-cve2012-1823.nse +102 -0
  499. nse-library/scripts/http-vuln-cve2013-0156.nse +123 -0
  500. nse-library/scripts/http-vuln-cve2013-6786.nse +78 -0
  501. nse-library/scripts/http-vuln-cve2013-7091.nse +121 -0
  502. nse-library/scripts/http-vuln-cve2014-2126.nse +88 -0
  503. nse-library/scripts/http-vuln-cve2014-2127.nse +88 -0
  504. nse-library/scripts/http-vuln-cve2014-2128.nse +89 -0
  505. nse-library/scripts/http-vuln-cve2014-2129.nse +86 -0
  506. nse-library/scripts/http-vuln-cve2014-3704.nse +430 -0
  507. nse-library/scripts/http-vuln-cve2014-8877.nse +134 -0
  508. nse-library/scripts/http-vuln-cve2015-1427.nse +210 -0
  509. nse-library/scripts/http-vuln-cve2015-1635.nse +86 -0
  510. nse-library/scripts/http-vuln-cve2017-1001000.nse +126 -0
  511. nse-library/scripts/http-vuln-cve2017-5638.nse +78 -0
  512. nse-library/scripts/http-vuln-cve2017-5689.nse +127 -0
  513. nse-library/scripts/http-vuln-cve2017-8917.nse +143 -0
  514. nse-library/scripts/http-vuln-misfortune-cookie.nse +77 -0
  515. nse-library/scripts/http-vuln-wnr1000-creds.nse +103 -0
  516. nse-library/scripts/http-waf-detect.nse +129 -0
  517. nse-library/scripts/http-waf-fingerprint.nse +677 -0
  518. nse-library/scripts/http-webdav-scan.nse +182 -0
  519. nse-library/scripts/http-wordpress-brute.nse +141 -0
  520. nse-library/scripts/http-wordpress-enum.nse +299 -0
  521. nse-library/scripts/http-wordpress-users.nse +149 -0
  522. nse-library/scripts/http-xssed.nse +92 -0
  523. nse-library/scripts/https-redirect.nse +78 -0
  524. nse-library/scripts/iax2-brute.nse +76 -0
  525. nse-library/scripts/iax2-version.nse +55 -0
  526. nse-library/scripts/icap-info.nse +119 -0
  527. nse-library/scripts/iec-identify.nse +161 -0
  528. nse-library/scripts/iec61850-mms.nse +380 -0
  529. nse-library/scripts/ike-version.nse +171 -0
  530. nse-library/scripts/imap-brute.nse +144 -0
  531. nse-library/scripts/imap-capabilities.nse +53 -0
  532. nse-library/scripts/imap-ntlm-info.nse +176 -0
  533. nse-library/scripts/impress-remote-discover.nse +213 -0
  534. nse-library/scripts/informix-brute.nse +111 -0
  535. nse-library/scripts/informix-query.nse +94 -0
  536. nse-library/scripts/informix-tables.nse +122 -0
  537. nse-library/scripts/ip-forwarding.nse +113 -0
  538. nse-library/scripts/ip-geolocation-geoplugin.nse +72 -0
  539. nse-library/scripts/ip-geolocation-ipinfodb.nse +96 -0
  540. nse-library/scripts/ip-geolocation-map-bing.nse +191 -0
  541. nse-library/scripts/ip-geolocation-map-google.nse +181 -0
  542. nse-library/scripts/ip-geolocation-map-kml.nse +90 -0
  543. nse-library/scripts/ip-geolocation-maxmind.nse +628 -0
  544. nse-library/scripts/ip-https-discover.nse +76 -0
  545. nse-library/scripts/ipidseq.nse +238 -0
  546. nse-library/scripts/ipmi-brute.nse +130 -0
  547. nse-library/scripts/ipmi-cipher-zero.nse +102 -0
  548. nse-library/scripts/ipmi-version.nse +170 -0
  549. nse-library/scripts/ipv6-multicast-mld-list.nse +390 -0
  550. nse-library/scripts/ipv6-node-info.nse +337 -0
  551. nse-library/scripts/ipv6-ra-flood.nse +193 -0
  552. nse-library/scripts/irc-botnet-channels.nse +279 -0
  553. nse-library/scripts/irc-brute.nse +136 -0
  554. nse-library/scripts/irc-info.nse +166 -0
  555. nse-library/scripts/irc-sasl-brute.nse +204 -0
  556. nse-library/scripts/irc-unrealircd-backdoor.nse +223 -0
  557. nse-library/scripts/iscsi-brute.nse +91 -0
  558. nse-library/scripts/iscsi-info.nse +106 -0
  559. nse-library/scripts/isns-info.nse +71 -0
  560. nse-library/scripts/jdwp-exec.nse +97 -0
  561. nse-library/scripts/jdwp-info.nse +93 -0
  562. nse-library/scripts/jdwp-inject.nse +87 -0
  563. nse-library/scripts/jdwp-version.nse +59 -0
  564. nse-library/scripts/knx-gateway-discover.nse +309 -0
  565. nse-library/scripts/knx-gateway-info.nse +147 -0
  566. nse-library/scripts/krb5-enum-users.nse +404 -0
  567. nse-library/scripts/ldap-brute.nse +316 -0
  568. nse-library/scripts/ldap-novell-getpass.nse +139 -0
  569. nse-library/scripts/ldap-rootdse.nse +212 -0
  570. nse-library/scripts/ldap-search.nse +315 -0
  571. nse-library/scripts/lexmark-config.nse +88 -0
  572. nse-library/scripts/llmnr-resolve.nse +220 -0
  573. nse-library/scripts/lltd-discovery.nse +300 -0
  574. nse-library/scripts/lu-enum.nse +217 -0
  575. nse-library/scripts/maxdb-info.nse +179 -0
  576. nse-library/scripts/mcafee-epo-agent.nse +77 -0
  577. nse-library/scripts/membase-brute.nse +113 -0
  578. nse-library/scripts/membase-http-info.nse +151 -0
  579. nse-library/scripts/memcached-info.nse +184 -0
  580. nse-library/scripts/metasploit-info.nse +287 -0
  581. nse-library/scripts/metasploit-msgrpc-brute.nse +110 -0
  582. nse-library/scripts/metasploit-xmlrpc-brute.nse +99 -0
  583. nse-library/scripts/mikrotik-routeros-brute.nse +99 -0
  584. nse-library/scripts/mikrotik-routeros-username-brute.nse +138 -0
  585. nse-library/scripts/mikrotik-routeros-version.nse +238 -0
  586. nse-library/scripts/mmouse-brute.nse +120 -0
  587. nse-library/scripts/mmouse-exec.nse +180 -0
  588. nse-library/scripts/modbus-discover.nse +163 -0
  589. nse-library/scripts/mongodb-brute.nse +108 -0
  590. nse-library/scripts/mongodb-databases.nse +100 -0
  591. nse-library/scripts/mongodb-info.nse +132 -0
  592. nse-library/scripts/mqtt-subscribe.nse +393 -0
  593. nse-library/scripts/mrinfo.nse +297 -0
  594. nse-library/scripts/ms-sql-brute.nse +290 -0
  595. nse-library/scripts/ms-sql-config.nse +132 -0
  596. nse-library/scripts/ms-sql-dac.nse +85 -0
  597. nse-library/scripts/ms-sql-dump-hashes.nse +113 -0
  598. nse-library/scripts/ms-sql-empty-password.nse +163 -0
  599. nse-library/scripts/ms-sql-hasdbaccess.nse +150 -0
  600. nse-library/scripts/ms-sql-info.nse +237 -0
  601. nse-library/scripts/ms-sql-ntlm-info.nse +134 -0
  602. nse-library/scripts/ms-sql-query.nse +107 -0
  603. nse-library/scripts/ms-sql-tables.nse +253 -0
  604. nse-library/scripts/ms-sql-xp-cmdshell.nse +153 -0
  605. nse-library/scripts/msrpc-enum.nse +112 -0
  606. nse-library/scripts/mtrace.nse +386 -0
  607. nse-library/scripts/multicast-profinet-discovery.nse +346 -0
  608. nse-library/scripts/murmur-version.nse +101 -0
  609. nse-library/scripts/mysql-audit.nse +184 -0
  610. nse-library/scripts/mysql-brute.nse +99 -0
  611. nse-library/scripts/mysql-databases.nse +98 -0
  612. nse-library/scripts/mysql-dump-hashes.nse +113 -0
  613. nse-library/scripts/mysql-empty-password.nse +67 -0
  614. nse-library/scripts/mysql-enum.nse +113 -0
  615. nse-library/scripts/mysql-info.nse +132 -0
  616. nse-library/scripts/mysql-query.nse +118 -0
  617. nse-library/scripts/mysql-users.nse +97 -0
  618. nse-library/scripts/mysql-variables.nse +109 -0
  619. nse-library/scripts/mysql-vuln-cve2012-2122.nse +153 -0
  620. nse-library/scripts/nat-pmp-info.nse +47 -0
  621. nse-library/scripts/nat-pmp-mapport.nse +117 -0
  622. nse-library/scripts/nbd-info.nse +197 -0
  623. nse-library/scripts/nbns-interfaces.nse +69 -0
  624. nse-library/scripts/nbstat.nse +244 -0
  625. nse-library/scripts/ncp-enum-users.nse +54 -0
  626. nse-library/scripts/ncp-serverinfo.nse +51 -0
  627. nse-library/scripts/ndmp-fs-info.nse +72 -0
  628. nse-library/scripts/ndmp-version.nse +71 -0
  629. nse-library/scripts/nessus-brute.nse +153 -0
  630. nse-library/scripts/nessus-xmlrpc-brute.nse +130 -0
  631. nse-library/scripts/netbus-auth-bypass.nse +63 -0
  632. nse-library/scripts/netbus-brute.nse +63 -0
  633. nse-library/scripts/netbus-info.nse +200 -0
  634. nse-library/scripts/netbus-version.nse +54 -0
  635. nse-library/scripts/nexpose-brute.nse +83 -0
  636. nse-library/scripts/nfs-ls.nse +470 -0
  637. nse-library/scripts/nfs-showmount.nse +97 -0
  638. nse-library/scripts/nfs-statfs.nse +359 -0
  639. nse-library/scripts/nje-node-brute.nse +175 -0
  640. nse-library/scripts/nje-pass-brute.nse +148 -0
  641. nse-library/scripts/nntp-ntlm-info.nse +162 -0
  642. nse-library/scripts/nping-brute.nse +145 -0
  643. nse-library/scripts/nrpe-enum.nse +241 -0
  644. nse-library/scripts/ntp-info.nse +172 -0
  645. nse-library/scripts/ntp-monlist.nse +1036 -0
  646. nse-library/scripts/omp2-brute.nse +81 -0
  647. nse-library/scripts/omp2-enum-targets.nse +126 -0
  648. nse-library/scripts/omron-info.nse +197 -0
  649. nse-library/scripts/openflow-info.nse +205 -0
  650. nse-library/scripts/openlookup-info.nse +246 -0
  651. nse-library/scripts/openvas-otp-brute.nse +112 -0
  652. nse-library/scripts/openwebnet-discovery.nse +291 -0
  653. nse-library/scripts/oracle-brute-stealth.nse +207 -0
  654. nse-library/scripts/oracle-brute.nse +228 -0
  655. nse-library/scripts/oracle-enum-users.nse +134 -0
  656. nse-library/scripts/oracle-sid-brute.nse +171 -0
  657. nse-library/scripts/oracle-tns-version.nse +104 -0
  658. nse-library/scripts/ovs-agent-version.nse +78 -0
  659. nse-library/scripts/p2p-conficker.nse +651 -0
  660. nse-library/scripts/path-mtu.nse +402 -0
  661. nse-library/scripts/pcanywhere-brute.nse +158 -0
  662. nse-library/scripts/pcworx-info.nse +111 -0
  663. nse-library/scripts/pgsql-brute.nse +169 -0
  664. nse-library/scripts/pjl-ready-message.nse +105 -0
  665. nse-library/scripts/pop3-brute.nse +136 -0
  666. nse-library/scripts/pop3-capabilities.nse +47 -0
  667. nse-library/scripts/pop3-ntlm-info.nse +161 -0
  668. nse-library/scripts/port-states.nse +86 -0
  669. nse-library/scripts/pptp-version.nse +81 -0
  670. nse-library/scripts/profinet-cm-lookup.nse +166 -0
  671. nse-library/scripts/puppet-naivesigning.nse +192 -0
  672. nse-library/scripts/qconn-exec.nse +114 -0
  673. nse-library/scripts/qscan.nse +504 -0
  674. nse-library/scripts/quake1-info.nse +319 -0
  675. nse-library/scripts/quake3-info.nse +256 -0
  676. nse-library/scripts/quake3-master-getservers.nse +249 -0
  677. nse-library/scripts/rdp-enum-encryption.nse +213 -0
  678. nse-library/scripts/rdp-ntlm-info.nse +168 -0
  679. nse-library/scripts/rdp-vuln-ms12-020.nse +237 -0
  680. nse-library/scripts/realvnc-auth-bypass.nse +110 -0
  681. nse-library/scripts/redis-brute.nse +113 -0
  682. nse-library/scripts/redis-info.nse +250 -0
  683. nse-library/scripts/resolveall.nse +170 -0
  684. nse-library/scripts/reverse-index.nse +121 -0
  685. nse-library/scripts/rexec-brute.nse +113 -0
  686. nse-library/scripts/rfc868-time.nse +65 -0
  687. nse-library/scripts/riak-http-info.nse +145 -0
  688. nse-library/scripts/rlogin-brute.nse +163 -0
  689. nse-library/scripts/rmi-dumpregistry.nse +231 -0
  690. nse-library/scripts/rmi-vuln-classloader.nse +115 -0
  691. nse-library/scripts/rpc-grind.nse +271 -0
  692. nse-library/scripts/rpcap-brute.nse +94 -0
  693. nse-library/scripts/rpcap-info.nse +94 -0
  694. nse-library/scripts/rpcinfo.nse +134 -0
  695. nse-library/scripts/rsa-vuln-roca.nse +176 -0
  696. nse-library/scripts/rsync-brute.nse +110 -0
  697. nse-library/scripts/rsync-list-modules.nse +62 -0
  698. nse-library/scripts/rtsp-methods.nse +58 -0
  699. nse-library/scripts/rtsp-url-brute.nse +202 -0
  700. nse-library/scripts/rusers.nse +176 -0
  701. nse-library/scripts/s7-info.nse +271 -0
  702. nse-library/scripts/samba-vuln-cve-2012-1182.nse +130 -0
  703. nse-library/scripts/script.db +619 -0
  704. nse-library/scripts/servicetags.nse +297 -0
  705. nse-library/scripts/shodan-api.nse +223 -0
  706. nse-library/scripts/sip-brute.nse +111 -0
  707. nse-library/scripts/sip-call-spoof.nse +170 -0
  708. nse-library/scripts/sip-enum-users.nse +266 -0
  709. nse-library/scripts/sip-methods.nse +65 -0
  710. nse-library/scripts/skypev2-version.nse +80 -0
  711. nse-library/scripts/smb-brute.nse +1114 -0
  712. nse-library/scripts/smb-double-pulsar-backdoor.nse +146 -0
  713. nse-library/scripts/smb-enum-domains.nse +123 -0
  714. nse-library/scripts/smb-enum-groups.nse +174 -0
  715. nse-library/scripts/smb-enum-processes.nse +278 -0
  716. nse-library/scripts/smb-enum-services.nse +921 -0
  717. nse-library/scripts/smb-enum-sessions.nse +328 -0
  718. nse-library/scripts/smb-enum-shares.nse +194 -0
  719. nse-library/scripts/smb-enum-users.nse +267 -0
  720. nse-library/scripts/smb-flood.nse +146 -0
  721. nse-library/scripts/smb-ls.nse +218 -0
  722. nse-library/scripts/smb-mbenum.nse +246 -0
  723. nse-library/scripts/smb-os-discovery.nse +220 -0
  724. nse-library/scripts/smb-print-text.nse +133 -0
  725. nse-library/scripts/smb-protocols.nse +71 -0
  726. nse-library/scripts/smb-psexec.nse +1565 -0
  727. nse-library/scripts/smb-security-mode.nse +158 -0
  728. nse-library/scripts/smb-server-stats.nse +66 -0
  729. nse-library/scripts/smb-system-info.nse +249 -0
  730. nse-library/scripts/smb-vuln-conficker.nse +188 -0
  731. nse-library/scripts/smb-vuln-cve-2017-7494.nse +517 -0
  732. nse-library/scripts/smb-vuln-cve2009-3103.nse +174 -0
  733. nse-library/scripts/smb-vuln-ms06-025.nse +163 -0
  734. nse-library/scripts/smb-vuln-ms07-029.nse +150 -0
  735. nse-library/scripts/smb-vuln-ms08-067.nse +154 -0
  736. nse-library/scripts/smb-vuln-ms10-054.nse +144 -0
  737. nse-library/scripts/smb-vuln-ms10-061.nse +171 -0
  738. nse-library/scripts/smb-vuln-ms17-010.nse +192 -0
  739. nse-library/scripts/smb-vuln-regsvc-dos.nse +124 -0
  740. nse-library/scripts/smb-vuln-webexec.nse +167 -0
  741. nse-library/scripts/smb-webexec-exploit.nse +140 -0
  742. nse-library/scripts/smb2-capabilities.nse +129 -0
  743. nse-library/scripts/smb2-security-mode.nse +88 -0
  744. nse-library/scripts/smb2-time.nse +51 -0
  745. nse-library/scripts/smb2-vuln-uptime.nse +157 -0
  746. nse-library/scripts/smtp-brute.nse +140 -0
  747. nse-library/scripts/smtp-commands.nse +131 -0
  748. nse-library/scripts/smtp-enum-users.nse +382 -0
  749. nse-library/scripts/smtp-ntlm-info.nse +189 -0
  750. nse-library/scripts/smtp-open-relay.nse +288 -0
  751. nse-library/scripts/smtp-strangeport.nse +29 -0
  752. nse-library/scripts/smtp-vuln-cve2010-4344.nse +461 -0
  753. nse-library/scripts/smtp-vuln-cve2011-1720.nse +285 -0
  754. nse-library/scripts/smtp-vuln-cve2011-1764.nse +235 -0
  755. nse-library/scripts/sniffer-detect.nse +144 -0
  756. nse-library/scripts/snmp-brute.nse +278 -0
  757. nse-library/scripts/snmp-hh3c-logins.nse +148 -0
  758. nse-library/scripts/snmp-info.nse +145 -0
  759. nse-library/scripts/snmp-interfaces.nse +736 -0
  760. nse-library/scripts/snmp-ios-config.nse +178 -0
  761. nse-library/scripts/snmp-netstat.nse +138 -0
  762. nse-library/scripts/snmp-processes.nse +162 -0
  763. nse-library/scripts/snmp-sysdescr.nse +69 -0
  764. nse-library/scripts/snmp-win32-services.nse +95 -0
  765. nse-library/scripts/snmp-win32-shares.nse +100 -0
  766. nse-library/scripts/snmp-win32-software.nse +163 -0
  767. nse-library/scripts/snmp-win32-users.nse +92 -0
  768. nse-library/scripts/socks-auth-info.nse +65 -0
  769. nse-library/scripts/socks-brute.nse +102 -0
  770. nse-library/scripts/socks-open-proxy.nse +191 -0
  771. nse-library/scripts/ssh-auth-methods.nse +55 -0
  772. nse-library/scripts/ssh-brute.nse +108 -0
  773. nse-library/scripts/ssh-hostkey.nse +426 -0
  774. nse-library/scripts/ssh-publickey-acceptance.nse +166 -0
  775. nse-library/scripts/ssh-run.nse +104 -0
  776. nse-library/scripts/ssh2-enum-algos.nse +212 -0
  777. nse-library/scripts/sshv1.nse +74 -0
  778. nse-library/scripts/ssl-ccs-injection.nse +328 -0
  779. nse-library/scripts/ssl-cert-intaddr.nse +149 -0
  780. nse-library/scripts/ssl-cert.nse +376 -0
  781. nse-library/scripts/ssl-date.nse +215 -0
  782. nse-library/scripts/ssl-dh-params.nse +941 -0
  783. nse-library/scripts/ssl-enum-ciphers.nse +1142 -0
  784. nse-library/scripts/ssl-heartbleed.nse +238 -0
  785. nse-library/scripts/ssl-known-key.nse +138 -0
  786. nse-library/scripts/ssl-poodle.nse +357 -0
  787. nse-library/scripts/sslv2-drown.nse +341 -0
  788. nse-library/scripts/sslv2.nse +57 -0
  789. nse-library/scripts/sstp-discover.nse +80 -0
  790. nse-library/scripts/stun-info.nse +49 -0
  791. nse-library/scripts/stun-version.nse +44 -0
  792. nse-library/scripts/stuxnet-detect.nse +119 -0
  793. nse-library/scripts/supermicro-ipmi-conf.nse +99 -0
  794. nse-library/scripts/svn-brute.nse +273 -0
  795. nse-library/scripts/targets-asn.nse +101 -0
  796. nse-library/scripts/targets-ipv6-eui64.nse +121 -0
  797. nse-library/scripts/targets-ipv6-map4to6.nse +247 -0
  798. nse-library/scripts/targets-ipv6-multicast-echo.nse +151 -0
  799. nse-library/scripts/targets-ipv6-multicast-invalid-dst.nse +182 -0
  800. nse-library/scripts/targets-ipv6-multicast-mld.nse +137 -0
  801. nse-library/scripts/targets-ipv6-multicast-slaac.nse +238 -0
  802. nse-library/scripts/targets-ipv6-wordlist.nse +283 -0
  803. nse-library/scripts/targets-sniffer.nse +163 -0
  804. nse-library/scripts/targets-traceroute.nse +64 -0
  805. nse-library/scripts/targets-xml.nse +142 -0
  806. nse-library/scripts/teamspeak2-version.nse +71 -0
  807. nse-library/scripts/telnet-brute.nse +698 -0
  808. nse-library/scripts/telnet-encryption.nse +106 -0
  809. nse-library/scripts/telnet-ntlm-info.nse +141 -0
  810. nse-library/scripts/tftp-enum.nse +212 -0
  811. nse-library/scripts/tftp-version.nse +321 -0
  812. nse-library/scripts/tls-alpn.nse +244 -0
  813. nse-library/scripts/tls-nextprotoneg.nse +160 -0
  814. nse-library/scripts/tls-ticketbleed.nse +360 -0
  815. nse-library/scripts/tn3270-screen.nse +122 -0
  816. nse-library/scripts/tor-consensus-checker.nse +135 -0
  817. nse-library/scripts/traceroute-geolocation.nse +187 -0
  818. nse-library/scripts/tso-brute.nse +368 -0
  819. nse-library/scripts/tso-enum.nse +291 -0
  820. nse-library/scripts/ubiquiti-discovery.nse +375 -0
  821. nse-library/scripts/unittest.nse +44 -0
  822. nse-library/scripts/unusual-port.nse +130 -0
  823. nse-library/scripts/upnp-info.nse +57 -0
  824. nse-library/scripts/uptime-agent-info.nse +95 -0
  825. nse-library/scripts/url-snarf.nse +154 -0
  826. nse-library/scripts/ventrilo-info.nse +665 -0
  827. nse-library/scripts/versant-info.nse +115 -0
  828. nse-library/scripts/vmauthd-brute.nse +121 -0
  829. nse-library/scripts/vmware-version.nse +88 -0
  830. nse-library/scripts/vnc-brute.nse +152 -0
  831. nse-library/scripts/vnc-info.nse +163 -0
  832. nse-library/scripts/vnc-title.nse +104 -0
  833. nse-library/scripts/voldemort-info.nse +173 -0
  834. nse-library/scripts/vtam-enum.nse +278 -0
  835. nse-library/scripts/vulners.nse +249 -0
  836. nse-library/scripts/vuze-dht-info.nse +88 -0
  837. nse-library/scripts/wdb-version.nse +222 -0
  838. nse-library/scripts/weblogic-t3-info.nse +94 -0
  839. nse-library/scripts/whois-domain.nse +173 -0
  840. nse-library/scripts/whois-ip.nse +2263 -0
  841. nse-library/scripts/wsdd-discover.nse +91 -0
  842. nse-library/scripts/x11-access.nse +74 -0
  843. nse-library/scripts/xdmcp-discover.nse +67 -0
  844. nse-library/scripts/xmlrpc-methods.nse +120 -0
  845. nse-library/scripts/xmpp-brute.nse +142 -0
  846. nse-library/scripts/xmpp-info.nse +579 -0
  847. nse-library/sources/cldrn/README.md +10 -0
  848. nse-library/sources/cldrn/UPDATES +1 -0
  849. nse-library/sources/cldrn/count_targets.sh +10 -0
  850. nse-library/sources/cldrn/data/http-default-accounts-fingerprints.lua +125 -0
  851. nse-library/sources/cldrn/data/http-fingerprints.lua +11424 -0
  852. nse-library/sources/cldrn/data/huawei-udp-info.bin +0 -0
  853. nse-library/sources/cldrn/nmap-mon.sh +35 -0
  854. nse-library/sources/cldrn/nmap-nse-linter.sh +196 -0
  855. nse-library/sources/cldrn/nse-script-template.nse +21 -0
  856. nse-library/sources/cldrn/nsedoc.tar.gz +0 -0
  857. nse-library/sources/cldrn/nselib/brute.lua +1556 -0
  858. nse-library/sources/cldrn/nselib/data/http-fingerprints.lua +12054 -0
  859. nse-library/sources/cldrn/nselib/dicom.lua +272 -0
  860. nse-library/sources/cldrn/nselib/http.lua +2622 -0
  861. nse-library/sources/cldrn/nselib/httpspider.lua +725 -0
  862. nse-library/sources/cldrn/nselib/smb.lua +4316 -0
  863. nse-library/sources/cldrn/nselib/stdnse.lua +964 -0
  864. nse-library/sources/cldrn/old-scripts/hostmap.nse +207 -0
  865. nse-library/sources/cldrn/old-scripts/http-awstatstotals-exec.nse +130 -0
  866. nse-library/sources/cldrn/old-scripts/http-axis2-dir-traversal.nse +188 -0
  867. nse-library/sources/cldrn/old-scripts/http-brute.nse +124 -0
  868. nse-library/sources/cldrn/old-scripts/http-cakephp-version.nse +99 -0
  869. nse-library/sources/cldrn/old-scripts/http-default-accounts.nse +286 -0
  870. nse-library/sources/cldrn/old-scripts/http-email-harvest.nse +59 -0
  871. nse-library/sources/cldrn/old-scripts/http-form-brute.nse +244 -0
  872. nse-library/sources/cldrn/old-scripts/http-google-malware.nse +95 -0
  873. nse-library/sources/cldrn/old-scripts/http-huawei-hg5xx-vuln.nse +109 -0
  874. nse-library/sources/cldrn/old-scripts/http-joomla-brute.nse +146 -0
  875. nse-library/sources/cldrn/old-scripts/http-litespeed-sourcecode-download.nse +66 -0
  876. nse-library/sources/cldrn/old-scripts/http-majordomo2-dir-traversal.nse +90 -0
  877. nse-library/sources/cldrn/old-scripts/http-phpself-xss.nse +142 -0
  878. nse-library/sources/cldrn/old-scripts/http-phpselfxss-scan.nse +81 -0
  879. nse-library/sources/cldrn/old-scripts/http-sitemap-dump.nse +335 -0
  880. nse-library/sources/cldrn/old-scripts/http-sitemap.nse +42 -0
  881. nse-library/sources/cldrn/old-scripts/http-tomcat-brute.nse +116 -0
  882. nse-library/sources/cldrn/old-scripts/http-trace.nse +66 -0
  883. nse-library/sources/cldrn/old-scripts/http-vuln-cve2012-1823.nse +99 -0
  884. nse-library/sources/cldrn/old-scripts/http-waf-detect.nse +121 -0
  885. nse-library/sources/cldrn/old-scripts/http-wordpress-brute.nse +134 -0
  886. nse-library/sources/cldrn/old-scripts/http-wp-enum.nse +137 -0
  887. nse-library/sources/cldrn/old-scripts/huawei5xx-udp-info.nse +103 -0
  888. nse-library/sources/cldrn/scripts/dicom-brute.nse +80 -0
  889. nse-library/sources/cldrn/scripts/dicom-cfind-ls.nse +800 -0
  890. nse-library/sources/cldrn/scripts/dicom-cmove.nse +583 -0
  891. nse-library/sources/cldrn/scripts/dicom-get.nse +655 -0
  892. nse-library/sources/cldrn/scripts/dicom-info.nse +631 -0
  893. nse-library/sources/cldrn/scripts/dicom-ping.nse +70 -0
  894. nse-library/sources/cldrn/scripts/dicom-store-fuzzer.nse +789 -0
  895. nse-library/sources/cldrn/scripts/dicom.lua +1533 -0
  896. nse-library/sources/cldrn/scripts/dns-cname-dangling.nse +504 -0
  897. nse-library/sources/cldrn/scripts/dns-openresolvers-check.nse +84 -0
  898. nse-library/sources/cldrn/scripts/google-people-enum.nse +213 -0
  899. nse-library/sources/cldrn/scripts/hostmap-crtsh.nse +115 -0
  900. nse-library/sources/cldrn/scripts/hostmap-ip2hosts.nse +131 -0
  901. nse-library/sources/cldrn/scripts/hostmap.nse +207 -0
  902. nse-library/sources/cldrn/scripts/http-adobe-coldfusion-apsa1301.nse +58 -0
  903. nse-library/sources/cldrn/scripts/http-awstatstotals-exec.nse +134 -0
  904. nse-library/sources/cldrn/scripts/http-axis2-dir-traversal.nse +192 -0
  905. nse-library/sources/cldrn/scripts/http-brute.nse +130 -0
  906. nse-library/sources/cldrn/scripts/http-cakephp-version.nse +106 -0
  907. nse-library/sources/cldrn/scripts/http-coldfusion-subzero.nse +128 -0
  908. nse-library/sources/cldrn/scripts/http-default-accounts.nse +295 -0
  909. nse-library/sources/cldrn/scripts/http-email-harvest.nse +86 -0
  910. nse-library/sources/cldrn/scripts/http-form-brute.nse +251 -0
  911. nse-library/sources/cldrn/scripts/http-google-malware.nse +99 -0
  912. nse-library/sources/cldrn/scripts/http-httpoxy.nse +151 -0
  913. nse-library/sources/cldrn/scripts/http-huawei-hg5xx-vuln.nse +128 -0
  914. nse-library/sources/cldrn/scripts/http-iis-short-name-brute.nse +173 -0
  915. nse-library/sources/cldrn/scripts/http-iis-shortname-dos.nse +53 -0
  916. nse-library/sources/cldrn/scripts/http-joomla-brute.nse +150 -0
  917. nse-library/sources/cldrn/scripts/http-litespeed-sourcecode-download.nse +70 -0
  918. nse-library/sources/cldrn/scripts/http-majordomo2-dir-traversal.nse +95 -0
  919. nse-library/sources/cldrn/scripts/http-method-tamper.nse +168 -0
  920. nse-library/sources/cldrn/scripts/http-phpself-xss.nse +157 -0
  921. nse-library/sources/cldrn/scripts/http-shellshock-spider.nse +74 -0
  922. nse-library/sources/cldrn/scripts/http-tplink-dir-traversal.nse +155 -0
  923. nse-library/sources/cldrn/scripts/http-trace.nse +68 -0
  924. nse-library/sources/cldrn/scripts/http-trendnet-tvip110w.nse +39 -0
  925. nse-library/sources/cldrn/scripts/http-vuln-cve2012-1823.nse +99 -0
  926. nse-library/sources/cldrn/scripts/http-vuln-cve2013-0156.nse +121 -0
  927. nse-library/sources/cldrn/scripts/http-vuln-cve2015-1635.nse +85 -0
  928. nse-library/sources/cldrn/scripts/http-waf-detect.nse +124 -0
  929. nse-library/sources/cldrn/scripts/http-wordpress-brute.nse +136 -0
  930. nse-library/sources/cldrn/scripts/http-wordpress-enum.nse +146 -0
  931. nse-library/sources/cldrn/scripts/huawei5xx-udp-info.nse +105 -0
  932. nse-library/sources/cldrn/scripts/mikrotik-routeros-brute.nse +104 -0
  933. nse-library/sources/cldrn/scripts/mysql-vuln-cve2012-2122.nse +146 -0
  934. nse-library/sources/cldrn/scripts/smb-vuln-conficker.nse +190 -0
  935. nse-library/sources/cldrn/scripts/smb-vuln-cve2009-3103.nse +178 -0
  936. nse-library/sources/cldrn/scripts/smb-vuln-ms06-025.nse +165 -0
  937. nse-library/sources/cldrn/scripts/smb-vuln-ms07-029.nse +152 -0
  938. nse-library/sources/cldrn/scripts/smb-vuln-ms08-067.nse +157 -0
  939. nse-library/sources/cldrn/scripts/smb-vuln-ms17-010.nse +187 -0
  940. nse-library/sources/cldrn/scripts/smb-vuln-regsvc-dos.nse +126 -0
  941. nse-library/sources/cldrn/scripts/smtp-dovecot-exim-exec.nse +110 -0
  942. nse-library/sources/cldrn/scripts/vulscan.nse +538 -0
  943. nse-library/sources/cldrn/workshops/command-cheatsheet.md +29 -0
  944. nse-library/sources/cldrn/workshops/dc24/dotvimrc.txt +7 -0
  945. nse-library/sources/cldrn/workshops/dc24/fakewebapp/login.php +18 -0
  946. nse-library/sources/cldrn/workshops/dc24/http-shellshock-spider.nse +74 -0
  947. nse-library/sources/cldrn/workshops/dc24/nmap-check.sh +213 -0
  948. nse-library/sources/cldrn/workshops/dc24/nmap.jpg +0 -0
  949. nse-library/sources/cldrn/workshops/dc24/nse-script-template.nse +21 -0
  950. nse-library/sources/cldrn/workshops/dc24/sample-scan/scanme.gnmap +4 -0
  951. nse-library/sources/cldrn/workshops/dc24/sample-scan/scanme.nmap +15 -0
  952. nse-library/sources/cldrn/workshops/dc24/sample-scan/scanme.xml +28 -0
  953. nse-library/sources/cldrn/workshops/nmap-nse.odp +0 -0
  954. nse-library/sources/hackertarget/LICENSE +340 -0
  955. nse-library/sources/hackertarget/README.md +43 -0
  956. nse-library/sources/hackertarget/hostmap-hackertarget.nse +83 -0
  957. nse-library/sources/hackertarget/http-wordpress-info.nse +227 -0
  958. nse-library/sources/hackertarget/http-wordpress-plugins.nse +197 -0
  959. nse-library/sources/hackertarget/http-wordpress-themes.nse +192 -0
  960. nse-library/sources/hackertarget/wp-plugins.lst +56908 -0
  961. nse-library/sources/hackertarget/wp-themes.lst +14528 -0
  962. nse-library/sources/personal/exploit-xunlei-rce.nse +6 -0
  963. nse-library/sources/personal/my-dokuwiki-audit.nse +17 -0
  964. nse-library/sources/psc4re/CVE-2021-21972.nse +89 -0
  965. nse-library/sources/psc4re/README.md +98 -0
  966. nse-library/sources/psc4re/cve-2020-0796.nse +101 -0
  967. nse-library/sources/psc4re/cve-2020-1350.nse +89 -0
  968. nse-library/sources/psc4re/http-custom-title.nse +99 -0
  969. nse-library/sources/psc4re/proxyshell.nse +41 -0
  970. nse-library/sources/vulners/LICENSE +583 -0
  971. nse-library/sources/vulners/README.md +923 -0
  972. nse-library/sources/vulners/catalog/fingerprints.json +6960 -0
  973. nse-library/sources/vulners/catalog/index.json +19 -0
  974. nse-library/sources/vulners/catalog/paths.json +958 -0
  975. nse-library/sources/vulners/catalog/probes.json +180 -0
  976. nse-library/sources/vulners/install.ps1 +391 -0
  977. nse-library/sources/vulners/install.sh +428 -0
  978. nse-library/sources/vulners/vulners.nse +4395 -0
  979. nseft/__init__.py +3 -0
  980. nseft/calibration.json +14 -0
  981. nseft/data.py +145 -0
  982. nseft/doctor.py +112 -0
  983. nseft/grpo.py +53 -0
  984. nseft/library.py +225 -0
  985. nseft/model.py +143 -0
  986. nseft/output.py +100 -0
  987. nseft/personal.py +83 -0
  988. nseft/phronesis.py +65 -0
  989. nseft/profiles.py +111 -0
  990. nseft/rlvr.py +300 -0
  991. nseft/scoring.py +128 -0
  992. nseft/services.py +97 -0
  993. nseft/templates.py +136 -0
  994. nseft/update_db.py +408 -0
  995. nseft/weights.py +190 -0
  996. phronesis_nse-0.3.0.dist-info/METADATA +434 -0
  997. phronesis_nse-0.3.0.dist-info/RECORD +1001 -0
  998. phronesis_nse-0.3.0.dist-info/WHEEL +5 -0
  999. phronesis_nse-0.3.0.dist-info/entry_points.txt +2 -0
  1000. phronesis_nse-0.3.0.dist-info/licenses/LICENSE +201 -0
  1001. phronesis_nse-0.3.0.dist-info/top_level.txt +3 -0
nmap_select.py ADDED
@@ -0,0 +1,801 @@
1
+ """Phronesis NSE selector.
2
+
3
+ The default path reads an Nmap XML stream from stdin, chooses one NSE action per
4
+ open port, and prints the suggestion. It never runs a script unless --run is set.
5
+ """
6
+ import argparse
7
+ import io
8
+ import ipaddress
9
+ import json
10
+ import os
11
+ import re
12
+ import shutil
13
+ import subprocess
14
+ import sys
15
+ import tempfile
16
+ import time
17
+ import xml.etree.ElementTree as ET
18
+ from pathlib import Path
19
+
20
+ from nseft.library import (
21
+ DEFAULT_CATEGORIES, EXTERNAL_CATEGORY, RISKY_CATEGORIES, default_safe,
22
+ hash_file, legacy_scripts_dir, load_catalog as load_library_catalog,
23
+ resolve_library, script_metadata,
24
+ )
25
+ from nseft.output import (Logger, result_json, result_line, shell_command, suggest_line, table,
26
+ write_file)
27
+ from nseft.personal import index_personal, merge_catalogs, personal_rows
28
+ from nseft.profiles import load_profile
29
+ from nseft.scoring import (TRAINED_MAX_CANDIDATES, TRAINED_MAX_PROMPT_TOKENS, in_training_range,
30
+ load_calibration, rank_candidates, softmax)
31
+ from nseft.services import infer_families
32
+ from nseft.templates import apply_templates, load_templates
33
+ from nseft.weights import WeightsError, resolve_model_dir
34
+
35
+ sys.stdout.reconfigure(encoding="utf-8", errors="replace")
36
+
37
+ ROOT = Path(__file__).resolve().parent
38
+ CAT = ROOT / "data/nse-catalog.jsonl"
39
+ WINDOWS = os.name == "nt"
40
+ SCRIPTS_DIR = legacy_scripts_dir()
41
+ PERSONAL_DIR = Path(os.environ.get("NSE_PERSONAL", "D:/nse-scripts" if WINDOWS else "~/nse-scripts")).expanduser()
42
+ MODEL_DIR = resolve_model_dir(download=False, repo_root=ROOT)
43
+ FAMILY = {
44
+ "http": ("http-", "ssl-", "vhost-", "banner"), "https": ("http-", "ssl-", "banner"),
45
+ "ssh": ("ssh", "ssh2-", "banner"), "ftp": ("ftp-", "banner"),
46
+ "smtp": ("smtp-", "pop3-", "banner"), "pop3": ("pop3-", "banner"),
47
+ "redis": ("redis-", "banner"), "mysql": ("mysql-", "banner"),
48
+ "postgresql": ("pgsql-", "banner"), "memcached": ("memcached-", "banner"),
49
+ "imap": ("imap-", "banner"), "snmp": ("snmp-", "banner"),
50
+ "domain": ("dns-", "banner"), "dns": ("dns-", "banner"),
51
+ "mongodb": ("mongodb-", "banner"),
52
+ "microsoft-ds": ("smb-", "banner"), "smb": ("smb-", "banner"),
53
+ "netbios-ssn": ("smb-", "banner"), "tls": ("ssl-", "banner"),
54
+ }
55
+ PORT_FAMILY = {80: "http", 443: "https", 8000: "http", 8080: "http", 8443: "https", 5000: "http", 9000: "http"}
56
+ DEFAULTS = {"banner", "default", "http-title", "http-server-header", "http-robots.txt", "http-methods",
57
+ "http-git", "http-favicon", "ssl-cert", "ssl-enum-ciphers", "ssh-hostkey", "ssh2-enum-algos",
58
+ "ftp-anon", "smtp-commands", "redis-info"}
59
+
60
+
61
+ def c(code, s):
62
+ if os.environ.get("NO_COLOR") or not (os.environ.get("FORCE_COLOR") or sys.stdout.isatty()):
63
+ return s
64
+ return f"\033[{code}m{s}\033[0m"
65
+
66
+
67
+ def norm(s):
68
+ return re.sub(r"[|_\\`'\"]+", " ", re.sub(r"\s+", " ", (s or "").lower())).strip()
69
+
70
+
71
+ def valid_target(value):
72
+ """Reject Nmap option injection while allowing hostnames, IPs, and CIDRs."""
73
+ if not value or value.startswith("-") or not re.fullmatch(r"[A-Za-z0-9_.:/%-]+", value):
74
+ return False
75
+ try:
76
+ ipaddress.ip_network(value, strict=False)
77
+ return True
78
+ except ValueError:
79
+ return bool(re.fullmatch(r"(?=.{1,253}$)(?:[A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?)(?:\.(?:[A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?))*\.?", value))
80
+
81
+
82
+ def valid_script_id(value):
83
+ return not value.startswith("-") and bool(re.fullmatch(r"[A-Za-z0-9_.-]+", value)) and value not in (".", "..")
84
+
85
+
86
+ def build_catalog(scripts_dir=None, library=None):
87
+ """Build catalog rows in memory; write data/nse-catalog.jsonl only for a legacy dir."""
88
+ scripts_dir = Path(scripts_dir or SCRIPTS_DIR)
89
+ rows = [script_metadata(path, "nmap-official", library or scripts_dir)
90
+ for path in sorted(scripts_dir.rglob("*.nse"))]
91
+ if not rows:
92
+ raise SystemExit(f"aucun .nse sous {scripts_dir} : definir NSE_SCRIPTS")
93
+ if library is None:
94
+ CAT.parent.mkdir(parents=True, exist_ok=True)
95
+ CAT.write_text("".join(json.dumps(row, ensure_ascii=False, sort_keys=True) + "\n"
96
+ for row in rows), encoding="utf-8")
97
+ return rows
98
+
99
+
100
+ def load_catalog(datadir=None):
101
+ library = resolve_library(datadir)
102
+ if library:
103
+ return load_library_catalog(library / "catalog.jsonl", library), library
104
+ if CAT.is_file():
105
+ return load_library_catalog(CAT), None
106
+ if SCRIPTS_DIR.is_dir():
107
+ return build_catalog(), None
108
+ raise SystemExit("bibliothèque NSE introuvable: utiliser --datadir ou definir NSE_SCRIPTS")
109
+
110
+
111
+ def host_states(source):
112
+ """-> [{host, ports:[{port, service_name, known, uncertain, done}]} dans le format vu au train."""
113
+ raw = source.read() if hasattr(source, "read") else Path(source).read_bytes()
114
+ if len(raw) > 20 * 1024 * 1024 or b"<!ENTITY" in raw.upper():
115
+ raise ValueError("XML trop volumineux ou contenant des entités")
116
+ root = ET.fromstring(raw)
117
+ out = []
118
+ for host in root.findall("host"):
119
+ addr = next((a.get("addr") for a in host.findall("address") if a.get("addrtype") == "ipv4"),
120
+ host.get("name") or "?")
121
+ ports = []
122
+ for pt in host.findall("ports/port"):
123
+ st = pt.find("state")
124
+ if st is None or st.get("state") != "open":
125
+ continue
126
+ port = int(pt.get("portid"))
127
+ known, uncertain = [f"port {port}/tcp open"], []
128
+ svc = pt.find("service")
129
+ name = (svc.get("name") if svc is not None else "") or ""
130
+ prod = svc.get("product") if svc is not None else None
131
+ conf = int((svc.get("conf") if svc is not None else 0) or 0)
132
+ if prod and conf >= 7:
133
+ known.append(f"service {port}: {prod} {svc.get('version', '')}".strip())
134
+ elif prod:
135
+ known.append(f"service {port}: {prod}")
136
+ elif name:
137
+ uncertain.append(f"service {port}: {name}")
138
+ done, outputs = set(), []
139
+ for script in pt.findall("script"):
140
+ done.add(script.get("id"))
141
+ output = script.find("output")
142
+ text = (output.text if output is not None and output.text else None) or script.get("output") or ""
143
+ outputs.extend(norm(x) for x in re.split(r"[\r\n]+", text) if len(norm(x)) >= 10)
144
+ known.extend(item for item in outputs if not any(item in known_item or known_item in item
145
+ for known_item in known))
146
+ ports.append({"port": port, "protocol": pt.get("protocol") or "tcp",
147
+ "service": name, "product": prod or "",
148
+ "version": (svc.get("version", "") if svc is not None else "") or "",
149
+ "tunnel": (svc.get("tunnel", "") if svc is not None else "") or "",
150
+ "servicefp": (svc.get("servicefp", "") if svc is not None else "") or "",
151
+ "known": known[:12], "uncertain": uncertain[:6],
152
+ "evidence": known + uncertain, "done": done})
153
+ out.append({"host": addr, "ports": ports,
154
+ "host_scripts": [{"id": s.get("id"), "output": s.get("output") or ""}
155
+ for s in host.findall("hostscript/script")]})
156
+ if len(out) > 1024:
157
+ raise ValueError("XML dépasse la limite de 1024 hôtes")
158
+ return out
159
+
160
+
161
+ def _row_path(row, library):
162
+ path = Path(row.get("path", ""))
163
+ if not path.is_absolute():
164
+ if library:
165
+ path = Path(library) / path
166
+ elif len(path.parts) > 1 and path.parts[0] == "scripts":
167
+ path = SCRIPTS_DIR / path.name
168
+ else:
169
+ path = SCRIPTS_DIR / path
170
+ return path
171
+
172
+
173
+ def _manual_row(script_id, catalog, library):
174
+ for row in catalog:
175
+ if row["script_id"] == script_id:
176
+ return row
177
+ for path in PERSONAL_DIR.rglob(f"{script_id}.nse"):
178
+ text = path.read_text(encoding="utf-8", errors="replace")
179
+ row = script_metadata(path, "personal", None, "unlicensed")
180
+ row["description"] = row["description"] or script_id
181
+ row["path"] = str(path)
182
+ return row
183
+ return None
184
+
185
+
186
+ def _auto_allowed(row, allow_risky, all_scripts=False, personal_auto=False, allow_external=False):
187
+ source = row.get("source", "nmap-official")
188
+ categories = set(row.get("categories", []))
189
+ if source == "personal":
190
+ return personal_auto and bool(row.get("auto_allowed")) and (
191
+ allow_external or EXTERNAL_CATEGORY not in categories)
192
+ if source != "nmap-official" and not all_scripts:
193
+ return False
194
+ if EXTERNAL_CATEGORY in categories:
195
+ return allow_external
196
+ if categories & RISKY_CATEGORIES:
197
+ return allow_risky
198
+ if source == "nmap-official":
199
+ if "auto_allowed" in row:
200
+ return bool(row["auto_allowed"])
201
+ return bool(categories & DEFAULT_CATEGORIES) or not categories
202
+ return bool(categories & DEFAULT_CATEGORIES)
203
+
204
+
205
+ def pick_candidates(svc, port, done, catalog, manual, cap, allow_risky=False,
206
+ all_scripts=False, families=None, personal_auto=False,
207
+ allow_external=False):
208
+ if manual:
209
+ ids = list(dict.fromkeys(s.strip() for s in manual.split(",") if s.strip()))
210
+ invalid = sorted(sid for sid in ids if not valid_script_id(sid))
211
+ if invalid:
212
+ raise ValueError(f"identifiant NSE invalide: {invalid[0]!r}")
213
+ found = []
214
+ for sid in ids:
215
+ row = _manual_row(sid, catalog, None)
216
+ if row:
217
+ found.append(row)
218
+ return found[:cap]
219
+ if families:
220
+ prefixes = []
221
+ wanted = []
222
+ for item in families:
223
+ name = item["name"] if isinstance(item, dict) else item
224
+ wanted.append(name)
225
+ prefixes.extend(FAMILY.get(name, (name,)))
226
+ prefs = tuple(dict.fromkeys(prefix for prefix in prefixes if prefix))
227
+ wanted = set(wanted)
228
+ else:
229
+ wanted = set()
230
+ prefs = FAMILY.get(svc)
231
+ if not prefs and port in PORT_FAMILY:
232
+ prefs = FAMILY[PORT_FAMILY[port]]
233
+ prefs = prefs or tuple(p for p in (svc.split("-")[0], "banner") if p)
234
+ def matches(row):
235
+ if any(row["script_id"].startswith(prefix) or prefix == row["script_id"]
236
+ for prefix in prefs if prefix):
237
+ return True
238
+ return (row.get("source") == "personal" and personal_auto
239
+ and bool(set(row.get("families", [])) & wanted))
240
+ pool = [row for row in catalog if row["script_id"] not in done
241
+ and matches(row)
242
+ and _auto_allowed(row, allow_risky, all_scripts, personal_auto, allow_external)]
243
+ ordered = sorted(pool, key=lambda row: (
244
+ row["script_id"] not in DEFAULTS,
245
+ 0 if row.get("source") == "personal" else 1 if row.get("source", "nmap-official") == "nmap-official" else 2,
246
+ row["script_id"]))
247
+ return ordered[:cap]
248
+
249
+
250
+ def resolve_nmap():
251
+ native = shutil.which("nmap")
252
+ if native:
253
+ return [native], False
254
+ if WINDOWS and shutil.which("wsl"):
255
+ return ["wsl", "nmap"], True
256
+ raise RuntimeError("nmap introuvable : installez Nmap, ou WSL avec Nmap sous Windows")
257
+
258
+
259
+ def nmap_path(path, use_wsl=None):
260
+ if use_wsl is None:
261
+ use_wsl = WINDOWS
262
+ path = Path(path).resolve()
263
+ if not use_wsl:
264
+ return str(path)
265
+ value = path.as_posix()
266
+ return "/mnt/" + value[0].lower() + value[2:]
267
+
268
+
269
+ def nmap_command(base, library, use_wsl):
270
+ if library and use_wsl:
271
+ return ["wsl", "env", f"NMAPDIR={nmap_path(library, True)}", "nmap"] + base
272
+ if library:
273
+ return ["nmap"] + base
274
+ return (["wsl", "nmap"] if use_wsl else ["nmap"]) + base
275
+
276
+
277
+ def nmap_env(library, use_wsl):
278
+ if not library or use_wsl:
279
+ return None
280
+ env = os.environ.copy()
281
+ env["NMAPDIR"] = str(Path(library).resolve())
282
+ return env
283
+
284
+
285
+ def run_nmap(argv, timeout, env=None, capture=False, stderr=None):
286
+ return subprocess.run(argv, timeout=timeout, env=env, stdin=subprocess.DEVNULL,
287
+ cwd=tempfile.gettempdir(), text=capture,
288
+ stdout=subprocess.PIPE if capture else stderr,
289
+ stderr=subprocess.PIPE if capture else stderr)
290
+
291
+
292
+ def xml_from_stdin():
293
+ data = sys.stdin.buffer.read()
294
+ if not data.strip():
295
+ raise ValueError("stdin vide : fournir un XML Nmap (-oX -)")
296
+ return io.BytesIO(data)
297
+
298
+
299
+ def script_argument(row, library, use_wsl):
300
+ path = _row_path(row, library)
301
+ if row.get("source", "nmap-official") == "nmap-official":
302
+ return row["script_id"]
303
+ return nmap_path(path, use_wsl)
304
+
305
+
306
+ def verify_script(row, library, personal_root=None):
307
+ path = _row_path(row, library)
308
+ if not path.is_file():
309
+ raise ValueError(f"script introuvable: {path}")
310
+ if hash_file(path) != row.get("script_sha256"):
311
+ raise ValueError(f"empreinte du script modifiée: {path}")
312
+ if row.get("source") == "personal":
313
+ root = Path(personal_root).expanduser().resolve() if personal_root else PERSONAL_DIR.resolve()
314
+ else:
315
+ root = Path(library).resolve() if library else PERSONAL_DIR.resolve()
316
+ if root not in path.resolve().parents and path.resolve() != root:
317
+ raise ValueError(f"script hors bibliothèque: {path}")
318
+ return path
319
+
320
+
321
+ def make_parser():
322
+ parser = argparse.ArgumentParser(
323
+ prog="phronesis",
324
+ description="Choisit un script NSE utile, ou STOP, à partir d'un XML Nmap.",
325
+ epilog="Sous-commandes: suggest, index, update-db.")
326
+ parser.add_argument("target", nargs="?", help="hôte/IP à scanner si aucun XML n'est fourni")
327
+ parser.add_argument("-p", "--ports", default="")
328
+ parser.add_argument("--xml", help="XML Nmap existant, ou - pour stdin")
329
+ parser.add_argument("--scripts", default="", help="candidats forcés, ex: http-title,ssl-cert")
330
+ parser.add_argument("--top", type=int, default=None,
331
+ help="nombre maximal de candidats par port (défaut: 8)")
332
+ parser.add_argument("--datadir", help="racine de la bibliothèque NSE (scripts/ et nselib/)")
333
+ parser.add_argument("--personal-dir", help="dossier des scripts NSE personnels")
334
+ parser.add_argument("--personal-overrides", action="store_true",
335
+ help="un script perso remplace un script officiel de même identifiant")
336
+ parser.add_argument("--allow-undocumented-personal", action="store_true")
337
+ parser.add_argument("--model-dir", help="dossier local du modèle Phronesis Safetensors")
338
+ parser.add_argument("--device", default=None)
339
+ parser.add_argument("--allow-risky", action="store_true",
340
+ help="autorise les scripts officiels intrusive/brute/dos/exploit")
341
+ parser.add_argument("--all-scripts", action="store_true",
342
+ help="inclut les scripts communautaires sûrs dans le pool automatique")
343
+ parser.add_argument("--allow-external", action="store_true",
344
+ help="autorise les scripts qui contactent un service tiers")
345
+ parser.add_argument("--all-candidates", action="store_true",
346
+ help="note tout le pool filtré au lieu de le plafonner")
347
+ parser.add_argument("--templates", action="append", default=[],
348
+ help="fichier ou dossier de templates YAML/JSON (répétable)")
349
+ parser.add_argument("--no-templates", action="store_true")
350
+ parser.add_argument("--max-candidates", type=int, default=None,
351
+ help="candidats notés par port en mode suggest (défaut: 24)")
352
+ parser.add_argument("--top-k", type=int, default=None,
353
+ help="suggestions affichées par port (défaut: 8)")
354
+ parser.add_argument("--min-prob", type=float, default=None)
355
+ parser.add_argument("--stop-threshold", type=float, default=None)
356
+ parser.add_argument("--method", choices=("sequence", "generative"), default=None)
357
+ parser.add_argument("--profile", help="profil YAML/JSON de suggestions")
358
+ parser.add_argument("--explain", action="store_true")
359
+ parser.add_argument("--timeout", type=float, default=300.0, help="timeout Nmap en secondes")
360
+ parser.add_argument("--format", choices=("lines", "table", "jsonl", "commands"), default=None)
361
+ parser.add_argument("-json", "--json", action="store_true", help="sortie JSONL")
362
+ parser.add_argument("--table", action="store_true", help="sortie tableau")
363
+ parser.add_argument("--commands", action="store_true", help="sortie commandes seulement")
364
+ parser.add_argument("-silent", "--silent", action="store_true")
365
+ parser.add_argument("-nc", "--no-color", action="store_true")
366
+ parser.add_argument("-v", "--verbose", action="store_true")
367
+ parser.add_argument("-o", "--output", help="écrit les résultats dans un fichier")
368
+ parser.add_argument("-version", "--version", action="store_true")
369
+ parser.add_argument("--catalog", action="store_true", help="affiche le catalogue et quitte")
370
+ parser.add_argument("--run", action="store_true", help="exécute les scripts proposés")
371
+ return parser
372
+
373
+
374
+ def command_for(host, ps, selected, library):
375
+ native, use_wsl = resolve_nmap()
376
+ script_arg = script_argument(selected, library, use_wsl)
377
+ base = ["-Pn", "-sV"]
378
+ if ps.get("protocol") == "udp":
379
+ base.append("-sU")
380
+ base += ["-p", str(ps["port"]), "--script", script_arg, host]
381
+ return nmap_command(base, library, use_wsl)
382
+
383
+
384
+ def index_main(argv):
385
+ parser = argparse.ArgumentParser(prog="phronesis index")
386
+ parser.add_argument("--personal", required=True, help="dossier des scripts NSE personnels")
387
+ parser.add_argument("--output", required=True, help="catalogue JSONL à écrire")
388
+ parser.add_argument("--include-undocumented", action="store_true")
389
+ args = parser.parse_args(argv)
390
+ try:
391
+ result = index_personal(args.personal, args.output, args.include_undocumented)
392
+ except (ValueError, OSError, json.JSONDecodeError) as exc:
393
+ print(f"[ERR] {exc}", file=sys.stderr)
394
+ return 1
395
+ print(json.dumps(result, indent=2, ensure_ascii=False))
396
+ return 0
397
+
398
+
399
+ def main(argv=None):
400
+ argv = list(sys.argv[1:] if argv is None else argv)
401
+ if argv and argv[0] == "doctor":
402
+ from nseft.doctor import main as doctor_main
403
+ return doctor_main(argv[1:])
404
+ suggest_mode = bool(argv and argv[0] == "suggest")
405
+ if suggest_mode:
406
+ argv = argv[1:]
407
+ if argv and argv[0] == "update-db":
408
+ from nseft.update_db import main as update_main
409
+ return update_main(argv[1:])
410
+ if argv and argv[0] == "index":
411
+ return index_main(argv[1:])
412
+ parser = make_parser()
413
+ args = parser.parse_args(argv)
414
+ args.suggest_mode = suggest_mode
415
+ profile = {}
416
+ if args.profile:
417
+ try:
418
+ profile = load_profile(args.profile)
419
+ except (ValueError, OSError, json.JSONDecodeError) as exc:
420
+ parser.error(f"profil illisible: {exc}")
421
+ base = Path(args.profile).resolve().parent
422
+ profile["templates"] = [str(path if Path(path).is_absolute() else base / path)
423
+ for path in profile.get("templates", [])]
424
+ for key, default in (("top", 8), ("max_candidates", 24), ("top_k", 8),
425
+ ("min_prob", 0.0), ("stop_threshold", 0.5), ("format", "lines")):
426
+ if getattr(args, key) is None:
427
+ setattr(args, key, profile.get(key, default))
428
+ for key in ("all_scripts", "allow_risky", "allow_external"):
429
+ setattr(args, key, getattr(args, key) or profile.get(key, False))
430
+ for key in ("datadir", "personal_dir", "model_dir", "device", "method"):
431
+ if getattr(args, key) is None and key in profile:
432
+ setattr(args, key, profile[key])
433
+ if profile.get("templates"):
434
+ args.templates = profile["templates"] + args.templates
435
+ if args.version:
436
+ try:
437
+ from importlib.metadata import version
438
+ print(f"phronesis {version('phronesis-nse')}")
439
+ except Exception:
440
+ print("phronesis 0.3.0")
441
+ return 0
442
+ if args.top < 1:
443
+ parser.error("--top doit être supérieur ou égal à 1")
444
+ if args.target and not valid_target(args.target):
445
+ parser.error("cible invalide ; utiliser un nom d'hôte, une adresse IP ou un CIDR")
446
+ logger = Logger(args.silent, args.no_color, args.verbose)
447
+ if args.json:
448
+ args.format = "jsonl"
449
+ if args.table:
450
+ args.format = "table"
451
+ if args.commands:
452
+ args.format = "commands"
453
+ if not args.catalog and not args.target and not args.xml and sys.stdin.isatty():
454
+ parser.print_help()
455
+ return 0
456
+
457
+ try:
458
+ catalog, library = load_catalog(args.datadir)
459
+ except (ValueError, SystemExit) as exc:
460
+ logger.error(str(exc))
461
+ return 1
462
+ personal_auto = False
463
+ if args.personal_dir:
464
+ try:
465
+ personal = personal_rows(args.personal_dir, args.allow_undocumented_personal)
466
+ catalog, diagnostics = merge_catalogs(catalog, personal, args.personal_overrides)
467
+ personal_auto = True
468
+ logger.info(f"scripts personnels: {len(personal)} indexés, "
469
+ f"{len(diagnostics)} doublon(s) ignoré(s)")
470
+ except (ValueError, OSError, json.JSONDecodeError) as exc:
471
+ logger.error(f"scripts personnels illisibles: {exc}")
472
+ return 1
473
+ templates = []
474
+ if args.templates and not args.no_templates:
475
+ try:
476
+ templates = load_templates(args.templates)
477
+ logger.info(f"templates chargés: {len(templates)}")
478
+ except (ValueError, OSError, json.JSONDecodeError) as exc:
479
+ logger.error(f"templates illisibles: {exc}")
480
+ return 1
481
+ if args.catalog:
482
+ for row in catalog:
483
+ print(result_json(row) if args.format == "jsonl" else row["script_id"])
484
+ return 0
485
+
486
+ try:
487
+ if args.xml == "-":
488
+ source = xml_from_stdin()
489
+ elif args.xml:
490
+ source = Path(args.xml)
491
+ elif args.target:
492
+ native, use_wsl = resolve_nmap()
493
+ base = ["-Pn", "-sV", "-n"]
494
+ if args.ports:
495
+ base += ["-p", args.ports]
496
+ base += ["-oX", "-", args.target]
497
+ command = nmap_command(base, library, use_wsl)
498
+ logger.info("scan baseline: " + shell_command(command))
499
+ result = run_nmap(command, args.timeout, nmap_env(library, use_wsl), capture=True)
500
+ if result.returncode:
501
+ logger.error(result.stderr.strip() or "nmap a échoué")
502
+ return 1
503
+ source = io.BytesIO(result.stdout.encode())
504
+ elif not sys.stdin.isatty():
505
+ source = xml_from_stdin()
506
+ else:
507
+ parser.print_help()
508
+ return 0
509
+ states = host_states(source)
510
+ except (ValueError, OSError, ET.ParseError, subprocess.TimeoutExpired, RuntimeError) as exc:
511
+ logger.error(str(exc))
512
+ return 2
513
+
514
+ safe_count = sum(1 for row in catalog
515
+ if _auto_allowed(row, False, args.all_scripts, personal_auto, args.allow_external))
516
+ pool_name = "all" if args.all_scripts else "safe"
517
+ logger.info(f"bibliothèque: {len(catalog)} scripts, pool {pool_name}: {safe_count}")
518
+
519
+ pending = []
520
+ for host in states:
521
+ for ps in host["ports"]:
522
+ families = infer_families(ps)
523
+ cands = pick_candidates(ps["service"], ps["port"], ps["done"], catalog,
524
+ args.scripts,
525
+ 10000 if args.all_candidates else
526
+ (args.max_candidates if args.suggest_mode else args.top),
527
+ args.allow_risky,
528
+ args.all_scripts, families=families,
529
+ personal_auto=personal_auto,
530
+ allow_external=args.allow_external)
531
+ boosts, reasons, forced_stop, matched_templates = {}, {}, False, []
532
+ if templates:
533
+ template_state = {"port": ps["port"], "service": ps["service"] or "unknown"}
534
+ template_evidence = {
535
+ "port": ps["port"], "protocol": ps.get("protocol", "tcp"),
536
+ "service": ps["service"] or "", "product": ps.get("product", ""),
537
+ "version": ps.get("version", ""), "tunnel": ps.get("tunnel", ""),
538
+ "evidence": ps.get("evidence", []),
539
+ }
540
+ cands, boosts, reasons, forced_stop, matched_templates = apply_templates(
541
+ templates, template_state, template_evidence, ps["done"], cands, catalog,
542
+ lambda row: _auto_allowed(row, args.allow_risky, args.all_scripts,
543
+ personal_auto, args.allow_external))
544
+ pending.append({"host": host["host"], "ps": ps, "candidates": cands,
545
+ "families": families, "boosts": boosts, "reasons": reasons,
546
+ "forced_stop": forced_stop, "templates": matched_templates})
547
+ if not pending:
548
+ logger.warn("aucun port ouvert dans le XML")
549
+ return 0
550
+ if not any(item["candidates"] for item in pending):
551
+ logger.warn("aucun candidat pour les ports analysés")
552
+ return 0
553
+
554
+ try:
555
+ import torch
556
+ from nseft.phronesis import choose_action, load_model
557
+ except ImportError as exc:
558
+ logger.error(f"environnement d'inférence incomplet ({exc})")
559
+ return 1
560
+ device = args.device or ("cuda:0" if torch.cuda.is_available() else "cpu")
561
+ model_dir = Path(args.model_dir).resolve() if args.model_dir else MODEL_DIR
562
+ if model_dir is None and not args.model_dir:
563
+ try:
564
+ model_dir = resolve_model_dir(download=True, repo_root=ROOT)
565
+ except WeightsError as exc:
566
+ logger.error(f"modèle Phronesis : {exc}")
567
+ return 1
568
+ if model_dir is None or not (model_dir / "model.safetensors").is_file():
569
+ logger.error("modèle Phronesis introuvable ; utiliser --model-dir")
570
+ return 1
571
+ logger.info(f"chargement du modèle depuis {model_dir} sur {device}")
572
+ try:
573
+ model, tokenizer = load_model(model_dir, device)
574
+ except Exception as exc:
575
+ logger.error(f"chargement du modèle impossible: {exc}")
576
+ return 1
577
+
578
+ records = []
579
+ commands = []
580
+ failures = 0
581
+ started = time.perf_counter()
582
+ try:
583
+ calibration = load_calibration()
584
+ except ValueError as exc:
585
+ logger.error(f"calibration invalide: {exc}")
586
+ return 1
587
+ method = "sequence" if args.suggest_mode else (args.method or "generative")
588
+
589
+ def candidate_record(row, source_row, pre_probabilities, boosts, reasons):
590
+ return {
591
+ "script_id": row["script_id"],
592
+ "rank": row.get("rank"),
593
+ "score": round(row["score"], 6),
594
+ "probability": round(row["probability"], 6),
595
+ "probability_pre_template": round(pre_probabilities.get(row["script_id"], row["probability"]), 6),
596
+ "probability_kind": "sequence_softmax",
597
+ "temperature": calibration["temperature"],
598
+ "calibrated": calibration["calibrated"],
599
+ "calibration_scope": calibration["calibration_scope"],
600
+ "confidence": "uncalibrated",
601
+ "support": "trained_id" if source_row.get("source", "nmap-official") == "nmap-official" else "zero_shot",
602
+ "source": source_row.get("source", "nmap-official"),
603
+ "documented": bool(source_row.get("documented", True)),
604
+ "auto_allowed": bool(source_row.get("auto_allowed", True)),
605
+ "runnable": True,
606
+ "template_boosts": [{"template": template,
607
+ "delta": round(boosts.get(row["script_id"], 0.0), 6)}
608
+ for template in reasons.get(row["script_id"], [])],
609
+ }
610
+
611
+ for item in pending:
612
+ host = item["host"]
613
+ ps = item["ps"]
614
+ cands = item["candidates"]
615
+ families = item["families"]
616
+ boosts = item["boosts"]
617
+ reasons = item["reasons"]
618
+ if not cands or item["forced_stop"]:
619
+ decision = "STOP" if item["forced_stop"] else "SKIP"
620
+ record = {"host": host, "port": ps["port"], "protocol": ps.get("protocol", "tcp"),
621
+ "service": ps["service"], "decision": decision, "script": None,
622
+ "summary": "aucun candidat" if decision == "SKIP" else "template stop",
623
+ "command": None, "seconds": 0.0, "families": families,
624
+ "templates": item["templates"]}
625
+ records.append(record)
626
+ if args.format == "jsonl":
627
+ print(result_json(record))
628
+ elif args.format == "table":
629
+ pass
630
+ else:
631
+ print(result_line(host, ps["port"], ps["service"], decision, args.no_color,
632
+ ps.get("protocol", "tcp")))
633
+ continue
634
+ state = {"host": host, "port": ps["port"], "service": ps["service"] or "unknown",
635
+ "known_findings": ps["known"], "uncertain_findings": ps["uncertain"]}
636
+ began = time.perf_counter()
637
+ if method == "sequence":
638
+ try:
639
+ ranked = rank_candidates(model, tokenizer, state, cands, calibration["temperature"])
640
+ except Exception as exc:
641
+ logger.error(f"port {ps['port']}/{ps.get('protocol', 'tcp')} : notation impossible ({exc})")
642
+ return 1
643
+ pre_probabilities = {row["script_id"]: row["probability"] for row in ranked}
644
+ for row in ranked:
645
+ row["score"] += boosts.get(row["script_id"], 0.0)
646
+ post = softmax([row["score"] for row in ranked], calibration["temperature"])
647
+ for row, probability in zip(ranked, post):
648
+ row["probability"] = probability
649
+ stop_row = next(row for row in ranked if row["script_id"] == "STOP")
650
+ choices = [row for row in ranked if row["script_id"] != "STOP"]
651
+ choices.sort(key=lambda row: (-row["probability"], row["script_id"]))
652
+ for index, row in enumerate(choices, 1):
653
+ row["rank"] = index
654
+ top = [row for row in choices[:max(0, args.top_k)]
655
+ if row["probability"] >= args.min_prob]
656
+ action = "STOP"
657
+ if top and top[0]["probability"] >= args.min_prob and stop_row["probability"] < args.stop_threshold:
658
+ action = top[0]["script_id"]
659
+ selected = next((row for row in cands if row["script_id"] == action), None)
660
+ command = command_for(host, ps, selected, library) if selected else None
661
+ if command:
662
+ commands.append(command)
663
+ seconds = round(time.perf_counter() - began, 3)
664
+ source_by_id = {row["script_id"]: row for row in cands}
665
+ record = {
666
+ "schema": "phronesis-rank-v1" if args.suggest_mode else "phronesis-select-v1",
667
+ "host": host, "port": ps["port"], "protocol": ps.get("protocol", "tcp"),
668
+ "service": ps["service"], "method": "sequence",
669
+ "families": families, "decision": action,
670
+ "script": action if selected else None,
671
+ "summary": selected["description"] if selected else "",
672
+ "command": shell_command(command) if command else None,
673
+ "seconds": seconds,
674
+ "templates": item["templates"],
675
+ "in_training_range": in_training_range(len(cands), ranked[0]["prompt_tokens"]),
676
+ "candidates": [candidate_record(row, source_by_id[row["script_id"]],
677
+ pre_probabilities, boosts, reasons)
678
+ for row in top],
679
+ "stop": {"score": round(stop_row["score"], 6),
680
+ "probability": round(stop_row["probability"], 6), "boost": 0.0},
681
+ }
682
+ # Template attribution is carried separately to keep the schema simple.
683
+ for row in record["candidates"]:
684
+ row["template_hits"] = reasons.get(row["script_id"], [])
685
+ records.append(record)
686
+ if args.format == "jsonl":
687
+ print(result_json(record))
688
+ elif args.format == "commands":
689
+ if command:
690
+ print(shell_command(command))
691
+ elif args.format == "table":
692
+ pass
693
+ else:
694
+ if args.suggest_mode:
695
+ for row in top:
696
+ suffix = ""
697
+ if args.explain and reasons.get(row["script_id"]):
698
+ suffix = " templates=" + ",".join(reasons[row["script_id"]])
699
+ print(suggest_line(host, ps["port"], ps["service"], row["rank"],
700
+ row["script_id"], row["probability"], args.no_color,
701
+ ps.get("protocol", "tcp")) + suffix)
702
+ elif action != "STOP":
703
+ print(result_line(host, ps["port"], ps["service"], action, args.no_color,
704
+ ps.get("protocol", "tcp")))
705
+ if action == "STOP":
706
+ print(result_line(host, ps["port"], ps["service"], "STOP", args.no_color,
707
+ ps.get("protocol", "tcp")))
708
+ if command:
709
+ logger.info("commande: " + shell_command(command))
710
+ else:
711
+ try:
712
+ action = choose_action(model, tokenizer, state, cands)
713
+ except ValueError as exc:
714
+ logger.error(f"port {ps['port']}/{ps.get('protocol', 'tcp')} : sortie Phronesis invalide ({exc})")
715
+ records.append({"host": host, "port": ps["port"],
716
+ "protocol": ps.get("protocol", "tcp"),
717
+ "service": ps["service"], "decision": "INVALID", "script": None,
718
+ "summary": str(exc), "command": None,
719
+ "seconds": round(time.perf_counter() - began, 3),
720
+ "families": families})
721
+ failures += 1
722
+ continue
723
+ except Exception as exc:
724
+ logger.error(f"port {ps['port']}/{ps.get('protocol', 'tcp')} : inférence impossible ({exc})")
725
+ return 1
726
+ selected = next((row for row in cands if row["script_id"] == action), None)
727
+ command = command_for(host, ps, selected, library) if selected else None
728
+ if command:
729
+ commands.append(command)
730
+ seconds = round(time.perf_counter() - began, 3)
731
+ record = {"host": host, "port": ps["port"], "protocol": ps.get("protocol", "tcp"),
732
+ "service": ps["service"], "decision": action,
733
+ "script": action if selected else None,
734
+ "summary": selected["description"] if selected else "",
735
+ "command": shell_command(command) if command else None, "seconds": seconds,
736
+ "families": families, "templates": item["templates"]}
737
+ records.append(record)
738
+ if args.format == "jsonl":
739
+ print(result_json(record))
740
+ elif args.format == "commands":
741
+ if command:
742
+ print(shell_command(command))
743
+ elif args.format == "table":
744
+ pass
745
+ else:
746
+ print(result_line(host, ps["port"], ps["service"], action, args.no_color,
747
+ ps.get("protocol", "tcp")))
748
+ if command:
749
+ logger.info("commande: " + shell_command(command))
750
+ if args.run and selected:
751
+ try:
752
+ verify_script(selected, library, args.personal_dir)
753
+ except ValueError as exc:
754
+ logger.error(f"exécution refusée: {exc}")
755
+ failures += 1
756
+ continue
757
+ logger.info("exécution: " + shell_command(command))
758
+ native, use_wsl = resolve_nmap()
759
+ result = run_nmap(command, args.timeout, nmap_env(library, use_wsl), stderr=sys.stderr)
760
+ if result.returncode:
761
+ logger.error(f"nmap a échoué sur le port {ps['port']}")
762
+ failures += 1
763
+
764
+ if args.format == "table":
765
+ table(records, args.no_color)
766
+ if commands:
767
+ print()
768
+ for command in commands:
769
+ print(shell_command(command))
770
+ outside = sum(1 for record in records if record.get("in_training_range") is False)
771
+ if outside:
772
+ logger.warn(f"{outside} port(s) hors de la plage d'entraînement "
773
+ f"(> {TRAINED_MAX_CANDIDATES} candidats ou > {TRAINED_MAX_PROMPT_TOKENS} jetons) : "
774
+ "classement peu fiable, à vérifier à la main")
775
+ elapsed = round(time.perf_counter() - started, 3)
776
+ selected_count = sum(1 for record in records if record["decision"] not in ("STOP", "SKIP", "INVALID"))
777
+ stop_count = sum(1 for record in records if record["decision"] == "STOP")
778
+ logger.info(f"stats: {len(states)} hôte(s), {len(pending)} port(s), "
779
+ f"{selected_count} sélection(s), {stop_count} STOP, {failures} erreur(s), {elapsed}s")
780
+ lines = [result_json(record) if args.format == "jsonl"
781
+ else result_line(record["host"], record["port"], record["service"],
782
+ record["decision"], args.no_color, record.get("protocol", "tcp"))
783
+ for record in records]
784
+ if args.format == "commands":
785
+ lines = [shell_command(command) for command in commands]
786
+ if args.output:
787
+ try:
788
+ write_file(args.output, lines)
789
+ except OSError as exc:
790
+ logger.error(f"écriture impossible: {exc}")
791
+ return 1
792
+ return 1 if failures else 0
793
+
794
+
795
+ if __name__ == "__main__":
796
+ try:
797
+ raise SystemExit(main())
798
+ except BrokenPipeError:
799
+ raise SystemExit(0)
800
+ except KeyboardInterrupt:
801
+ raise SystemExit(130)