mirror of
https://github.com/nmap/nmap.git
synced 2025-12-25 08:59:01 +00:00
d6288c5280176160f2776a68c0a2dbb2f483a185
A user reported this crash when scanning a target whose name contained the '%' character: NSE: Script Engine Scan Aborted. An error was thrown by the engine: nse_main.lua:322: invalid capture index stack traceback: [C]: in function 'gsub' nse_main.lua:322: in function 'd' nse_main.lua:377: in function 'start' nse_main.lua:912: in function 'run' nse_main.lua:1390: in function <nse_main.lua:1293> [C]: in ? I'm not sure how a name with '%' got resolved, but I was able to reproduce the crash by adding this line to /etc/hosts: 127.0.0.1 a%40b and then running ./nmap --script=banner a%40b -d --top-ports 5 The gsub function recognizes "%d", where d is a digit, as a capture index. The constructed string is then passed to print_debug, which is like printf. Therefore we escape every occurrence of "%" twice, to get "%%%%".
Here is some documentation for Nmap, but these files are much less comprehensive than what you'll find at the actual Nmap documentation site ( http://nmap.org ).
Description
Languages
C
37.8%
Lua
28.1%
C++
16.7%
Shell
5.8%
Python
4.2%
Other
7.2%