From 21a1db855b569ec2eebfb78d564c543941c58d5e Mon Sep 17 00:00:00 2001 From: Bug Bounty Zip <133497067+BugBountyzip@users.noreply.github.com> Date: Wed, 17 Jan 2024 21:34:30 +0300 Subject: [PATCH 1/4] Create ChatGPT_API_Predictor.bambda Create ChatGPT_API_Predictor.bambda --- Proxy/HTTP/ChatGPT_API_Predictor.bambda | 68 +++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 Proxy/HTTP/ChatGPT_API_Predictor.bambda diff --git a/Proxy/HTTP/ChatGPT_API_Predictor.bambda b/Proxy/HTTP/ChatGPT_API_Predictor.bambda new file mode 100644 index 0000000..66b3fcf --- /dev/null +++ b/Proxy/HTTP/ChatGPT_API_Predictor.bambda @@ -0,0 +1,68 @@ +/** + * Bambda ChatGPT-Enhanced Endpoint Guesser + * Author: Tur24Tur / 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")) { + String requestUrl = requestResponse.request().url().toLowerCase(); + + // Extract the path from the URL + String path = requestUrl.replaceAll("^[^:]+://[^/]+", "").split("\\?", 2)[0]; + + // 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}\""; + + // Write the command to a file + try (BufferedWriter commandWriter = new BufferedWriter(new FileWriter("C:\\Users\\User\\Path\\httpRequest.txt"))) { + commandWriter.write(command); + } + + // Execute the curl command using cmd + ProcessBuilder processBuilder = new ProcessBuilder("cmd", "/c", command); + processBuilder.redirectErrorStream(true); + Process process = processBuilder.start(); + + + + +// 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"); + } +} + +// 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("C:\\Users\\User\\Path\\endpoints.txt"))) { + endpointWriter.write(content); + } + } +} + + // Highlight the request/response in yellow + requestResponse.annotations().setHighlightColor(HighlightColor.YELLOW); + return true; + } + } +} + +return false; From a483318bce868e52d780d76dbc437b9e179f638c Mon Sep 17 00:00:00 2001 From: Bug Bounty Zip <133497067+BugBountyzip@users.noreply.github.com> Date: Wed, 17 Jan 2024 22:23:14 +0300 Subject: [PATCH 2/4] Update ChatGPT_API_Predictor.bambda One suggestion, you can replace the regexes with requestResponse.request().path() or requestResponse.request().pathWithoutQuery() for a slight speed boost --- Proxy/HTTP/ChatGPT_API_Predictor.bambda | 72 +++++++++++++------------ 1 file changed, 39 insertions(+), 33 deletions(-) diff --git a/Proxy/HTTP/ChatGPT_API_Predictor.bambda b/Proxy/HTTP/ChatGPT_API_Predictor.bambda index 66b3fcf..7aea2ae 100644 --- a/Proxy/HTTP/ChatGPT_API_Predictor.bambda +++ b/Proxy/HTTP/ChatGPT_API_Predictor.bambda @@ -1,6 +1,6 @@ /** * Bambda ChatGPT-Enhanced Endpoint Guesser - * Author: Tur24Tur / BugBountyzip (https://github.com/BugBountyzip) + * Author: Tur24Tur & CoreyD97 / BugBountyzip (https://github.com/BugBountyzip) * This script leverages ChatGPT to intelligently guess endpoints. */ @@ -11,52 +11,58 @@ if (requestResponse.request().url() != null && requestResponse.hasResponse()) { String notes = requestResponse.annotations().notes(); if (notes.contains("aaa")) { - String requestUrl = requestResponse.request().url().toLowerCase(); - - // Extract the path from the URL - String path = requestUrl.replaceAll("^[^:]+://[^/]+", "").split("\\?", 2)[0]; + // 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}\""; // Write the command to a file - try (BufferedWriter commandWriter = new BufferedWriter(new FileWriter("C:\\Users\\User\\Path\\httpRequest.txt"))) { + try (BufferedWriter commandWriter = new BufferedWriter(new FileWriter("C:\\Users\\User\\XYZ\\httpRequest.txt"))) { commandWriter.write(command); + } catch (IOException e) { + e.printStackTrace(); } // Execute the curl command using cmd ProcessBuilder processBuilder = new ProcessBuilder("cmd", "/c", command); processBuilder.redirectErrorStream(true); - Process process = processBuilder.start(); - - - + 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"); - } -} + // 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"); + // 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("C:\\Users\\User\\Path\\endpoints.txt"))) { - endpointWriter.write(content); - } - } -} + // Write the endpoints to a file + try (BufferedWriter endpointWriter = new BufferedWriter(new FileWriter("C:\\Users\\User\\XYZ\\endpoints.txt"))) { + endpointWriter.write(content); + } catch (IOException e) { + e.printStackTrace(); + } + } + } // Highlight the request/response in yellow requestResponse.annotations().setHighlightColor(HighlightColor.YELLOW); From 6e7503d8100b422d9d21ba3b41f61dabb9536746 Mon Sep 17 00:00:00 2001 From: Bug Bounty Zip <133497067+BugBountyzip@users.noreply.github.com> Date: Thu, 18 Jan 2024 12:03:57 +0300 Subject: [PATCH 3/4] Update ChatGPT_API_Predictor.bambda Update 2 --- Proxy/HTTP/ChatGPT_API_Predictor.bambda | 32 ++++++++++++++++++------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/Proxy/HTTP/ChatGPT_API_Predictor.bambda b/Proxy/HTTP/ChatGPT_API_Predictor.bambda index 7aea2ae..d727f1a 100644 --- a/Proxy/HTTP/ChatGPT_API_Predictor.bambda +++ b/Proxy/HTTP/ChatGPT_API_Predictor.bambda @@ -1,31 +1,47 @@ /** * Bambda ChatGPT-Enhanced Endpoint Guesser - * Author: Tur24Tur & CoreyD97 / BugBountyzip (https://github.com/BugBountyzip) + * 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 + // Use pathWithoutQuery() to get the path part of the URL without the query string 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("C:\\Users\\User\\XYZ\\httpRequest.txt"))) { + try (BufferedWriter commandWriter = new BufferedWriter(new FileWriter(filePath))) { commandWriter.write(command); } catch (IOException e) { e.printStackTrace(); } - // Execute the curl command using cmd - ProcessBuilder processBuilder = new ProcessBuilder("cmd", "/c", command); + // Execute the curl command using the appropriate shell + ProcessBuilder processBuilder = new ProcessBuilder(commandArray); processBuilder.redirectErrorStream(true); Process process = null; try { @@ -56,7 +72,7 @@ if (requestResponse.request().url() != null && requestResponse.hasResponse()) { String content = jsonResponse.substring(contentStart, contentEnd).replace("\\n", "\n"); // Write the endpoints to a file - try (BufferedWriter endpointWriter = new BufferedWriter(new FileWriter("C:\\Users\\User\\XYZ\\endpoints.txt"))) { + try (BufferedWriter endpointWriter = new BufferedWriter(new FileWriter(endpointsPath))) { endpointWriter.write(content); } catch (IOException e) { e.printStackTrace(); From 5cc9cbaaa51f63d94f9ba025bc3c2e79c3aa0bc6 Mon Sep 17 00:00:00 2001 From: Bug Bounty Zip <133497067+BugBountyzip@users.noreply.github.com> Date: Thu, 18 Jan 2024 12:05:33 +0300 Subject: [PATCH 4/4] Update ChatGPT_API_Predictor.bambda Update --- Proxy/HTTP/ChatGPT_API_Predictor.bambda | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Proxy/HTTP/ChatGPT_API_Predictor.bambda b/Proxy/HTTP/ChatGPT_API_Predictor.bambda index d727f1a..894d0d9 100644 --- a/Proxy/HTTP/ChatGPT_API_Predictor.bambda +++ b/Proxy/HTTP/ChatGPT_API_Predictor.bambda @@ -9,7 +9,7 @@ if (requestResponse.request().url() != null && requestResponse.hasResponse()) { String notes = requestResponse.annotations().notes(); if (notes.contains("aaa")) { - // Use pathWithoutQuery() to get the path part of the URL without the query string + // 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