forked from r4sas/PBinCLI
R4SAS
8 years ago
3 changed files with 26 additions and 12 deletions
@ -1,7 +1,27 @@ |
|||||||
"""Action functions for argparser""" |
"""Action functions for argparser""" |
||||||
import pbincli.sjcl_gcm |
import base64 |
||||||
import pbincli.actions |
import pbincli.actions |
||||||
|
from Crypto.Hash import SHA256 |
||||||
|
from Crypto.Random import get_random_bytes |
||||||
|
from pbincli.sjcl_gcm import SJCL |
||||||
from pbincli.utils import PBinCLIException, check_readable, check_writable |
from pbincli.utils import PBinCLIException, check_readable, check_writable |
||||||
|
from zlib import compress |
||||||
|
|
||||||
def send(args): |
def send(args): |
||||||
print("Meow!") |
""" Sub-command for sending paste """ |
||||||
|
check_readable(args.filename) |
||||||
|
with open(args.filename, "rb") as f: |
||||||
|
contents = f.read() |
||||||
|
file = base64.b64encode(compress(contents)) |
||||||
|
|
||||||
|
passphrase = base64.b64encode(get_random_bytes(32)) |
||||||
|
if not args.password: |
||||||
|
password = passphrase |
||||||
|
else: |
||||||
|
p = SHA256.new() |
||||||
|
p.update(args.password.encode("UTF-8")) |
||||||
|
password = passphrase + p.hexdigest().encode("UTF-8") |
||||||
|
|
||||||
|
data = SJCL().encrypt(file, password) |
||||||
|
'''Here we must run function post from pbincli.transports''' |
||||||
|
print(data) |
||||||
|
Loading…
Reference in new issue