Skip to content

Instantly share code, notes, and snippets.

@Robertof
Created August 5, 2012 18:49
Show Gist options
  • Save Robertof/3266648 to your computer and use it in GitHub Desktop.
Save Robertof/3266648 to your computer and use it in GitHub Desktop.
This snippet allows to download without going through the site from Zippyshare. Licensed under GNU/GPL v3 (I'm too lazy to add the header)
#!/usr/bin/perl
# =================================
# @author Robertof #
# @license GNU/GPL v3 #
# @name Zippyshare downloader #
# @reqby deletefile #
# @requires curl #
# =================================
use strict;
use warnings;
use IO::Socket::INET;
use URI::Escape;
my $link = $ARGV[0] || die "usage: perl $0 link\n";
if ($link =~ /^http:\/\/www(\d+)\.zippyshare\.com\/v\/(\d+)/)
{
my $downloadserver = "www${1}.zippyshare.com";
my $downloadid = $2;
my $sock = IO::Socket::INET->new (
PeerHost => $downloadserver,
PeerPort => 80,
Proto => "tcp"
) or die "cannot init socket: ${!}\n";
print $sock "GET /v/${downloadid}/file.html HTTP/1.1\n";
print $sock "Host: ${downloadserver}\n";
print $sock "User-Agent: Mozilla/5.0 (Windows NT 90.3; WOW99; rv:0.0) Gecko/20150915 Firefox/83.0.1\n";
print $sock "Connection: close\n\n";
my $cnt = "";
$cnt .= $_ while (<$sock>);
close $sock if $sock;
my $cookies = [];
while ($cnt =~ /Set-Cookie: ([^;]+)/g)
{
push @{$cookies}, $1;
}
$cnt =~ s/\s\s\s+//g; $cnt =~ s/(\t|\n|\r\n)//g; # content cleaning
if ($cnt =~ /<\/a> <script type="text\/javascript">(.+?)<\/script>/)
{
my ($script, $vars) = ($1, {});
# get the first two vars
while ($script =~ /var ([^\s]+) = (\d+)/g)
{
$vars->{$1} = $2;
}
# parse link code
if ($script =~ /\.href = \"\/d\/\d+\/\"\+\(([^\)]+)\)\+\"([^"]+)\"/)
{
my ($mathToApply, $restOfDaLink) = ($1, $2);
# replace vars with their value
#print $mathToApply . "\n";
foreach (keys %{$vars})
{
$mathToApply =~ s/$_/$vars->{$_}/g;
}
# calc!
my $ticket = eval $mathToApply;
# return link
$restOfDaLink = uri_unescape ($restOfDaLink);
my $link = "http://${downloadserver}/d/${downloadid}/${ticket}${restOfDaLink}";
print "=> Download link: ${link}\n";
print " > I'm going to download that file in this directory. Don't try to go on that URL with your browser, you can't. Proceed? [hit ctrl-c if no, or just press enter] > ";
<STDIN>;
my $cs;
foreach (@{$cookies})
{
$cs .= "${_}; ";
}
$cs = substr ($cs, 0, (length ($cs) - 2));
my $commandline = "curl -O -# -b \"${cs}\" -A \"Mozilla/5.0 (Windows NT 90.3; WOW99; rv:0.0) Gecko/20150915 Firefox/83.0.1\" \"${link}\"";
print "Launching: ${commandline}\n";
exec $commandline;
} else { die ":(((\n"; }
}
else
{
die "nope\n";
}
}
else
{
die "faggot :(\n";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment