コード例 #1
0
ファイル: boop.py プロジェクト: youmuyou/BoopSuite
    def parse_channel(self, channel):
        five_ghz = [
            36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 132, 136,
            140, 149, 153, 157, 161, 165
        ]
        if channel == None:
            self.channel = None
            return

        elif 0 < int(channel) < 12:

            print(c.OKGREEN + " [+] " + c.WHITE + "Channel in range: 2GHz")
            self.frequency = "2GHz"

            if self.frequency in pyw.phyinfo(pyw.getcard(
                    self.interface))['bands'].keys():
                print(c.OKGREEN + " [+] " + c.WHITE +
                      "Valid Channel selected.")
                self.channel = channel
                return

            else:
                print(c.FAIL + " [-] " + c.WHITE +
                      " Invalid Channel selected.")
                exit(0)

        elif int(channel) in five_ghz:

            print(" [+] Channel in range: 5GHz")
            self.frequency = "5GHz"

            if self.frequency in pyw.phyinfo(pyw.getcard(
                    self.interface))['bands'].keys():
                print(c.OKGREEN + " [+] " + c.WHITE +
                      "Valid Channel selected.")
                self.channel = channel
                return

            else:
                print(c.FAIL + " [-] " + c.WHITE +
                      " Invalid Channel selected.")
                exit(0)

        else:
            print(c.FAIL + " [-] " + c.WHITE +
                  " Channel is invalid in either frequency")
            exit(0)
        return
コード例 #2
0
 def get_supported_swmodes(self, iface):
     '''
     Get supported WiFi software modes
     '''
     w0 = self.get_wifi_chard(iface)  # get a card for interface
     pinfo = pyw.phyinfo(w0)
     return pinfo['swmodes']
コード例 #3
0
 def get_rf_band_info(self, iface):
     '''
     Get info about supported RF bands
     '''
     w0 = self.get_wifi_chard(iface)  # get a card for interface
     pinfo = pyw.phyinfo(w0)
     return pinfo['bands']
コード例 #4
0
ファイル: boopsniff_gui.py プロジェクト: sirus20x6/BoopSuite
    def create_menu(self, master):
        interfaces = pyw.interfaces();

        self.inter_options   = [];
        self.freq_options    = [];
        self.channel_options = [];

        for interface in interfaces:
            try:
                if pyw.modeget(interface) == "monitor":
                    self.inter_options.append(interface);
            except:
                pass;

        self.INTERFACE = StringVar();
        self.FREQUENCY = StringVar();
        self.CHANNEL   = StringVar();

        try:
            self.INTERFACE.set(self.inter_options[0]);

            interface = pyw.getcard(self.inter_options[0]);
            pinfo = pyw.phyinfo(interface)['bands'];
            self.freq_options = pinfo.keys();

            self.FREQUENCY.set(self.freq_options[0]);
            if self.FREQUENCY.get() == "2GHz":
                self.channel_options = ["all", 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11];
            else:
                self.channel_options = ["all", 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 132, 136, 140, 149, 153, 157, 161, 165];
            self.CHANNEL.set(self.channel_options[0]);

        except:
            print("No Valid Monitor Interfaces.")
            sys.exit(0);

        self.header_frame = Frame(master, height=50, bg=Color.BACKGROUND);
        self.header_frame.pack(fill=X);

        self.interface_label = Label(self.header_frame, text="Face: ", bg=Color.BACKGROUND, fg="black", font="14");
        self.interface_label.pack(padx=(15,0), pady=(10,0), anchor=NW, side=LEFT);

        self.interface_options = apply(OptionMenu, (self.header_frame, self.INTERFACE) + tuple(self.inter_options));
        self.interface_options.pack(padx=(5, 0), pady=(7, 0), anchor=NW, side=LEFT);

        self.frequency_label = Label(self.header_frame, text="Freq: ", bg=Color.BACKGROUND, fg="black", font="14");
        self.frequency_label.pack(padx=(5,0), pady=(10,0), anchor=NW, side=LEFT);

        self.frequency_options = apply(OptionMenu, (self.header_frame, self.FREQUENCY) + tuple(self.freq_options));
        self.frequency_options.pack(padx=(5, 0), pady=(7, 0), anchor=NW, side=LEFT);

        self.channel_label = Label(self.header_frame, text="Ch: ", bg=Color.BACKGROUND, fg="black", font="14");
        self.channel_label.pack(padx=(5,0), pady=(10,0), anchor=NW, side=LEFT);

        self.ch_options = apply(OptionMenu, (self.header_frame, self.CHANNEL) + tuple(self.channel_options));
        self.ch_options.pack(padx=(5, 0), pady=(7, 0), anchor=NW);

        self.INTERFACE.trace('w', self.update_freq_options);
        self.FREQUENCY.trace('w', self.update_channel_options);
        return;
コード例 #5
0
 def get_ciphers(self, iface):
     '''
     Get info about supported ciphers
     '''
     w0 = self.get_wifi_chard(iface)  # get a card for interface
     pinfo = pyw.phyinfo(w0)
     return pinfo['ciphers']
コード例 #6
0
    def get_phy_info(self, ifaceName):
        if not self._check_if_my_iface(ifaceName):
            self.log.error('check_if_my_iface failed')
            raise exceptions.FunctionExecutionFailed(
                func_name=inspect.currentframe().f_code.co_name,
                err_msg='No such interface: ' + ifaceName)

        dinfo = pyw.devinfo(ifaceName)
        card = dinfo['card']
        pinfo = pyw.phyinfo(card)
        return pinfo
