Code Monkey home page Code Monkey logo

pyric's People

Contributors

blackhatmonkey avatar saroesler avatar wraith-wireless avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

pyric's Issues

Testing

Needing more testing to include
o different distros
o kernel 4.x
o Python 3

Differentiate betw/ no device present and no/partial support for netlink

Need a way to notify users when a device is not present vs their card's driver does not fully support netlink/nl80211.

Possible Solutions:

  1. compose a check script that identifies cards and their support (or lack of) for netlink functions
  2. add a check in errors of type errno 19 no such device to identify lack of support for netlink
    #2 is the preferred solution.

PyRic on ARM processor

Did somebody tried to implement PyRic on ARM processor?
More specifically, does PyRic run on Raspberry PI with kali?

Unknown Command 104

Unknown Command 104. After updating to kernel 4, iw phy info returns
a Unknown command (104). pyw.phyinfo does not return this.

  • iw 3.17 being used

  • command 104 is NL80211_CMD_SET_QOS_MAP

  • iw->util.c:
    const char *command_name(enum nl80211_commands cmd)
    {
    if (cmd <= NL80211_CMD_MAX && commands[cmd])
    return commands[cmd];
    sprintf(cmdbuf, "Unknown command (%d)", cmd);
    return cmdbuf;
    }

    iw's nl80211.h defines NL80211_CMD_SET_QOS_MAP but util.c does not specify
    this command in commands which explains the unknown command.

  • I've gone through the stream returned from the kernel for a wiphy request
    and pyw is not getting this command

  • It does not look like iw is hardcoding this but I cannot see any other way.

  • If this command was being returned, pyw would correctly identify it as
    NL80211_CMD_SET_QOS_MAP - need to identify a card that supports this command
    and determine that pyw does correctly identify it

Question: can't get card info in docker container

My question is: is it possible to get card info in docker container?
Here is my Dockerfile:

FROM ubuntu:latest

# RUN echo "deb http://http.kali.org/kali kali-rolling main contrib non-free" >> /etc/apt/sources.list

RUN apt-get -y update && apt-get -y dist-upgrade && apt-get clean
RUN apt-get -y install git

RUN git clone https://github.com/wifiphisher/wifiphisher.git
RUN apt-get -y install software-properties-common python-software-properties
RUN apt-get install -y python-setuptools
RUN apt-get install -y hostapd
RUN apt-get install -y dnsmasq
RUN cd wifiphisher && python setup.py install
RUN apt-get install -y python-scapy
RUN apt-get install -y python-dbus
RUN apt-get install -y network-manager
RUN apt-get install -y whoopsie
RUN apt-get install -y nano
RUN apt-get install -y tcpdump

CMD ["/bin/bash"]

Build image:
docker build . -t "ubuntu:1"

Start container:
docker run -it --privileged ubuntu:1 /bin/bash

Restart dbus:
/etc/init.d/dbus restart

Get card:

root@4453a82e7028:# python
Python 2.7.12 (default, Nov 19 2016, 06:48:10)
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyric.pyw as pyw
>>> pyw.getcard('eth0')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/PyRIC-0.1.6.3-py2.7.egg/pyric/pyw.py", line 269, in getcard
    if nlsock is None: return _nlstub_(getcard, dev)
  File "/usr/local/lib/python2.7/dist-packages/PyRIC-0.1.6.3-py2.7.egg/pyric/pyw.py", line 2236, in _nlstub_
    return fct(*argv)
  File "/usr/local/lib/python2.7/dist-packages/PyRIC-0.1.6.3-py2.7.egg/pyric/pyw.py", line 270, in getcard
    return devinfo(dev, nlsock)['card']
  File "/usr/local/lib/python2.7/dist-packages/PyRIC-0.1.6.3-py2.7.egg/pyric/pyw.py", line 1050, in devinfo
    raise pyric.error(e.errno, e.strerror)
pyric.error: [Errno 2] No such file or directory
>>>

Or maybe I'm doing something wrong?

Interface Combinations

There doesn't appear to be any way to extract interface combinations, crucial info to create virtual interfaces.

