diff --git a/java_core/img.png b/java_core/img.png new file mode 100644 index 0000000..928767c Binary files /dev/null and b/java_core/img.png differ diff --git a/java_core/out/artifacts/java_core_jar/java_core.jar b/java_core/out/artifacts/java_core_jar/java_core.jar new file mode 100644 index 0000000..4e3f48d Binary files /dev/null and b/java_core/out/artifacts/java_core_jar/java_core.jar differ diff --git a/java_core/pom.xml b/java_core/pom.xml new file mode 100644 index 0000000..d287194 --- /dev/null +++ b/java_core/pom.xml @@ -0,0 +1,22 @@ + + + 4.0.0 + + org.example + java_core + 1.0-SNAPSHOT + + + org.telegram + telegrambots + 5.0.1 + + + + 17 + 17 + UTF-8 + + \ No newline at end of file diff --git a/java_core/src/main/java/org/example/Main.java b/java_core/src/main/java/org/example/Main.java new file mode 100644 index 0000000..b300dc2 --- /dev/null +++ b/java_core/src/main/java/org/example/Main.java @@ -0,0 +1,139 @@ +package org.example; + +import java.awt.image.BufferedImage; +import java.io.File; +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.util.Random; +import javax.imageio.ImageIO; +import java.io.BufferedReader; + +import java.io.InputStreamReader; +import java.net.HttpURLConnection; +import java.net.URL; + +import com.google.common.hash.Hashing; + +import java.io.*; + +import static org.apache.commons.io.IOUtils.length; + +public class Main{ + static int width = 512; + static int height = 512; + static String[] bot_tokens = new String[]{}; + static String ChatID = "-1001966701084"; + static String post_link = "https://t.me/TheLibraryofBabelImg"; + static String temp_file_path = "img.png"; + + public static void main(String[] args) { + + int current_bot_index = 0; + while (true) { + + int[][] collors = new int[width][height]; + int nohash = 0; + + + Random random = new Random(); + for (int i = 0; i < width; i++) { + for (int j = 0; j < height; j++) { + collors[i][j] = random.nextInt(16777216) + 1; + } + } + BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); + for (int h = 0; h < height; h++) { + for (int w = 0; w < width; w++) { + int color = collors[h][w]; + nohash = nohash + color; + int red = (color / 65536) % 256; + int green = (color / 256) % 256; + int blue = color % 256; + int rgb = (red << 16) | (green << 8) | blue; + image.setRGB(w, h, rgb); + } + } + File outputFile = new File(temp_file_path); + try { + ImageIO.write(image, "png", outputFile); + } catch (IOException e) { + e.printStackTrace(); + } + String current_bot_token = bot_tokens[current_bot_index]; + + String hashed = Hashing.sha256().hashString(String.valueOf(nohash), StandardCharsets.UTF_8).toString(); + System.out.println("hash " + hashed); + + try { + URL url = new URL("https://api.telegram.org/bot" + current_bot_token + "/getChatHistory"); + HttpURLConnection connection = (HttpURLConnection) url.openConnection(); + connection.setRequestMethod("POST"); + connection.setDoOutput(true); + String parameters = "chat_id=" + ChatID + "&text=" + hashed; + byte[] postData = parameters.getBytes("UTF-8"); + connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); + connection.setRequestProperty("Content-Length", String.valueOf(postData.length)); + OutputStream outputStream = connection.getOutputStream(); + outputStream.write(postData); + int responseCode = connection.getResponseCode(); + if (responseCode != 404) { + break; + } + + + } catch (IOException e) { + e.printStackTrace(); + } + + try { + URL url = new URL("https://api.telegram.org/bot" + current_bot_token + "/sendPhoto"); + HttpURLConnection connection = (HttpURLConnection) url.openConnection(); + connection.setRequestMethod("POST"); + connection.setDoOutput(true); + connection.setUseCaches(false); + connection.setChunkedStreamingMode(0); + connection.setRequestProperty("Content-Type", "multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW"); + String boundary = "----WebKitFormBoundary7MA4YWxkTrZu0gW"; + String CRLF = "\r\n"; + String postData = "--" + boundary + CRLF + + "Content-Disposition: form-data; name=\"chat_id\"" + CRLF + CRLF + + ChatID + CRLF + + "--" + boundary + CRLF + + "Content-Disposition: form-data; name=\"photo\"; filename=\"" + temp_file_path + "\"" + CRLF + + "Content-Type: png" + CRLF + CRLF; + OutputStream outputStream = connection.getOutputStream(); + outputStream.write(postData.getBytes()); + File imageFile = new File(temp_file_path); + FileInputStream fileInputStream = new FileInputStream(imageFile); + byte[] buffer = new byte[4096]; + int bytesRead; + while ((bytesRead = fileInputStream.read(buffer)) != -1) { + outputStream.write(buffer, 0, bytesRead); + } + outputStream.write((CRLF + "--" + boundary + CRLF).getBytes()); + outputStream.write(("Content-Disposition: form-data; name=\"caption\"" + CRLF + CRLF + hashed + " " + post_link + CRLF).getBytes()); + outputStream.write((CRLF + "--" + boundary + "--" + CRLF).getBytes()); + outputStream.flush(); + outputStream.close(); + int responseCode = connection.getResponseCode(); + BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream())); + String line; + StringBuilder response = new StringBuilder(); + while ((line = reader.readLine()) != null) { + response.append(line); + } + reader.close(); + connection.disconnect(); + if (responseCode == 200){ + System.out.println("Image sent successfully using Bot " + current_bot_index); + } + current_bot_index = (current_bot_index + 1) % length(bot_tokens); + + } catch (IOException e) { + e.printStackTrace(); + } + + } + } + +} \ No newline at end of file diff --git a/java_core/src/main/resources/META-INF/MANIFEST.MF b/java_core/src/main/resources/META-INF/MANIFEST.MF new file mode 100644 index 0000000..c304d41 --- /dev/null +++ b/java_core/src/main/resources/META-INF/MANIFEST.MF @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +Main-Class: org.example.Main + diff --git a/java_core/target/classes/META-INF/MANIFEST.MF b/java_core/target/classes/META-INF/MANIFEST.MF new file mode 100644 index 0000000..c304d41 --- /dev/null +++ b/java_core/target/classes/META-INF/MANIFEST.MF @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +Main-Class: org.example.Main + diff --git a/java_core/target/classes/org/example/Main.class b/java_core/target/classes/org/example/Main.class new file mode 100644 index 0000000..2556752 Binary files /dev/null and b/java_core/target/classes/org/example/Main.class differ diff --git a/python_core/img.png b/python_core/img.png new file mode 100644 index 0000000..727fadc Binary files /dev/null and b/python_core/img.png differ diff --git a/python_core/main.py b/python_core/main.py new file mode 100644 index 0000000..82d2b5b --- /dev/null +++ b/python_core/main.py @@ -0,0 +1,69 @@ +from PIL import Image +import requests +import time +import random +import hashlib + +bot_tokens = [] + +width, height = 512, 512 +current_bot_index = 0 + +while True: + # Создание двумерного массива + collors = [[0] * width for _ in range(height)] + + # Заполнение массива случайными числами + for i in range(512): + for j in range(512): + collors[i][j] = random.randint(1, 16777216) + nohash = 0 + + image = Image.new('RGB', (width, height)) + + for h in range(512): + for w in range(512): + color = collors[h][w] + R = (color // 65536) % 256 + G = (color // 256) % 256 + B = color % 256 + image.putpixel((w, h), (R, G, B)) + nohash += color + + + temp_file_path = f'img.png' + image.save(temp_file_path) + + current_bot_token = bot_tokens[current_bot_index] + files = {'photo': open(temp_file_path, 'rb')} + ChatID = '-1001966701084' + post_link = f'https://t.me/TheLibraryofBabelImg' + + + hash = hashlib.sha256(str(nohash).encode('utf-8')).hexdigest() + + while True: + url = f'https://api.telegram.org/bot{current_bot_token}/getChatHistory' + params = { + 'chat_id': ChatID, + 'text': hash + } + response = requests.get(url, params=params) + if response.status_code != 404: + break + + url = f'https://api.telegram.org/bot{current_bot_token}/sendPhoto' + with open(f'{temp_file_path}', 'rb') as photo: + # Создаем данные для отправки + data = {'chat_id': ChatID, 'caption': f'{hash} https://t.me/TheLibraryofBabelImg'} + files = {'photo': photo} + # Отправляем запрос с помощью метода POST + response = requests.post(url, data=data, files=files) + if response.status_code == 200: + print(f"Image sent successfully using Bot {current_bot_index+1}") + #time.sleep(0.2) + break # Выход из цикла, если отправка прошла успешно + print(f"Failed to send image: {response.text}") + print("Retrying after 5 seconds...") + time.sleep(5) # Пауза перед повторной попыткой отправки + current_bot_index = (current_bot_index + 1) % len(bot_tokens) \ No newline at end of file