apt-get install tor
#!/usr/bin/perl use warnings; use HTTP::Proxy; use LWP::UserAgent; use LWP::Protocol::socks; use URI::Escape; use CGI qw(:standard -nph); my $q = new CGI; my $ua = LWP::UserAgent->new(max_redirect => 0, agent => $q->user_agent(),); $ua->timeout(60); $ua->proxy([qw/ http https /] => 'socks://127.0.0.1:9050'); # Tor proxy my $refer = $q->referer(); $refer = "" unless defined($refer); $refer =~ s/proxy\.flibusta\.net/flibustahezeous3.onion/g; #handle extra parameters my $ep =""; foreach my $par ($q->param) {$ep .= $par.'='.uri_escape($q->param($par)).'&' unless ($par eq 'url');} chop $ep; $ep = '?'.$ep if ($ep ne ''); my $rsp = $ua->get('http://flibustahezeous3.onion'.$q->param('url').$ep, 'Referer'=>$refer, 'Accept'=>$q->http('Accept'), 'Accept-Language'=>$q->http('Accept-Language'), 'Accept-Encoding'=>'identity', 'Cookie'=>$q->http('Cookie') ); my $fstr = $rsp->as_string; $fstr =~ s/flibustahezeous3\.onion/proxy.flibusta.net/g; #define templates my $nbl = <<DATA1; <link href="/b/BOOOOOOOK/fb2" rel="http://opds-spec.org/acquisition/open-access" type="application/fb2+zip" /> <link href="/b/BOOOOOOOK/html" rel="http://opds-spec.org/acquisition/open-access" type="application/html+zip" /> <link href="/b/BOOOOOOOK/txt" rel="http://opds-spec.org/acquisition/open-access" type="application/txt+zip" /> <link href="/b/BOOOOOOOK/rtf" rel="http://opds-spec.org/acquisition/open-access" type="application/rtf+zip" /> <link href="/b/BOOOOOOOK/epub" rel="http://opds-spec.org/acquisition/open-access" type="application/epub+zip" /> <link href="/b/BOOOOOOOK/mobi" rel="http://opds-spec.org/acquisition/open-access" type="application/x-mobipocket-ebook" /> DATA1 my $olb = quotemeta <<DATA2; <link href="/b/BOOOOOOOK/download" rel="http://opds-spec.org/acquisition/disabled" type="disabled/fb2+zip" /> DATA2 #get all book IDs my @IDs = $fstr =~ /\/b\/(\d+)\/download/g; foreach my $id (@IDs) { # prepare search and replace strings my $ao = $olb; $ao =~ s/BOOOOOOOK/$id/g; my $an= $nbl; $an =~ s/BOOOOOOOK/$id/g; # do replace to fix format for cool reader $fstr =~ s/$ao/$an/g; } print $fstr;
<VirtualHost *:80> ServerAdmin webmaster@flibusta.net ServerName proxy.flibusta.net DirectoryIndex /home/user/flibusta/nph-flibusta.pl DocumentRoot /home/user/flibusta/ <Directory /home/user/flibusta/ > AllowOverride None Options -Indexes +ExecCGI -MultiViews +SymLinksIfOwnerMatch Order allow,deny Allow from all </Directory> RewriteEngine On RewriteCond %{HTTP_HOST} =proxy.flibusta.net RewriteRule ^(.*)$ /nph-flibusta.pl?url=$1 [H=cgi-script,QSA,L] LogLevel warn CustomLog /var/log/apache2/access.log combined </VirtualHost>
a2ensite proxy.flibusta.net
service apache2 restart
address=/proxy.flibusta.net/99.99.99.99
Source: https://habr.com/ru/post/235581/
All Articles