コード例 #7
0
def DebuggingInterface(iface):
    interfaces = pyw.interfaces()
    print(interfaces)
    print(("Is %s an interface? %s" % (iface, pyw.isinterface(iface))))
    print(("Is %s a wireless device? %s" % (iface, pyw.iswireless(iface))))
    w0 = pyw.getcard(iface)
    print(("Is %s active?  %s" % (iface, pyw.isup(w0))))
    print(("Is %s blocked? %s" % (iface, pyw.isblocked(w0))))
    iinfo = pyw.ifinfo(w0)
    print(iinfo)
    pinfo = pyw.phyinfo(w0)
    print((pinfo['bands']))
コード例 #8
0
ファイル: boopsniff_gui.py プロジェクト: wikijm/BoopSuite
    def update_freq_options(self, *args):
        interface = pyw.getcard(self.INTERFACE.get());
        pinfo = pyw.phyinfo(interface)['bands'];

        self.freq_options = pinfo.keys();

        self.FREQUENCY.set(self.freq_options[0]);

        menu = self.frequency_options["menu"];
        menu.delete(0, "end");

        for string in self.freq_options:
            menu.add_command(
                label=string, command=lambda value=string: self.FREQUENCY.set(value));

        return;
コード例 #9
0
    def my_start_function(self):
        found = False
        # This is only a basic example that show how it is possible to look
        # for a PHY with the desired capabilities (in this case VHT support on
        # the 5GHz band).
        for phy in pyw.phylist():
            phy_info = pyw.phyinfo(pyw.Card(phy[0], None, 0))
            if bool(phy_info['bands']['5GHz']['VHT']):
                found = True
                self.phyIndex = phy[0]
                self.phyName = phy[1]
                print(phy_info)

        if not found:
            self.log.error("Device {} not found".format(self.device))
            raise exceptions.UniFlexException(msg='Device not found')

        else:
            self.log.info("Device {} found, index: {}".format(
                self.phyName, self.phyIndex))

        cmd = "rfkill unblock wifi"
        self.run_command(cmd)
コード例 #10
0
ファイル: interfaces.py プロジェクト: ondrocks/BoopSuite
def interface_command(interface, verbose):
    faces = pyw.winterfaces() if interface == "all" else [interface]
    for face in faces:
        if face not in pyw.winterfaces():
            sys.exit(f"{face} is not an interface")

    print(f"{Fore.GREEN}Interfaces:{Fore.YELLOW}")
    for interface in faces:
        face = pyw.getcard(interface)
        up = Fore.YELLOW if pyw.isup(face) else Fore.RED

        print(f"  {up}{interface:<10} {Style.RESET_ALL}")
        if verbose >= 1:
            iinfo = pyw.ifinfo(face)
            for i in iinfo:
                print(
                    f"\t{i.title():<15} {Fore.CYAN}{iinfo[i]}{Style.RESET_ALL}"
                )
        if verbose >= 2:
            dinfo = pyw.devinfo(face)
            for d in dinfo:
                print(
                    f"\t{d.title():<15} {Fore.CYAN}{dinfo[d]}{Style.RESET_ALL}"
                )

        if verbose >= 3:
            pinfo = pyw.phyinfo(face)
            for p in pinfo:
                if type(pinfo[p]) == list:
                    print(
                        f"\t{p.title():<15} {Fore.CYAN}{', '.join(pinfo[p])}{Style.RESET_ALL}"
                    )
                elif p == "bands":
                    print(
                        f"\t{p.title():<15} {Fore.CYAN}{', '.join(pinfo[p].keys())}{Style.RESET_ALL}"
                    )
コード例 #11
0
    def start_adhoc(self,
                    driver,
                    iface,
                    essid,
                    freq,
                    txpower,
                    rate,
                    ip_addr,
                    rts='off',
                    mac_address="aa:bb:cc:dd:ee:ff",
                    skip_reload=False):

        # search for a wifi device that does not have VHT
        intcap = "VHT"

        wifi_int = pyw.winterfaces()
        for wifi_int_name in wifi_int:
            del_cmd = "sudo iw dev " + wifi_int_name + " del"
            [rcode, sout, serr] = run_command(del_cmd)
            self.log.debug("Deleting interface {}".format(wifi_int_name))

        self.band = "2GHz"
        if int(freq) > 3000:
            self.band = "5GHz"

        # Look for a candidate PHY (currently based on frequency and
        # capabilities (HT or VHT) support
        phys = pyw.phylist()
        selected_phy = None

        for phy in phys:
            phy_info = pyw.phyinfo(pyw.Card(phy[0], None, 0))
            if phy_info['bands'].get(self.band) and phy_info.get('modes'):
                if not bool(phy_info['bands'][self.band][intcap]):
                    if 'ibss' in phy_info['modes']:
                        selected_phy = phy
                        break

        # Add and configure mesh and monitor interfaces
        if selected_phy is not None:

            # Create ibss point interface
            ibss_cmd = 'sudo iw phy ' + selected_phy[1] + \
                       ' interface add ' + iface + \
                       ' type ibss'
            [rcode, sout, serr] = run_command(ibss_cmd)
            self.log.debug("Creating interface {} on phy {}".format(
                iface, selected_phy[1]))

            self.interface = iface

            # Set ibss interface IP address
            ibss_ip_cmd = 'sudo ip addr add ' + ip_addr + \
                          ' dev ' + iface
            [rcode, sout, serr] = run_command(ibss_ip_cmd)
            # TODO: search for UPI
            self.log.debug("Setting IP addr {} to interface {}".format(
                ip_addr, iface))

            # Add monitor interface
            ibss_mon_cmd = 'sudo iw dev ' + iface + ' interface add ' + \
                           'mon0 type monitor'
            # TODO: search for UPI
            [rcode, sout, serr] = run_command(ibss_mon_cmd)
            self.log.debug(
                "Creating monitor interface mon0 for {}".format(iface))

            # Bring interfaces up
            ibss_up_cmd = 'sudo ip link set dev ' + iface + ' up'
            [rcode, sout, serr] = run_command(ibss_up_cmd)
            self.log.debug("Bringing interface {} up".format(iface))
            ibss_mon_up_cmd = 'sudo ip link set dev mon0 up'
            [rcode, sout, serr] = run_command(ibss_mon_up_cmd)
            self.log.debug("Bringing interface mon0 up")

            ibss_join_cmd = 'sudo iw dev ' + iface + ' ibss join ' + \
                            essid + ' ' + str(freq) + \
                            ' fixed-freq ' + mac_address + ' beacon-interval ' \
                            + "100"
            [rcode, sout, serr] = run_command(ibss_join_cmd)
            self.log.debug("Joining ad-hoc network {}, frequency {} GHz, "
                           "cell {} with interface {}".format(
                               essid, freq, mac_address, iface))

            self.set_modulation_rate(rate)
            self.set_tx_power(txpower)
