Ejemplo n.º 1
0
def background_loader(do_reload=True, folder="./datasets"):
    print "folder=%s , reload = %s " % (folder, reload)
    sniff(folder=folder,
          lock=lock,
          interval=1,
          on_start=on_start,
          on_create=on_create,
          on_modified=on_modified,
          on_delete=on_delete,
          do_reload=do_reload)
Ejemplo n.º 2
0
def main():
    conn = pymysql.connect(host='localhost',
                           user='******',
                           password='******',
                           db='wallofsheep',
                           charset='utf8')
    cur = conn.cursor()

    while (True):
        pkt, ip, mac, protocol = sniff.sniff("wlan1")
        rlt = parsePkt(pkt)
        if rlt is not None:
            uid, upw, obsupw, host = rlt[0], rlt[1], rlt[2], rlt[3]
            try:
                print("\nParsing Result \nID: ", uid.decode(), "\nPW: ",
                      upw.decode(), "\nHost: ", host, "\nIP: ", ip,
                      "\nMAC Address: ", mac, "\nProtocol: ", protocol, "\n")
                insertInfo(conn, cur, uid, obsupw, ip, host, mac, protocol)
                cntHost(conn, cur, host)
            except Exception:
                pass

    conn.close()
Ejemplo n.º 3
0
# Author:	Andy Horn
# Date:		4/4/2018
# Modified:	4/10/2018
# Filename:     main_auto.py
# Overview:     Uses the sniff function to automatically detect USB devices
#               and begin independent threads for each device at baud=57600.
#               This was more for my own experimentation and potential future use
#               than for use in this year's (2018) Rocksat-C program.

from DataThread_Test import DataThread
#from serial_func import read_serial
import sniff

try:
    portList = sniff.sniff()
    print("Found {} ports in use.".format(len(portList)))
    if len(portList) > 0:
        dt = DataThread()
        for port in portList:
            dt.add_thread('/dev/' + port, 57600, port)
            print("Connected to {}.".format(port))
        dt.start()
except KeyboardInterrupt:
    print("Exit main")
Ejemplo n.º 4
0
def main():
    # sniff() returns dict {src: [dst, upper protocols(TCP/UDP)]}
    inputs = sniff.sniff()
    print(inputs)

    data = list()

    for src, dst_proto in inputs.items():
        print("src:", src, "lists:", dst_proto)
        try:
            src_response = reader.city(src)
            if ("192.168" in dst_proto[0]):
                dst_response = reader.city("133.14.0.0")
            else:
                dst_response = reader.city(dst_proto[0])
            s_latitude = src_response.location.latitude
            s_longitude = src_response.location.longitude
            d_latitude = dst_response.location.latitude
            d_longitude = dst_response.location.longitude
            comm = {
                "src": src,
                "dst": dst_proto[0],
                "s_latitude": s_latitude,
                "s_longitude": s_longitude,
                "d_latitude": d_latitude,
                "d_longitude": d_longitude,
                "protocol": dst_proto[1]
            }
            data.append(comm)
        except geoip2.errors.AddressNotFoundError:
            print("error!")
            continue
        except ValueError:
            print("Invalid IP")
            continue

    reader.close()
    print("DATA\n")
    print(data)
    # generate map
    m = folium.Map(
        location=[str(info[0]["latitude"]),
                  str(info[0]["longitude"])],
        tiles='Stamen Terrain',
        zoom_start=2)

    tooltip = "Click me!"
    for i in range(len(data)):
        # dst がdbにないとき
        if data[i]["d_latitude"] == "":
            print("skipped")
        # src mapping
        folium.Marker(location=[data[i]["s_latitude"], data[i]["s_longitude"]],
                      popup='src:' + str(data[i]["src"]) + "\n緯度:\n" +
                      str(data[i]["s_latitude"]) + "\n経度:\n" +
                      str(data[i]["s_longitude"]),
                      icon=folium.Icon(color='blue'),
                      tooltip=tooltip).add_to(m)

        # dst mapping
        folium.Marker(location=[data[i]["d_latitude"], data[i]["d_longitude"]],
                      popup='dst:' + str(data[i]["dst"]) + "\n緯度:\n" +
                      str(data[i]["d_latitude"]) + "\n経度:\n" +
                      str(data[i]["d_longitude"]),
                      icon=folium.Icon(color='red'),
                      tooltip=tooltip).add_to(m)

        locations = [[
            float(data[i]["s_latitude"]),
            float(data[i]["s_longitude"])
        ], [float(data[i]["d_latitude"]),
            float(data[i]["d_longitude"])]]

        folium.PolyLine(locations=locations,
                        popup="protocol: " + data[i]['protocol']).add_to(m)

    m.save('test1.html')
    url = ""
    url += os.getcwd() + r"\test1.html"
    browser = webbrowser.get()
    browser.open(url)