Commit 3d82bf85 authored by setop's avatar setop 🚀
Browse files

experiment with stdin/stdout, no ciphering, no b64 overhead

parent 9a87d877
......@@ -83,4 +83,7 @@ curl -s -S 'https://framadrop.org/d/<shortid>/<token>' | html2text
# Limitation
**pylufic** handles only one file at a time ; no multi-files upload or download.
**pylufic** handles only one file at a time ; no multi-files upload or download.
There is a special version of the program provided - pylufic_nocrypt - which has some features incompatible with the official version : no ciphring, no base64 overhead, work with stdin/stdout.
Use at your own risk.
pylufic
upload 75'264 32.00% 10.18
download 41'844 65.00% 8.41
payload 11'481'436
pylufic_nob64
upload 56'204 29.00% 8.67
download 35'600 47.00% 7.63
payload 8'611'264
upload 74.68% 90.63% 85.17%
download 85.08% 72.31% 90.73%
payload 75.00%
#!/usr/bin/env python3
import sys
import baker
from websocket import create_connection
from json import loads, dumps
from base64 import b64decode, b64encode
MAGIC = "XXMOJOXX"
CHUNK_SIZE = 2*1000*1000
def _send_chunk(ws, shortid, part, total, data):
meta = {
"id": shortid,
"name": "stdin",
"i": 0,
"part": part,
"total": total,
}
ws.send(dumps(meta)+MAGIC+b64encode(data).decode("ascii"))
result = ws.recv()
print(result, file=sys.stderr)
result = loads(result)
return (result["short"], result["token"])
@baker.command(
params={
"filepath": "path to local file to encrypt and upload",
"url": "URL of the Lufi service, eg: https://framadrop.org/",
"delay": "delay after which file is deleted on server, in days",
"del_at_first_view": "delete file after first successful download", })
def upload(url, delay=None, del_at_first_view=False):
wsurl = url.replace("http", "ws")+"upload/"
ws = create_connection(wsurl)
shortid = None
for (i, data) in enumerate(iter(lambda: sys.stdin.buffer.read(CHUNK_SIZE), b"")):
(shortid, _) = _send_chunk(ws, shortid, i, i+1, data)
(shortid, token) = _send_chunk(ws, shortid, i+1, i+1, b"")
ws.close()
print("download_url "+url+"r/"+shortid+"#nokey")
print("delete_url "+url+"d/"+shortid+"/"+token)
@baker.command(
params={
"url": "download link given by the upload function", })
def download(url):
[url, _] = url.split('#')
url = url.replace("http", "ws").replace("/r/", "/download/")
ws = create_connection(url)
p = 0
stop = False
while not stop:
ws.send('{"part":%d}' % p)
result = ws.recv()
idx = result.find(MAGIC)
meta = loads(result[0:idx])
print(meta, file=sys.stderr)
data = result[idx+len(MAGIC):]
sys.stdout.buffer.write(b64decode(data))
t = meta["total"]
stop = t == p
p += 1
ws.close()
if __name__ == "__main__":
print(''' " m
m m mmm m mm m mm mmm m mm mmmm #
"m m m" " # #" " #" # # #" # #" "# #
#m#m# m"""# # # # # # # # # "
# # "mm"# # # # mm#mm # # "#m"# #
m #
this version does not protect your privacy ""
this version is not compatible with the web version
''', file=sys.stderr)
baker.run()
#!/bin/bash -e
CKSUM=crc32
LUFI="https://framadrop.org/"
PYLUFIC=$(realpath pylufic_nob64.py)
PYLUFIC=$(realpath pylufic.py)
# upload with FF, download with pylufic
#TODO
# upload with pylufic, download with FF
#TODO
# upload with pylufic, download with pylufic
## gen payload
pl=$(mktemp)
head -c 3123456 /dev/random > $pl
sign1=$($CKSUM $pl)
## upload
declare result=($($PYLUFIC upload $pl $LUFI | cut -f2 -d\ ))
dl="${result[0]}"
rm="${result[1]}"
echo $dl
echo $rm
## download
wd=$(mktemp -d)
pwd=$(pwd)
cd $wd
$PYLUFIC download $dl
sign2=$($CKSUM *)
[[ $sign1 == $sign2 ]]
echo $?
## delete
curl -s -S $rm | html2text | grep -q -i "file deleted"
echo $?
cd $pwd
rm $wd/*
rmdir $wd
rm $pl
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment