Linux software to randomize PC hostname & wireless MAC for privacy at hotspots

If I understand Jeff L. correctly, hotspots often log your hostname and wirelss car MAC address; so I wish to automatically change my wireless card MAC and laptop PC hostname upon every reboot.

On Windows, I can change these things manually but there are plenty of freeware packages which pseudo-randomize the hostname (based on a lookup table) and wireless MAC address for added privacy at hotspots upon every reboot. These work great!

However, on Linux, while I can change these things manually, I have not yet found software that does so automatically upon every reboot.

Here's how I change the hostname on Linux manually: $ sudo vi /etc/hosts

Change the contents of /etc/hosts from:

127.0.1.1 ubuntu ubuntu

Change the contents of /etc/hosts to: # 127.0.1.1 ubuntu ubuntu

127.0.0.1 foo foo $ sudo echo foo > /etc/hostname $ sudo reboot

And, here's how I change the MAC address on Linux manually: $ ifconfig -a | grep HWaddr $ sudo ifconfig wlan0 down hw ether DE:AD:BE:EF:CA:FE $ sudo ifconfig wlan0 up

The question is where can I find software that will perform that task of changing the wireless card MAC address and PC hostname upon every reboot?

Reply to
Y Knot
Loading thread data ...

I know nothing about Linux, but can't you put your code into a bat file and execute upon every boot?

Reply to
Nomen Nescio

For about 99.99% of the time, whatever you can do manually, you can put the commands in a script to do the same thing.

If you look in /etc/init.d you will see several scripts which execute during system startup/shutdown.

If you look in /etc you will see several directories which contain links back to /etc/init.d scripts. Do a ls /etc/rc?.d

