Jump to content

Tracking Script Variables


FrozT

Recommended Posts

I'm playing with the tracking script but the variables are not working for me. Even something simple like:

#!/bin/bash
echo $MAC > /var/found.txt

The rest of the script works, just nothing is expanded for the variables. I would like to be able to use tracking with the $MAC variable expanded. I'm basing $MAC off of the default syntax in that script after install.

Any ideas?

Link to comment
Share on other sites

might be worth showing us the script to aid us in debugging for you, orherwise it like peeling an orange
with a garden spade.
 

Link to comment
Share on other sites

Where are you running this script - on the pineapple or on a *UNIX image connecting to it.  As kerravon said, post the script.   You might need to so a "set -a".  You can also do 

 

#!/bin/bash -x

 

This will put the script into debug mode and yo can watch what it is doing.

 

FIN/ACK,

Jim

Link to comment
Share on other sites

@kerravon, I did show the script. It is this:

#!/bin/bash
echo $MAC > /var/found.txt

 

i'm running it from the tracking tab.  It's only a minor modification of the default script that is there in the beginning.  The script does run when I associate with a tracked client, I just don't get to see any of the variables. Even the other ones like $SSID don't show anything.

Link to comment
Share on other sites

The variable MAC has no value due to scoping.  At this point MAC has no value unless it would be an environment variable.  If you type the command "env" from the command line you will see what values are inherent to your session.  If you export those values, your script till know about them.  What value did you expect MAC to have.

 

You need to do something like this:

#!/bin/bash

set -a

export MAC="00:AA:BB:CC:DD:EE"

echo ${MAC} > /var/found.txt

exit 0

What you have above prints nothing, you need to assign a value to the variable MAC.

Link to comment
Share on other sites

How would I know what MAC address the Pineapple just saw in order to export it?  What is the whole point of the tracking script then if it is not able to relay information about MAC or SSID dynamically? Why does the default script include these variables $MAC, $SSID, and $TYPE if they were never going to be populated with anything?

Link to comment
Share on other sites

OK I figured out how to do it but I find it odd i should even have to do this.  If the example script has a $MAC variable it implies it should be pre-populated at the time the script executes.

To get MAC:
tail -n1 /tmp/pineap.log | sed 's/[[:space:]]//g' | cut -d, -f3 >> /var/found.txt
To get SSID:
tail -n1 /tmp/pineap.log | sed 's/[[:space:]]//g' | cut -d, -f4 >> /var/found.txt

Link to comment
Share on other sites

For me personally I wanted to send this MAC to another API via http, I am able to do so like this:

#!/bin/bash

wget -q "http://user:password@x.x.x.x/JSON?variable="$(tail -n1 /tmp/pineap.log | sed 's/[[:space:]]//g' | cut -d, -f3)

Link to comment
Share on other sites

  • 7 months later...

Nobody else has looked at this since January?  That's a bit disappointing.

If I can get the default script to run I can turn my attention to extending the functionality of this feature.

There are two scripts located in /etc/pineapple/.   They are: 

  • tracking_script
  • tracking_script_user

tracking_script_user is the script you see in the web interface on the Tracking page.  By default it is:

#!/bin/bash

echo $MAC
echo $TYPE # 0 PROBE; 1 ASSOCIATION
echo $SSID 

The contents of tracking_script are: 

#!/bin/bash

export $MAC
export $TYPE
export $SSID

[[ "$(uci get reporting.settings.tracking)" == "1" ]] && {
	[[ "$TYPE" == "0" ]] && {
	    echo "$(date): Probe request from $MAC for SSID '$SSID'" >> /tmp/tracking.report
	} || {
	    echo "$(date): Association from $MAC to SSID '$SSID'" >> /tmp/tracking.report
	}
}

/etc/pineapple/tracking_script_user

This latter script reads the value  of "option tracking" in the file at /etc/config/reporting.

root@Pineapple:~# cat /etc/config/reporting 