コード例 #12
0
    # Delete all Wi-Fi interfaces
    wifi_int = pyw.winterfaces()
    for wifi_int_name in wifi_int:
        pyw.devdel(pyw.getcard(wifi_int_name))

    band = "2GHz"
    if args.chan > 14:
        band = "5GHz"

    # Look for a candidate PHY (currently based on frequency and capabilities
    # (HT or VHT) support
    phys = pyw.phylist()
    selected_phy = None

    for phy in phys:
        phy_info = pyw.phyinfo(pyw.Card(phy[0], None, 0))
        if phy_info['bands'].get(band) and phy_info.get('modes'):
            if bool(phy_info['bands'][band][args.intcap]):
                if 'ibss' in phy_info['modes']:
                    selected_phy = phy
                    # print(selected_phy)
                    break

    # Add and configure mesh and monitor interfaces
    if selected_phy is not None:
        phy_info = pyw.phyinfo(pyw.Card(selected_phy[0], None, 0))
        # print(phy_info)

        # Create ibss point interface
        ibss_cmd = 'iw phy ' + selected_phy[1] +\
                   ' interface add ' + args.ibssiname +\
コード例 #13
0
ファイル: pentest.py プロジェクト: wifiphisher/WiPy
def execute(dev):
    print('Setting up...')
    # ensure dev is a wireless interfaces
    ifaces = pyw.interfaces()
    wifaces = pyw.winterfaces()
    if dev not in ifaces:
        print("Device {0} is not valid, use one of {1}".format(dev, ifaces))
        return
    elif dev not in wifaces:
        print("Device {0} is not wireless, use one of {1}".format(
            dev, wifaces))

    # get a Card & info for dev
    print("Regulatory Domain currently: ", pyw.regget())
    dinfo = pyw.devinfo(dev)
    card = dinfo['card']
    pinfo = pyw.phyinfo(card)
    driver = hw.ifdriver(card.dev)
    chipset = hw.ifchipset(driver)

    # bring the card down and change the mac
    pyw.down(card)
    pyw.macset(card, '00:03:93:57:54:46')

    # print details
    msg = "Using {0} currently in mode: {1}\n".format(card, dinfo['mode'])
    msg += "\tDriver: {0} Chipset: {1}\n".format(driver, chipset)
    if dinfo['mode'] == 'managed':
        msg += "\tcurrently on channel {0} width {1}\n".format(
            rf2ch(dinfo['RF']), dinfo['CHW'])
    msg += "\tSupports modes {0}\n".format(pinfo['modes'])
    msg += "\tSupports commands {0}".format(pinfo['commands'])
    msg += "\thw addr {0}".format(pyw.macget(card))
    print(msg)

    # prepare a virtual interface named pent0 in monitor mode
    # delete all ifaces on the phy to avoid interference
    # bring the card up when down
    print('Preparing pent0 for monitor mode')
    pdev = 'pent0'
    pcard = pyw.devadd(card, pdev, 'monitor')
    for iface in pyw.ifaces(card):
        if iface[0].dev != pcard.dev:
            print("deleting {0} in mode {1}".format(iface[0], iface[1]))
            pyw.devdel(iface[0])
    pyw.up(pcard)
    print("Using", pcard)

    print("Setting channel to 6 NOHT")
    pyw.chset(pcard, 6, None)
    msg = "Virtual interface {0} in monitor mode on ch 6".format(pcard)
    print(msg + ", using hwaddr: {0}".format(pyw.macget(pcard)))

    # DO stuff here
    try:
        print('Now ready to do stuff')
        print(
            'For example, run wireshark to verify card is seeing all packets')
        print('Hit Ctrl-C to quit and restore')
        while True:
            time.sleep(1)
    except KeyboardInterrupt:
        pass

    # restore original
    print('Restoring', card, 'mode =', dinfo['mode'], 'mac =', dinfo['mac'])
    card = pyw.devadd(pcard, card.dev, dinfo['mode'])
    print('Deleting', pcard)
    pyw.devdel(pcard)
    pyw.macset(card, dinfo['mac'])
    pyw.up(card)
    print("card ", card, " restored")
