shramos / polymorph

Polymorph is a real-time network packet manipulation framework with support for almost all existing protocols
GNU General Public License v2.0
445 stars 61 forks source link

python importing modules into functions #27

Open majandres opened 3 years ago

majandres commented 3 years ago

Hello Santiago,

I'm trying to use the sleep function from the time module, but when I import in the function, I get an error

Exception ignored in: 'netfilterqueue.global_callback'
Traceback (most recent call last):
  File "/home/andres/polymorph/venv/lib/python3.8/site-packages/polymorph/interceptor.py", line 69, in linux_modify
    pkt = function(self.packet)
TypeError: 'module' object is not callable

how could I use sleep in a function?

thank you

shramos commented 3 years ago

Hi @majandres,

Try to perform the import within the function:

def test_func(packet):
    import time
    time.sleep(4)
    return packet