iw list returns (this is for a raspberry pi 3):

	valid interface combinations:
		 * #{ managed } <= 1, #{ P2P-device } <= 1, #{ P2P-client, P2P-GO } <= 1,
		   total <= 3, #channels <= 2
		 * #{ managed } <= 1, #{ AP } <= 1, #{ P2P-client } <= 1, #{ P2P-device } <= 1,
		   total <= 4, #channels <= 1

phyinfo() doesn't return this info. With a bit of wrangling it's possible like this:

import pyric
import pyric.pyw as pyw

import pyric.net.wireless.nl80211_h as nl80211h # nl80211 definition
import pyric.lib.libnl as nl                    # netlink (library) functions
import pyric.net.netlink_h as nlh               # netlink definition

def parse_combinations(cs):
    _combinations = []
    try:
       for _, combo in nl.nla_parse_nested(cs.encode()):
            _combodata = {'limits': []}
            for combofield, combovalue in nl.nla_parse_nested(combo):
                if combofield == nl80211h.NL80211_IFACE_COMB_MAXNUM:
                    _combodata['max'] = struct.unpack_from('I', combovalue, 0)[0]
                if combofield == nl80211h.NL80211_IFACE_COMB_NUM_CHANNELS:
                    _combodata['channels'] = struct.unpack_from('I', combovalue, 0)[0]
                if combofield == nl80211h.NL80211_IFACE_COMB_LIMITS:
                    for combo_option in nl.nla_parse_nested(combovalue):
                        combo_option_unpacked = nl.nla_parse_nested(combo_option[1])
                        for combo_option_fragment in combo_option_unpacked:
                            if combo_option_fragment[0] == 1:
                                option_max = struct.unpack_from('I', combo_option_fragment[1], 0)[0]
                            if combo_option_fragment[0] == 2:
                                option_types = [nl80211h.NL80211_IFTYPES[x[0]] for x in nl.nla_parse_nested(combo_option_fragment[1])]
                        _combodata['limits'].append((option_max, option_types))
            _combinations.append(_combodata)
    except Exception as e:
        print("Error: {}".format(repr(e)))
    return _combinations

def combinations(interface):
    card = pyw.getcard(interface)
    nlsock = None
    try:
        # Open netlink socket
        nlsock = nl.nl_socket_alloc(timeout=2)
        try:
            # Request physical device info through netlink
            msg = nl.nlmsg_new(nltype=pyw._familyid_(nlsock),
                               cmd=nl80211h.NL80211_CMD_GET_WIPHY,
                               flags=nlh.NLM_F_REQUEST | nlh.NLM_F_ACK)
            nl.nla_put_u32(msg, card.phy, nl80211h.NL80211_ATTR_WIPHY)
            nl.nl_sendmsg(nlsock, msg)
            rmsg = nl.nl_recvmsg(nlsock)
            # Parse the response and extract supported interface combinations
            _, cs, d = nl.nla_find(rmsg, nl80211h.NL80211_ATTR_INTERFACE_COMBINATIONS, False)
            if d != nlh.NLA_ERROR: return parse_combinations(cs)
            else: return None
        except AttributeError:
            raise pyric.error(pyric.EINVAL, "Invalid Card")
        except nl.error as e:
            raise pyric.error(e.errno, e.strerror)
    except nl.error as e:
        raise pyric.error(e.errno, pyric.strerror(e.errno))
    except pyric.error:
        raise
    finally:
        if nlsock: nl.nl_socket_free(nlsock)

PR to come to add this to phyinfo()

python 3 support

I have tried to use the library with python3 and it doesn't work. I don't think there is any particular reason why it shouldn't, it just needs a bit of work to support both 2 and 3.

If you are open to collaboration I can look into bringing python3 in. I will have to look into testing in my environment too.

txset

txset
o NOTE: the following is consistent with what iw (v 3.17) gives
o when using dBm
- get Operation not supported for setting tx power (see pyw.txset)
- have tried using the ifindex and phy. Both methods are accepted, returning only Errno 95.
o when using mBm
- no errors reported but tx power is not changed
o Is the operation not supported by my cards? or is it not supported by the
kernel?

Library Caused Kernel Panic

I was attempting to use this library as a replacement for Airmon-NG that i could work with entirely in python with. I can say, it seemed to work great with no hiccups or errors. And yet after running my script over and over again doing testing on different things it eventually lead to a kernel panic.

