What’s the issue here ?
#1
Hope some of the good people on Grey Sec can help me with my python script, I’ve used the Linux vim editor to compile the script and ran it in the Terminal
So, I’m scanning my network and looking for packets with 802.11 layers and want to get the MAC Address 
When I run the script it doesn’t give any _error_ message but it also doesn’t give any results 

Here’s the script 

Devices = set()
def PacketHandler(pkt):
if pkt.haslayer(Dot11)
dot11_layer=pkt.getlayer(Dot11)
if dot11_layer.addr2 and (dot11_layer.addr2 not in Devices)
Devices.add(dot11_layer.addr2)
print(dot11_layer.addr2)
sniff(iface=sys.argv[1], count=int(sys.argv[2]), prn=PacketHandler)
Reply
#2
Code:
Use code blocks
    to preserve the
    formatting of your data.

And post the script you're actually running, there are enough syntax errors to make the interpreter lose its mind, not return nothing.
Reply
#3
(01-12-2021, 05:22 PM)poppopret Wrote:
Code:
Use code blocks
    to preserve the
    formatting of your data.

And post the script you're actually running, there are enough syntax errors to make the interpreter lose its mind, not return nothing.

This.  Please make sure to post your entire source script in code tags, and try to run it from the Terminal first, the interpreter is there for a reason. And while you can compile python scripts, it's a scripting language and you really don't have to. Especially if your project is nowhere near the 'production' stage.

Also i bet once you run it from the Terminal it will display the exact errors just fine, which means we will be better able to help you.
Reply
#4
#!/usr/bin/python3
Import sys
Import scapy.all
From scapy.all import *
conf.iface= “wlan0mon”
Devices = set()
def PacketHandler(pkt):
if pkt.haslayer(Dot11):
dot11_layer=pkt.get layer(Dot11)
if dot11_layer.addr2 and (dot11_layer.addr2 not in Devices):
Devices.add(dot11_layer.addr2)
print(dot11_layer.addr2)
sniff(iface=sys.argv[1], count=int(sys.argv[2]), prn=PacketHandler)
Reply
#5
(01-13-2021, 04:53 PM)FancyBear Wrote: #!/usr/bin/python3
Import sys
Import scapy.all
From scapy.all import *
conf.iface= “wlan0mon”
Devices = set()
def PacketHandler(pkt):
        if pkt.haslayer(Dot11):
            dot11_layer=pkt.get layer(Dot11)
            if dot11_layer.addr2 and (dot11_layer.addr2 not in Devices):
                            Devices.add(dot11_layer.addr2)
                            print(dot11_layer.addr2)
sniff(iface=sys.argv[1], count=int(sys.argv[2]), prn=PacketHandler)

I am having a hard time remaining patient with you. Code tags work like so:

[ code ]

Code goes here

[ /code]

If you remove the spaces and paste your source between the tags it will look like this:

Code:
#!/usr/bin/python3
Import sys
Import scapy.all
From scapy.all import *
conf.iface= “wlan0mon”
Devices = set()
def PacketHandler(pkt):
        if pkt.haslayer(Dot11):
            dot11_layer=pkt.get layer(Dot11)
            if dot11_layer.addr2 and (dot11_layer.addr2 not in Devices):
                            Devices.add(dot11_layer.addr2)
                            print(dot11_layer.addr2)
sniff(iface=sys.argv[1], count=int(sys.argv[2]), prn=PacketHandler)

Ok great, but you still did not post any error messages. Do you even know how to use your Terminal?

Even without error messages i can tell you that:
Code:
# If you do this
From scapy.all import *
# This becomes redundant
Import scapy.all
#Not only that, doing it like that will only instantiate the scapy.all module object

Also, by doing `From scapy.all import *` you are only aggregating the top level objects from all scapy modules. `pkt.haslayer` is class notation. There is no `pkt` class in any top level object for scapy.

I can go on for multiple pages here but you get the point. And unless you post the entirety of your source code in proper code tags i am going to assume you have no clue on how any of this works, and don't know what you are doing.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Having an issue writing a python script with vim FancyBear 4 22,491 01-03-2021, 11:27 PM
Last Post: FancyBear
  Here is a quick Python tool i wrote. Vector 0 10,396 04-09-2017, 01:46 PM
Last Post: Vector
  Here is a little bash script i wrote to help with kernel management. Vector 8 23,945 12-31-2016, 01:08 PM
Last Post: Vector