-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsniffer.py
109 lines (76 loc) · 3.31 KB
/
sniffer.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
import tkinter as tk
from tkinter import *
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
from subprocess import Popen, PIPE
import os
import subprocess
import numpy as np
window = Tk()
texto = tk.Label(window,text="")
def tshark():
#os.system('iwconfig')
#subprocess.run('tshark -V -i wlx8416f9131ae9 -T fields -E separator=, -E quote=d -e wlan.sa')
#subprocess.run("iwconfig")
subprocess.call('sudo /usr/bin/tshark -V -i wlx8416f9131ae9 -T fields -E header=y -E separator="/s" -E quote=d -a duration:10 -e wlan.sa -e wlan.ra -e wlan.ta -e wlan.da -e frame.time -q > apolo55.csv',shell=True)
def iniciar():
texto.config(text="DISPOSITIVOS DETECTADOS")
texto.place(x=175,y=225)
tshark()
#subprocess.run('tshark -V -i wlx8416f9131ae9 -T fields -E header=y -E separator=, -E quote=d -e wlan.sa -e frame.time -q -a duration:5 > lectura3.csv')
#window.after(10000,lambda : texto.config(text='DISPOSITIVOS DETECTADOS'))
def grafico():
texto.config(text = "Generando grafico...")
texto.place(x=175, y=225)
datos = pd.read_csv('apolo55.csv', sep=' ')
informacion = pd.read_csv('diccionariofinal.csv', sep=';')
dflectura = pd.DataFrame({'A': datos['wlan.sa']})
# df['A'].unique()
matrix = dflectura['A'].unique()
dflecturaunica = pd.DataFrame({'L': list(matrix)})
dfdic = pd.DataFrame({'D': informacion['MAC'], 'E': informacion['FABRICANTE']})
# dflecturaunica['P']=((dflecturaunica.L.str[0:8]).str.upper()).isin(dfdic.D)
# dflecturaunica['P']=np.nan
dflecturaunica["M"] = dflecturaunica.L.str[0:8].str.upper()
dflecturaunica["P"] = ''
# print(dflecturaunica)
for i in range(len(dflecturaunica)):
for j in range(len(dfdic)):
if (dflecturaunica["M"][i] == dfdic.D[j]):
dflecturaunica["P"][i] = dfdic.E.loc[j]
# crear graficos
df = dflecturaunica
df['Cantidad'] = 1
dims = (30, 50)
fig, ays = plt.subplots(figsize=dims) # cambiar el 2 luego por el numero de columnas del dataframe final
df_2 = df.groupby('P').sum()
print(df_2)
df_2.reset_index(inplace=True)
df_2 = df_2.tail(len(df_2) - 1)
chart = sns.barplot(x='P', y='Cantidad', data=df_2)
for p in chart.patches:
chart.set_xticklabels(chart.get_xticklabels(), rotation=90)
chart.annotate(format(p.get_height(), '.2f'), (p.get_x() + p.get_width() / 2., p.get_height()), ha='center',
va='center', xytext=(0, 10), textcoords='offset points')
# df_2 = df.groupby('Minuto').sum()
# df_2.reset_index(inplace = True)
# sns.barplot(x="Minuto", y="Cantidad", data = df_2,ax=axs[1])
o = "El numero de\ndispositivos registrados\nes de: " + str(len(df))
plt.figtext(21,5,o)
plt.show()
o = "El numero de\ndispositivos registrados\nes de: " + str(len(df))
texto.config(text=o,width=30)
texto.place(x=150, y=195)
# setting geometry of tk window
window.geometry("400x400")
window.title(" Lecturas con Antena")
Boton1 = tk.Button(window,text='INICIAR',command=iniciar)
Boton3 = tk.Button(window,text='GRAFICO',command=grafico)
Boton1.place(x=40, y = 175)
Boton3.place(x=40, y = 275)
logo1 = tk.PhotoImage(file="inginf.gif")
logo2 = logo1.subsample(1,1)
imag = tk.Label(image = logo2,height = 92, width = 400)
imag.place(x =0, y = 0)
window.mainloop()