Skip to content

Instantly share code, notes, and snippets.

@bruvv
Last active March 28, 2024 23:34
Show Gist options
  • Star 16 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bruvv/f13cc2c74e52368bd32e1e8ef4e76b4d to your computer and use it in GitHub Desktop.
Save bruvv/f13cc2c74e52368bd32e1e8ef4e76b4d to your computer and use it in GitHub Desktop.
pwnagotchi change wlan card

I want to disable monitor mode for the interal wlan0 card of the pi. If you want to do that too and use wlan1 as mon0 do:

sed -i 's/phy0/phy1/g' /usr/bin/pwnlib

If you want wlan0 and wlan1 in monitor mode and want to use wlan1 as pwnagotchi device, use this ps did didn't work for me but above example

sudo su
rm /etc/network/interfaces.d/wlan1-cfg
echo 'allow-hotplug wlan1' >> /etc/network/interfaces.d/wlan1-cfg
echo 'iface wlan1 inet manual' >> /etc/network/interfaces.d/wlan1-cfg
echo 'pre-up iw phy phy1 interface add mon1 type monitor' >> /etc/network/interfaces.d/wlan1-cfg
echo 'pre-up iw dev wlan1 del' >> /etc/network/interfaces.d/wlan1-cfg
echo 'pre-up ifconfig mon1 up' >> /etc/network/interfaces.d/wlan1-cfg
sed -i 's/mon0/mon1/g' /usr/bin/bettercap-launcher
sed -i 's/mon0/mon1/g' /usr/local/share/bettercap/caplets/pwnagotchi-auto.cap
sed -i 's/mon0/mon1/g' /usr/local/share/bettercap/caplets/pwnagotchi-manual.cap
sed -i 's/mon0/mon1/g' /etc/pwnagotchi/config.toml
sed -i 's/iface mon0/iface mon1/g' /etc/systemd/system/pwngrid-peer.service
sed -i 's/mon0/mon1/g' /usr/bin/pwnlib

If you want to revert to the onboard wireless run this command:

sed -i ‘s/mon1/mon0/g’ /usr/bin/bettercap-launcher
sed -i 's/mon1/mon0/g' /usr/bin/bettercap-launcher
sed -i 's/mon1/mon0/g' /usr/local/share/bettercap/caplets/pwnagotchi-auto.cap
sed -i 's/mon1/mon0/g' /usr/local/share/bettercap/caplets/pwnagotchi-manual.cap
sed -i 's/mon1/mon0/g' /etc/pwnagotchi/config.toml
sed -i 's/phy1/phy0/g' /usr/bin/pwnlib

if you just want to disable the internal pi card and use an adapter use this:

echo dtoverlay=pi3-disable-wifi | sudo tee -a /boot/config.txt
@Overbryd
Copy link

Overbryd commented Sep 9, 2020

I had to change a bit more:

sed -i 's/iface mon0/iface mon1/g' /etc/systemd/system/pwngrid-peer.service
sed -i 's/mon0/mon1/g' /usr/bin/pwnlib

phy0 did not exist in /usr/bin/pwnlib. I had to change the function start_monitor_interface,
and I had to switch mon0 with mon1.

# in /usr/bin/pwnlib

# starts mon1
start_monitor_interface() {
  # iw phy "$(iw phy | head -1 | cut -d" " -f2)" interface add mon1 type monitor && ifconfig mon1 up
  iw phy phy1 interface add mon1 type monitor && ifconfig mon1 up
}

# stops mon1
stop_monitor_interface() {
  ifconfig mon1 down && iw dev mon1 del
}

@rxmrclean
Copy link

^^^^^^

sed -i 's/iface mon0/iface mon1/g' /etc/systemd/ssytem/pwngrid-peer.service

^^^

check the typo's:

/etc/systemd/ !ssytem ! /pwngrid-peer.service

@HugoDL
Copy link

HugoDL commented Jan 6, 2023

As @rxmrclean said earlier, the right command is sed -i 's/iface mon0/iface mon1/g' /etc/systemd/system/pwngrid-peer.service fixing the word "system"

@Overbryd
Copy link

Overbryd commented Jan 6, 2023

@rxmrclean @HugoDL thanks for the notice, I edited my comment above and removed the typo. All hail the internet, long live the internet.

@etothex23
Copy link

Hey there! I have been messing with the pwnagotchi for a couple days. I started with a pi3b and used the LAN to help make configs easier. I got a pi zero and wanted to use wifi for the same and just turn it on to config and back off to work. I don't entirely understand the pwnagotchi/bettercap setup. So is bettercap in control of the wifi, for the purposes of the gadget? I couldn't do any configs to get a dongle working or internal. This sed -i /phy0/phy1/g was the only thing that worked. Sorry if this is amateur hour, but do i reverse it by switching back sed -i /phy1/ph0/g ? I was just going to make a script to bounce it on/off while I work. ANy help or pointing me to info to learn more about it would be appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment