Results 1 to 5 of 5

Thread: UPDATED HOWTO: Start Kali with a new hostname on every boot

  1. #1
    Join Date
    2016-Sep
    Posts
    4

    UPDATED HOWTO: Start Kali with a new hostname on every boot

    I didn't want to revive an old / dead thread, but this was such a great idea it just needed a little updating.

    tl;dr - reboot (or change) your hostname on every boot or by running a service command in order to avoid the detection of having a host named "kali-laptop" or "my_super_hacking_box"

    I updated your script a little bit so that it will work with the latest Kali Rolling 2016.2 which uses systemd - I called mine changehost.sh

    Code:
    #!/bin/bash
    
    cp -n /etc/hosts{,.old}
    
    newhn=$(cat /dev/urandom | tr -dc 'A-Za-z' | head -c8)
    hostnamectl set-hostname $newhn
    
    echo "127.0.0.1    localhost" > /etc/hosts
    echo "127.0.0.1    $newhn" >> /etc/hosts
    
    exit
    Then create a file called
    Code:
    /etc/systemd/system/changehost.service
    In that file:
    Code:
    [Unit]
    Description=Hostname Randomizer
    
    [Service]
    ExecStart=/usr/bin/changehost.sh
    
    
    [Install]
    WantedBy=multi-user.target
    Finally you have to enable the service:

    Code:
    systemctl enable changehost.service
    Now on boot your hostname should change as part of the services starting. You can also invoke it anytime with
    Code:
     service changehost start

  2. #2
    Join Date
    2016-Oct
    Posts
    2
    Sys0p1791, perhaps you revived an old thread, however, to me it is brand new. The thrill of finding it inspired me to register as a member and thank you! I have a similar script that runs on my windows system. There are times when the names just crack me up.

    You mention you updated the script to work in the latest Kali 2016.2. By any chance, will it run on 2016.1? It may seem as a silly question to some, but for a newbie like me, it is best to ask.

    Thank you for posting the code and instructions. Very clever and I cannot wait to run it.

  3. #3
    Join Date
    2016-Sep
    Posts
    4
    @OKayLee - I honestly don't know if this would work on the 2016.1. I followed a thread linked here but it was for a much older version (from 2013). I am pretty new to Kali myself and have only been using the 2016.2 Rolling so missed all of that.

    I would say that if 2016.1 uses systemd then yes it should work! If not, that thread or a variant of it should likely work for you.

    Happy Hunting!

  4. #4
    Join Date
    2017-Oct
    Posts
    1
    Quote Originally Posted by Sys0p1791 View Post
    I didn't want to revive an old / dead thread, but this was such a great idea it just needed a little updating.

    tl;dr - reboot (or change) your hostname on every boot or by running a service command in order to avoid the detection of having a host named "kali-laptop" or "my_super_hacking_box"

    I updated your script a little bit so that it will work with the latest Kali Rolling 2016.2 which uses systemd - I called mine changehost.sh

    Code:
    #!/bin/bash
    
    cp -n /etc/hosts{,.old}
    
    newhn=$(cat /dev/urandom | tr -dc 'A-Za-z' | head -c8)
    hostnamectl set-hostname $newhn
    
    echo "127.0.0.1    localhost" > /etc/hosts
    echo "127.0.0.1    $newhn" >> /etc/hosts
    
    exit
    Then create a file called
    Code:
    /etc/systemd/system/changehost.service
    In that file:
    Code:
    [Unit]
    Description=Hostname Randomizer
    
    [Service]
    ExecStart=/usr/bin/changehost.sh
    
    
    [Install]
    WantedBy=multi-user.target
    Finally you have to enable the service:

    Code:
    systemctl enable changehost.service
    Now on boot your hostname should change as part of the services starting. You can also invoke it anytime with
    Code:
     service changehost start
    Hi Sys0p1791, i have followed your steps but my hostname is not changing randomly. Is it possible to change the hostname to a name that i choose?
    Thank you

  5. Thanks for this. Very usefull

Similar Threads

  1. Updated Guide: How to make random MAC address at each boot
    By bluedangerforyou in forum How-To Archive
    Replies: 2
    Last Post: 2017-07-28, 23:51
  2. HOW TO: Start Kali with a new unique hostname for each boot
    By testingresults in forum How-To Archive
    Replies: 5
    Last Post: 2013-12-05, 07:33

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •