Skip to content

Commit

Permalink
add PrivateBin support
Browse files Browse the repository at this point in the history
  • Loading branch information
grawity committed Jul 4, 2019
1 parent 3697ed2 commit 28934bf
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion getpaste
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use warnings;
use strict;
no locale;
use open qw(:std :utf8);
use Encode qw(decode);
use Encode qw(decode encode);
use Getopt::Long qw(:config bundling no_ignore_case);
use JSON;
use LWP::UserAgent;
Expand Down Expand Up @@ -863,6 +863,25 @@ sub dl_ncrypt {
return $data;
}

sub dl_privatebin {
my ($url, $frag) = @_;

# Trick the server into returning the JSON blob
$UA->default_header("X-Requested-With" => "JSONHttpRequest");

my $body = get($url) // return;
$body = decode_json($body);

my $data = $body->{data};
$data = unwrap_sjcl($data, $frag);
$data = decode_base64($data);
# The example code that comes with js-deflate mistakenly encodes binary
# data as UTF-8, and of course PrivateBin just used it verbatim.
$data = encode("latin1", decode("utf-8", $data));
$data = decompress_deflate($data);
return $data;
}

sub dl_riseup {
eval {
require Crypt::Digest::SHA512;
Expand Down Expand Up @@ -1163,6 +1182,10 @@ sub dl_zerobin {
path => qr!^/(?:show|raw)/(\w+)!,
to_path => "/raw/#1",
},
{
host => "privatebin.net",
parser => \&dl_privatebin,
},
{
host => "www.refheap.com",
path => qr!^/\d+!,
Expand Down

0 comments on commit 28934bf

Please sign in to comment.