There were no signs that it had happened at all until after i rebooted my machine and I realized all of my Xorg-drivers were completely broken with no easy way of fixing or reinstalling them.

Unfortunately I neglected to save the code after the panic occurred before I wiped and re-installed my OS onto my machine. Just wanted to let you know that it happened. Sadly, I will have to avoid this library for now. :/

nlmsg_fromstream can incorrectly return error based on stream size

Line 436: if t == nlh.NLMSG_ERROR or l == nlh.NLMSGACKLEN:

Some messages are 36 bytes, nlh.NLMSGACKLEN which causes nlmsg_fromstream to incorrectly raise an error. Have to rework this.

NOTE: this will not cause failure in the execution of pyw. However, if attempting to parse netlink messages from strace and iw, can result in incorrectly throwing error

Interference of NetworkManager on managed interface

On Wifiphisher, we need to spawn a vif on managed mode that NetworkManager does not interfere with, so we can pass it to hostapd. Otherwise, hostapd will fail to set it on AP.

From the README:

In my experience, virtual interfaces are primarily used to recon, attack or some other tomfoolery but can also be used to analyze your wireless network. In either case, it is generally advised to create a virtual monitor interface and delete all others (on the same phy) - this makes sure that some external process like NetworkManager does not interfere with your shenanigans.

This seems to be true when you create a vif on Monitor mode. However, when I create a vif on Managed mode, NetworkManager will find it and interfere with it either way. For example, if you create a pyric0 vif (on managed mode) and delete (or not) the rest on the same phy, nmcli dev status will show the vif as recognized by NetworkManager. I come to the conclusion that the only way to avoid this interference is by either killing these kind of procs (e.g. like airmon-ng check kill does) or tell NetworkManager to stop messing with it (by specifying it to its .conf).

I am wondering if there is a way to spawn a vif directly on AP (or Master) mode (e.g. using devadd). Network-manager should not interfere with it then, and hostapd should happily accept it too.

List of wireless physical devices

Is there a way to get list of just the physical interfaces?

Let's assume I have deleted all virtual devices via command line. In such situation I have no easy way (or I haven't found it) to check what wiphy interfaces are there to add devices from scratch. In all examples you start with at least one existing interface (that you often delete) and create new ones.

pyric.error: [Errno 98] Address already in use

when I try to set up card to monitor mode:
Ubuntu 18:
wlan1: TL-WN722N
wlan1 is not blocked by software...

on my kali linux all works fine!

>>>self._iwface
Card(phy=0,dev=wlan0,ifindex=3)
>>> newcard = pyw.devset(self._iwface, f'{self._iwface.dev}mon')
this line raise error:

newcard = pyw.devset(self._iwface, f'{self._iwface.dev}mon')
  File "..../lib/python3.6/site-packages/pyric/pyw.py", line 1380, in devset
    if nlsock is None: return _nlstub_(devset, card, ndev)
  File "..../lib/python3.6/site-packages/pyric/pyw.py", line 2236, in _nlstub_
    return fct(*argv)
  File "..../lib/python3.6/site-packages/pyric/pyw.py", line 1395, in devset
    if not validcard(card):
  File "..../lib/python3.6/site-packages/pyric/pyw.py", line 279, in validcard
    if nlsock is None: return _nlstub_(validcard, card)
  File "..../lib/python3.6/site-packages/pyric/pyw.py", line 2238, in _nlstub_
    raise pyric.error(e.errno, pyric.strerror(e.errno))
pyric.error: [Errno 98] Address already in use

:update


>>>'monitor' in pyw.devmodes(w1)
True
>>>m1 = pyw.devadd(w1, 'mon1', 'monitor')

Traceback (most recent call last):
  File ".../lib/python3.6/site-packages/pyric/pyw.py", line 1448, in devadd
    rmsg = nl.nl_recvmsg(nlsock) # success returns new device attributes
  File ".../lib/python3.6/site-packages/pyric/lib/libnl.py", line 244, in nl_recvmsg
    msg = nlmsg_fromstream(sock.recv())
  File ".../lib/python3.6/site-packages/pyric/lib/libnl.py", line 444, in nlmsg_fromstream
    raise error(abs(e),strerror(abs(e)))
