Jump to content

[Script] PineAP & Karma trigger script


MrGadget

Recommended Posts

Hi guys, 

I just wanted to share a little script I made to trigger PineAP & Karma if my phone connects to my management AP. 

As soon as my device with the specified MAC address connects to it, PineAP and Karma are started (including some visual feedback using the LEDs).

When the device disconnects from the AP, PineAP & Karma are turned off.

 

#!/bin/bash
<<COMMENT1
Script that checks if a defined MAC address is connected
to the hotspot on interface wlan0-1. If the device is connected,
the pineapple automatically starts to generate wifi-honeypots.
On client dissconnect the honeypots are turned off.

COMMENT1

triggerMAC="FF:FF:FF:FF:FF:FF"

#Checks if a client with the defined MAC connects to AP
client=`iw dev wlan0-1 station dump | grep "$triggerMAC"`
echo "Starting to listen for "

#Wait for client to connect
while [ -z "$client" ];
do
	sleep 1
	client=`iw dev wlan0-1 station dump | grep "$triggerMAC"`
done

#Notification to WebGUI on client connect
pineapple notify "Client connected"

#LED animation for visual feedback
for i in {1..3}
do
	pineapple led red on
	pineapple led blue on
	pineapple led yellow on
	sleep 1
	pineapple led red off
	pineapple led blue off
	pineapple led yellow off
	sleep 1
done
pineapple notify "Firing up PineAP and Karma"
#Start PineAP
pineapple module PineAP start
sleep 5
pineapple led yellow on
echo "Starting dogma"
#Start dogma
pineapple module PineAP dogma start
sleep 2
echo "Starting responder"
#Start beacon responder
pineapple module PineAP responder start
sleep 2
#Start collecting SSID
pineapple module PineAP harvester start
pineapple led blue on
sleep 5

#Start Karma, to allow client assosiation
echo "Starting Karma"
pineapple karma start
pineapple led red on
sleep 5

#Turn LEDs off => for animation
pineapple led red off
pineapple led blue off
pineapple led yellow off

#While client is connected, LED animation is running => visual feedback
while [ ! -z "$client" ];
do
        pineapple led yellow on
	sleep 1
        pineapple led yellow off
        pineapple led blue on
	sleep 1
        pineapple led blue off
        pineapple led red on
	sleep 1
        pineapple led red off
        pineapple led blue on
	sleep 1
        pineapple led blue off
	#Check if client is still connected
	client=`iw dev wlan0-1 station dump | grep "$triggerMAC"`
done

#Stop Pineap
pineapple notify "Client diconnected! Stopping PineAP and Karma!"
pineapple karma stop
sleep 5
pineapple module PineAP stop
sleep 5

#Reset LEDs to work in default mode
pineapple led reset
echo "PineAP was shutdown"

 

Hope you guys like it :)

 

Cheers MrGadget

  • Upvote 2
Link to comment
Share on other sites

3 hours ago, MrGadget said:

Hi guys, 

I just wanted to share a little script I made to trigger PineAP & Karma if my phone connects to my management AP. 

As soon as my device with the specified MAC address connects to it, PineAP and Karma are started (including some visual feedback using the LEDs).

When the device disconnects from the AP, PineAP & Karma are turned off.

 


#!/bin/bash
<<COMMENT1
Script that checks if a defined MAC address is connected
to the hotspot on interface wlan0-1. If the device is connected,
the pineapple automatically starts to generate wifi-honeypots.
On client dissconnect the honeypots are turned off.

COMMENT1

triggerMAC="FF:FF:FF:FF:FF:FF"

#Checks if a client with the defined MAC connects to AP
client=`iw dev wlan0-1 station dump | grep "$triggerMAC"`
echo "Starting to listen for "

#Wait for client to connect
while [ -z "$client" ];
do
	sleep 1
	client=`iw dev wlan0-1 station dump | grep "$triggerMAC"`
done

#Notification to WebGUI on client connect
pineapple notify "Client connected"

#LED animation for visual feedback
for i in {1..3}
do
	pineapple led red on
	pineapple led blue on
	pineapple led yellow on
	sleep 1
	pineapple led red off
	pineapple led blue off
	pineapple led yellow off
	sleep 1
done
pineapple notify "Firing up PineAP and Karma"
#Start PineAP
pineapple module PineAP start
sleep 5
pineapple led yellow on
echo "Starting dogma"
#Start dogma
pineapple module PineAP dogma start
sleep 2
echo "Starting responder"
#Start beacon responder
pineapple module PineAP responder start
sleep 2
#Start collecting SSID
pineapple module PineAP harvester start
pineapple led blue on
sleep 5

#Start Karma, to allow client assosiation
echo "Starting Karma"
pineapple karma start
pineapple led red on
sleep 5

#Turn LEDs off => for animation
pineapple led red off
pineapple led blue off
pineapple led yellow off

#While client is connected, LED animation is running => visual feedback
while [ ! -z "$client" ];
do
        pineapple led yellow on
	sleep 1
        pineapple led yellow off
        pineapple led blue on
	sleep 1
        pineapple led blue off
        pineapple led red on
	sleep 1
        pineapple led red off
        pineapple led blue on
	sleep 1
        pineapple led blue off
	#Check if client is still connected
	client=`iw dev wlan0-1 station dump | grep "$triggerMAC"`
done

#Stop Pineap
pineapple notify "Client diconnected! Stopping PineAP and Karma!"
pineapple karma stop
sleep 5
pineapple module PineAP stop
sleep 5

#Reset LEDs to work in default mode
pineapple led reset
echo "PineAP was shutdown"

 

Hope you guys like it :)

 

Cheers MrGadget

Thanks MrGadget, never knew i could call pineapple directly in the cli. Saved me all the coding complexity of having to use curl with apiToken.

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...