sickcodes / Docker-OSX

Run macOS VM in a Docker! Run near native OSX-KVM in Docker! X11 Forwarding! CI/CD for OS X Security Research! Docker mac Containers.
https://hub.docker.com/r/sickcodes/docker-osx
GNU General Public License v3.0
48.79k stars 2.72k forks source link

Failed to open host usb device #214

Open Nouw opened 3 years ago

Nouw commented 3 years ago

Hello,

I'm trying to add an usb-device, as stated in the readme you can do that with the following argument:

-e EXTRA='-usb -device usb-host,hostbus=1,hostaddr=8' \

I added that command and changed the hostbus and hostaddr to the correct numbers. I got the hostbus and hostadrr from lsusb (see the output of lsusb below)

Bus 001 Device 014: ID 05ac:12ab Apple, Inc. iPad 4/Mini1

My docker run looks like this:

docker run -it \
    -e EXTRA='-usb -device usb-host,hostbus=1,hostaddr=14' \
    --device /dev/kvm \
    -p 50922:10022 \
    -v /tmp/.X11-unix:/tmp/.X11-unix \
    -e "DISPLAY=${DISPLAY:-:0.0}" \
    sickcodes/docker-osx:auto

when i run it, I get the following error: qemu-system-x86_64: -device usb-host,hostbus=1,hostaddr=14: failed to open host usb device 1:14 and after that error it starts looping /usr/sbin/ssh-copy-id: INFO: Source of key(s) to be installed: "/home/arch/.ssh/id_docker_osx.pub" ssh: connect to host 127.0.0.1 port 10022: Connection refused

How do I solve this?

Full output of docker run command

docker run -it \                                                                                                                                                                             [13:14:34]
        -e EXTRA='-usb -device usb-host,hostbus=1,hostaddr=14' \
        --device /dev/kvm \
        -p 50922:10022 \
    -v /tmp/.X11-unix:/tmp/.X11-unix \
    -e "DISPLAY=${DISPLAY:-:0.0}" \
    sickcodes/docker-osx:auto
By using this Dockerfile, you hereby agree that you are a security reseacher or developer and agree to use this Dockerfile to make the world a safer place. Examples include: making your apps safer, finding your mobile phone, compiling security products, etc. You understand that Docker-OSX is an Open Source project, which is released to the public under the GNU Pulic License version 3 and above. You acknowledge that the Open Source project is absolutely unaffiliated with any third party, in any form whatsoever. Any trademarks or intelectual property which happen to be mentioned anywhere in or around the project are owned by their respective owners. By using this Dockerfile, you agree to agree to the EULA of each piece of upstream or downstream software. The following code is released for the sole purpose of security research, under the GNU Public License version 3. If you are concerned about the licensing, please note that this project is not AGPL. A copy of the license is available online: https://github.com/sickcodes/Docker-OSX/blob/master/LICENSE. In order to use the following Dockerfile you must read and understand the terms. Once you have read the terms, use the -e TERMS_OF_USE=i_agree or -e TERMS_OF_USE=i_disagree
Disk is being copied between layers... Please wait a minute...
touch: cannot touch '': No such file or directory
chown: cannot access '': No such file or directory
  File: /home/arch/OSX-KVM/mac_hdd_ng.img
  Size: 19139461120 Blocks: 37381768   IO Block: 4096   regular file
Device: 3ah/58d Inode: 19016119    Links: 1
Access: (0644/-rw-r--r--)  Uid: ( 1000/    arch)   Gid: ( 1000/    arch)
Access: 2021-03-19 12:15:16.471540259 +0000
Modify: 2021-03-19 12:15:16.471540259 +0000
Change: 2021-03-19 12:15:16.507540373 +0000
 Birth: 2021-03-19 12:14:49.915456539 +0000
