Hello everybody and welcome to this tutorial. Today, I will talk about how you
can actually schedule tasks to run at reboots, or how you can schedule tasks to
run at a certain point of time. Namely, this connects to the previous tutorial
as this is a follow up, how you can set a script or a command to
change the MAC addresses of your interfaces at startup. So every time you
basically reset your computer, or something like that, every time you turn
off your computer and turn it back on, not only does it give you a random
address that anonymizes you further on wireless networks, but rather instead you
are effectively making sure that you will absolutely never use your own real
MAC address anywhere. That's not a bad idea. You might think to yourself,
oh, well, I can just why would I need to do that I can just change it every
time I need to change it. Well, you forget, trust me. You don't think about it all
the time, and it can be painstaking to think about it all the time, not a good
idea, and you will find yourselves in a situation where you
will forget to do it and you will need to do it. That can cause a bit of
inconvenience, not a good idea. It's far simpler to set a cronjob
once, and it's gonna run every time you reboot your computer, change your MAC
address, and that will be just perfect in such a way you will effectively insure
that you will absolutely never on any Wi-Fi network use your own MAC address.
Or on any network, of any kind or sort. Now if we take a look in ifconfig,
I don't actually have any wireless interfaces configured here.
Primarily, because this is a virtual machine. We will be doing some of the
things on my other machine, on Fedora which is my host machine, but for the
time being we will use eth0, my wired interface, as an example. But you can just
as easily do this with any other interface that you have. All
that is really different is the name of interface. So, for example, this one is eth0,
wireless1 would be eth1. On my fedora Fedora OS it's vlp2s0,
that's the name of a wireless interface. Why they have named it so I have no idea,
but so it is. In any case, what you would need to do is let's just go ahead and
clear the screen first. There is something called cronjobs, so cronjob
in pretty much every Linux distribution out there, this is what you use in order
to schedule tasks to run for you in an automated fashion. So what you need to
type in is crontab - - help, press Enter, and there we go. We have a help
menu. It's really small, there aren't that many options, the tool is fairly simple.
You use - e to edit user's crontab, you use - u to specify the user
for which you wish to edit the crontab. That's not a bad idea either
if you have lots of users on the system, or something of a kind, but other than
that by default it will edit the cronjobs of a a current user. So, you can just
type in, before we start typing it in you can also list the user's crontabs,
delete the user's crontabs, very important, and you can also
always use - i to prompt before deleting. Primarily, because when you
delete something in Linux it's not like in Windows. Once you delete it's gone,
and it's gone. There are some methods of retrieving that sort of information,
but more likely than not it's permanently gone. You will find it very
difficult to retrieve information that you have deleted through the usage of
terminal. For example, using the RM command, or something of a kind, yeah.
I've talked about this previously, but I just wanted to remind
you because it is very important, and it has happened to me lots of times that I
deleted something which I either could not retrieve, or I could only retrieve
it but it was fragmented and there were only bits and pieces of it.
So not a good idea. Anyway, enough about that. Let's
go ahead and start editing our scripts that will run on startup. So just
type in crontab - e, press ENTER, and there we go.
We are prompted with this file. This is opened with vi editor, so we will need to
go through some of the basics. There it says edit this file to introduce tasks
to run by cron. I strongly advise reading through this entire file. It's very small.
Like look it goes from here to here so that's the entire readme file.
Just read it. I'm 99% sure that you will be able to
understand pretty much everything that is written here, I will explain some of
the things, but if you find anything unclear that you see here, feel free to
post it in the questions section. Over here the last line is actually the
format. So you got minutes, you got day of the month, you got day of the
week, you got a command for the meaning of each of these separate sections. You
can read this file here. So mon is month, the dom is day of the month, this is hour,
this is minute, and so on, and so forth. So just go through this file, read
through it, and you will understand this format to the fullest extent. But, for the
time being, here is the command that I wish to use. In order for you to
edit pretty much anything in VI, VI is a linux text editor,
you need to open a file and then press I. Just go ahead and press I on
your keyboard, letter I, and it says you are currently in the insert mode. You can
see how I'm highlighting it, now it says insert, and now you can
actually type things in. What we want to type in is @reboot, and then
type in the command macchanger - r,
eth0. That is the command that we use in order to randomize the MAC
address of our eth0 network interface. And here you have at reboot. So when do
we want this to happen? At reboot we want it to happen. When we reboot our machine
execute this command. If you wanted to run a script, or something like that, you
would just need to specify a path to that script and then a command to
execute it. But for the time being, we're not gonna use that. We're just gonna use
a command in order to randomize the MAC address of our network interface. So just
press escape now to exit insert mode, and press : on your keyboard. So just press
colon on your keyboard and you will be prompted with a command line here. In the
command line you need to type in w for write, so write these changes to a file,
and then in addition to W you also need to write q, quit. After you've
written to a file I want you to quit the file. If this doesn't work you
can also add an additional argument which is an exclamation mark to forcibly
do it, but there is no need in this example, it's gonna work. So
quit, there we go. This says installing new crontab, excellent! So we'll just go ahead
and clear the screen, type in ifconfig eth0, wait, no, I don't want to use
that one. I'll do mac changer - s to show me the MAC address
of my interface, eth0, press Enter, and you see it says permanent Mac, this
one. Current Mac that we are using, same one, pretty much. I don't know this is the
manufacturer Cadmus computer systems, whatever. Just go ahead and reboot the
computer, and after the reboot we will see a different MAC address there. Now
you don't need to remember the whole MAC address to verify this, just remember the
first pair, the first two digits, the first two
places, actually, not digits, it was 08. 08 were the first two places that were
occupied in the MAC address. Once we reboot the system I will start up the
ifconfig...actually not the ifconfig. I will use macchanger from now on to actually
verify the MAC addresses of my interfaces. Even though, even though, that
is not a good thing. You should really be using ifconfig, primarily because it is the
universal way of checking a MAC address on pretty much any Linux distro
out there. While on the other hand, Mac changer is most likely only installed by
default on Kali Linux, and pretty much any other distro does not have it installed
by default. So just go ahead and use ifconfig. No, I do not wish to login
this test, I wish to login as root. So, root, test, there we go.
We're being logged in at the moment. Sorry for any delays, this is a virtual
machine so it's bound to have some slight delays, but surprisingly I have
found it very efficient. It's working at a relatively fast pace. I'll just go
ahead and open up our terminal, type in ifconfig, and you can see that the
hardware address has been changed indeed. This one is no longer 08. So to confirm
this further, we'll just go ahead and type in macchanger -s eth0, excellent! So
you see permanent Mac is this, current Mac is this. It's of an unknown type,
unknown manufacturer that is. You can take a look at the macchanger help
menu to specify the type of a MAC address that you want it to assign to
your interface. You can play around with that. I strongly advise that you do. Again,
if you have any questions in regards to that, feel free to post them, I will be
more than happy to help you out in any way that I can. In any case, I bid you
farewell, and I hope to see you in the next tutorial.