mirror of
https://github.com/r4sas/PBinCLI
synced 2025-01-11 07:17:52 +00:00
update for testing purposes
This commit is contained in:
parent
6274f8016a
commit
e7f3610fdb
@ -6,7 +6,12 @@ PrivateBin CLI (in development)
|
|||||||
Installing
|
Installing
|
||||||
-----
|
-----
|
||||||
```bash
|
```bash
|
||||||
$ virtualenv --python=python3 venv
|
$ virtualenv --python=python2.7 venv
|
||||||
$ . venv/bin/activate
|
$ . venv/bin/activate
|
||||||
$ pip install -r requirements.txt
|
$ pip install -r requirements.txt
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Using
|
||||||
|
-----
|
||||||
|
Edit `self.server = 'http://paste.r4sas.i2p/'` in `pbincli/transports.py` to your server.
|
||||||
|
Run inside `venv` command `python pbincli.py send`. It will send string `Test!` to PrivateBin.
|
||||||
|
@ -20,7 +20,7 @@ def main():
|
|||||||
send_parser.add_argument("-e", "--expire", default="1day", action="store", help="expiration of paste (default: 1day)")
|
send_parser.add_argument("-e", "--expire", default="1day", action="store", help="expiration of paste (default: 1day)")
|
||||||
send_parser.add_argument("-f", "--format", default="plaintext", action="store", help="format of paste (default: plaintext)")
|
send_parser.add_argument("-f", "--format", default="plaintext", action="store", help="format of paste (default: plaintext)")
|
||||||
send_parser.add_argument("-p", "--password", help="password for crypting paste")
|
send_parser.add_argument("-p", "--password", help="password for crypting paste")
|
||||||
send_parser.add_argument("filename", help="filename (example: image.jpg)")
|
#send_parser.add_argument("filename", help="filename (example: image.jpg)")
|
||||||
send_parser.set_defaults(func=pbincli.actions.send)
|
send_parser.set_defaults(func=pbincli.actions.send)
|
||||||
|
|
||||||
# parse arguments
|
# parse arguments
|
||||||
|
@ -12,24 +12,28 @@ from zlib import compress
|
|||||||
|
|
||||||
def send(args):
|
def send(args):
|
||||||
""" Sub-command for sending paste """
|
""" Sub-command for sending paste """
|
||||||
check_readable(args.filename)
|
#check_readable(args.filename)
|
||||||
with open(args.filename, "rb") as f:
|
#with open(args.filename, "rb") as f:
|
||||||
contents = f.read()
|
# contents = f.read()
|
||||||
file = b64encode(compress(contents))
|
#file = b64encode(compress(contents))
|
||||||
|
|
||||||
|
data = b'Test!'
|
||||||
|
|
||||||
passphrase = os.urandom(32)
|
passphrase = os.urandom(32)
|
||||||
print("Passphrase: {}".format(passphrase))
|
#print("Passphrase: {}".format(passphrase))
|
||||||
if args.password:
|
if args.password:
|
||||||
|
#print("Password: {}".format(password))
|
||||||
p = SHA256.new()
|
p = SHA256.new()
|
||||||
p.update(args.password.encode("UTF-8"))
|
p.update(args.password.encode("UTF-8"))
|
||||||
passphrase = passphrase + p.hexdigest().encode("UTF-8")
|
passphrase = passphrase + p.hexdigest().encode("UTF-8")
|
||||||
print("Password: {}".format(password))
|
|
||||||
print(args.password)
|
|
||||||
|
|
||||||
'''data = SJCL().encrypt(file, password.decode("UTF-8"))'''
|
|
||||||
data = pbincli.sjcl_simple.encrypt(password, file)
|
#data = SJCL().encrypt(file, password.decode("UTF-8"))
|
||||||
request = {'data':json.dumps(data, ensure_ascii=False),'expire':args.expire,'formatter':args.format,'burnafterreading':int(args.burn),'opendiscussion':int(args.discus)
|
"""Sending text from 'data' string"""
|
||||||
|
#cipher = pbincli.sjcl_simple.encrypt(b64encode(passphrase), file)
|
||||||
|
cipher = pbincli.sjcl_simple.encrypt(b64encode(passphrase), data)
|
||||||
|
request = {'data':json.dumps(cipher, ensure_ascii=False),'expire':args.expire,'formatter':args.format,'burnafterreading':int(args.burn),'opendiscussion':int(args.discus)
|
||||||
}
|
}
|
||||||
print(request)
|
print(request)
|
||||||
'''Here we must run function post from pbincli.transports'''
|
'''Here we run function post from pbincli.transports'''
|
||||||
privatebin().post(request, passphrase)
|
privatebin().post(request, b64encode(passphrase))
|
||||||
|
@ -35,7 +35,7 @@ def decrypt(pwd, json):
|
|||||||
|
|
||||||
|
|
||||||
def encrypt(pwd, plaintext, mode='gcm', algorithm='aes',
|
def encrypt(pwd, plaintext, mode='gcm', algorithm='aes',
|
||||||
keysize=256, tagsize=128, iters=256000):
|
keysize=256, tagsize=128, iters=10000):
|
||||||
ts = tagsize / 8
|
ts = tagsize / 8
|
||||||
|
|
||||||
mode_class = getattr(modes, mode.upper())
|
mode_class = getattr(modes, mode.upper())
|
||||||
@ -68,7 +68,6 @@ def encrypt(pwd, plaintext, mode='gcm', algorithm='aes',
|
|||||||
|
|
||||||
def _kdf(keysize=256, iters=256000, salt=None, **kwargs):
|
def _kdf(keysize=256, iters=256000, salt=None, **kwargs):
|
||||||
kdf_salt = salt or os.urandom(8)
|
kdf_salt = salt or os.urandom(8)
|
||||||
print("Salt: {}".format(kdf_salt))
|
|
||||||
kdf = PBKDF2HMAC(algorithm=hashes.SHA256(),
|
kdf = PBKDF2HMAC(algorithm=hashes.SHA256(),
|
||||||
length=keysize / 8,
|
length=keysize / 8,
|
||||||
salt=kdf_salt,
|
salt=kdf_salt,
|
||||||
|
@ -5,14 +5,15 @@ from pprint import pprint
|
|||||||
class privatebin(object):
|
class privatebin(object):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.proxies = {'http': 'http://127.0.0.1:4444'}
|
#self.proxies = {'http': 'http://127.0.0.1:4444'}
|
||||||
self.server = 'http://paste.r4sas.i2p/'
|
self.server = 'http://paste.r4sas.i2p/'
|
||||||
self.headers = {'X-Requested-With': 'JSONHttpRequest'}
|
self.headers = {'X-Requested-With': 'JSONHttpRequest'}
|
||||||
|
|
||||||
def post(self, data, password):
|
def post(self, data, password):
|
||||||
r = requests.post(url=self.server, headers=self.headers, proxies=self.proxies, data=data)
|
#r = requests.post(url=self.server, headers=self.headers, proxies=self.proxies, data=data)
|
||||||
|
r = requests.post(url=self.server, headers=self.headers, data=data)
|
||||||
print(r.text)
|
print(r.text)
|
||||||
result = json.loads(r.text)
|
result = json.loads(r.text)
|
||||||
'''{"status":0,"id":"aaabbb","url":"\/?aaabbb","deletetoken":"aaabbbccc"}'''
|
'''Standart response: {"status":0,"id":"aaabbb","url":"\/?aaabbb","deletetoken":"aaabbbccc"}'''
|
||||||
if result['status'] == 0:
|
if result['status'] == 0:
|
||||||
print("Paste uploaded!\nPasteID:\t{}\nPassword:\t{}\nDelete token:\t{}\n".format(result['id'], password.decode("UTF-8"), result['deletetoken']))
|
print("Paste uploaded!\nPasteID:\t{}\nPassword:\t{}\nDelete token:\t{}\n".format(result['id'], password.decode("UTF-8"), result['deletetoken']))
|
||||||
|
Loading…
Reference in New Issue
Block a user