Large image is being copied between layers, please wait a minute...
ssh-keygen: generating new host keys: RSA DSA ECDSA ED25519 
nohup: appending output to 'nohup.out'
Booting Docker-OSX in the background. Please wait...
/usr/sbin/ssh-copy-id: INFO: Source of key(s) to be installed: "/home/arch/.ssh/id_docker_osx.pub"
ssh: connect to host 127.0.0.1 port 10022: Connection refused
Disk is being copied between layers. Repeating until able to copy SSH key into OSX...
qemu-system-x86_64: warning: dbind: Couldn't connect to accessibility bus: Failed to connect to socket /tmp/dbus-DlsmwTEyqP: Connection refused
QEMU 5.2.0 monitor - type 'help' for more information
(qemu) ALSA lib confmisc.c:767:(parse_card) cannot find card '0'
ALSA lib conf.c:4745:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
ALSA lib conf.c:4745:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1246:(snd_func_refer) error evaluating name
ALSA lib conf.c:4745:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5233:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM default
alsa: Could not initialize DAC
alsa: Failed to open `default':
alsa: Reason: No such file or directory
ALSA lib confmisc.c:767:(parse_card) cannot find card '0'
ALSA lib conf.c:4745:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
ALSA lib conf.c:4745:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1246:(snd_func_refer) error evaluating name
ALSA lib conf.c:4745:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5233:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM default
alsa: Could not initialize DAC
alsa: Failed to open `default':
alsa: Reason: No such file or directory
audio: Failed to create voice `dac'
ALSA lib confmisc.c:767:(parse_card) cannot find card '0'
ALSA lib conf.c:4745:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
ALSA lib conf.c:4745:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1246:(snd_func_refer) error evaluating name
ALSA lib conf.c:4745:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5233:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM default
alsa: Could not initialize ADC
alsa: Failed to open `default':
alsa: Reason: No such file or directory
ALSA lib confmisc.c:767:(parse_card) cannot find card '0'
ALSA lib conf.c:4745:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
ALSA lib conf.c:4745:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1246:(snd_func_refer) error evaluating name
ALSA lib conf.c:4745:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5233:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM default
alsa: Could not initialize ADC
alsa: Failed to open `default':
alsa: Reason: No such file or directory
audio: Failed to create voice `adc'
qemu-system-x86_64: -device usb-host,hostbus=1,hostaddr=14: failed to open host usb device 1:14
/usr/sbin/ssh-copy-id: INFO: Source of key(s) to be installed: "/home/arch/.ssh/id_docker_osx.pub"
ssh: connect to host 127.0.0.1 port 10022: Connection refused

Output of the requested command:

NAME="Ubuntu"
PRETTY_NAME="Ubuntu 20.04.2 LTS"
VERSION_CODENAME=focal
UBUNTU_CODENAME=focal
Filesystem      Size  Used Avail Use% Mounted on
/dev/nvme0n1p2  768G  291G  439G  40% /
zsh: command not found: qemu-system-x86_64
zsh: command not found: libvirtd
              total        used        free      shared  buff/cache   available
Mem:           15Gi       4,6Gi       230Mi       247Mi        10Gi        10Gi
Swap:           9Gi       279Mi       9,7Gi
12
24
crw-rw----+ 1 root kvm 10, 232 mrt 19 13:15 /dev/kvm
total 140K
drwxrwxrwt  2 root root 4,0K mrt 19 12:03 .
drwxrwxrwt 42 root root 132K mrt 19 13:19 ..
srwxrwxrwx  1 root root    0 mrt 19 09:05 X0
srwxrwxrwx  1 root root    0 mrt 19 12:03 X1
root       72948  0.1  0.5 1760296 85988 ?       Ssl  12:02   0:05 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
fabio      93424  0.0  0.0   9048  2548 pts/1    S+   13:22   0:00 grep --color=auto --exclude-dir=.bzr --exclude-dir=CVS --exclude-dir=.git --exclude-dir=.hg --exclude-dir=.svn --exclude-dir=.idea --exclude-dir=.tox dockerd
kvm:x:108:fabio
docker:x:998:fabio
sickcodes commented 3 years ago

iPhone pasthrough isnt working properly yet, working on it so Xcode works

andersondelgado commented 3 years ago

I also the same problem regarding recognition of usb ports

sudo docker run -it --device /dev/kvm -p 50922:10022 -v "${PWD}/mac_hdd_ng_auto.img:/image" -v /tmp/.X11-unix:/tmp/.X11-unix -e "DISPLAY=${DISPLAY:-:0.0}" -e EXTRA="-device usb-host,hostbus=1,hostport=2" -e "NOPICKER=false" sickcodes/docker-osx:naked ssh-keygen: generating new host keys: RSA DSA ECDSA ED25519 nohup: appending output to 'nohup.out' ++ id -u ++ id -g

sickcodes commented 3 years ago

iPhone passthrough has been solved here: https://github.com/sickcodes/Docker-OSX/issues/133#issuecomment-836855901

I am yet to try it but it is confirmed working.