|
jubegnx
|
 |
« on: October 09, 2007, 09:40:57 AM » |
|
hey guys i need some help. im trying to get into cPanel and use the addon domain tool there... #!/usr/bin/perl -w
use strict; use WWW::Mechanize; use MIME::Base64;
my $mech = WWW::Mechanize->new( autocheck => 1 ); my @args = ( Authorization => "Basic " . MIME::Base64::encode( 'user' . ':' . 'pass' ) );
$mech->credentials( 'http://hosting.com:5555', 'cPanel', 'user', 'pass' ); $mech->get( 'http://hosting.com:5555', @args ); $mech->follow_link( text => 'Addon Domains', n=> 1 ); it logs in fine however when i ask it to follow the link it gives me the following error Error GETing http://hosting.com:5555/addon/index.html: Access Denied Still Working at login.pl line 19
|
|
|
|
|
Logged
|
|
|
|
|
dirk
|
 |
« Reply #1 on: October 10, 2007, 09:49:09 AM » |
|
Just tested the script and got the same error message.
I think that the credentials are not passed to the new link because there is no get with @args.
Will have a look if there is a solution.
Dirk
|
|
|
|
|
Logged
|
|
|
|
perkiset
Olde World Hacker
Administrator
Lifer
   
Offline
Posts: 5135
:sniffle: Humor was so much easier before.
|
 |
« Reply #2 on: October 10, 2007, 10:01:20 AM » |
|
<hijack> Nice to see you back a bit Dirk... how is the new place? </hijack>
|
|
|
|
|
Logged
|
If I can't be Mr. Root then I don't want to play.
|
|
|
|
Bompa
|
 |
« Reply #3 on: October 10, 2007, 03:54:26 PM » |
|
Are you sure it's logging in fine? Maybe I'm missing something cuz I dont use mech, (i think it's buggy), but dont you have to post to log in?
|
|
|
|
|
Logged
|
|
|
|
|
dirk
|
 |
« Reply #4 on: October 10, 2007, 06:34:40 PM » |
|
Did some further debugging with Komodo and displayed the passed array @args. For the first get it contains the credentials, for the second get it's empty. So it seems you can't use follow_link for such links. You could try the following workaround. I have tested it and it was working. $mech->get( 'http://hosting.com:5555', @args ); #$mech->follow_link( text => 'Addon Domains', n=> 1 );
my $link = $mech->find_link( text => 'Addon Domains' );
my $addon_url = 'http://hosting.com:5555/frontend/x/' . $link->[0]; $mech->get( $addon_url, @args ); ...
@Ed: The new place is fine and very quiet. Specially in the middle of the night when I'm still working.
|
|
|
|
|
Logged
|
|
|
|
|
nop_90
|
 |
« Reply #5 on: October 10, 2007, 06:48:05 PM » |
|
A cpanel class i use package CPanel; use strict; use warnings; use WWW::Mechanize;
sub new { my $class = shift; my $self = bless {}, $class; $self->{mech} = WWW::Mechanize->new(); $self->{url} = shift; $self->{mech}->credentials(shift,shift); return $self; }
sub add_subdomain { my $self = shift; my ($domain,$subdomain) = @_; my $mech = $self->{mech}; my $response = $mech->get($self->{url}); die "unable to get main page" unless $response->is_success; $response = $mech->follow_link(text_regex => qr/Subdomain/ ); die "unable to get subdomain page" unless $response->is_success; my $form = $mech->form_name("domainform"); die "unable to find form" unless $form; $mech->field("rootdomain",$domain); $mech->field("domain",$subdomain); $mech->submit(); 1; }
sub add_on_domain { my $self = shift; my ($domain,$password) = @_; my $mech = $self->{mech}; my $response = $mech->get($self->{url} . "/frontend/x/addon/index.html"); die "unable to get add_on_domain form" unless $response->is_success; my $form = $mech->form_name("mainform"); die "unable to find form" unless $form; my $userdir = $domain; $userdir =~ s/\./-/g; $mech->field("domain",$domain); $mech->field("user",$userdir); $mech->field("pass",$password); $response = $mech->click(); die "unable to post add on domain" unless $response->is_success; 1; }
sub install_wordpress { my $self = shift; my ($domain,$username,$password) = @_; my $mech = $self->{mech}; my $response = $mech->get($self->{url} . "/frontend/x/fantastico/autoinstallwordpress.php"); die "unable to get wordpress form" unless $response->is_success; my $form = $mech->form_with_fields("installdirdomain","installdir"); die "unable to get wordpress form" unless $form; $mech->field("installdirdomain",$domain); $mech->field("adminuser",$username); $mech->field("INST_password",$password); $mech->field("socketpass",$password); $response = $mech->click(); die "unable to submit form" unless $response->is_success; $form = $mech->form_with_fields("adminuser","continuepage"); die "unable to get finish wordpress form" unless $form; $response = $mech->click(); die "unable to submit form" unless $response->is_success; 1; }
1;
|
|
|
|
|
Logged
|
|
|
|
|
dirk
|
 |
« Reply #6 on: October 11, 2007, 01:30:36 PM » |
|
Thanks for the CPanel package. Well-timed posting. I'm just working on some Perl scripts to create domains via cPanel. BTW, I have tested the cPanel XML API which is easy to use. Here is an example for a respective URL: http://$user0:$password0\@yourdomain.com:2086/xml-api/createacct?username=$user&plan=$plan&ip=$ip&cpmod=$cpmod&password=$password&contactemail=$contactemail&domain=$domain&useregns=$useregns&reseller=$reseller
You have to define the variables and then submit the URL via LWP::UserAgent or WWW::Mechanize.
|
|
|
|
|
Logged
|
|
|
|
|
nop_90
|
 |
« Reply #7 on: October 11, 2007, 03:31:53 PM » |
|
CPanel has xmlrpc api  now u tell me. if you going to do xmlrpc use the perl lib that does it, i will look into when start doing that shit again Anyway above script works on hostigator (not sure about others) you use like this (incase u not familiar with object perl) my $panel = CPanel->new($cpanel_url,$username,$password); $panel->add_on_domain("mydomain.domain.com",$password); $panel->install_wordpress("$site.$domain",$blog_username,$blog_password);
you get idea
|
|
|
|
|
Logged
|
|
|
|
|
dirk
|
 |
« Reply #8 on: October 11, 2007, 06:43:32 PM » |
|
Hm, you don't need a Perl module.
Don't think that xml rpc modules, like XMLRPC::Lite would work.
You only have to submit a customized URL containing the fields and values in the query string.
The output is XML. Here you could use a module, like XML:Simple to parse the output.
|
|
|
|
|
Logged
|
|
|
|
|
jubegnx
|
 |
« Reply #9 on: October 13, 2007, 06:29:14 PM » |
|
got it... thanks for the help
|
|
|
|
|
Logged
|
|
|
|
|
nop_90
|
 |
« Reply #10 on: October 14, 2007, 01:31:51 AM » |
|
Your are right about the xmlapi , xml rpc will not work. Looked at the documentation, an extremely stupid API Would have made a heck of a lot more sense if the just use xmlrpc
|
|
|
|
|
Logged
|
|
|
|
|
arms
|
 |
« Reply #11 on: October 14, 2007, 06:23:17 AM » |
|
just what i was looking for. thanks.
|
|
|
|
|
Logged
|
|
|
|
|