コード例 #14
0
def execute(dev, itype):
    # ensure dev is a wireless interfaces
    wifaces = pyw.winterfaces()
    if dev not in wifaces:
        print("Device {0} is not wireless, use one of {1}".format(
            dev, wifaces))

    # get info dicts
    dinfo = pyw.devinfo(dev)
    card = dinfo['card']
    pinfo = pyw.phyinfo(card)
    iinfo = pyw.ifinfo(card)

    if itype == 'all' or itype == 'if':
        msg = "Interface {0}\n".format(card.idx)
        msg += "\tDriver: {0} Chipset: {1}\n".format(iinfo['driver'],
                                                     iinfo['chipset'])
        msg += "\tHW Addr: {0} Manufacturer: {1}\n".format(
            iinfo['hwaddr'], iinfo['manufacturer'])
        msg += "\tInet: {0} Bcast: {1} Mask: {2}\n".format(
            iinfo['inet'], iinfo['bcast'], iinfo['mask'])
        print(msg)

    if itype == 'all' or itype == 'dev':
        msg = "Device {0}\n".format(card.dev)
        msg += "\tifindex: {0}\n".format(card.idx)
        msg += "\twdev: {0}\n".format(dinfo['wdev'])
        msg += "\taddr: {0}\n".format(dinfo['mac'])
        msg += "\tmode: {0}\n".format(dinfo['mode'])
        msg += "\twiphy: {0}\n".format(card.phy)
        if dinfo['mode'] != 'managed': msg += "\tDevice not associated\n"
        else:
            msg += "\tchannel: {0} ({1} MHz), width: {2}, CF: {3} MHz\n".format(
                rf2ch(dinfo['RF']), dinfo['RF'], dinfo['CHW'], dinfo['CF'])
        print(msg)

    if itype == 'all' or itype == 'phy':
        msg = "Wiphy phy{0}\n".format(card.phy)
        msg += "\tGeneration: {0}m Coverage Class: {1}\n".format(
            pinfo['generation'], pinfo['cov_class'])
        msg += "\tMax # scan SSIDs: {0}\n".format(pinfo['scan_ssids'])
        msg += "\tRetry Short: {0}, Long: {1}\n".format(
            pinfo['retry_short'], pinfo['retry_long'])
        msg += "\tThreshold Frag: {0}, RTS: {1}\n".format(
            pinfo['frag_thresh'], pinfo['rts_thresh'])
        msg += "\tSupported Modes:\n"
        for mode in pinfo['modes']:
            msg += "\t  * {0}\n".format(mode)
        msg += "\tSupported Commands:\n"
        for cmd in pinfo['commands']:
            msg += "\t  * {0}\n".format(cmd)
        msg += "\tSupported Ciphers:\n"
        for cipher in pinfo['ciphers']:
            msg += "\t  * {0}\n".format(cipher)
        for band in pinfo['bands']:
            msg += "\tBand {0}: (HT: {1} VHT: {2})\n".format(
                band, pinfo['bands'][band]['HT'], pinfo['bands'][band]['VHT'])
            msg += "\t   Rates:\n"
            for rate in pinfo['bands'][band]['rates']:
                msg += "\t    * {0} Mbps\n".format(rate)
            msg += "\t   Frequencies:\n"
            for i, rf in enumerate(pinfo['bands'][band]['rfs']):
                dbm = pinfo['bands'][band]['rf-data'][i]['max-tx']
                msg += "\t    * {0} MHz ({1} dBm)".format(rf, dbm)
                if not pinfo['bands'][band]['rf-data'][i]['enabled']:
                    msg += " (disabled)\n"
                else:
                    msg += "\n"
        print(msg)