Now look in a directory, with ls -l /etc/rc2.d/* Those S* links are the order they execute during Startup and the K* are the links executed in that order during kill/shutdown.

If you were to do the command runlevel you would see what level you are running and can look in that directory to see what executes when.

If you do a $ runlevel N 2 the your runlevel is 2. So, do a ls -l /etc/rc2.d/*

I your case you might try creating a /etc/init.d/rnd_hostname then create a /etc/rc2.d/S05rnd_hostname link pointing to /etc/init.d/rnd_hostname.

Next boot, S05rnd_hostname would run your script to change host name.

Going to guess you are running ubuntu. It runs dhclient which gets your ip address and whatnot to connect to the internet.

Doing a man dhclient eventually suggests doing a man dhclient_script which can lead to the fact that you can create a /etc/dhcp3/dhclient-exit-hooks script. That is where I would try to put code to munge your MAC address.

You might want to bookmark this url

formatting link
You could create /etc/dhcp3/dhclient-exit-hooks with echo $@ > /tmp/hooks env >> /tmp/hooks

Set execute permission with chmod +x /etc/dhcp3/dhclient-exit-hooks

After booting, look at /tmp/hooks to see what information is available for your code.

Now, delete /tmp/hooks and restart the network and see what you have.

rm /tmp/hooks service network-manager restart cat /tmp/hooks

All the above needs to done from a root terminal. To get to a root terminal:

sudo -i

when through with root terminal, enter the command exit or do a control d

Reply to
Bit Twister

Y Knot wrote in news:i7ildi$pda$2 @speranza.aioe.org:

that task of

every reboot?

What makes you ASSume that they cannot id you by means other than MAC and hostname? They can.

Reply to
Madeup

Probably.

The goal is to put it in the 'startup' directory (/etc/init.d/) somehow.

I did find a good way to 'randomize' the MAC address manually: `echo $RANDOM$RANDOM | md5sum | sed -r 's/(..)/\1:/g; s/^(.{17}).*$/\1/;'`

And, I did find a way to 'randomize' the hostname based on a random selection out of the standard Linux dictionary of words at /usr/share/ dict/words

The question now is how to tie all that together so that the random wlan0 mac and the random hostname are assigned upon reboot of the Ubuntu 10.04 laptop.

Reply to
Y Knot

As an FYI: I took a quick peek through Ubuntu's init.d/ scripts. I will suggest you change hostname on shutdown since I did not see when hostname set during boot/start.

Put you code in rnd_hostname script I suggested and create a Kxxrnd_hostname link in /etc/rcx.d

Suggest taking one of the scripts in init.d, copy to rnd_hostname and start playing around.

Better yet, install virtualbox, create a guest virtual machine, take a snapshot and start playing around. That way if you screw it up, you can delete current snapshot, create a new on, and try again.

Changing hostname on the fly can cause you to lose gui desktop manager.

You might want to

formatting link
to check out init scripts.

formatting link
*ubuntu*&as_usubject=&as_uauthors=&safe=off alt.computer.security would be off topic now that you have a direction.

comp.unix.shell for scripting questions. alt.os.linux.ubuntu for specific ubuntu questions. ubuntu has a forum where you might get some help.

Reply to
Bit Twister

Meanwhile, at the alt.internet.wireless Job Justification Hearings, Bit Twister chose the tried and tested strategy of:

I've got /etc/init.d/hostname on my 10.04 laptop, although it's an Upstart skeleton script so I can't actually see what it does.

Reply to
alexd

Meanwhile, at the alt.internet.wireless Job Justification Hearings, Y Knot chose the tried and tested strategy of:

Wouldn't it be funny if you got busted because your laptop had assigned itself a hostname of 'pederast' [or similar].

Reply to
alexd

Yes, saw that, and grep'ed for hostname and never saw it called from another script in init.d or a rc?.d link.

Found several directories where scripts could be placed to munge things. Example: /etc/network/if-up.d, if-down.d, if-pre-up.d, if-post-down.d

If it were me, it would be a shutdown script to modify /etc/hostname and set a fake MAC with "hwaddress ether 01:02:03:04:05:06" under the wifi interface in /etc/network/interfaces.

Next system boot would have new values.

Reply to
Bit Twister

formatting link
Been around for ages. Packages available for ubuntu, debian, etc etc Put it in rc.local. But why on boot ? Just link to a script. Don't forget the gksu, or whatever, you need to be root. []'s

Reply to
Shadow

I already tested MacChanger which didn't add ANY value whatsoever. It's EXACTLY the same number of steps with MacChanger than without MacChanger (so what's the point of the program anyway?).

With MacChanger, the steps are:

  1. sudo macchanger -s wlan0
  2. sudo /etc/init.d/networking stop
  3. sudo macchanger --another wlan0
  4. sudo /etc/init.d/networking start

Without MacChanger, the steps are:

  1. sudo /etc/init.d/networking stop
  2. sudo ifconfig wlan0 down hw ether DE:AD:BE:EF:CA:FE
  3. sudo ifconfig wlan0 up
  4. sudo /etc/init.d/networking start

The hostname can ONLY be changed (AFAIK) upon reboot anyway, so you may as well do the MAC at the same time.

This is such a basic need that I'm sure a LOT of people have done it already. The trick is to find them! :)

I'm working on adapting this script:

formatting link

Reply to
Y Knot

is line one necessary ? /sbin/ifconfig wlan0 down /sbin/(or wherever)/macchanger -A wlan0 /sbin/ifconfig wlan0 up

And that gives you a random MAC ? DeadBeefCafe ? HELP!!! ALERT!! A HACKER!!!! macchanger -A gives you a random MAC from a KNOWN manufacturer. and macchanger can be easily scripted. This second example does not give you a random MAC.

Reply to
Shadow

Meanwhile, at the alt.internet.wireless Job Justification Hearings, Shadow chose the tried and tested strategy of:

Come on, it's not that hard to put information together from this thread:

$ sudo ifconfig wlan0 down hw ether `echo $RANDOM$RANDOM | md5sum | sed -r 's/(..)/\1:/g; s/^(.{17}).*$/\1/;'`

Reply to
alexd

Nobody understands me correctly. I don't even understand myself sometimes.

That might not help as your black hat, mask, and cape, with the skull and crossbones are rather obvious. Shave your head and get some tattoos, and you'll fit right in. To complete the disguise, I suggest you camouflage your laptop as a pizza:

Before you inflict your MAC address manufacturing machine on the world, you may find it amusing to see how many times you can change your MAC address connecting your wireless router before it fails. Download and run:

This tool generates new MAC addresses (and therefore new wireless connections) until the router can't open any more. The doc is in the ZIP file.

You may need to set the netmask to /16 (255.255.0.0) in order to get a decent number on high end wireless routers.

Most cheap /24 wireless routers will choke at 253 IP addresses if they're not smart enough to discard unused DHCP leases or have limited RAM. Better routers, that are smart enough to dump unsused leases, will usually go to maybe 2046 before the MAC address to port number table fills. Some will go to about 16000 connections.

If your script just changes the MAC address when you boot, there will be no problem. If you script goes insane and spews random MAC addresses without end, you're likely to hang the router.

As an added misfeature, some routers (i.e. DD-WRT) save the DHCP leases in NVRAM. Reboot the router and it's still messed up because the leases won't flush until they expire, which can take days. (There's a check box in DD-WRT to disable this feature).

Reply to
Jeff Liebermann

HELP!!! ALERT!! A HACKER!!!! Not that hard ? I won't learn that kind of stuff in the time I have left :)

~$ echo $RANDOM$RANDOM | md5sum | sed -r 's/(..)/\1:/g; s/^(.{17}).*$/\1/;' e0:02:83:73:7a:2a Yeah, it works.

The macchanger program can give you real manufacturer strings though. It checks the

formatting link
(uses an older version). []'s

Reply to
Shadow

Wouldn't it be funny, if the noobs got busted because they don't realize MAC addresses follow certain conventions and totally random selections stick out even more than a consistent "standard" MAC address.

Yeah, once again the noobs are getting it all wrong and missing an already well established solution...

formatting link
Oh, and wireless connections aren't typically established under Linux desktop distros until a user logs in, so setting up a fake MAC at boot time isn't only unnecessary, it could actually defeat the purpose completely depending on distribution. If an interface is reinitialized at login it would revert back to it's "natural state".

Reply to
Anne Onime

It's what I'm trying to say. My English obviously is not good enough.... Now if that "sed" guy (troffaskyBLURBhotmail.com)could use the latest oui.txt to feed his random mac generator, we would have a very up-to-date macchanger. Just need to download the oui.txt (and put it in the same directory as the script - to keep it tidy) []'s

Reply to
Shadow

No - this is too late: by then you've posted your MAC and received a DHCP response. If you're going to tweak your MAC it should be done no later than by a file in /etc/network/if-pre-up.d/ or a pre-up stanza in /etc/network/interfaces.

Re setting the hostname, on my (Debian) box it's handled as part of /etc/init.d/hostname.sh, which is called on system bootup as /etc/rcS.d/S02hostname.sh. Obviously this may be different for Ubuntu (I found the relevant script by running this command: grep -l hostname /etc/init.d/* )

Chris

Reply to
Chris Davies

Why on earth should this be the case? Chris

Reply to
Chris Davies

Yep, ubuntu hostname was not called in /etc/rcS.d/ or /etc/rc2.d/

I hear where you are coming from about dhclient-exit-hooks but you have to decide if you want mac/hostname changed on startup, shutdown, or each network restart.

I suggest setting them during shutdown. Major reason would be so next boot would be pretty clean. You do not want to change host name after some service/daemon has started with old name. Examples; postfix, sendmail, leafnode, dovecot,..

Reply to
Bit Twister

Cabling-Design.com Forums website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.