-
Notifications
You must be signed in to change notification settings - Fork 420
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
265 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
model/src/test/java/com/test/vendor/postgres/PostgresExploitRceSuiteIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package com.test.vendor.postgres; | ||
|
||
import com.jsql.model.InjectionModel; | ||
import com.jsql.model.accessible.ExploitMethod; | ||
import com.jsql.model.exception.JSqlException; | ||
import com.jsql.view.terminal.SystemOutTerminal; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junitpioneer.jupiter.RetryingTest; | ||
|
||
import java.util.UUID; | ||
|
||
public class PostgresExploitRceSuiteIT extends ConcretePostgresSuiteIT { | ||
|
||
@Override | ||
public void setupInjection() throws Exception { | ||
InjectionModel model = new InjectionModel(); | ||
this.injectionModel = model; | ||
|
||
model.subscribe(new SystemOutTerminal()); | ||
|
||
model.getMediatorUtils().getParameterUtil().initQueryString( | ||
"http://jsql-lamp:8079/php/get-pg.php?id=" | ||
); | ||
|
||
model | ||
.getMediatorUtils() | ||
.getPreferencesUtil() | ||
.withIsStrategyBlindDisabled(true) | ||
.withIsStrategyTimeDisabled(true); | ||
|
||
model | ||
.getMediatorUtils() | ||
.getConnectionUtil() | ||
.withMethodInjection(model.getMediatorMethod().getQuery()) | ||
.withTypeRequest("GET"); | ||
|
||
model.beginInjection(); | ||
} | ||
|
||
@RetryingTest(3) | ||
public void exploitUdfAuto() throws JSqlException { | ||
this.injectionModel.getUdfAccess().createExploitRcePostgres(ExploitMethod.AUTO); | ||
String resultCommand = this.injectionModel.getUdfAccess().runCommandRcePostgres("uname", UUID.randomUUID()); | ||
LOGGER.info("rce: found {}, to find {}", resultCommand.trim(), "Linux"); | ||
Assertions.assertTrue(resultCommand.trim().contains("Linux")); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,9 @@ | ||
<?php | ||
ini_set('display_errors', 1); | ||
$db = new PDO("pgsql:host=localhost;port=5432;dbname=test", 'postgres', 'my-secret-pw'); | ||
foreach($db->query("SELECT '1' FROM (select 1)x where '1'={$_GET['id']}") as $row) { | ||
echo "<li>" . join(',', $row) . "</li>"; | ||
$array = explode(";", "SELECT '1' FROM (select 1)x where '1'={$_GET['id']}"); | ||
foreach ($array as $item) { | ||
foreach($db->query($item) as $row) { | ||
echo "<li>" . join(',', $row) . "</li>"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
view/src/main/java/com/jsql/view/swing/interaction/AddTabExploitRcePostgres.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/******************************************************************************* | ||
* Copyhacked (H) 2012-2025. | ||
* This program and the accompanying materials | ||
* are made available under no term at all, use it like | ||
* you want, but share and discuss it | ||
* every time possible with every body. | ||
* | ||
* Contributors: | ||
* ron190 at ymail dot com - initial implementation | ||
******************************************************************************/ | ||
package com.jsql.view.swing.interaction; | ||
|
||
import com.jsql.view.interaction.InteractionCommand; | ||
import com.jsql.view.swing.util.MediatorHelper; | ||
|
||
import javax.swing.*; | ||
|
||
/** | ||
* Create a new tab for the terminal. | ||
*/ | ||
public class AddTabExploitRcePostgres extends CreateTabHelper implements InteractionCommand { | ||
|
||
/** | ||
* @param interactionParams The local path and url for the shell | ||
*/ | ||
public AddTabExploitRcePostgres(Object[] interactionParams) { | ||
// nothing | ||
} | ||
|
||
@Override | ||
public void execute() { | ||
SwingUtilities.invokeLater(() -> MediatorHelper.tabResults().addTabExploitRcePostgres()); | ||
} | ||
} |
Oops, something went wrong.