Initial state of mpaste, tool to paste to multiple pastebin at once.

This commit is contained in:
kalzu rekku 2024-07-26 17:33:17 +03:00
commit d0e5e7b679
2 changed files with 58 additions and 0 deletions

57
mpaste.py Normal file
View File

@ -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}")

1
test.txt Normal file
View File

@ -0,0 +1 @@
This is a test file.