Run Fluxion in a Headless Environment using SSH

Beginner
Practice Now

Introduction

Welcome to this lab on running Fluxion in a headless environment. Fluxion is a popular security auditing and social-engineering research tool. It is often used for tasks that can take a significant amount of time to complete.

A "headless" environment is a system that operates without a graphical user interface (GUI) and is typically managed remotely over a network. When running long tasks on a remote machine, you risk interruption if your network connection drops.

In this lab, you will learn how to use SSH (Secure Shell) for remote access and tmux (a terminal multiplexer) to create a persistent session. This setup allows you to start a task like a Fluxion scan, disconnect from the remote machine, and have the task continue running in the background. You can reconnect later to check the progress.

We will simulate this entire process within the LabEx environment. We will first install Fluxion and then walk through the steps of using tmux to manage the Fluxion process.

SSH into your Kali Linux machine

In a real-world scenario, the first step would be to use an SSH client to connect from your local computer to the remote server (which might be a Kali Linux machine or any other Linux distribution). The command would look something like ssh user@remote_ip_address.

For this lab, we will simulate this process. The terminal you are currently using represents your remote session on the server. The necessary software, Fluxion, has already been downloaded into the ~/project/fluxion directory by the setup script.

In this step, let's navigate into the Fluxion directory to prepare for the next steps.

Execute the following command to change your current directory:

cd ~/project/fluxion

You can verify that you are in the correct directory by running the ls command, which should list the contents of the Fluxion repository.

ls
CHANGELOG.md    fluxion.sh      README.md
CONTRIBUTORS.md  install         requirements.txt
docs            LICENSE         sites
files           Makefile        tmp

Use 'tmux' or 'screen' to create a persistent session

Now that we are "on" the remote machine and in the correct directory, we need to create a persistent session. This ensures that any command we run inside this session will continue to execute even if we get disconnected. We will use tmux, a powerful terminal multiplexer.

In this step, you will create a new tmux session named fluxion_session. This named session is easy to identify and re-attach to later.

Run the following command to start a new tmux session:

tmux new -s fluxion_session

After running this command, your terminal will look almost the same, but you are now inside a tmux session. You'll notice a green status bar at the bottom of the screen, which indicates that tmux is active. Any commands you run now will be within this persistent session.

Launch 'fluxion.sh' from within the tmux/screen session

With our persistent tmux session active, we can now safely launch Fluxion. Because we are inside tmux, the Fluxion process will be protected from any potential network disconnects.

We are already in the ~/project/fluxion directory from Step 1. The main executable for Fluxion is the fluxion.sh script. It requires root privileges to manage network interfaces and run its attack tools, so we must run it with sudo.

Execute the following command to start Fluxion:

sudo ./fluxion.sh

Fluxion will start and may perform a check for required tools. Since we installed them in the setup script, it should proceed directly to the main menu. You will first be prompted to choose a language.

Perform an attack as usual through the SSH terminal

Now that Fluxion is running, you can interact with its menu-driven interface just as you would in a normal terminal.

First, Fluxion will ask you to select a language. Type 1 and press Enter to select English.

[#] Select your language:
[1] English
...
[*] Language> 1

Next, Fluxion will scan for wireless interfaces. In the LabEx virtual environment, there is no physical wireless hardware. Therefore, Fluxion will report that it cannot find any suitable interfaces and will exit. This is expected behavior for this lab.

In a real-world scenario on a machine with a compatible wireless card, you would see a list of interfaces (like wlan0) and proceed to select an attack vector.

For this lab, the goal is simply to see the program run. After Fluxion shows the error about missing wireless adapters and exits, you will be returned to the command prompt inside your tmux session. We will now re-launch it and immediately proceed to the next step to practice detaching while it's "running".

Please run the script again:

sudo ./fluxion.sh

Once you see the language selection menu, you can proceed to the next step. We will leave it running at this menu to simulate a long-running process.

Detach from the session and let the attack run in the background

This is the most critical step. With Fluxion running inside our tmux session, we can now "detach" from the session. This will return you to your main terminal, but the tmux session—and Fluxion inside it—will continue to run in the background.

To detach from the tmux session, press the following key combination: Press Ctrl+b, release the keys, and then press d (for detach).

You will see a message [detached (from session fluxion_session)] and you will be back in your regular shell.

How can you be sure the session is still running? You can list all active tmux sessions with the tmux ls command.

tmux ls

You should see your session listed in the output:

fluxion_session: 1 windows (created ...) [159x41]

This confirms that Fluxion is still running in the background. You could now safely close your SSH connection, and the process would continue.

To get back into the session to check on its status, you "attach" to it using its name.

tmux attach -t fluxion_session

You will be instantly returned to the tmux session, right where you left off, with the Fluxion language menu visible. To finish the lab, you can now press Ctrl+C to exit Fluxion, and then type exit and press Enter to close the tmux session.

Summary

In this lab, you have successfully learned a crucial skill for any remote system administrator or penetration tester: running processes in a headless environment persistently.

You have learned:

  • The concept of a headless environment and why persistent sessions are necessary for long-running tasks.
  • How to simulate a remote connection and navigate the file system.
  • How to use tmux to create a new named session (tmux new -s).
  • How to launch a program like Fluxion from within a tmux session.
  • The key command (Ctrl+b, d) to detach from a tmux session, leaving the process running.
  • How to list active sessions (tmux ls) and re-attach to a running session (tmux attach -t) to resume your work.

This technique is not limited to Fluxion; it can be used for any command-line tool or script that needs to run for an extended period on a remote machine.