config reporting 'settings'
	option interval '1'
	option log '0'
	option clear_log '0'
	option survey '0'
	option duration '15'
	option client '0'
	option tracking '0'
	option save_report '1'

config reporting 'ssmtp'

Using the command in the script from a terminal yields a value of '0' (as seen in the file above)

root@Pineapple:~# uci get reporting.settings.tracking
0

The script tracking_script exports the values $MAC, $TYPE and $SSID but they aren't defined.

The script is configured to echo strings of text into the file /tmp/tracking.report using the variables $MAC, $SSID when the value $TYPE is 0.

My Tracking tab is seen in the attached image.

My PineAP tab is seen in the attached image.

When I connect the client listed in the Tracking tab nothing is updated.  The script runs but because the values $MAC, $SSID and $TYPE are not defined they don't get written.  But, because the value of uci get reporting.settings.tracking is 0 the script doesn't even try.  This is evidenced by the fact that the tracking.report file is not created in the /tmp/ directory when the node associates to one of the Pineapple's SSIDs.

If I change the tracking_script value uci get reporting.settings.tracking to a "0" and re-connect the node the Pineapple the tracking.report file is created but its contents are:

root@Pineapple:/tmp# tail -f /tmp/tracking.report 
Fri Sep 15 13:52:45 GMT 2017: Association from  to SSID ''
Fri Sep 15 13:52:45 GMT 2017: Association from  to SSID ''
Fri Sep 15 13:52:45 GMT 2017: Association from  to SSID ''
Fri Sep 15 13:53:15 GMT 2017: Association from  to SSID ''
Fri Sep 15 13:53:45 GMT 2017: Association from  to SSID ''

This is the text echoed by the tracking_script file but, because the $MAC, $TYPE and $SSID values remain undefined they are not show in the file.

Questions:

  • Where are these MAC, TYPE and SSID variables supposed to be coming from?
  • Is the value of uci get reporting.settings.tracking supposed to be changing when a node connects to the AP or when a Probe Request frame is sent?  I'm a little confused on what that value means.
  • Can someone from the Pineapple team tell us if there is a bug in this or if we are just doing something wrong?

Thanks.

Colin

 

clienttrackingfeature.png

pineapsettings.png

Link to comment
Share on other sites

  • 3 months later...
On 14-1-2017 at 3:56 AM, FrozT said:

OK I figured out how to do it but I find it odd i should even have to do this.  If the example script has a $MAC variable it implies it should be pre-populated at the time the script executes.

To get MAC:
tail -n1 /tmp/pineap.log | sed 's/[[:space:]]//g' | cut -d, -f3 >> /var/found.txt
To get SSID:
tail -n1 /tmp/pineap.log | sed 's/[[:space:]]//g' | cut -d, -f4 >> /var/found.txt

I included these statements in the /etc/pineapple/tracking_script file and got results from $MAC etc. The values are wrong however since the /tmp/pineap.log is only updated once every 30 seconds so you get old values.

 

However, if you change these lines in /etc/pineapple/tracking_script:

On 15-9-2017 at 9:06 PM, cmw said:

#!/bin/bash

export $MAC

export $TYPE

export $SSID

to:

#!/bin/bash

export MAC=$TRACKING_MAC
export SSID=$TRACKING_SSID
export TYPE=$TRACKING_ACTION

 

the tracking variables will work.

 

@Sepkinne, could you include this fix in the next release?

 

Link to comment
Share on other sites

23 minutes ago, JohnJohn said:

I included these statements in the /etc/pineapple/tracking_script file and got results from $MAC etc. The values are wrong however since the /tmp/pineap.log is only updated once every 30 seconds so you get old values.

 

However, if you change these lines in /etc/pineapple/tracking_script:

to:

#!/bin/bash

export MAC=$TRACKING_MAC
export SSID=$TRACKING_SSID
export TYPE=$TRACKING_ACTION

 

Thanks for reporting this. We had fixed this for the recent 2.0.2 release but it appears our change was lost. The fix will be included in the next release.

Link to comment
Share on other sites

  • 1 year later...

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

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