コード例 #15
0
    def getinfo(self):
        try:
            self.data['macaddress'] = netifaces.ifaddresses(
                self._if)[netifaces.AF_LINK][0]['addr']
        except:
            self.data['macaddress'] = None
        try:
            self.data['ipaddress'] = netifaces.ifaddresses(
                self._if)[netifaces.AF_INET][0]['addr']
        except:
            self.data['ipaddress'] = None
        try:
            self.data['vendorstr'] = self.udevnet.data[
                self._if + "_id_vendor_from_database"]
        except:
            self.data['vendorstr'] = None
        try:
            self.data['vendoroui'] = self.udevnet.data[self._if +
                                                       "_id_oui_from_database"]
        except:
            self.data['vendoroui'] = None
        try:
            self.data['vendor'] = self.udevnet.data[self._if + "_id_vendor"]
        except:
            self.data['vendor'] = None
        # Hack for onboard raspberry devices
        if type(self.data['vendoroui']) is str:
            if re.search("^Raspberry", self.data['vendoroui']):
                self.data['vendor'] = "RaspberryPi"

        try:
            self.data['driver'] = self.udevnet.data[self._if +
                                                    "_id_net_driver"]
        except:
            try:
                self.data['driver'] = self.udevnet.data[self._if +
                                                        "_id_usb_driver"]
            except:
                self.data['driver'] = None
        try:
            self.data['model'] = self.udevnet.data[self._if + "_id_model_id"]
        except:
            self.data['model'] = None
        try:
            self.data['modelstr'] = self.udevnet.data[
                self._if + "_id_model_from_database"]
        except:
            self.data['modelstr'] = None
        try:
            self.data['netname'] = self.udevnet.data[
                self._if + "_id_net_name_from_database"]
        except:
            try:
                self.data['netname'] = self.udevnet.data[
                    self._if + "_id_net_name_onboard"]
            except:
                try:
                    self.data['netname'] = self.udevnet.data[
                        self._if + "_id_net_name_slot"]
                except:
                    try:
                        self.data['netname'] = self.udevnet.data[
                            self._if + "_id_net_name_path"]
                    except:
                        try:
                            self.data['netname'] = self.udevnet.data[
                                self._if + "_id_net_name_mac"]
                        except:
                            self.data['netname'] = None
        try:
            self.data['type'] = self.udevnet.data[self._if + "_devtype"]
            if self.data['type'] == "wlan": self.data['type'] = "Wireless"
        except:
            try:
                if re.search("^en", self.data['netname']):
                    self.data['type'] = "Ethernet"
                elif re.search("^wl", self.data['netname']):
                    self.data['type'] = "Wireless"
                else:
                    self.data['type'] = None
            except:
                self.data['type'] = None

        # Stop here if we don't have a wireless card
        if self.data['type'] != "Wireless":
            return
        # Retrieve wireless info
        try:
            _ifobj = pyw.getcard(self._if)
            _ifinfo = pyw.ifinfo(_ifobj)
            _devinfo = pyw.devinfo(_ifobj)
            _physinfo = pyw.phyinfo(_ifobj)
            _linkinfo = pyw.link(_ifobj)
        except:
            pass
        try:
            self.data['isup'] = pyw.isup(_ifobj)
        except:
            self.data['isup'] = None
        try:
            self.data['blocked'] = pyw.isblocked(_ifobj)
        except:
            self.data['blocked'] = None
        try:
            self.data['mode'] = _devinfo['mode']
        except:
            self.data['mode'] = None
        try:
            self.data['modes'] = _physinfo['modes']
        except:
            self.data['modes'] = None
        try:
            self.data['bands'] = _physinfo['bands']
        except:
            self.data['bands'] = None
        try:
            self.data['standards'] = pyw.devstds(_ifobj)
        except:
            self.data['standards'] = None
        try:
            self.data['freqs'] = pyw.devfreqs(_ifobj)
        except:
            self.data['freqs'] = None
        try:
            self.data['txpower'] = pyw.txget(_ifobj)
        except:
            self.data['txpower'] = None
        try:
            self.data['chans'] = pyw.devchs(_ifobj)
        except:
            self.data['chans'] = None
        try:
            self.data['reg'] = pyw.regget(_ifobj)
        except:
            self.data['reg'] = None
        try:
            self.data['chipset'] = _ifinfo['chipset']
        except:
            self.data['chipset'] = None
        try:
            self.data['state'] = _linkinfo['stat']
        except:
            self.data['state'] = None
        try:
            self.data['ssid'] = _linkinfo['ssid']
        except:
            self.data['ssid'] = None
        try:
            self.data['chw'] = _devinfo['CHW']
        except:
            self.data['chw'] = None
        try:
            self.data['frequency'] = _devinfo['RF']
        except:
            self.data['frequency'] = None
        try:
            self.data['rss'] = _linkinfo['rss']
        except:
            self.data['rss'] = None
        try:
            self.data['wtx'] = _linkinfo['tx']
        except:
            self.data['wtx'] = None
        try:
            self.data['wrx'] = _linkinfo['rx']
        except:
            self.data['wrx'] = None
コード例 #16
0
ファイル: pyw.unittest.py プロジェクト: wifiphisher/WiPy
 def test_phyinfo(self):
     self.assertIsInstance(pyw.phyinfo(self.card), dict)
コード例 #17
0
	def read_network_interfaces(self):
		import pyric.pyw as pyw
		
		network_info = ''
		try:
			network_info = pyw.interfaces()
		except:
			pass

		self.available_share = [_('none'),'auto']
		unavailable_net = ['wlan9','lo']
		if self.bridge.GetValue():
			unavailable_net.append('eth0')

		for i in network_info:
			if not 'can' in i and not 'canable' in i and not i in unavailable_net: self.available_share.append(i)

		self.share.Clear()
		for i in self.available_share:
			self.share.Append(i)
		
		type=''
		phy=''
		AP=-1
		GHz=-1
		
		self.available_ap_device = []
		self.available_ap_device.append([_('none'),'',-1,-1,'none'])
		
		for i in pyw.winterfaces():
			if 'wlan' in i:
				try:
					wlan = 'wlan9'  #AP allways on wlan9
					w0 = pyw.getcard(i)
					mac = subprocess.check_output(('cat /sys/class/net/'+i+'/address').split()).decode()[:-1]

					AP = -1
					if 'AP' in pyw.phyinfo(w0)['modes']:AP = 0

					GHz = -1
					if 'a' in pyw.devstds(w0): GHz = 1

					if b'usb' in subprocess.check_output(('ls -l /sys/class/net/'+i).split()):
						type  = 'usb'
						if AP > -1:
								self.available_ap_device.append([mac+' '+type, mac, type, GHz, wlan])
					else:
						type = 'on board'
						do_exist = False
						for j in self.available_ap_device:
							if j[1] == mac: do_exist = True
						if not do_exist:
							self.available_ap_device.append([mac+' '+type, mac, type, GHz, wlan])
				except: pass

		if not ('Raspberry Pi 2' in self.rpimodel) and len(self.available_ap_device) == 2:
			for i in self.available_ap_device:
				if 'on board' == i[2]:
					type = 'AP and Station'
					wlan = 'uap'
					self.available_ap_device.append([i[1]+' '+type, i[1], type, i[3], wlan])

		self.available_ap_device2 = []
		for i in self.available_ap_device:
			self.available_ap_device2.append(i[0])
			
		self.ap_device.Clear()
		for i in self.available_ap_device2:
			self.ap_device.Append(i)
