#!/usr/bin/env perl
# cnhacktnt
use strict;
use Mojo::UserAgent;
use Data::Dumper;
my ($user, $pass) = @ARGV;
my $ua = Mojo::UserAgent->new;
$ua = $ua->cookie_jar(Mojo::UserAgent::CookieJar->new);
$ua->transactor->name('Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:27.0) Gecko/20100101 Firefox/27.0');
print " -> Visiting pan.baidu.com to get cookie initialized...\n";
$ua->get('http://pan.baidu.com');
print " -> getting app token...";
my $tx = $ua->get('https://passport.baidu.com/v2/api/?getapi&tpl=netdisk&class=login&logintype=basicLogin');
my ($token) = $tx->res->body =~ /login_token='([a-f0-9]+)'/;
print "[token: $token]\n";
my $form = {
staticpage => 'http://pan.baidu.com/res/static/thirdparty/pass_v3_jump.html',
charset => 'utf-8',
token => $token,
tpl => 'netdisk',
apiver => 'v3',
tt => time.sprintf("%3d", rand(10)*100),
codestring => undef,
safeflg => 0,
u => 'http://pan.baidu.com/',
isPhone => 'false',
quick_user => 0,
loginmerge => 'true',
logintype => 'basicLogin',
username => $user,
password => $pass,
verifycode => undef,
mem_pass => 'on',
ppui_logintime => substr(time, 4, 6),
callback => 'parent.bd__pcbs__opvzmz',
};
print " -> logging...[user: $user pass: $pass]\n";
$ua->post('https://passport.baidu.com/v2/api/?login' => {} => form => $form);
print " -> listing all filenames on the first page...\n\n";
$tx = $ua->get('http://pan.baidu.com/api/categorylist?channel=chunlei&clienttype=0&web=1&category=3&pri=-1&num=100&t='.time.'&page=1&order=time&desc=1&_='.(time+1).'&bdstoken='.$token);
print "files:\n======\n";
my $content = $tx->res->body;
while ($content =~ /"server_filename":"([^"]+)"/g) {
print "$1\n";
}
print "\n======\nDone.\n";
转载于:https://my.oschina.net/OliverTwist/blog/207199