1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Curl post comments in blogs problem

Discussion in 'PHP & Perl' started by blackhatchan, Jan 21, 2012.

  1. blackhatchan

    blackhatchan Registered Member

    Joined:
    Jan 7, 2012
    Messages:
    51
    Likes Received:
    8
    I made a script with curl that loops a txt file with a list of wordpress blogs with autoapprove comments, because the url for post comments may change i read first the source code and take the action attribute from the form of comments and the id of the post from the head tag, but the problem is that the success rate is very small.

    PHP:
    <?

    set_time_limit(0);

    function 
    postComment($url_main$postfields$agent) {

        
    $url $url_main;
        
    $useragent $agent;
        
    $referer $url;

        
    $urlParse parse_url($url);
        
    $urlComment $urlParse['host'].'/wp-comments-post-php';
        
        
    $lines = array();
        
        
    $ch curl_init($url);
        
    curl_setopt($chCURLOPT_RETURNTRANSFERtrue);
        
    curl_setopt($chCURLOPT_BINARYTRANSFERtrue);
        
    $content curl_exec($ch);
        
    curl_close($ch);

        
    $lines explode("\n"$content);
        
        
    $idPost 0;

        if(
    count($lines) > && $lines != false){
            
    $matriz_fl preg_grep("/shortlink/"$lines);
            if(
    is_array($matriz_fl) && count($matriz_fl) > 0){
                
    $first_key key($matriz_fl);
                
    $idPost preg_replace('/\D/'''$lines[$first_key]);
            }
            
    $matriz_post preg_grep("/wp-comments-post-php/"$lines);
            if(
    is_array($matriz_post) && count($matriz_post) > 0){
                
    $first_key key($matriz_post);
                
    $idPostUrl $lines[$first_key];
                
    $regexp "<form\s[^>]*action=(\"??)([^\" >]*?)\\1[^>]*>";
                if(
    preg_match_all("/$regexp/siU"$idPostUrl$matches)) {
                    if(isset(
    $matches[2]) && $matches[2] != "")
                        
    $urlComment $matches[2];
                }
            }
        }

        if(
    $idPost != 0){

            
    $postfields["comment_post_ID"] = $idPost;

            
    $ch curl_init($urlComment);
            
    curl_setopt($chCURLOPT_POST1);
            
    curl_setopt($chCURLOPT_POSTFIELDS$postfields);
            
    curl_setopt($chCURLOPT_USERAGENT'(Mozilla/5.0)');
            
    curl_setopt($chCURLOPT_AUTOREFERERtrue);
            
    curl_setopt($chCURLOPT_RETURNTRANSFER1);
            
    $result curl_exec($ch);
            
    curl_close($ch);
            
        }

        
    $lines = array();
        
        
    $ch curl_init($url_main);
        
    curl_setopt($chCURLOPT_RETURNTRANSFERtrue);
        
    curl_setopt($chCURLOPT_BINARYTRANSFERtrue);
        
    $content curl_exec($ch);
        
    curl_close($ch);
        
        
    $lines explode("\n"$content);
        
        if(
    count($lines) > && $lines != false){
            
    $lastUrl str_replace('h t t p : / / ','',$postfields["url"]);
            
    $lastUrl str_replace('/','',$lastUrl);
            
    $matriz_co preg_grep("/".$lastUrl."/"$lines);
            if(
    is_array($matriz_co) && count($matriz_co) > 0){
                
    $first_key key($matriz_co);
                
    $url $lines[$first_key];
                if(
    $url != ""){
                    
    $filename 'txtfileworking';
                    
    $fp fopen($filename"a+");
                    
    $write fputs($fp$url_main."\n");
                    
    fclose($fp);
                }
            } else {
                    
    $filename 'txtfilenotworking';
                    
    $fp fopen($filename"a+");
                    
    $write fputs($fp$url_main."\n");
                    
    fclose($fp);
            }
            
        }

    }

    $agents file('useragentstxt');
    $backlinks file('backlinkstxt');
    $comments file('commentstxt');

    for(
    $i=0;$i<count($comments);$i++){
        
    $string =  preg_split('/[\}{]/'$comments[$i]);
        
    $str '';
        for(
    $x=0;$x<count($string);$x++){
            
    $strSplitted[$x] = explode('|',$string[$x]);
            
    $str .= $strSplitted[$x][array_rand($strSplitted[$x])];
        }
        
        
    $comments[$i] = preg_replace('!\s+!'' '$str);
    }

    $commentsArr = array();

    for(
    $i=0;$i<count($comments);$i++){
        if(
    $comments[$i] != ' ')
            
    $commentsArr[$i] = $comments[$i];
    }

    $postfields = array();
    $postfields['action'] = 'submit';
    $postfields['submit'] = 'Submit Comment';
    $postfields['author'] = 'Author';
    $postfields['url'] = 'mywebpageurl';
    $postfields['comment_parent'] = 0;
    $postfields['_wp_unfiltered_html_comment'] = '0d870b294b';
    $postfields['subscribe_comments'] = 'suscribe';
    $postfields['subscribe_blog'] = 'suscribe';

    $names = array('michael','peter','scott','lincoln','joseph','phill','luke');
    $servers = array('yahoocom','hotmailcom','gmailcom','aolcom');

    for(
    $i=1;$i<count($backlinks);$i++){
        
        
    $randName $names[array_rand($names)];
        
    $randNumber mt_rand(1,9999);
        
    $randServer $servers[array_rand($servers)];
        
        
    $postfields['email'] = $randName.$randNumber.'aaaa'.$randServer;
        
    $postfields['comment'] = $commentsArr[array_rand($commentsArr)];

        
    postComment($backlinks[$i], $postfields$agents[mt_rand(0,count($agents)-1)]);

        
    sleep(1);
        
    }

    ?>
    I replaced all the URL and email address because BHW don't let me put that info in the post, file for comments are in the format that use scrapebox.
     
    Last edited: Jan 22, 2012
  2. heiska

    heiska Junior Member

    Joined:
    Dec 5, 2008
    Messages:
    138
    Likes Received:
    169
    Perhaps the blog is using a captcha to prevent such spam attempts?
     
  3. blackhatchan

    blackhatchan Registered Member

    Joined:
    Jan 7, 2012
    Messages:
    51
    Likes Received:
    8
    I don't think because with scrapebox is working good.
     
  4. idoit

    idoit Registered Member

    Joined:
    Oct 27, 2011
    Messages:
    77
    Likes Received:
    42
    Home Page:
    you should probably pick one of the blogs that's having this issue and then post it here... otherwise, even if people want to help, they'd only be shooting blanks

    speaking of blanks... i remember not being able to log to twitter and post tweets with curl, but made it with httpclient and java. turned out to be a cookie issue... not saying this is your problem here, but just wanted to give example why something is working and something else isn't :)

    maybe scrapebox is better than your script ;)
     
  5. blackhatchan

    blackhatchan Registered Member

    Joined:
    Jan 7, 2012
    Messages:
    51
    Likes Received:
    8
    sure i will post my script here but i don't have now it's in other computer
     
  6. Narrator

    Narrator Power Member

    Joined:
    Oct 5, 2010
    Messages:
    507
    Likes Received:
    396
    Occupation:
    Internet Marketing
    Location:
    /dev/null
    They might have hidden form fields for confirmation. Check a couple of the failed blogs and see if there is anything different.

    They also may check the referrer so you would have to spoof that.
     
    Last edited: Jan 22, 2012
  7. hip_hop_x

    hip_hop_x Jr. VIP Jr. VIP Premium Member

    Joined:
    Aug 27, 2009
    Messages:
    299
    Likes Received:
    61
    Occupation:
    Developer
    Home Page:
    it's hard to track all the code, make sure that $idPost is being fetched