commit d0e5e7b679536b399ba1d1d2a0d76cf2dcc38723 Author: kalzu rekku Date: Fri Jul 26 17:33:17 2024 +0300 Initial state of mpaste, tool to paste to multiple pastebin at once. diff --git a/mpaste.py b/mpaste.py new file mode 100644 index 0000000..5823c70 --- /dev/null +++ b/mpaste.py @@ -0,0 +1,57 @@ +import requests +import json +import socket + +def publish_to_mozilla(content): + url = 'https://pastebin.mozilla.org/api/' + data = { + 'content': content, + 'expires': '86400', # 24 hours + 'format': 'text', + 'lexer': '_text' + } + response = requests.post(url, data=data) + if response.status_code == 200: + return f"https://pastebin.mozilla.org/{response.text}" + return None + +def publish_to_termbin(content): + host = 'termbin.com' + port = 9999 + try: + sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + sock.connect((host, port)) + sock.sendall(content.encode('utf-8')) + response = sock.recv(1024).decode('utf-8').strip() + sock.close() + return response + except Exception as e: + print(f"Error connecting to Termbin: {e}") + return None + +def publish_to_multiple_pastebins(file_path): + # Read the file content + with open(file_path, 'r') as file: + file_content = file.read() + + results = {} + + # Publish to Mozilla Pastebin + mozilla_url = publish_to_mozilla(file_content) + if mozilla_url: + results['Mozilla Pastebin'] = mozilla_url + + # Publish to Termbin + termbin_url = publish_to_termbin(file_content) + if termbin_url: + results['Termbin'] = termbin_url + + return results + +# Example usage +file_path = 'test.txt' + +results = publish_to_multiple_pastebins(file_path) + +for service, url in results.items(): + print(f"{service}: {url}") diff --git a/test.txt b/test.txt new file mode 100644 index 0000000..6de7b8c --- /dev/null +++ b/test.txt @@ -0,0 +1 @@ +This is a test file.