1
1
mirror of https://github.com/r4sas/PBinCLI synced 2025-01-10 14:58:04 +00:00

implement settings file

This commit is contained in:
R4SAS 2017-03-02 13:09:52 +03:00
parent 320d2824dc
commit 6a6427a134
5 changed files with 32 additions and 10 deletions

View File

@ -13,7 +13,7 @@ $ pip install -r requirements.txt
Usage
-----
Edit `self.server = 'http://paste.r4sas.i2p/'` in `pbincli/transports.py` to your server.
Edit variables `server`, `proxies` and `useproxy` in `pbincli/settings.py` to your values.
Run inside `venv` command:

View File

@ -6,6 +6,7 @@ import argparse
import pbincli.actions
from pbincli.utils import PBinCLIException
def main():
parser = argparse.ArgumentParser()
subparsers = parser.add_subparsers(title="actions", help="List of commands")
@ -54,5 +55,6 @@ def main():
else:
parser.print_help()
if __name__ == "__main__":
main()

View File

@ -1,11 +1,13 @@
import json, hashlib, ntpath, os, sys
import pbincli.actions, pbincli.sjcl_simple
import pbincli.settings
from base64 import b64encode, b64decode
from mimetypes import guess_type
from pbincli.transports import privatebin
from pbincli.utils import PBinCLIException, check_readable, check_writable, json_load_byteified
pbincli.settings.init()
def path_leaf(path):
head, tail = ntpath.split(path)
@ -21,6 +23,9 @@ def send(args):
print("Nothing to send!")
sys.exit(1)
"""Formatting request"""
request = {'expire':args.expire,'formatter':args.format,'burnafterreading':int(args.burn),'opendiscussion':int(args.discus)}
salt = os.urandom(8)
passphrase = b64encode(os.urandom(32))
if args.debug: print("Passphrase:\t{}".format(passphrase))
@ -34,8 +39,9 @@ def send(args):
if args.debug: print("Password:\t{}".format(password))
"""Encrypting text (comment)"""
cipher = pbincli.sjcl_simple.encrypt(password, text, salt)
request = {'data':json.dumps(cipher, ensure_ascii=False).replace(' ',''),'expire':args.expire,'formatter':args.format,'burnafterreading':int(args.burn),'opendiscussion':int(args.discus)}
request['data'] = json.dumps(cipher, ensure_ascii=False).replace(' ','')
"""If we set FILE variable"""
if args.file:
@ -57,7 +63,8 @@ def send(args):
if args.debug: print("Request:\t{}".format(request))
result, server = privatebin().post(request)
server = pbincli.settings.server
result = privatebin().post(request)
if args.debug: print("Response:\t{}\n".format(result.decode("UTF-8")))

13
pbincli/settings.py Normal file
View File

@ -0,0 +1,13 @@
def init():
global server, proxies, useproxy
"""Edit that variables"""
server = "https://privatebin.net/"
proxies = {'http': 'http://127.0.0.1:4444'}
useproxy = False
""" There is nothing more to do :D """
"""if you set useproxy to false, we clean proxies variable"""
if useproxy == False:
proxies = {}

View File

@ -1,16 +1,16 @@
import requests
import pbincli.settings
class privatebin(object):
def __init__(self):
self.proxies = {'http': 'http://127.0.0.1:4444'}
self.server = 'http://paste.r4sas.i2p/'
self.server = pbincli.settings.server
self.proxies = pbincli.settings.proxies
self.headers = {'X-Requested-With': 'JSONHttpRequest'}
def post(self, request):
r = requests.post(url = self.server, headers = self.headers, proxies = self.proxies, data = request)
return r.text, self.server
return r.text
def get(self, request):