This forum is in archive mode. You will not be able to post new content.

Author Topic: Mac Spoofing with systemd  (Read 5041 times)

0 Members and 1 Guest are viewing this topic.

Offline lucid

  • #Underground
  • Titan
  • **
  • Posts: 2683
  • Cookies: 243
  • psychonaut
    • View Profile
Mac Spoofing with systemd
« on: January 22, 2013, 02:16:45 AM »
                               Mac Spoofing with systemd

// This tutorial created by lucid

::In this tutorial
- Creating custom systemd scripts(Arch Linux)
- Mac spoofing at startup



::What you will need
- Arch Linux switched to systemd. If you do not know what this means visit the Arch Wiki.
- The ability to read.
- A text editor. (nano, vi, emacs, gedit)
- A penis or vagina. (but not both)
- Macchanger


::Let's Get Started!


For those of you that do not know what systemd is and are interested in switching over to it should visit the Arch Wiki here https://wiki.archlinux.org/index.php/Systemd and read through it carefully.

Now. What I'm going to be showing you today is how to write a custom startup script or .service file in systemd. It actually took me a long time to figure out how to write a script and have it run at startup in systemd. It is true that if you are running some WM like openbox/fluxbox you can put your script in an autostart file and that shoud normally do the trick. I should be specific. In particular I'm going to teach you to write a .service file that will spoof your Mac address at startup.

Here's the basic format of a .service file in Arch Linux:

Code: [Select]
[Unit]
Description=
Before=

[Service]
ExecStart=

[Install]
WantedBy=

These are usually located in /etc/systemd/system. Take a look at a few of them if you like. As I said before I just showed you the basic format of one of these files. If you're already sick of reading I assure you this tutorial will be short and to the point. These are very simple.



Description=

This is pretty straightforward. All this is, is what you will see in the startup messages you will see when you boot up your system if you have systemd. So for example.

Code: [Select]
[Unit]
Description=Mac Spoof
Before=

[Service]
ExecStart=

[Install]
WantedBy=

Notice what it says in Description. When you start up systemd you will see a bunch of messages on the screen looking like this:

[   OK   ]Started Network Manager
[   OK   ]Started Mac Spoof << This is what ours will look like

Pretty simple.



Before=

This is basically where you put a service you want your custom service to start before. You could also change it to After=. For our example we will use this:

Code: [Select]
[Unit]
Description=Mac Spoof
Before=dhcpcd.service

[Service]
ExecStart=

[Install]
WantedBy=

The reason we put this in the Before= area is so that your Mac will be spoofed before dhcpcd. That way, you don't have to reconfigure the network after you start up. Lets move on.



ExecStart=

This is where you will put whatever script it is that you want to run. In our case we will be using our macchanger script.

Code: [Select]
[Unit]
Description=Mac Spoof
Before=dhcpcd.service

[Service]
ExecStart=/bin/bash /home/lucid/code/sh/macchanger.sh

[Install]
WantedBy=

The /bin/bash before the path to the script is to make sure it knows that you want to run a bash script. Otherwise this won't work. Also, you have to make sure that you use the full path. In case you aren't sure about this part I will show you my script that I called here:

Code: [Select]
#! /bin/sh
sudo macchanger -r wlan0

If you can't understand what I did here you should read up on macchanger. All this does is set you interface(wireless in my case)mac address to a random one(-r).


WantedBy=

This creates a symlink in the .wants/ directory. Doing this enables whatever service you put here along with your custom service.

Code: [Select]
[Unit]
Description=Mac Spoof
Before=dhcpcd.service

[Service]
ExecStart=/bin/bash /home/lucid/code/sh/macchanger.sh

[Install]
WantedBy=network.target

This way, the network service is started along with our macchanger service. That's about all you need to do to write a very simple .service file. For a more detailed and harder to read documentation you can refer to man systemd.unit. Also, don't forget to put this in /etc/systemd/system and name it something like macspoof@wlan0.service. or macchanger@wlan0.service. Make sure that after you create this file you run systemctl start macspoof@wlan0.service to enable your new service. Oh, and one more thing. Before you do this you can run this command:

ifconfig wlan0 | grep -o -E '([[:xdigit:]]{1,2}:){5}[[:xdigit:]]{1,2}'

To see what your mac address is. After you have done this, run it again to verify the change of mac so that you know it worked. I hope this helped someone who is either looking to create their own system service files and/or spoof your mac address on startup in Arch linux. Thanks for reading.



-lucid
« Last Edit: January 22, 2013, 05:28:24 AM by lucid »
"Hacking is at least as much about ideas as about computers and technology. We use our skills to open doors that should never have been shut. We open these doors not only for our own benefit but for the benefit of others, too." - Brian the Hacker

Quote
15:04  @Phage : I'm bored of Python

Offline proxx

  • Avatarception
  • Global Moderator
  • Titan
  • *
  • Posts: 2803
  • Cookies: 256
  • ФФФ
    • View Profile
Re: Mac Spoofing with systemd
« Reply #1 on: January 22, 2013, 04:56:26 AM »
Im gonna re-read this when im done working.
Thanks, looks good.
+1

I only recently switched to systemD because im lazy at times.
Havnt looked in the startup scripts etc.
I should though, I still have some stuff broken ever since.
« Last Edit: January 22, 2013, 04:59:39 AM by proxx »
Wtf where you thinking with that signature? - Phage.
This was another little experiment *evillaughter - Proxx.
Evilception... - Phage

Offline lucid

  • #Underground
  • Titan
  • **
  • Posts: 2683
  • Cookies: 243
  • psychonaut
    • View Profile
Re: Mac Spoofing with systemd
« Reply #2 on: January 22, 2013, 05:22:42 AM »
Thanks I thought it was ok. Yeah I procrastinated systemd for quite a little while but now I love it.
« Last Edit: January 22, 2013, 05:23:45 AM by lucid »
"Hacking is at least as much about ideas as about computers and technology. We use our skills to open doors that should never have been shut. We open these doors not only for our own benefit but for the benefit of others, too." - Brian the Hacker

Quote
15:04  @Phage : I'm bored of Python

 



Want to be here? Contact Ande, Factionwars or Kulverstukas on the forum or at IRC.