Skip to content
KitploitKITPLOIT
도구익스플로잇블로그
Log in
제출
도구익스플로잇블로그
제출

해킹, 침투 테스트 및 사이버 보안 도구를 당신의 보안 무기고에!

Kitploit은 해킹, 사이버 보안 및 침투 테스트 도구 디렉토리입니다. 최신 프로젝트 업데이트를 발견하여 취약점을 찾고, 시스템을 분석하고, 테스트를 자동화하고, 보안을 강화하세요.

피드문의개인정보© 2026 Kitploit

도구 디렉토리

카테고리

모든 카테고리 보기
Loading categories
AppArmor-Simulation-CVE-2021-3156 — TP2 — AppArmor en pratique & simulation de la CVE-2021-3156 (Baron Samedit) sur sudo. Rapport FR avec captures, profil AppArmor et analyse des logs. | Kitploit
도구/GitHubGitHub/hanabouikni/apparmor-simulation-cve-2021-3156
Privilege EscalationVulnerability AnalysisExploitationConfiguration AuditingPapers & ResearchLearning & EducationIncident ResponseLog AnalysisLabs & Practice
GitHubhanabouikni/apparmor-simulation-cve-2021-3156

AppArmor-Simulation-CVE-2021-3156

12026년 11월 14일아직 검토되지 않음
공유

TP2 — AppArmor en pratique & simulation de la CVE-2021-3156 (Baron Samedit) sur sudo. Rapport FR avec captures, profil AppArmor et analyse des logs.

저장소 보기
요청한 언어로 콘텐츠를 사용할 수 없습니다. 영어 버전을 표시합니다.

TP2 — AppArmor in practice & Simulation of CVE-2021-3156 (Baron Samedit)

Operating System Security — CS.ENG.4 — 2025/2026 USTHB — Faculty of Computer Science Student: BOUIKNI Lydia Hana · Supervisor: Pr. Dr. Sofiane HAMRIOUI Session 02 — Saturday, April 11, 2026

⚠️ Disclaimer — All work was carried out on an isolated VMware virtual machine, for strictly educational purposes. Exploiting a vulnerability on a system you do not own is illegal.


Table of contents

  • Objectives
  • Environment
  • Step 1 — AppArmor in practice
    • 1.1 Introduction to AppArmor
    • 1.2 Checking AppArmor
    • 1.3 Creating the test script
    • 1.4 Test without protection
    • 1.5 Creating and applying the profile
    • 1.6 Test with protection (enforce)
    • 1.7 Checking the logs
  • Step 2 — Simulation of CVE-2021-3156
  • Step 3 — Log analysis
  • Answers to the lab questions
  • Conclusion
  • Repository tree

Objectives

  1. Create and test an AppArmor profile to restrict the access of a bash script.
  2. Simulate the CVE-2021-3156 attack (Baron Samedit) on sudo.
  3. Analyze the system logs to detect traces of the attack.

Environment

ItemValue
SystemUbuntu 24.04 LTS (VMware Virtual Platform)
Userhana
Initial (patched) sudo version1.9.15p5
Vulnerable sudo version installed1.8.31

Step 1 — AppArmor in practice

1.1 Introduction to AppArmor

AppArmor (Application Armor) is a Linux kernel security module (LSM — Linux Security Module) that restricts the capabilities of programs through security profiles. Each profile defines, by path, the files a program may access and the permitted operations (read r, write w, execute x, etc.).

Unlike SELinux (which is label-based), AppArmor works by file path (path-based), which makes it simpler to read and maintain.

Two main modes:

ModeBehavior
ComplainThe program runs normally; violations are only logged (useful for building a profile).
EnforceViolations are blocked and logged.

1.2 Checking AppArmor

sudo aa-status

AppArmor status check Figure 1.1 — AppArmor is active: apparmor module is loaded — 163 profiles loaded.

Result — AppArmor is properly loaded and active, with 163 profiles already present (provided by the system packages).

1.3 Creating the test script

A simple bash script attempts to read /etc/shadow, a file containing the hashed passwords of all users (a read normally reserved for root).

#!/bin/bash
cat /etc/shadow

Script contents Figure 1.2 — Contents of mon_script.sh: reading /etc/shadow.

File provided in this repository: scripts/mon_script.sh

1.4 Test without protection

chmod +x /home/hana/mon_script.sh
sudo /home/hana/mon_script.sh

The /etc/shadow file readable without protection Figure 1.3 — Without an AppArmor profile, the full contents of /etc/shadow are displayed.

⚠️ Important — Without protection, the password hashes of all users are exposed. This is precisely the behavior that AppArmor will block.

1.5 Creating and applying the AppArmor profile

The profile is created manually in /etc/apparmor.d/home.hana.mon_script.sh with a deny rule on /etc/shadow:

