Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

quick HOWTO for linux: USB networking + internet access for the p4wnp1 aloa #64

Open
xorr0 opened this issue Jan 15, 2019 · 8 comments
Open

Comments

@xorr0
Copy link

xorr0 commented Jan 15, 2019

quick HOWTO for linux: USB networking + internet access for the p4wnp1 aloa

  • initially I was trying for USB serial on the p4wnp1 aloa, but that required one to manually enable the USB serial option (and disable one of the other USB options).
  • this method works out-of-the-box, and works better for me personally.

after connecting the p4wnp1 aloa to your computer via USB, setup your linux host computer to forward IP packets

$ echo "1" | sudo tee /proc/sys/net/ipv4/ip_forward

  • if doing this via a script, add > /dev/null:
    $ echo "1" | sudo tee /proc/sys/net/ipv4/ip_forward > /dev/null

$ sudo iptables -A POSTROUTING -t nat -j MASQUERADE -s 172.16.0.0/30

bring up the usb# interface (usb0 in my case) on your linux host computer

$ sudo ifconfig usb0 172.16.0.2 netmask 255.255.255.252

  • you can issue sudo dmesg | grep cdc_ether to see what interface got created, and/or ifconfig -a to view all your usb interfaces... for me personally, usb0 has been pretty consistent across linux distros I've used.

test connectivity, ping the p4wnp1 aloa at 172.16.0.1, and you should get a successful response

$ ping 172.16.0.1

ssh to the p4wnp1 aloa at 172.16.0.1 (DEFAULT SSH PASSWORD: toor)

$ ssh root@172.16.0.1

setup a default route on the p4wnp1 aloa back to the linux host device:

root@kali:~# route add default gw 172.16.0.2 usbeth

test connectivity via ping to the internet, you should get a successful response

root@kali:~# ping 1.1.1.1
PING 1.1.1.1 (1.1.1.1) 56(84) bytes of data.
64 bytes from 1.1.1.1: icmp_seq=1 ttl=57 time=15.0 ms
64 bytes from 1.1.1.1: icmp_seq=2 ttl=57 time=17.3 ms
^C
--- 1.1.1.1 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 3ms
rtt min/avg/max/mdev = 15.021/16.177/17.333/1.156 ms
  • OPTIONAL: feel free to add custom nameserver(s) to /etc/resolv.conf
    root@kali:~# echo "nameserver 1.1.1.1" >> /etc/resolv.conf
root@kali:~# cat /etc/resolv.conf
nameserver 8.8.8.8
nameserver 1.1.1.1

when finished, disable forwarding packets on your linux host computer

$ echo "0" | sudo tee /proc/sys/net/ipv4/ip_forward > /dev/null
$ sudo iptables -t nat -F POSTROUTING
@xorr0
Copy link
Author

xorr0 commented Jan 19, 2019

  • even more streamlined; bash functions (utilizes ssh-pass)
p4wnp1 () {
        echo "1" | sudo tee /proc/sys/net/ipv4/ip_forward > /dev/null
        sudo iptables -A POSTROUTING -t nat -j MASQUERADE -s 172.16.0.0/30
        sudo ifconfig usb0 172.16.0.2 netmask 255.255.255.252
        ping -c 1 172.16.0.1 >/dev/null 2>&1
        if [ $? -eq 0 ]; then
            sshpass -p "toor" ssh -f root@172.16.0.1 "route add default gw 172.16.0.2 usbeth"
            echo "[+]  SUCCESS: access P4wnP1 via USB CDC Ethernet @ 172.16.0.1/30"
        else
            echo "[!]  FAILURE, something went wrong"
        fi
}

nop4wnp1 () {
        sshpass -p "toor" ssh -f root@172.16.0.1 "route del default gw 172.16.0.2 usbeth"
        sleep 2
        echo "0" | sudo tee /proc/sys/net/ipv4/ip_forward > /dev/null
        sudo iptables -t nat -F POSTROUTING
        if [ $? -eq 0 ]; then 
            echo "[+]  SUCCESS: P4wnP1 connectivity removed"
        else
            echo "[!]  FAILURE, something went wrong"
        fi
}

@quesodipesto
Copy link

Wow, good joob! We can connect us P4wnP1 to internet and works like ever?
If us host is windows, what we have to do?

Thanks men :)

@mame82
Copy link
Collaborator

mame82 commented Mar 13, 2019

For Windows:

  1. Enable RNDIS on P4wnP1
  2. Reconfigure usbeth to use DHCP client instead of DHCP server
  3. On the Windows host enable Internet Connection Sharing (ICS) for the Network adapter which provides Internet access
  4. Configure ICS to share the connection with the RNDIS adapter deployed by P4wnP1 (after attaching via USB)

@quesodipesto
Copy link

quesodipesto commented Mar 14, 2019

imagen

Ok, i connect with my phone to 172.24.0.1, acced the web interface, goes to "Networking", selected "usbeth" and changed DHCP-SERVER to DCHP-CLIENT, pressed "DEPLOY" but...

In my W10 i can't find the network interface "Red no identificada" (spanish) --> "Unidentified network" (english).
With this error we can't ICS us real w10 connection (Wifi).

I have enabled the RNDIS "USB SETTINGS"--> RNDIS (by default)

EDIT:

Ok, it works!!

When y press "DEPLOY" in your web interface, the P4wnP1 don't "tell us" nothing, but if we send a ping (P4wnP1 ssh 172.24.0.1 --> ping 8.8.8.8) we can see the packets 💃

THANKS!

@poritz
Copy link

poritz commented Jul 11, 2019

Hi, I'm having a Problem with sshing into my p4wnp1 after getting dynamic ip (in my case 192.168.137.1). What i tried without success so far:
-sshing into 172.16/24.0.1 couldn't reach it, neither via phone nor putty from targetmachine
-sshing into 192.168.137.1 connection refused (via putty and phone)
-using the discribed method on a vm ware kali linux distro
-using a ethernet to usb adapter directly plugged into my router and sshing into p4p1 via phone network unreachable/ temporary nameressolve error
Looking forward to hear some suggetsions on what to try next :)

btw I also tried to install software (ettercap) manually but cmake is missing and installing cmake is not working due to make not working properly XD

@anduril-glitch
Copy link

Hi, I'm having a Problem with sshing into my p4wnp1 after getting dynamic ip (in my case 192.168.137.1). What i tried without success so far:
-sshing into 172.16/24.0.1 couldn't reach it, neither via phone nor putty from targetmachine
-sshing into 192.168.137.1 connection refused (via putty and phone)
-using the discribed method on a vm ware kali linux distro
-using a ethernet to usb adapter directly plugged into my router and sshing into p4p1 via phone network unreachable/ temporary nameressolve error
Looking forward to hear some suggetsions on what to try next :)

btw I also tried to install software (ettercap) manually but cmake is missing and installing cmake is not working due to make not working properly XD

I have the same problem.

Could you find a solution?

Thank you

A +

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants
@mame82 @xorr0 @quesodipesto @poritz @anduril-glitch and others