コード例 #18
0
ファイル: netinfo.py プロジェクト: fnoop/maverick
    def getinfo(self):
        try:
            self.data['macaddress'] = netifaces.ifaddresses(self._if)[netifaces.AF_LINK][0]['addr']
        except:
            self.data['macaddress'] = None
        try:
            self.data['ipaddress'] = netifaces.ifaddresses(self._if)[netifaces.AF_INET][0]['addr']
        except:
            self.data['ipaddress'] = None
        try:
            self.data['vendorstr'] = self.udevnet.data[self._if+"_id_vendor_from_database"]
        except:
            self.data['vendorstr'] = None
        try:
            self.data['vendoroui'] = self.udevnet.data[self._if+"_id_oui_from_database"]
        except:
            self.data['vendoroui'] = None
        try:
            self.data['vendor'] = self.udevnet.data[self._if+"_id_vendor"]
        except:
            self.data['vendor'] = None
        # Hack for onboard raspberry devices
        if type(self.data['vendoroui']) is str:
            if re.search("^Raspberry", self.data['vendoroui']):
                self.data['vendor'] = "RaspberryPi"

        try:
            self.data['driver'] = self.udevnet.data[self._if+"_id_net_driver"]
        except:
            try:
                self.data['driver'] = self.udevnet.data[self._if+"_id_usb_driver"]
            except:
                self.data['driver'] = None
        try:
            self.data['model'] = self.udevnet.data[self._if+"_id_model_id"]
        except:
            self.data['model'] = None
        try:
            self.data['modelstr'] = self.udevnet.data[self._if+"_id_model_from_database"]
        except:
            self.data['modelstr'] = None
        try:
            self.data['netname'] = self.udevnet.data[self._if+"_id_net_name_from_database"]
        except:
            try:
                self.data['netname'] = self.udevnet.data[self._if+"_id_net_name_onboard"]
            except:
                try:
                    self.data['netname'] = self.udevnet.data[self._if+"_id_net_name_slot"]
                except:
                    try:
                        self.data['netname'] = self.udevnet.data[self._if+"_id_net_name_path"]
                    except:
                        try:
                            self.data['netname'] = self.udevnet.data[self._if+"_id_net_name_mac"]
                        except:
                            self.data['netname'] = None
        try:
            self.data['type'] = self.udevnet.data[self._if+"_devtype"]
            if self.data['type'] == "wlan": self.data['type'] = "Wireless"
        except:
            try:
                if re.search("^en", self.data['netname']):
                    self.data['type'] = "Ethernet"
                elif re.search("^wl", self.data['netname']):
                    self.data['type'] = "Wireless"
                else:
                    self.data['type'] = None
            except:
                self.data['type'] = None

        # Stop here if we don't have a wireless card
        if self.data['type'] != "Wireless":
            return
        # Retrieve wireless info
        try:
            _ifobj = pyw.getcard(self._if)
            _ifinfo = pyw.ifinfo(_ifobj)
            _devinfo = pyw.devinfo(_ifobj)
            _physinfo = pyw.phyinfo(_ifobj)
            _linkinfo = pyw.link(_ifobj)
        except:
            pass
        try:
            self.data['isup'] = pyw.isup(_ifobj)
        except:
            self.data['isup'] = None
        try:
            self.data['blocked'] = pyw.isblocked(_ifobj)
        except:
            self.data['blocked'] = None
        try:
            self.data['mode'] = _devinfo['mode']
        except:
            self.data['mode'] = None
        try:
            self.data['modes'] = _physinfo['modes']
        except:
            self.data['modes'] = None
        try:
            self.data['bands'] = _physinfo['bands']
        except:
            self.data['bands'] = None
        try:
            self.data['standards'] = pyw.devstds(_ifobj)
        except:
            self.data['standards'] = None
        try:
            self.data['freqs'] = pyw.devfreqs(_ifobj)
        except:
            self.data['freqs'] = None
        try:
            self.data['txpower'] = pyw.txget(_ifobj)
        except:
            self.data['txpower'] = None
        try:
            self.data['chans'] = pyw.devchs(_ifobj)
        except:
            self.data['chans'] = None
        try:
            self.data['reg'] = pyw.regget(_ifobj)
        except:
            self.data['reg'] = None
        try:
            self.data['chipset'] = _ifinfo['chipset']
        except:
            self.data['chipset'] = None
        try:
            self.data['state'] = _linkinfo['stat']
        except:
            self.data['state'] = None
        try:
            self.data['ssid'] = _linkinfo['ssid']
        except:
            self.data['ssid'] = None
        try:
            self.data['chw'] = _devinfo['CHW']
        except:
            self.data['chw'] = None
        try:
            self.data['frequency'] = _devinfo['RF']
        except:
            self.data['frequency'] = None
        try:
            self.data['rss'] = _linkinfo['rss']
        except:
            self.data['rss'] = None
        try:
            self.data['wtx'] = _linkinfo['tx']
        except:
            self.data['wtx'] = None
        try:
            self.data['wrx'] = _linkinfo['rx']
        except:
            self.data['wrx'] = None
