Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create ChatGPT_API_Predictor.bambda #54

Closed
wants to merge 4 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 90 additions & 0 deletions Proxy/HTTP/ChatGPT_API_Predictor.bambda
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
/**
* Bambda ChatGPT-Enhanced Endpoint Guesser
* Author: Tur24Tur & CoreyD97 & JaveleyQAQ / BugBountyzip (https://github.com/BugBountyzip)
* This script leverages ChatGPT to intelligently guess endpoints.
*/
// Main logic of the Bambda
if (requestResponse.request().url() != null && requestResponse.hasResponse()) {
if (requestResponse.annotations().hasNotes()) {
String notes = requestResponse.annotations().notes();

if (notes.contains("aaa")) {
// Use pathWithoutQuery() to get the path part of the URL without the query string By CoreyD97
String path = requestResponse.request().pathWithoutQuery();

// Construct the curl command with headers
String command = "curl https://api.openai.com/v1/chat/completions -H \"Content-Type: application/json\" -H \"Authorization: Bearer XYZ\" -d \"{\\\"model\\\": \\\"gpt-3.5-turbo\\\", \\\"messages\\\": [{\\\"role\\\": \\\"user\\\", \\\"content\\\": \\\"Based on the specified path in an HTTP request, please guess 50 potential endpoints. " + path + "\\\"}], \\\"temperature\\\": 0.7}\"";

// Determine the operating system By JaveleyQAQ
String os = System.getProperty("os.name").toLowerCase();
String[] commandArray;
String filePath;
String endpointsPath;

if (os.contains("win")) {
// Windows command and paths
commandArray = new String[]{"cmd", "/c", command};
filePath = "C:\\Users\\User\\Path\\httpRequest.txt"; // Corrected path
endpointsPath = "C:\\Users\\User\\Path\\endpoints.txt"; // Corrected path
} else {
// Unix/Linux/macOS command and paths
commandArray = new String[]{"/bin/bash", "-c", command};
filePath = "/home/kali/Desktop/httpRequest.txt"; // Path for Linux/macOS
endpointsPath = "/home/kali/Desktop/endpoints.txt"; // Path for Linux/macOS
}

// Write the command to a file
try (BufferedWriter commandWriter = new BufferedWriter(new FileWriter(filePath))) {
commandWriter.write(command);
} catch (IOException e) {
e.printStackTrace();
}

// Execute the curl command using the appropriate shell
ProcessBuilder processBuilder = new ProcessBuilder(commandArray);
processBuilder.redirectErrorStream(true);
Process process = null;
try {
process = processBuilder.start();
} catch (IOException e) {
e.printStackTrace();
}

// Read the output from the command
StringBuilder output = new StringBuilder();
try (BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()))) {
String line;
while ((line = reader.readLine()) != null) {
output.append(line).append("\n");
}
} catch (IOException e) {
e.printStackTrace();
}

// Extract the JSON part of the response
String jsonResponse = output.toString();
String contentMarker = "\"content\": \"";
int contentStart = jsonResponse.indexOf(contentMarker);
if (contentStart != -1) {
contentStart += contentMarker.length();
int contentEnd = jsonResponse.indexOf("\"", contentStart);
if (contentEnd != -1) {
String content = jsonResponse.substring(contentStart, contentEnd).replace("\\n", "\n");

// Write the endpoints to a file
try (BufferedWriter endpointWriter = new BufferedWriter(new FileWriter(endpointsPath))) {
endpointWriter.write(content);
} catch (IOException e) {
e.printStackTrace();
}
}
}

// Highlight the request/response in yellow
requestResponse.annotations().setHighlightColor(HighlightColor.YELLOW);
return true;
}
}
}

return false;
Loading