|
|
@ -1,16 +1,12 @@ |
|
|
|
import json, hashlib, ntpath, os, sys, zlib |
|
|
|
import json, hashlib, ntpath, os, sys, zlib |
|
|
|
import pbincli.actions, pbincli.settings |
|
|
|
import pbincli.actions |
|
|
|
from sjcl import SJCL |
|
|
|
from sjcl import SJCL |
|
|
|
|
|
|
|
|
|
|
|
from base64 import b64encode, b64decode |
|
|
|
from base64 import b64encode, b64decode |
|
|
|
from mimetypes import guess_type |
|
|
|
from mimetypes import guess_type |
|
|
|
from pbincli.transports import PrivateBin |
|
|
|
|
|
|
|
from pbincli.utils import PBinCLIException, check_readable, check_writable, json_load_byteified |
|
|
|
from pbincli.utils import PBinCLIException, check_readable, check_writable, json_load_byteified |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Initialise settings |
|
|
|
|
|
|
|
pbincli.settings.init() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def path_leaf(path): |
|
|
|
def path_leaf(path): |
|
|
|
head, tail = ntpath.split(path) |
|
|
|
head, tail = ntpath.split(path) |
|
|
|
return tail or ntpath.basename(head) |
|
|
|
return tail or ntpath.basename(head) |
|
|
@ -25,9 +21,7 @@ def compress(s): |
|
|
|
|
|
|
|
|
|
|
|
return b64encode(''.join(map(chr, b)).encode('utf-8')) |
|
|
|
return b64encode(''.join(map(chr, b)).encode('utf-8')) |
|
|
|
|
|
|
|
|
|
|
|
def send(args): |
|
|
|
def send(args, api_client): |
|
|
|
api = PrivateBin(args.server, args.proxy, args.use-proxy) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if args.stdin: |
|
|
|
if args.stdin: |
|
|
|
text = args.stdin.read() |
|
|
|
text = args.stdin.read() |
|
|
|
elif args.text: |
|
|
|
elif args.text: |
|
|
@ -87,8 +81,7 @@ def send(args): |
|
|
|
# If we use dry option, exit now |
|
|
|
# If we use dry option, exit now |
|
|
|
if args.dry: sys.exit(0) |
|
|
|
if args.dry: sys.exit(0) |
|
|
|
|
|
|
|
|
|
|
|
server = pbincli.settings.server |
|
|
|
result = api_client.post(request) |
|
|
|
result = api.post(request) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if args.debug: print("Response:\t{}\n".format(result)) |
|
|
|
if args.debug: print("Response:\t{}\n".format(result)) |
|
|
|
|
|
|
|
|
|
|
@ -99,7 +92,7 @@ def send(args): |
|
|
|
sys.exit(1) |
|
|
|
sys.exit(1) |
|
|
|
|
|
|
|
|
|
|
|
if 'status' in result and not result['status']: |
|
|
|
if 'status' in result and not result['status']: |
|
|
|
print("Paste uploaded!\nPasteID:\t{}\nPassword:\t{}\nDelete token:\t{}\n\nLink:\t\t{}?{}#{}".format(result['id'], passphrase.decode(), result['deletetoken'], server, result['id'], passphrase.decode())) |
|
|
|
print("Paste uploaded!\nPasteID:\t{}\nPassword:\t{}\nDelete token:\t{}\n\nLink:\t\t{}?{}#{}".format(result['id'], passphrase.decode(), result['deletetoken'], api_client.server, result['id'], passphrase.decode())) |
|
|
|
elif 'status' in result and result['status']: |
|
|
|
elif 'status' in result and result['status']: |
|
|
|
print("Something went wrong...\nError:\t\t{}".format(result['message'])) |
|
|
|
print("Something went wrong...\nError:\t\t{}".format(result['message'])) |
|
|
|
sys.exit(1) |
|
|
|
sys.exit(1) |
|
|
@ -108,9 +101,7 @@ def send(args): |
|
|
|
sys.exit(1) |
|
|
|
sys.exit(1) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get(args): |
|
|
|
def get(args, api_client): |
|
|
|
api = PrivateBin(args.server, args.proxy, args.use-proxy) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pasteid, passphrase = args.pasteinfo.split("#") |
|
|
|
pasteid, passphrase = args.pasteinfo.split("#") |
|
|
|
|
|
|
|
|
|
|
|
if pasteid and passphrase: |
|
|
|
if pasteid and passphrase: |
|
|
@ -124,7 +115,7 @@ def get(args): |
|
|
|
|
|
|
|
|
|
|
|
if args.debug: print("Password:\t{}".format(password)) |
|
|
|
if args.debug: print("Password:\t{}".format(password)) |
|
|
|
|
|
|
|
|
|
|
|
result = api.get(pasteid) |
|
|
|
result = api_client.get(pasteid) |
|
|
|
else: |
|
|
|
else: |
|
|
|
print("PBinCLI error: Incorrect request") |
|
|
|
print("PBinCLI error: Incorrect request") |
|
|
|
sys.exit(1) |
|
|
|
sys.exit(1) |
|
|
@ -175,7 +166,7 @@ def get(args): |
|
|
|
|
|
|
|
|
|
|
|
if 'burnafterreading' in result['meta'] and result['meta']['burnafterreading']: |
|
|
|
if 'burnafterreading' in result['meta'] and result['meta']['burnafterreading']: |
|
|
|
print("Burn afrer reading flag found. Deleting paste...") |
|
|
|
print("Burn afrer reading flag found. Deleting paste...") |
|
|
|
result = api.delete(pasteid, 'burnafterreading') |
|
|
|
result = api_client.delete(pasteid, 'burnafterreading') |
|
|
|
|
|
|
|
|
|
|
|
if args.debug: print("Delete response:\t{}\n".format(result)) |
|
|
|
if args.debug: print("Delete response:\t{}\n".format(result)) |
|
|
|
|
|
|
|
|
|
|
@ -202,15 +193,13 @@ def get(args): |
|
|
|
sys.exit(1) |
|
|
|
sys.exit(1) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def delete(args): |
|
|
|
def delete(args, api_client): |
|
|
|
api = PrivateBin(args.server, args.proxy, args.use-proxy) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pasteid = args.paste |
|
|
|
pasteid = args.paste |
|
|
|
token = args.token |
|
|
|
token = args.token |
|
|
|
|
|
|
|
|
|
|
|
if args.debug: print("PasteID:\t{}\nToken:\t\t{}".format(pasteid, token)) |
|
|
|
if args.debug: print("PasteID:\t{}\nToken:\t\t{}".format(pasteid, token)) |
|
|
|
|
|
|
|
|
|
|
|
result = api.delete(pasteid, token) |
|
|
|
result = api_client.delete(pasteid, token) |
|
|
|
|
|
|
|
|
|
|
|
if args.debug: print("Response:\t{}\n".format(result)) |
|
|
|
if args.debug: print("Response:\t{}\n".format(result)) |
|
|
|
|
|
|
|
|
|
|
|