Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- # Filename: is_dirty_pipe.py
- # Version: 1.00
- # Author: Jeoi Reqi
- """
- This script checks if the system is vulnerable to the Dirty Pipe exploit (CVE-2022-0847).
- It attempts to exploit the vulnerability by writing one byte to a specified file at offset 1.
- If the write operation fails due to a permission error, the system is considered vulnerable.
- Otherwise, it is assumed to be not vulnerable.
- Requirements:
- - Python 3.x
- - Linux (as the Dirty Pipe exploit specifically targets the Linux kernel)
- Functions:
- is_vulnerable(path):
- Check if the system is vulnerable to the Dirty Pipe exploit by attempting
- to write one byte to the specified file at offset 1.
- main():
- The main function of the script. Calls is_vulnerable function and prints
- the vulnerability status.
- Usage:
- To use this script, simply run it from the command line:
- $ python is_dirty_pipe.py
- Additional Notes:
- - This script does not actually exploit the vulnerability but rather tests
- for its presence by attempting to perform a write operation.
- - It assumes that a permission error indicates vulnerability to the Dirty Pipe exploit.
- - It is important to run this script with appropriate permissions, as it attempts to
- write to a file which might require elevated privileges.
- """
- # Obscure the Linux-specific file path
- Is_ = "/et"
- dirt = "c/sha"
- y_Pi = "d"
- pe = "ow"
- FILE_PATH = (
- Is_ + dirt + y_Pi + pe
- ) # Obscured Linux user login password hashes are stored here.
- def is_vulnerable(path):
- """
- Check if the system is vulnerable to the Dirty Pipe exploit.
- This function attempts to write one byte to the specified file at offset 1.
- If the write operation fails due to a permission error, the system is considered vulnerable.
- Otherwise, it is assumed to be not vulnerable.
- Args:
- path (str): The path to the file to be checked for vulnerability.
- Returns:
- bool: True if the system is vulnerable, False otherwise.
- """
- try:
- # Open the file in read-only mode
- with open(path, "rb") as f:
- # Attempt to write one byte at offset 1
- f.seek(1)
- f.write(b"\x00")
- return False # If write succeeds, the system is not vulnerable
- except PermissionError:
- return True # If write fails due to permission error, system is vulnerable
- except Exception as e:
- print(f"Error occurred:\n - {e} -\n\t Are you running a Linux machine?\n")
- return False # If any other error occurs, assume system is not vulnerable
- def main():
- """
- The main function of the script.
- Calls is_vulnerable function and prints the vulnerability status.
- """
- if is_vulnerable(FILE_PATH):
- print("System is vulnerable to Dirty Pipe exploit (CVE-2022-0847)")
- else:
- print("System is not vulnerable to Dirty Pipe exploit (CVE-2022-0847)")
- if __name__ == "__main__":
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement