XayOn / pyrcrack

Python Aircrack-ng bindings
122 stars 30 forks source link

AttributeError for AccessPoint score calculation #24

Closed alim4r closed 3 years ago

alim4r commented 3 years ago

After running Airodump for a while AttributeError: 'list' object has no attribute 'total' occurs.

Detailed Description

It seems like the kismet.netxml is missing data for the <packets> entry and is parsed as an empty list. The temporary kismet.netxml does not exist anymore , so I can't be sure.

When the score is calculated by results() with packet_score = int(self.packets.total) the attribute total does not exist.

Log Message

2021-09-13 13:26:01 
    async for result in pdump(self.wifi_mon_interface):
2021-09-13 13:26:01 
  File "/usr/local/lib/python3.8/site-packages/pyrcrack/executor.py", line 158, in __anext__
2021-09-13 13:26:01 
    return await self.results
2021-09-13 13:26:01 
  File "/usr/local/lib/python3.8/site-packages/pyrcrack/airodump.py", line 134, in results
2021-09-13 13:26:01 
    sorted([AccessPoint(ap) for ap in results],
2021-09-13 13:26:01 
  File "/usr/local/lib/python3.8/site-packages/pyrcrack/airodump.py", line 135, in <lambda>
2021-09-13 13:26:01 
    key=lambda x: x.score,
2021-09-13 13:26:01 
  File "/usr/local/lib/python3.8/site-packages/pyrcrack/models.py", line 160, in score
2021-09-13 13:26:01 
    packet_score = int(self.packets.total)
2021-09-13 13:26:01 
AttributeError: 'list' object has no attribute 'total'

Context

Possible Implementation

pyrcrack/models.py Method score() of AccessPoint can be updated with:

packet_score = 0 if isinstance(self.packets, list) else int(self.packets.total)

I'm not sure if other entries in the kismet.netxml like <snr-info> will be missing too.

Your Environment

XayOn commented 3 years ago

@alim4r I think you're right about the list issue. I've added a possible fix, should be safe wheter it's that specific case or any other when we don't have access to the "total" property

Also, if you set up an env variable like "PYRCRACK_DEBUG=1" on commit 34f3068e7d1cc99b71b7f35e613959cfe1204a97 temporary files should not be deleted, wich would help further identify this kind if issues.

Thanks for your help on this one, the report was perfectly detailed! 🥇

alim4r commented 3 years ago

Thanks! I added the environment variable to my setup. If it happens again, I'll let you know.