diff --git a/modules/zerobin/module.py b/modules/zerobin/module.py index e68903d71648eb23b2361715ae917f52f655d9dd..a1c7bc6c0eae537f1a228388738c285705ca718e 100644 --- a/modules/zerobin/module.py +++ b/modules/zerobin/module.py @@ -31,13 +31,13 @@ class ZerobinModule(Module, CapPaste): NAME = 'zerobin' - DESCRIPTION = u'ZeroBin/0bin encrypted pastebin' + DESCRIPTION = u'ZeroBin/0bin/PrivateBin encrypted pastebin' MAINTAINER = u'Vincent A' EMAIL = 'dev@indigo.re' LICENSE = 'AGPLv3+' VERSION = '1.4' CONFIG = BackendConfig( - Value('url', label='URL of the zerobin/0bin', regexp='https?://.*', default='https://zerobin.net'), + Value('url', label='URL of the zerobin/0bin/privatebin', regexp='https?://.*', default='https://zerobin.net'), ValueBool('discussion', label='Allow paste comments (ZeroBin only)', default=False), ) diff --git a/modules/zerobin/pages.py b/modules/zerobin/pages.py index 7ed954169bcc5d986b0cb1ef1ef1da228e25d1f8..1e3527419f55dc37147cddecfe56e5655daaad67 100644 --- a/modules/zerobin/pages.py +++ b/modules/zerobin/pages.py @@ -30,15 +30,23 @@ class ReadPageZero(HTMLPage): - # for zerobin - def decode_paste(self, key): + # for zerobin/privatebin + def _get_dict(self): d = json.loads(CleanText('//div[@id="cipherdata"]')(self.doc)) - subd = json.loads(d[0]['data']) + if isinstance(d, list): + # zerobin + return d[0] + else: + # privatebin + return d + + def decode_paste(self, key): + subd = json.loads(self._get_dict()['data']) decr = decrypt(key, subd) return decompress(b64decode(decr), -MAX_WBITS) def get_expire(self): - d = json.loads(CleanText('//div[@id="cipherdata"]')(self.doc))[0]['meta'] + d = self._get_dict()['meta'] if 'expire_date' in d: return datetime.fromtimestamp(d['expire_date']) @@ -84,7 +92,9 @@ class WritePageZero(HTMLPage): } def is_here(self): - return 'zerobin' in self.text and self.doc.xpath('//select[@id="pasteExpiration"]') + if not self.doc.xpath('//select[@id="pasteExpiration"]'): + return False + return 'zerobin' in self.text or 'privatebin' in self.text def post(self, contents, max_age): compressor = compressobj(-1, DEFLATED, -MAX_WBITS) @@ -99,7 +109,10 @@ def post(self, contents, max_age): 'opendiscussion': str(int(self.browser.opendiscussion)), 'syntaxcoloring': '1', } - response = self.browser.location(self.url, data=data) + headers = { + 'Accept': 'application/json', + } + response = self.browser.location(self.url, data=data, headers=headers) j = response.json() assert j['status'] == 0