Skip to content

TypeError: list indices must be integers or slices, not str #51

@nazmang

Description

@nazmang

Hi,

This happens during the run:

#python3 netbox-scanner.py nmap

Traceback (most recent call last):
  File "/root/netbox-scanner/netbox-scanner-master/netbox-scanner.py", line 145, in <module>
    cmd_nmap(scanner)
  File "/root/netbox-scanner/netbox-scanner-master/netbox-scanner.py", line 91, in cmd_nmap
    h.run()
  File "/root/netbox-scanner/netbox-scanner-master/nbs/nmap.py", line 26, in run
    v['hostname'][0]['name']
    ~^^^^^^^^^^^^
TypeError: list indices must be integers or slices, not str

nmap ran successfully:

#/usr/bin/nmap -v -oX - 10.210.151.1/24 -sn -R --system-dns
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE nmaprun>
<?xml-stylesheet href="file:///usr/bin/../share/nmap/nmap.xsl" type="text/xsl"?>
<!-- Nmap 7.94SVN scan initiated Wed Oct 15 11:01:39 2025 as: /usr/bin/nmap -v -oX - -sn -R -&#45;system-dns 10.210.151.1/24 -->
<nmaprun scanner="nmap" args="/usr/bin/nmap -v -oX - -sn -R -&#45;system-dns 10.210.151.1/24" start="1760526099" startstr="Wed Oct 15 11:01:39 2025" version="7.94SVN" xmloutputversion="1.05">
<verbose level="1"/>
<debugging level="0"/>
<taskbegin task="Ping Scan" time="1760526099"/>
<taskprogress task="Ping Scan" time="1760526130" percent="15.23" remaining="173" etc="1760526302"/>
<taskprogress task="Ping Scan" time="1760526160" percent="29.88" remaining="144" etc="1760526303"/>
<taskprogress task="Ping Scan" time="1760526190" percent="44.53" remaining="114" etc="1760526303"/>
<taskprogress task="Ping Scan" time="1760526220" percent="59.18" remaining="84" etc="1760526303"/>
<taskprogress task="Ping Scan" time="1760526250" percent="73.83" remaining="54" etc="1760526304"/>
<taskend task="Ping Scan" time="1760526305" extrainfo="256 total hosts"/>
<taskbegin task="System DNS resolution of 256 hosts." time="1760526305"/>
<taskend task="System DNS resolution of 256 hosts." time="1760526305"/>
<host><status state="down" reason="no-response" reason_ttl="0"/>
<address addr="10.210.151.0" addrtype="ipv4"/>
</host>
<host><status state="down" reason="no-response" reason_ttl="0"/>
<address addr="10.210.151.1" addrtype="ipv4"/>
</host>
...
<runstats><finished time="1760526305" timestr="Wed Oct 15 11:05:05 2025" summary="Nmap done at Wed Oct 15 11:05:05 2025; 256 IP addresses (0 hosts up) scanned in 206.50 seconds" elapsed="206.50" exit="success"/><hosts up="0" down="256" total="256"/>
</runstats>
</nmaprun>

Can someone help please?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions