Skip to content

anvilsecure/SAPCARve

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SAPCARve

A basic Python utility tool to manipulate SAP's SAR archive. It was developed when I found and exploited CVE-2024-47595.

Content of the repository:

Installation (requires python3-dev and build-essential to compile pysapcompress):

$ python3 setup.py develop --user

Examples

List the content of a SAR archive (default action is to list):

$ python3 SAPCARve.py ./tests/simple_test.sar
SAR archive version: 2.01
Number of files: 2
        0: -rwxrwxrwx 7         foobar.txt
        1: -rwxrwxrwx 14        hello_world.txt

Extracting the content of the first file and printing it to the console:

$ python3 SAPCARve.py ./tests/simple_test.sar extract 0
b'foobar\n'

Extracting the second file and storing it in 'extracted.txt':

$ python3 SAPCARve.py ./tests/simple_test.sar extract 1 extracted.txt
$ cat extracted.txt
Hello, World!

Renaming the file 'hello_world.txt' to 'new_name.txt' inside the archive:

$ python3 SAPCARve.py ./tests/simple_test.sar rename 1 new_name.txt
SAR archive version: 2.01
Number of files: 2
        0: -rwxrwxrwx 7         foobar.txt
        1: -rwxrwxrwx 14        new_name.txt

Swapping blocks inside the archive:

$ python3 SAPCARve.py ./tests/simple_test.sar swap 0 1
SAR archive version: 2.01
Number of files: 2
        0: -rwxrwxrwx 14        hello_world.txt
        1: -rwxrwxrwx 7         foobar.txt

Adding the file 'sar.ksy' to the archive:

$ python3 SAPCARve.py ./tests/simple_test.sar add file sar.ksy
SAR archive version: 2.01
Number of files: 3
        0: -rwxrwxrwx 7         foobar.txt
        1: -rwxrwxrwx 14        hello_world.txt
        2: -rwxrwxrwx 2139      sar.ksy

Usage

$ python3 SAPCARve.py -h
usage: SAPCARve.py [-h] sar {list,extract,add,delete,swap,rename,chmod,merge} ...

SAPCAR manipulation tool

positional arguments:
  sar                   Path to the .sar (or .car) archive
  {list,extract,add,delete,swap,rename,chmod,merge}
    list                List content of the archive
    extract             Extract a file from the archive
    add                 Add a file/symlink/directory to the archive (file, sym, dir respectively)
    delete              Delete a block inside the archive
    swap                Swap two blocks inside the archive
    rename              Rename a file inside the archive
    chmod               Change the permission of a file inside the archive
    merge               Merge two SAR archives by appending blocks from one to the other

options:
  -h, --help            show this help message and exit

About

Utility Python script for manipulating SAP's SAR archive files.

Resources

Stars

Watchers

Forks

Packages

No packages published