コード例 #19
0
ファイル: boopsniff_gui.py プロジェクト: wikijm/BoopSuite
    def create_options(self):
        self.options_frame = Frame(self.master, bg=c.TITLE_BACKGROUND, width=900, height=50);
        self.options_frame.pack(fill=BOTH);

        self.flag_frame = Frame(self.master, bg=c.TITLE_BACKGROUND, width=900, height=50);
        self.flag_frame.pack(fill=BOTH);

        interfaces = pyw.interfaces();

        self.inter_options   = [];
        self.freq_options    = [];
        self.channel_options = [];

        for interface in interfaces:
            try:
                if pyw.modeget(interface) == "monitor":
                    self.inter_options.append(interface);
            except:
                pass

        self.INTERFACE = StringVar();
        self.FREQUENCY = StringVar();
        self.CHANNEL   = StringVar();

        try:
            self.INTERFACE.set(self.inter_options[0]);

            interface = pyw.getcard(self.inter_options[0]);
            pinfo = pyw.phyinfo(interface)['bands'];
            self.freq_options = pinfo.keys();

            self.FREQUENCY.set(self.freq_options[0]);

            if self.FREQUENCY.get() == "2GHz":
                self.channel_options = ["all", 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11];
            else:
                self.channel_options = ["all", 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 132, 136, 140, 149, 153, 157, 161, 165];
            self.CHANNEL.set(self.channel_options[0]);

        except:
            print("No Valid Monitor Interfaces.");
            sys.exit(0);

        self.interface_label = Label(self.options_frame, text="Face: ", bg=c.TITLE_BACKGROUND, fg="white", font="14");
        self.interface_label.pack(padx=(25,0), pady=(15,0), anchor=NW, side=LEFT);

        self.interface_options = apply(OptionMenu, (self.options_frame, self.INTERFACE) + tuple(self.inter_options));
        self.interface_options.pack(padx=(0, 5), pady=(11, 0), anchor=NW, side=LEFT);

        self.frequency_label = Label(self.options_frame, text="Freq: ", bg=c.TITLE_BACKGROUND, fg="white", font="14");
        self.frequency_label.pack(padx=(7, 0), pady=(15,0), anchor=NW, side=LEFT);

        self.frequency_options = apply(OptionMenu, (self.options_frame, self.FREQUENCY) + tuple(self.freq_options));
        self.frequency_options.pack(padx=(0, 5), pady=(11, 0), anchor=NW, side=LEFT);

        self.channel_label = Label(self.options_frame, text="Ch: ", bg=c.TITLE_BACKGROUND, fg="white", font="14");
        self.channel_label.pack(padx=(7, 0), pady=(15,0), anchor=NW, side=LEFT);

        self.ch_options = apply(OptionMenu, (self.options_frame, self.CHANNEL) + tuple(self.channel_options));
        self.ch_options.pack(padx=(0, 5), pady=(11, 0), anchor=NW);

        self.INTERFACE.trace('w', self.update_freq_options);
        self.FREQUENCY.trace('w', self.update_channel_options);
        ########## FLAGS ################
        self.KILL = StringVar();
        self.UNASSOCIATED = StringVar();
        self.MACFILTER = StringVar();

        self.kill = Checkbutton(
            self.flag_frame, text="Kill blocking tasks",
            fg="white", selectcolor=c.TITLE_BACKGROUND,
            activeforeground="white", activebackground=c.TITLE_BACKGROUND,
            variable=self.KILL, highlightthickness = 0,
            bd = 0, relief=FLAT, font="10",
            bg=c.TITLE_BACKGROUND
            );
        self.kill.pack(padx=(25, 0), pady=(10, 0), anchor=W, side=LEFT);

        self.filter_label = Label(self.flag_frame, text="AP Filter: ", bg=c.TITLE_BACKGROUND, fg="white", font="14");
        self.filter_label.pack(padx=(12, 0), pady=(10, 0), anchor=W, side=LEFT);

        self.filter_entry = Entry(self.flag_frame, exportselection=0, state=DISABLED, takefocus=True, textvariable=self.MACFILTER);
        self.filter_entry.pack(padx=(5, 0), pady=(11, 0), anchor=W);
        self.filter_entry.config(state=NORMAL);
        return;
コード例 #20
0
ファイル: devices.py プロジェクト: pagosasia/BoopSuite
def get_phy_info(card):
    return pyw.phyinfo(card)