libnl.error: [Errno 1] Operation not permitted
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File ".../lib/python3.6/site-packages/pyric/pyw.py", line 1428, in devadd
    if nlsock is None: return _nlstub_(devadd, card, vdev, mode, flags)
  File ".../lib/python3.6/site-packages/pyric/pyw.py", line 2236, in _nlstub_
    return fct(*argv)
  File ".../lib/python3.6/site-packages/pyric/pyw.py", line 1452, in devadd
    raise pyric.error(e.errno, e.strerror)
pyric.error: [Errno 1] Operation not permitted

Connect to network feature

Hi wraith-wireless,

I`m one of the developers wifiphisher and I was wondering if you could implement this in Pyric.

So the feature that we want to implement in Wifiphisher is to check if the captured pre-shared key is correct or not. This operation is possible for WEP using

iw dev wlan0 connect your_essid key 0:your_key

We don't need to actually connect to the network, we just want to check if the key is correct or not.

Also I'm wondering if you could implement something with wpa_supplicant as well. If you have any questions let me know.

cannot set random mac address for TL-WN722N dongle

Hi wraith-wireless,

Recently I try to use the function macset in my python program; however when I use it, and it throws the following exception:
5

It seems that the ioctl function raise an IOException.

The following snapshot is set by macchanger, and it set the MAC address successfully.
6

To be more specifically the following is the commands I use in the interactive-Python:
7

Can you help to see this issue?
Thanks!

Test WEP key

Wifiphisher request (@blackHatMonkey) request WEP key test with following iw command

iw dev wlan0 connect your_essid key 0:your_key

iw connect not connecting

iw connect (on open network) returns status of successful connect but there is no connection

Able to replicate this in pyw, getting a status of SUCCESS but no connection is made.

?> sudo iw dev alfa0 connect -w ******net d8:c7:c8:**:**:** 
    alfa0 (phy #1): connected to d8:c7:c8:**:**:**
?>
?> iwconfig
      alfa0     IEEE 802.11bgn  ESSID:off/any  
      Mode:Managed  Access Point: Not-Associated   Tx-Power=20 dBm   
      Retry short limit:7   RTS thr:off   Fragment thr:off
      Power Management:

Add network IP and netmask

Would you be able to add a method that does approximately:

ifconfig interface up network_ip netmask netmask_address

RuntimeWarning

I seem to get this warning every time I'm importing PyRIC.

/home/blackhatmonkey/workspace/wifiphisher/PyRIC/pyric/__init__.py:116: RuntimeWarning: Parent module 'pyric' not found while handling absolute import
  from os import strerror

Add gitignore file

If possible add a .gitignorefile to ignore some of binary files that are created regularly such as .pyc files. A example of it would be this.

Change interface mode

@wraith-wireless Would you be able to add a method that can set the interface's mode.
An example would be:

pyw.set_mode(card, "mode")

which should be equivalent of:

iwconfig wlan0 set mode monitor

TypeError: not all arguments converted during string formatting

Description:
This is an error that I got after to get all modes for an interface.

Script Output:

Traceback (most recent call last):
  File "bin/wifiphisher", line 12, in <module>
    run()
  File "/root/pyric-test/wifiphisher/pywifiphisher.py", line 767, in run
    args.apinterface)
  File "/root/pyric-test/wifiphisher/interfaces.py", line 246, in __init__
    self._check_compatibility(interface_object)
  File "/root/pyric-test/wifiphisher/interfaces.py", line 270, in _check_compatibility
    modes = pyric.devmodes(card)
  File "/root/pyric-test/PyRIC/pyric/pyw.py", line 456, in devmodes
    return _nlstub_(devmodes,card)
  File "/root/pyric-test/PyRIC/pyric/pyw.py", line 957, in _nlstub_
    return fct(*argv)
  File "/root/pyric-test/PyRIC/pyric/pyw.py", line 458, in devmodes
    return phyinfo(card,nlsock)['modes']
  File "/root/pyric-test/PyRIC/pyric/pyw.py", line 572, in phyinfo
    info['modes'] = [_iftypes_(struct.unpack('>H',mode)[0]) for mode in modes]
  File "/root/pyric-test/PyRIC/pyric/pyw.py", line 926, in _iftypes_
    return 'Unknown mode ({0})' % i
TypeError: not all arguments converted during string formatting

MemoryError on nla_parse_nested()

Hi @wraith-wireless,

As you know we are trying to include PyRIC on Wifiphisher. On my system, I'm getting a MemoryError. Apparently, the script goes in an infinite loop when executing nla_parse_nested method.

Here's the traceback:

Traceback (most recent call last):
File "bin/wifiphisher", line 12, in
run()
File "/root/wifiphisher/wifiphisher/pywifiphisher.py", line 786, in run
args.apinterface)
File "/root/wifiphisher/wifiphisher/interfaces.py", line 246, in init
self._check_compatibility(interface_object)
File "/root/wifiphisher/wifiphisher/interfaces.py", line 270, in _check_compatibility
modes = pyric.devmodes(card)
File "/root/wifiphisher/PyRIC/pyric/pyw.py", line 456, in devmodes
return nlstub(devmodes,card)
File "/root/wifiphisher/PyRIC/pyric/pyw.py", line 957, in nlstub
return fct(*argv)
File "/root/wifiphisher/PyRIC/pyric/pyw.py", line 458, in devmodes
return phyinfo(card,nlsock)['modes']
File "/root/wifiphisher/PyRIC/pyric/pyw.py", line 555, in phyinfo
rmsg = nl.nl_recvmsg(nlsock)
File "/root/wifiphisher/PyRIC/pyric/lib/libnl.py", line 243, in nl_recvmsg
msg = nlmsg_fromstream(sock.recv())
File "/root/wifiphisher/PyRIC/pyric/lib/libnl.py", line 448, in nlmsg_fromstream
nla_parse(msg,l,t,stream,nlh.NLMSGHDRLEN + genlh.GENLMSGHDRLEN)
File "/root/wifiphisher/PyRIC/pyric/lib/libnl.py", line 478, in nla_parse
if dt == nlh.NLA_NESTED: a = nla_parse_nested(a)
File "/root/wifiphisher/PyRIC/pyric/lib/libnl.py", line 530, in nla_parse_nested
ns.append(nested[idx+1:idx+(alen-1)])
MemoryError

Question: Can you help me with nl80211 in C++

I have used your library in a sniffer program and love the high level nature of the library. Your library is easily my favorite python module of all time.

Now I am in a C++ class and want to reproduce the sniffer in C++ and am looking to open a socket on a card and change its channel periodically. I got the packet sniffing down so this is the last piece and was hoping you could help.

So to repeat:
I need to open a socket to a wireless card passed by name
Change its channel.

Hope you can help.

MAC on monitor interface

I have troubles running the example code ( pentest.py). I was able to get to the following statement.

In [11]: pyw.macget(pcard)
---------------------------------------------------------------------------
error                                     Traceback (most recent call last)
<ipython-input-11-b54fc24bf362> in <module>()
----> 1 pyw.macget(pcard)

.virtualenvs/venv/lib/python2.7/site-packages/pyric/pyw.pyc in macget(card, *argv)
    280         iosock = argv[0]
    281     except IndexError:
--> 282         return _iostub_(macget, card)
    283 
    284     try:

.virtualenvs/venv/lib/python2.7/site-packages/pyric/pyw.pyc in _iostub_(fct, *argv)
   1547     try:
   1548         argv = list(argv) + [iosock]
-> 1549         return fct(*argv)
   1550     except pyric.error:
   1551         raise # catch and rethrow

.virtualenvs/venv/lib/python2.7/site-packages/pyric/pyw.pyc in macget(card, *argv)
    289             return _hex2mac_(ret[18:24])
    290         else:
--> 291             raise pyric.error(errno.EAFNOSUPPORT, "Invalid return addr family {0}".format(fam))
    292     except AttributeError:
    293         raise pyric.error(errno.EINVAL, "Invalid Card object")

error: [Errno 97] Invalid return addr family 803

With standard tools I get:

ifconfig pent0        
pent0     Link encap:UNSPEC  HWaddr 24-77-03-D2-E4-E8-70-C2-00-00-00-00-00-00-00-00 

iwconfig pent0      
pent0     IEEE 802.11abgn  Mode:Monitor  Frequency:2.437 GHz  Tx-Power=15 dBm   
          Retry short limit:7   RTS thr:off   Fragment thr:off
          Power Management:off

Setting doesn't work either:

In [6]: pyw.macset(d,'00:03:93:57:54:46')
---------------------------------------------------------------------------
error                                     Traceback (most recent call last)
<ipython-input-6-40f960911357> in <module>()
----> 1 pyw.macset(d,'00:03:93:57:54:46')

.virtualenvs/venv/lib/python2.7/site-packages/pyric/pyw.pyc in macset(card, mac, *argv)
    308         iosock = argv[0]
    309     except IndexError:
--> 310         return _iostub_(macset, card, mac)
    311 
    312     try:

.virtualenvs/venv/lib/python2.7/site-packages/pyric/pyw.pyc in _iostub_(fct, *argv)
   1547     try:
   1548         argv = list(argv) + [iosock]
-> 1549         return fct(*argv)
   1550     except pyric.error:
   1551         raise # catch and rethrow

.virtualenvs/venv/lib/python2.7/site-packages/pyric/pyw.pyc in macset(card, mac, *argv)
    312     try:
    313         flag = sioch.SIOCSIFHWADDR
--> 314         ret = io.io_transfer(iosock, flag, ifh.ifreq(card.dev, flag, [mac]))
    315         fam = struct.unpack_from(ifh.sa_addr, ret, ifh.IFNAMELEN)[0]
    316         if fam == ifh.ARPHRD_ETHER or fam == ifh.AF_UNSPEC: # confirm we got a hwaddr back

.virtualenvs/twist-netter/lib/python2.7/site-packages/pyric/lib/libio.pyc in io_transfer(iosock, flag, ifreq)
     71         # permissions etc, catch and reraise as our own
     72         if e.errno is not None: # just in case we have a none 2-tuple error
---> 73             raise pyric.error(e.errno,e.strerror)
     74         else:
     75             raise pyric.error(pyric.EUNDEF,e)

error: [Errno 22] Invalid argument

I suspect it is due to the monitor interface as it by default has different mac address format.

Setting MAC on managed card is fine:

In [15]: wl = pyw.devinfo('wlan2')['card']

In [16]: pyw.macset(wl,'00:03:93:57:54:46')
Out[16]: '00:03:93:57:54:46'

In [17]: pyw.macget(wl)#,'00:03:93:57:54:46')
Out[17]: '00:03:93:57:54:46'

Documentation

Would you be open to the idea of using sphinx to generate the documentation. Currently this is pretty much setup but it's not used(use of :params, etc). sphinx can automatically generate the pages required.

Issue obtaining Link Metrics with OpenWRT

I run the following code, to see mode and properies of the wlan1 interface:

from __future__ import print_function 
import argparse as ap              
import sys         
import pyric        
import pyric.pyw as pyw               
from pyric.utils.channels import rf2ch 

w0 = pyw.getcard('wlan1') 

print (pyw.modeget(w0)) #averiguar modo

link=pyw.link(w0) #mostrar info de enlaces

for d in link:
	print (d, link[d])

But it raises the following:

AP
Traceback (most recent call last):
File "/tmp/Desarrollo_GauchoMesh/pyric/lib/libnl.py", line 247, in nl_recvmsg
_ = nlmsg_fromstream(sock.recv())
File "/tmp/Desarrollo_GauchoMesh/pyric/lib/libnl.py", line 152, in recv
return self['sock'].recv(self.rx)
socket.timeout: timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/tmp/Desarrollo_GauchoMesh/pyric/pyw.py", line 1688, in link
rmsg = nl.nl_recvmsg(nlsock)
File "/tmp/Desarrollo_GauchoMesh/pyric/lib/libnl.py", line 255, in nl_recvmsg
raise error(-1,"Socket timed out")
libnl.error: [Errno -1] Socket timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "pruebas_nl80211.py", line 23, in
link=pyw.link(w0) #mostrar info de enlaces
File "/tmp/Desarrollo_GauchoMesh/pyric/pyw.py", line 1675, in link
if nlsock is None: return nlstub(link, card)
File "/tmp/Desarrollo_GauchoMesh/pyric/pyw.py", line 2279, in nlstub
return fct(*argv)
File "/tmp/Desarrollo_GauchoMesh/pyric/pyw.py", line 1692, in link
raise pyric.error(e.errno, e.strerror)

Look that the first line says "AP", which is the mode of the interface, that is OK. The problem is with the link method.

Any clue or suggestion is welcome.

Thanks in advance.

Pablo.

Wifi Direct

Hello. Can i use PyRIC in order to make my laptop an access point ??
Setting ssid , password etc .

IndexError: list index out of range

Version:
3987c96

Distribution:
Kali 2016

Description:
Fails to show the available modes for a selected card. Note that the modes for the first card is returned back without any error but fails on the second card.

Steps to Reproduce:
Running a file with the following contents:

import PyRIC.pyric.pyw as pyw

# list wireless interfaces
interfaces = pyw.winterfaces()
print "Wireless Interfaces: ", interfaces

for interface in interfaces:
    card = pyw.getcard(interface)
    print card
    print pyw.devmodes(card)

Script Output:

Wireless Interfaces:  ['wlx00c0ca81e2d8', 'wlx00c0ca6da2a4']
Card(phy=6,dev=wlx00c0ca81e2d8,ifindex=9)
['ibss', 'managed', 'monitor']
Card(phy=5,dev=wlx00c0ca6da2a4,ifindex=8)
Traceback (most recent call last):
  File "t.py", line 16, in <module>
    print pyw.devmodes(card)
  File "/home/blackhatmonkey/Downloads/PyRIC/pyric/pyw.py", line 433, in devmodes
    return _nlstub_(devmodes,card)
  File "/home/blackhatmonkey/Downloads/PyRIC/pyric/pyw.py", line 846, in _nlstub_
    return fct(*argv)
  File "/home/blackhatmonkey/Downloads/PyRIC/pyric/pyw.py", line 435, in devmodes
    return phyinfo(card,nlsock)['modes']
  File "/home/blackhatmonkey/Downloads/PyRIC/pyric/pyw.py", line 552, in phyinfo
    info['modes'] = [IFTYPES[struct.unpack('>H', mode)[0]] for mode in modes]
IndexError: list index out of range

"Invalid parameter" when opening interface socket on devices with low rmem_max

When creating a new socket to claim an interface, pyric uses a default value for tx and rx BUFSZ of 32768 bytes. It also checks that the selected value is smaller than the configured maximum socket buffer size, but since BUFSZ is hardcoded, said default value may cause socket initialization to fail. I'm currently working on an embedded system where rmem_max is 163840, which puts the output of _maxbufsz_ at 8192.

Out of the box, this is what I get :

Traceback (most recent call last):
  File "./test_iw.py", line 5, in <module>
    iface = pyw.getcard('wlan0')
  File "/usr/lib/python2.7/site-packages/pyric/pyw.py", line 269, in getcard
    if nlsock is None: return _nlstub_(getcard, dev)
  File "/usr/lib/python2.7/site-packages/pyric/pyw.py", line 2238, in _nlstub_
    raise pyric.error(e.errno, pyric.strerror(e.errno))
pyric.error: [Errno 22] Invalid parameter

It's also not very helpful how _nlstub_ swallows any errors thrown by libnl and replaces them with this not very descriptive message and stack-trace instead.

New kernel 4 definitions in nl80211_h

@blackHatMonkey, referring back to Issue #1, one of your cards (a ath9k_htc) returned a interface type as * Unknown mode (11) . I've added the constant, NL80211_IFTYPE_OCB , for this IFTYPE in nl80211.h. Once you clone the lastest version from Github, can you run pyw.phyinfo on this card and see if it returns 'ocb' or still returns unknown.

Thanks

Failed to process commands.help

I'm using this PyRIC (0.1.1.post1) version and I can't import pyw module. I get the following error:

Traceback (most recent call last):
  File "wifiphisher/interfaces.py", line 6, in <module>
    import pyric.pyw as pyw
  File "/usr/local/lib/python2.7/dist-packages/pyric/pyw.py", line 118, in <module>
    from pyric.nlhelp.nlsearch import cmdbynum      # get command name
  File "/usr/local/lib/python2.7/dist-packages/pyric/nlhelp/nlsearch.py", line 57, in <module>
    raise pyric.error(pyric.EUNDEF,"Failed to process commands.help")

The error happens after version 0.1.0. So 0.1.0 works fine but newer version produce this error.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.