Git Product home page Git Product logo

linooxmalware's Introduction

WTF

A sample of hiding a payload in UEFI vars that persists in initramfs and then injects into auditd to make malicious processes invisible.

How to Play

  1. on attacker machine

    1. make
    2. copy splat to target
  2. on target

    1. run splat as root
    2. reboot target
    3. use timerslack.pl to set your timerslack and become invisible to auditd

Moving Parts

ORDER/order.h - ORDER for hooks

ORDER is a file in initramfs that specifies order of hooks, but in this case, runs stage1

splat - Infection Utility

Run to infect system. Everything needed for infection is included:

  • stage1
  • stage2
    • payload

injected.so - Injected Dyanmic Library Payload to auditd

Clobbers the fprintf symbol and keeps your tagged processes out of the audit log.

payload.asm - Shellcode Injected into auditd

  1. Fixup registers due to internal libc dlopen required 16byte aligned stack entry.
  2. call glibc's __libc_dlopen_mode
  3. jmp back to return value

stage2d - Daemon Spawned in initramfs

The executable stage2.

  1. survive MS_MOVE in initramfs
  2. fanotify on systemd-sysctl
  3. ptrace inject into autid
  4. host injected.so in memfd
  5. coerce auditd to dlopen() injected.so in memfd
  6. exit

stage1

Takes stage2 out of UEFI var, uncompresses, jams it into memfd, and execs stage2

stage2

Gzipped stage2d executable

loader.c - Loader Contained in Stage2d to Inject into auditd

This code uses code adapted from https://github.com/eklitzke/ptrace-call-userspace, a fantastic bit of code from Evan Klitzke used under the ISC license.

  1. ptrace auditd
  2. coerce auitd to call memfd_create
  3. find __libc_dlopen_mode
  4. write injected.so into auditd's memfd
  5. coerce auditd to call mmap
  6. write payload into page returned from mmap
  7. set rip to point to shellcode
  8. release process

libptrace_do.[ch]

Fantastic lib from @emptymonkey. https://github.com/emptymonkey/ptrace_do

Used under terms in MIT license

busybox.h - a Literal Copy of Static busybox

Used in debugging to get a shell in the initramfs. You will need to have installed busyboxy-static package. Enable by defining EMBED_SHELL to 1 and get a local bind shell on port 1111. Note that it will no longer fit into a UEFI variable because busyboxy is gigantic. Use make install and debug_utils/install.sh infect.

z.[ch] - Simple Wrapper Around zlib

Just a simple convenience function around zlib

timerslack.pl - Perl Script to Set Your timerslack

Simple wrapper around the prtcl(PR_SET_TIMERSLACK). Scoff all you want, but chances are, perl is there when you land.

Get an operator friendly version like so:

echo "use the following:"
echo -n "echo '"
cat timerslack.pl|tr -d '\n'
echo "'|perl"

Which produces:

use the following:
echo 'require("syscall.ph");syscall(&SYS_prctl,29,50001);exec("/bin/bash");'|perl

linooxmalware's People

Contributors

r00tkillah avatar tophertimzen 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.