コード例 #21
0
ファイル: info.py プロジェクト: pgawlowicz/PyRIC
def execute(dev,itype):
    # ensure dev is a wireless interfaces
    wifaces = pyw.winterfaces()
    if dev not in wifaces:
        print("Device {0} is not wireless, use one of {1}".format(dev,wifaces))

    # get info dicts
    dinfo = pyw.devinfo(dev)
    card = dinfo['card']
    pinfo = pyw.phyinfo(card)
    iinfo = pyw.ifinfo(card)

    if itype == 'all' or itype == 'if':
        msg = "Interface {0}\n".format(card.idx)
        msg += "\tDriver: {0} Chipset: {1}\n".format(iinfo['driver'],iinfo['chipset'])
        msg += "\tHW Addr: {0} Manufacturer: {1}\n".format(iinfo['hwaddr'],
                                                           iinfo['manufacturer'])
        msg += "\tInet: {0} Bcast: {1} Mask: {2}\n".format(iinfo['inet'],
                                                           iinfo['bcast'],
                                                           iinfo['mask'])
        print(msg)

    if itype == 'all' or itype == 'dev':
        msg = "Device {0}\n".format(card.dev)
        msg += "\tifindex: {0}\n".format(card.idx)
        msg += "\twdev: {0}\n".format(dinfo['wdev'])
        msg += "\taddr: {0}\n".format(dinfo['mac'])
        msg += "\tmode: {0}\n".format(dinfo['mode'])
        msg += "\twiphy: {0}\n".format(card.phy)
        if dinfo['mode'] != 'managed': msg += "\tDevice not associated\n"
        else:
            msg += "\tchannel: {0} ({1} MHz), width: {2}, CF: {3} MHz\n".format(rf2ch(dinfo['RF']),
                                                                                dinfo['RF'],
                                                                                dinfo['CHW'],
                                                                                dinfo['CF'])
        print(msg)

    if itype == 'all' or itype == 'phy':
        msg = "Wiphy phy{0}\n".format(card.phy)
        msg += "\tGeneration: {0}m Coverage Class: {1}\n".format(pinfo['generation'],
                                                                 pinfo['cov_class'])
        msg += "\tMax # scan SSIDs: {0}\n".format(pinfo['scan_ssids'])
        msg += "\tRetry Short: {0}, Long: {1}\n".format(pinfo['retry_short'],
                                                        pinfo['retry_long'])
        msg += "\tThreshold Frag: {0}, RTS: {1}\n".format(pinfo['frag_thresh'],
                                                          pinfo['rts_thresh'])
        msg += "\tSupported Modes:\n"
        for mode in pinfo['modes']: msg += "\t  * {0}\n".format(mode)
        msg += "\tSupported Commands:\n"
        for cmd in pinfo['commands']: msg += "\t  * {0}\n".format(cmd)
        msg += "\tSupported Ciphers:\n"
        for cipher in pinfo['ciphers']: msg += "\t  * {0}\n".format(cipher)
        for band in pinfo['bands']:
            msg += "\tBand {0}: (HT: {1} VHT: {2})\n".format(band,
                                                             pinfo['bands'][band]['HT'],
                                                             pinfo['bands'][band]['VHT'])
            msg += "\t   Rates:\n"
            for rate in pinfo['bands'][band]['rates']:
                msg += "\t    * {0} Mbps\n".format(rate)
            msg += "\t   Frequencies:\n"
            for i,rf in enumerate(pinfo['bands'][band]['rfs']):
                dbm = pinfo['bands'][band]['rf-data'][i]['max-tx']
                msg += "\t    * {0} MHz ({1} dBm)".format(rf,dbm)
                if not pinfo['bands'][band]['rf-data'][i]['enabled']:
                    msg += " (disabled)\n"
                else:
                    msg += "\n"
        print(msg)
コード例 #22
0
ファイル: pentest.py プロジェクト: wraith-wireless/PyRIC
def execute(dev):
    print('Setting up...')
    # ensure dev is a wireless interfaces
    ifaces = pyw.interfaces()
    wifaces = pyw.winterfaces()
    if dev not in ifaces:
        print("Device {0} is not valid, use one of {1}".format(dev,ifaces))
        return
    elif dev not in wifaces:
        print("Device {0} is not wireless, use one of {1}".format(dev,wifaces))

    # get a Card & info for dev
    print("Regulatory Domain currently: ", pyw.regget())
    dinfo = pyw.devinfo(dev)
    card = dinfo['card']
    pinfo = pyw.phyinfo(card)
    driver = hw.ifdriver(card.dev)
    chipset = hw.ifchipset(driver)

    # bring the card down and change the mac
    pyw.down(card)
    pyw.macset(card,'00:03:93:57:54:46')

    # print details
    msg = "Using {0} currently in mode: {1}\n".format(card,dinfo['mode'])
    msg += "\tDriver: {0} Chipset: {1}\n".format(driver,chipset)
    if dinfo['mode'] == 'managed':
        msg += "\tcurrently on channel {0} width {1}\n".format(rf2ch(dinfo['RF']),
                                                               dinfo['CHW'])
    msg += "\tSupports modes {0}\n".format(pinfo['modes'])
    msg += "\tSupports commands {0}".format(pinfo['commands'])
    msg += "\thw addr {0}".format(pyw.macget(card))
    print(msg)

    # prepare a virtual interface named pent0 in monitor mode
    # delete all ifaces on the phy to avoid interference
    # bring the card up when down
    print('Preparing pent0 for monitor mode')
    pdev = 'pent0'
    pcard = pyw.devadd(card, pdev, 'monitor')
    for iface in pyw.ifaces(card):
        if iface[0].dev != pcard.dev:
            print("deleting {0} in mode {1}".format(iface[0],iface[1]))
            pyw.devdel(iface[0])
    pyw.up(pcard)
    print("Using", pcard)

    print("Setting channel to 6 NOHT")
    pyw.chset(pcard,6,None)
    msg = "Virtual interface {0} in monitor mode on ch 6".format(pcard)
    print(msg + ", using hwaddr: {0}".format(pyw.macget(pcard)))

    # DO stuff here
    try:
        print('Now ready to do stuff')
        print('For example, run wireshark to verify card is seeing all packets')
        print('Hit Ctrl-C to quit and restore')
        while True: time.sleep(1)
    except KeyboardInterrupt:
        pass

    # restore original
    print('Restoring', card, 'mode =', dinfo['mode'], 'mac =', dinfo['mac'])
    card = pyw.devadd(pcard,card.dev,dinfo['mode'])
    print('Deleting', pcard)
    pyw.devdel(pcard)
    pyw.macset(card,dinfo['mac'])
    pyw.up(card)
    print("card ", card, " restored")
コード例 #23
0
ファイル: pyw.unittest.py プロジェクト: pgawlowicz/PyRIC
 def test_phyinfo(self):
     self.assertIsInstance(pyw.phyinfo(self.card),dict)
コード例 #24
0
ファイル: wifiinterface.py プロジェクト: zerlina0106/tpy
 def get_phy_info(self):
     try:
         w = pyw.getcard(self._interface)
         return pyw.phyinfo(w)
     except pyric.error as e:
         logger.error(e)