wifiphisher / wifiphisher

The Rogue Access Point Framework
https://wifiphisher.org
GNU General Public License v3.0
13.29k stars 2.59k forks source link

Error while running wifiphisher under docker #667

Closed slava-nikulin closed 7 years ago

slava-nikulin commented 7 years ago

I'm trying to run wifiphisher on Kali linux under Docker.

Here is my Dockerfile:

FROM kalilinux/kali-linux-docker
MAINTAINER steev@kali.org

RUN echo "deb http://http.kali.org/kali kali-rolling main contrib non-free" > /etc/apt/sources.list && \
echo "deb-src http://http.kali.org/kali kali-rolling main contrib non-free" >> /etc/apt/sources.list
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get -y update && apt-get -y dist-upgrade && apt-get clean
RUN apt-get -y install aircrack-ng usbutils pciutils git build-essential libssl-dev libffi-dev python-dev python-setuptools \
                       python-scapy python-dbus dnsmasq hostapd

RUN git clone https://github.com/wifiphisher/wifiphisher.git
RUN python wifiphisher/setup.py install

CMD ["/bin/bash"]

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

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

And the Error:

root@rnds-desktop:/wifiphisher python bin/wifiphisher
[*] Starting Wifiphisher 1.3GIT at 2017-07-07 17:18
Traceback (most recent call last):
  File "bin/wifiphisher", line 12, in <module>
    run()
  File "/wifiphisher/wifiphisher/pywifiphisher.py", line 776, in run
    engine.start()
  File "/wifiphisher/wifiphisher/pywifiphisher.py", line 526, in start
    kill_interfering_procs()
  File "/wifiphisher/wifiphisher/pywifiphisher.py", line 467, in kill_interfering_procs
    interfaces.toggle_networking(False)
  File "/wifiphisher/wifiphisher/common/interfaces.py", line 671, in toggle_networking
    bus = dbus.SystemBus()
  File "/usr/lib/python2.7/dist-packages/dbus/_dbus.py", line 194, in __new__
    private=private)
  File "/usr/lib/python2.7/dist-packages/dbus/_dbus.py", line 100, in __new__
    bus = BusConnection.__new__(subclass, bus_type, mainloop=mainloop)
  File "/usr/lib/python2.7/dist-packages/dbus/bus.py", line 122, in __new__
    bus = cls._new_for_bus(address_or_type, mainloop=mainloop)
dbus.exceptions.DBusException: org.freedesktop.DBus.Error.FileNotFound: Failed to connect to socket /var/run/dbus/system_bus_socket: No such file or director

Here is output of dhclient command:

root@rnds-desktop:/# dhclient
dhclient: error while loading shared libraries: libdns-export.so.162: cannot open shared object file: No such file or directory

Version: 8a31876423f1a6a51c4a4b4b5009ae882c691c77

Any ideas?

blackHatMonkey commented 7 years ago

Hi @slava-nikulin Thanks for filling a bug report, we will get to this as soon as we can. Also I did some experiments with docker images but I had trouble connecting my usb adapters to the docker image when running. Were you able to do this successfully?

@anakin1028 It seems that dbus.exceptions.DBusException is not getting captured properly.

anakin1028 commented 7 years ago

hmm, it seems that the dbus module is missing. @slava-nikulin, can you post the output of the following command? ldconfig -p |grep dbus

Also can you try to import dbus on the interactive Python interpreter and see if there is any error?

slava-nikulin commented 7 years ago

Hi, thanks for your responses, guys.

@blackHatMonkey If you start container with --privileged option you'll be able to use your usb devices(i.e. wifi adapters).

@anakin1028 dbus seems to be installed already:

