buckyroberts / Python-Packet-Sniffer

Python network packet sniffer.
249 stars 145 forks source link

Packet sniffing in Django #2

Closed manishkk closed 7 years ago

manishkk commented 7 years ago

Hi, I am trying to same functionality for pcap file in Django, but while importing package and function getting error. while I already installed all required package mentioned in code.

please suggest me something,

Thanking you in advance

sbyrne255 commented 7 years ago

We'll need to see the error before we can help much. Any other informton is appreciated too. Best of luck!

manishkk commented 7 years ago

In code, now not showing in error but while running showing import error. I am just trying to run this piece of code.


from django.http import HttpResponse
from socket import *
#from general import *
from networking import *
import socket
from general import *
#from networking.ethernet import Ethernet
from networking.pcap import Pcap

pcap = Pcap('Test.pcap')
conn = socket.socket(socket.AF_PACKET, socket.SOCK_RAW, socket.ntohs(3))

while True:
    raw_data, addr = conn.recvfrom(65)
    pcap.write(raw_data)
    eth = Ethernet(raw_data)

def index(request):
    answer = [
            str('Destination: {}, Source: {}, Protocol: {}'.format(eth.dest_mac, eth.src_mac, eth.proto))
    ]
    return HttpResponse("\n".join(answer))
maxvonhippel commented 7 years ago

What is the actual import error message?

manishkk commented 7 years ago

Not showing any error in code but on browser it's showing.


ImportError at /webapp
No module named networking
Request Method: GET
Request URL:    http://127.0.0.1:8000/webapp
Django Version: 1.8.7
Exception Type: ImportError
Exception Value:    
No module named networking
Exception Location: /home/manish/PycharmProjects/pcap/webapp/views.py in <module>, line 5
Python Executable:  /usr/bin/python
Python Version: 2.7.12
Python Path:    
['/home/manish/PycharmProjects/pcap',
 '/opt/stack/keystone',
 '/opt/stack/glance',
 '/opt/stack/cinder',
 '/opt/stack/neutron',
 '/opt/stack/nova',
 '/usr/lib/python2.7',
 '/usr/lib/python2.7/plat-x86_64-linux-gnu',
 '/usr/lib/python2.7/lib-tk',
 '/usr/lib/python2.7/lib-old',
 '/usr/lib/python2.7/lib-dynload',
 '/usr/local/lib/python2.7/dist-packages',
 '/usr/lib/python2.7/dist-packages',
 '/usr/lib/python2.7/dist-packages/PILcompat',
 '/usr/lib/python2.7/dist-packages/gtk-2.0',
 '/usr/lib/python2.7/dist-packages/ubuntu-sso-client']
Server time:    Tue, 20 Dec 2016 10:51:51 +0000
manishkk commented 7 years ago

Thanks Guys, This issue is resolved. Can you help in another open issue for this repository?

Thanks