#include <tunables/global>

/home/hana/mon_script.sh {
  #include <abstractions/base>
  #include <abstractions/bash>

  /home/hana/mon_script.sh r,
  /bin/bash              rix,
  /bin/cat               rix,
  /usr/bin/cat           rix,

  deny /etc/shadow r,
}

File provided in this repository: profiles/home.hana.mon_script.sh

Loading the profile, then switching to enforce mode:

sudo apparmor_parser -r /etc/apparmor.d/home.hana.mon_script.sh
sudo aa-enforce /home/hana/mon_script.sh

Explanation of permissions

RuleMeaning
/home/hana/mon_script.sh r,The script can read itself.
/bin/bash rix,Execution of bash while inheriting the profile (ix = inherit execute).
/bin/cat rix, / /usr/bin/cat rix,cat allowed but confined by the same profile.
deny /etc/shadow r,Explicit prohibition on reading /etc/shadow.

1.6 Test with AppArmor protection (enforce mode)

sudo /home/hana/mon_script.sh

Access denied in enforce mode Figure 1.4 — With the profile in enforce mode: cat: /etc/shadow: Permission non accordée.

✅ Expected result obtained — cat: /etc/shadow: Permission non accordée. AppArmor effectively blocks access to the sensitive file, even via sudo: confinement applies to the program, not just to the user.

1.7 Checking status and logs

sudo aa-status | grep mon_script
sudo journalctl | grep -i "apparmor.*DENIED" | tail -10

AppArmor DENIED logs Figure 1.5 — Violations are logged with the mention apparmor="DENIED".

The logs confirm enforce mode and trace every unauthorized access attempt (operation="...", profile="...", denied_mask="..."), which guarantees complete traceability.

✅ Step 1 summary — The script that could previously read /etc/shadow is now blocked. Every violation is recorded, allowing an administrator to detect abnormal behavior.


Step 2 — Simulating CVE-2021-3156

Overview of the vulnerability

CVE-2021-3156 — Baron Samedit
TypeHeap-based Buffer Overflow
VectorLocal
CVSS score7.8 (High)
Affected versionssudo 1.8.2 → 1.9.5p1
Fixsudo 1.9.5p2 (January 27, 2021)
DiscoveryQualys Research Team, January 2021

CVE-2021-3156 is a heap-based buffer overflow in sudo. When sudo is run in sudoedit mode (sudo -s / sudo -i / sudoedit link), an error in command-line argument handling allows out-of-bounds data to be written to the heap. An unprivileged local user can leverage this for privilege escalation to root, without a password.

Why "Baron Samedit"? A pun on sudoedit and Baron Samedi (a Vodou figure). The flaw remained in the sudo code for nearly 10 years.

Downgrading sudo to the vulnerable version

도구 다운로드

관련 도구

  • PEASS-ng

    PEASS - 권한 상승 멋진 스크립트 스위트 (색상 포함)

  • PrivescCheck

    Windows용 권한 상승 열거 스크립트

  • LinEnum

    스크립트 기반 로컬 Linux 열거 및 권한 상승 점검

인기

모두 보기 →

커뮤니티에서 가장 많이 사용되는 도구를 찾아보세요.

  • 1

    ghostlock-app

    yukonga/ghostlock-app

    # GhostLock 원탭 실행 앱 (CVE-2026-43499)

    745
  • 2

    IMSIcatcher

    28zaaky/imsicatcher

    SMS를 가로채고, 메시지를 주입하며, 모바일 기기를 추적하기 위해 악성 GSM 셀을 배포하는 IMSI Catcher 플랫폼

    732
  • 3

    Callisto

    jetp1ane/callisto

    Ghidra를 통해 실행 파일을 디컴파일하고, Semgrep으로 의사 C 코드를 스캔하며, GPT-3.5-Turbo를 사용하여 결과를 검증해 거짓 양성을 줄이는 자동화된 바이너리 취약점 분석 도구입니다.

    610
  • 4

    opencti

    opencti-platform/opencti

    오픈 사이버 위협 인텔리전스 플랫폼

    546
  • 5

    ARTEX

    baarai/artex

    LLM 멀티 에이전트 자율 침투 테스트 플랫폼으로, 플래너/워커 에이전트, 자산 및 탐색 그래프, MITM 트래픽 기록, 취약점 재테스트 기능을 제공합니다.

    414
  • 6

    DFRoot

    a2333c/dfroot

    삼성 Galaxy S25 Ultra(SM-S938B)용 Android 루트 도구로, DirtyFrag CVE-2026-43284와 CVE-2026-43499를 연쇄하여 KernelSU를 통해 부팅 시 자동으로 루트 권한을 획득합니다.

    413

모든 도구 탐색

도구 컬렉션을 둘러보세요

모든 도구 보기 →