Can Tasker obtain a list of Mac addresses on a lan

1,548 views
Skip to first unread message

Steve Hyde

unread,
Jun 28, 2013, 1:53:10 PM6/28/13
to tas...@googlegroups.com
Hello,

Has anyone been able to obtain a list of Mac addresses connected to a lan so that they can be used as variables, how is this done?

Many thanks

Bob Hansen

unread,
Jun 28, 2013, 4:49:57 PM6/28/13
to tas...@googlegroups.com

Yes it is possible. When the phone is not connected to a specific wifi signal, Tasker will return a list of available wifi signals using the %WIFII built-in variable. The info for each signal consists of name, mac, signal level and more.  

You will need to set a variable equal to %WIFII and then use Variable Split to create a set of variables which will begin with the mac address.  For the splitter use "Mac: ". Next extract the mac addresses from the variable using Tasker's Variable Section and take the first 17 characters which make up the mac address.

Refer to these Tasker guides:

Steve Hyde

unread,
Jun 28, 2013, 5:00:02 PM6/28/13
to tas...@googlegroups.com
Bob... thanks for your input. As I understand it though that would give me the mac addresses for the routers near me rather than what I'm looking for which is the mac addresses of devices connected to the same router I am?

TomL

unread,
Jun 28, 2013, 5:13:11 PM6/28/13
to tas...@googlegroups.com
You're looking for a nmap like app for Android. Google Play has some apps like that, one is called "Fing"

Tasker can't do any of that, sorry.

Tom

Steve Hyde

unread,
Jun 28, 2013, 5:20:58 PM6/28/13
to tas...@googlegroups.com
nmap like is exactly what was looking for! I saw Fing but I saw nothing to suggest it integrated with Tasker?

Steve Hyde

unread,
Jun 28, 2013, 5:22:50 PM6/28/13
to tas...@googlegroups.com

TomL

unread,
Jun 28, 2013, 6:11:11 PM6/28/13
to tas...@googlegroups.com
yeah, they don't have tasker plugins, as far as I know. you can try to ask the developers of those apps to consider writing such an add on.

you could run their app and then see if you could peek at any data files they create to see if you could extract mac id addresses.

another idea is if you have busybox installed on your phone. you could try the shell command:

arp -avn

and see if that gets you anything.

Tom

Steve Hyde

unread,
Jun 28, 2013, 7:55:36 PM6/28/13
to tas...@googlegroups.com
Ok so I messaged the dev of pamn IP scanner. He said he'll look at possibly making it a future feature. Will let you know how this goes.

Steve Hyde

unread,
Jun 28, 2013, 8:05:39 PM6/28/13
to tas...@googlegroups.com
Have to admit, I've never become comfortable with Linux. I would use it for awhile then get utterly frustrated as I couldn't achieve something and reading the online forums never gave me much success

TomL

unread,
Jun 28, 2013, 11:43:30 PM6/28/13
to tas...@googlegroups.com
linux/unix can be a bit frustrating at times. but it's still better than msdos. or vms.

:)


the shell command:
arp -avn

doesn't need root to work, but it won't give you all the hosts on your lan. so you need another method.

