'Why isnt python nmap scanner working with dpy?
I have been trying to make a nmap scanner and put it in a discord bot. However it doesnt seem to work. It isnt even throwing any error or anything
Can someone please tell me how should I get it to work
@client.command()
async def nmap(ctx, *, arg = "None"):
await ctx.message.delete()
if arg == "None":
embed = discord.Embed(color=000000, timestamp=ctx.message.created_at)
embed.set_author(name="Occult AutoBot Revamped")
embed.add_field(name='No ip',value="Enter an IP to scan", inline=True)
await ctx.send(embed=embed, delete_after = 10)
else:
nmScan = nmap.PortScanner()
embed = discord.Embed(color=000000, timestamp=ctx.message.created_at)
embed.set_author(name="Occult AutoBot Revamped")
embed.add_field(name='Starting NMAP scanner',value=f"Ip --> {arg}", inline=True)
await ctx.send(embed=embed, delete_after = 20)
try:
print("here")
nmScan.scan(arg, '1-65535')
embed = discord.Embed(color=000000, timestamp=ctx.message.created_at)
embed.set_author(name="Occult AutoBot Revamped")
embed.add_field(name='Host Name',value=f"{nmScan[arg].hostname()}", inline=True)
embed.add_field(name='State',value=f"{nmScan[arg].state()}", inline=True)
tcp_ports = nmScan[arg]['tcp'].keys()
for i in tcp_ports:
embed.add_field(name='Open TCP Port',value=str(i), inline=True)
await ctx.send(embed=embed, delete_after = 20)
except:
embed = discord.Embed(color=000000, timestamp=ctx.message.created_at)
embed.set_author(name="Occult AutoBot Revamped")
embed.add_field(name='Invalid IP',value="The IP is invalid", inline=True)
await ctx.send(embed=embed, delete_after = 10)```
Solution 1:[1]
For everyone who find this question in the future , I managed to find a fix for the issue
The issue - The NMAP software wasnt in my PATH (the path variable)
Putting it their solved the problem
And also as Thomas stated , THIS ISSUE HAS NOTHING TO DO WITH DISCORD OR DISCORD.PY
Hope this helps :)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Global-Occult |