root@eaae0a21ffed:/wifiphisher# ldconfig -p |grep dbus
        libdbus-1.so.3 (libc6,x86-64) => /lib/x86_64-linux-gnu/libdbus-1.so.3
        libdbus-glib-1.so.2 (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libdbus-glib-1.so.2
root@eaae0a21ffed:/wifiphisher# python
Python 2.7.13 (default, Jan 19 2017, 14:48:08)
[GCC 6.3.0 20170118] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import dbus
>>>
slava-nikulin commented 7 years ago

ok, if I run /etc/init.d/dbus restart in container, it fixes that error, but here is another one:

root@21851c5630bb:/wifiphisher# python bin/wifiphisher
WARNING: Failed to execute tcpdump. Check it is installed and in the PATH
[*] Starting Wifiphisher 1.3GIT at 2017-07-08 21:11
Traceback (most recent call last):
  File "bin/wifiphisher", line 12, in <module>
    run()
  File "/wifiphisher/wifiphisher/pywifiphisher.py", line 776, in run
    engine.start()
  File "/wifiphisher/wifiphisher/pywifiphisher.py", line 528, in start
    self.network_manager.start()
  File "/wifiphisher/wifiphisher/common/interfaces.py", line 606, in start
    raise error
pyric.error: [Errno 2] No such file or directory

network-manager is installed in container

sophron commented 7 years ago

Is tcpdump installed? This is a scapy requirement AFAIK.

slava-nikulin commented 7 years ago

It seems, that error is in PyRIC module. Maybe you know why PyRIC can't get card under docker? https://github.com/wraith-wireless/PyRIC/issues/39

nicovillanueva commented 7 years ago

I'm running Wifiphisher, on Kali, inside of a Docker container (ran in --privileged mode and with --net host). Had the exact same problem, but after restarting dbus and installing tcpdump, it works.

blackHatMonkey commented 7 years ago

@nicovillanueva Can you post your relevant configuration files?

nicovillanueva commented 7 years ago

Not much of config files, but I just started a new, clean container, installed a few things, and tried running wifiphisher and it ran fine. Exactly the commands I ran:

# In my host:
docker run -it --net host --privileged kalilinux/kali-linux-docker:latest

# Once inside the container:
apt update && apt -y dist-upgrade
apt install -y pciutils tcpdump python-pip git libnl-genl-3-dev hostapd dnsmasq
pip install scapy
/etc/init.d/dbus restart
cd ~
git clone https://github.com/wifiphisher/wifiphisher
cd wifiphisher
python setup.py install   
wifiphisher

# Wifiphisher's stdout:
root@lithium:~/wifiphisher# wifiphisher
[*] Starting Wifiphisher 1.3GIT ( https://wifiphisher.org ) at 2017-09-18 15:13
[+] Selecting wlp2s0 interface for the deauthentication attack
[+] Selecting wlan1 interface for creating the rogue Access Point
[+] Changing wlan1 MAC addr (BSSID) to 00:00:00:98:87:8e
[*] Cleared leases, started DHCP, set up iptables
[+] Show your support!
[+] Follow us: https://twitter.com/wifiphisher
[+] Like us: https://www.facebook.com/Wifiphisher
[+] Captured credentials:
[!] Closing

However, I didn't get it to actually do it's thing. I just verified that it starts running (the UI comes up and the above logs are shown). Restarting dbus and installing tcpdump are required steps, it seems.

sophron commented 7 years ago

@istais may want to have a look at that as he's maintaining https://hub.docker.com/r/istais/wifiphisher/

nicovillanueva commented 7 years ago

Sadly it seems kinda outdated, right? And I don't see the source of the Dockerfile. Maybe I can pick up the project and maintain a proper hub image. And I'll see to send a pull request, cause scapy and tcpdump seem to be required, but are not installed by the setup.py. Or am I doing something wrong?

blackHatMonkey commented 7 years ago

@sophron Maybe we can build it ourselves using travis. We can automatically build it with every new commit on the master.

sophron commented 7 years ago

Yes, it is outdated indeed.

@blackHatMonkey That's a good idea. @nicovillanueva maybe you can help us with that.

nicovillanueva commented 7 years ago

Gladly! I think that instead of Travis, the image build should be made using automated builds in Docker Hub. I can look into it, sure.

EDIT: Yeah, doable via Docker Hub directly: https://docs.docker.com/docker-hub/builds/#add-and-run-a-new-build

blackHatMonkey commented 7 years ago

@nicovillanueva Sounds great. While we are at it can you look into finding a smaller base file as Kali is huge and we don't need all of that. Maybe ubuntu or another linux base will be smaller and does what we need.

nicovillanueva commented 7 years ago

Yeah. I'm usually an Alpine fan, so I'll try to stick it in there. Otherwise I'll probably fall back to Debian/Ubuntu. I'll get to it once I get this damn meetup talk off my back.

About the original report, @slava-nikulin , did my setup "solve" your issue?

slava-nikulin commented 7 years ago

@nicovillanueva Thank you, it would be cool if you will make updated image! I tried to restart dbus, but that didn't help, I think that is because I run Docker on Windows 10, that uses Hyper-V containers. So, Docker containers are not fully crossplatform yet. Thank you, guys for the help!

nicovillanueva commented 7 years ago

I will! However, neither Windows nor Mac containers will properly work. I set up everything in my Macbook running docker, but Pyric fails. However, I did get it to run (using a USB Wifi card) in a Kali VM, running Docker inside it. Contrived, yeah, but as Docker containers are not native in these platforms, these kind of issues come up.