:(

Tom

Steve Hyde

unread,
Jul 5, 2013, 2:07:18 PM7/5/13
to tas...@googlegroups.com
OK so no go on the PIPS app:(

TomL

unread,
Jul 5, 2013, 2:31:32 PM7/5/13
to tas...@googlegroups.com
If you want a very clunky solution, you can try a shell script that does this:

look at current ip addr and net mask.
loop thru addr space
ping each possible addr in addr space
end loop
look in the arp cache for the mac addresses

TomL

unread,
Jul 5, 2013, 3:08:38 PM7/5/13
to tas...@googlegroups.com
Or, if you have a rooted phone, go and buy the pamn app, run it on the network you want to scan, and then extract the data you want from pamn's internal results database.

If you have a rooted phone, buying and running pamn installs the nmap binaries on your device, so, you could run nmap directly from the shell to get exactly what you need.

TomL

unread,
Jul 5, 2013, 3:23:19 PM7/5/13
to tas...@googlegroups.com
Check it out, run on my wifi lan on a rooted phone using a shell prompt:

/data/data/com.wjholden.nmap/bin # ./nmap -sn 192.168.2.100-254 &>2 /dev/null; ip neigh
192.168.2.100 dev tiwlan0 lladdr zz:qq:jj:qq:xx:yy REACHABLE
192.168.2.104 dev tiwlan0 lladdr 88:bb:55:zz:yy:xx STALE
192.168.2.107 dev tiwlan0 lladdr zz:tt:33:44:zz:22 STALE

... with my mac addrs fuzzed out to protect my privacy. :)

Steve Hyde

unread,
Jul 6, 2013, 8:06:12 AM7/6/13
to tas...@googlegroups.com
Thanks Tom! I'm on cyanogenmod 10.1 so rooted. Would happily buy pamn but do you know if it's possible to run it in background via tasker, I see that Tasker can loads apps but haven't really seen much in the way of tasker using apps if they don't have built in support already. If I can get all the network info into a task file I'm more than happy messing with it from there to get it to do what I want.

TomL

unread,
Jul 6, 2013, 8:38:24 AM7/6/13
to tas...@googlegroups.com
Absolutely,Tasker can run it. Just install pamn, run it once, grant it root permissions.

Then you can use tasker to run the shell command I posted in my previous reply. Catch the shell output in a var and use a notify flash action to display the contents of the var.

If that works, you can move onto extracting just the mac addrs from the output.

TomL

unread,
Jul 6, 2013, 8:49:48 AM7/6/13
to tas...@googlegroups.com
The Tasker action you want to create is Script > Run Shell. The command to run nmap is:

/data/data/com.wjholden.nmap/bin/nmap -sn 192.168.1.1-254

Obviously, replace 192.168.1.1-254 with your appropriate ip range. Make sure that Run As Root is enabled for the RunShell action. Fill in a global var in the output field like %OUTPUT. this will store any output from the shell command.

after this step, you can just have a simple Notify > Flash: %OUTPUT to see the results.

Get that working, then you can replace the shell command with something more refined:

/data/data/com.wjholden.nmap/bin/nmap -sn 192.168.2.100-254 &>2 /dev/null ; ip neighbor

this runs nmap, but hides any output from nmap. it then runs the command:

ip neighbor

which is the cmd that'll actually show you the interesting network data.

Once this is working, you can hop up the output and keep the column of mac addrs you need, either using awk on the command line or Tasker's var split actions.

Tom

Steve Hyde

unread,
Jul 6, 2013, 7:37:59 PM7/6/13
to tas...@googlegroups.com
Thanks Tom, works awesomely well. I'm assuming then that there are a lot of apps that can interact with Tasker through the shell, how do I go about finding the commands that I need to run for any given program?

TomL

unread,
Jul 6, 2013, 7:59:44 PM7/6/13
to tas...@googlegroups.com
It's the other way around. Tasker can interact with shell commands and programs via the RunShell action. And as for what else can you do thru RunShell, that's like asking what kind of stuff can you find on the internet.

Anything and everything, if you look hard enough. :)

Tom

TomL

unread,
Jul 6, 2013, 8:06:43 PM7/6/13
to tas...@googlegroups.com
I would recommend finding installers in Google Play for:

busybox: the Linux environment that you get with android is very striped down. Busybox puts back in a lot of what you'd expect to find in a Linux environment. Look in Busybox.net for more info.
sqlite: this is a popular database format that android uses. Learn to use sqlite on a rooted phone, and everything on your phone opens up to you like that moment of clarity when Neo can see the Matrix code.
octave: it's like MATLAB, on android

Etc etc etc

Tom

Steve Hyde

unread,
Jul 7, 2013, 8:05:45 AM7/7/13
to tas...@googlegroups.com
Thanks, I thought that was probably the case. I'm gonna guess I'll just have to learn linux afterall.
Reply all
Reply to author
Forward
0 new messages