论坛首页 编程语言技术论坛

人人农场 renren 外挂 Java 实现

浏览 16391 次
精华帖 (1) :: 良好帖 (1) :: 新手帖 (0) :: 隐藏帖 (0)
作者 正文
   发表时间:2012-04-08   最后修改:2012-04-11
看过《被偷无奈写个收菜外挂》 http://www.iteye.com/topic/692028

建议大家不要偷菜,因为偷菜如果遇到有狗的、有蜜蜂的将会失掉非常多的金币,本人以前的程序就有此功能,后来给删除了,

先交上java程序,供大家享用,

程序中添加了验证码功能,每隔5分钟收割一次。

MainFrame.java
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * MainFrame.java
 *
 * Created on Oct 10, 2011, 12:22:32 PM
 */
package com.myproj.renren3g_threads_2;

import java.awt.Image;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Date;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.imageio.ImageIO;
import javax.swing.ButtonGroup;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JRadioButton;

/**
 *
 * @author User
 */
public class MainFrame extends java.awt.Frame implements Runnable {

    private User currentUser;
    private boolean verifyCodeFlag;
    private String verifyCode;
    private Renren3G_Farm renren;
    private ByteArrayOutputStream bais;
    private Thread thread;
    private int actionCounter;
    private boolean pauseFlag;

    /** Creates new form MainFrame */
    public MainFrame() {
    }

    public void init() {
        initComponents();

        currentUser = new User();

        renren = new Renren3G_Farm();
        renren.setTextArea(outputTextArea);

        //
        actionCounter = 0;
        counterField.setText("" + actionCounter);

        pauseFlag = false;
        pauseButton.setSelected(pauseFlag);

        // redraw layout
        gifPanel.setVisible(false);
        validate();
        repaint();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc="Generated Code">                          
    private void initComponents() {

        basePanel = new javax.swing.JPanel();
        usersPanel = new javax.swing.JPanel();
        jSeparator1 = new javax.swing.JSeparator();
        loginPanel = new javax.swing.JPanel();
        userPanel = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        usernameTextField = new javax.swing.JTextField();
        passwordPanel = new javax.swing.JPanel();
        jLabel2 = new javax.swing.JLabel();
        passwordTextField = new javax.swing.JTextField();
        gifPanel = new javax.swing.JPanel();
        jPanel2 = new javax.swing.JPanel();
        imgPanel = new javax.swing.JPanel();
        refreshImgButton = new javax.swing.JButton();
        jSeparator3 = new javax.swing.JSeparator();
        dbImgPanel = new javax.swing.JPanel();
        jLabel4 = new javax.swing.JLabel();
        dbImgTextField = new javax.swing.JTextField();
        jLabel5 = new javax.swing.JLabel();
        dbCodeTextField = new javax.swing.JTextField();
        jPanel3 = new javax.swing.JPanel();
        jLabel3 = new javax.swing.JLabel();
        verifyTextField = new javax.swing.JTextField();
        dbUpdateButton = new javax.swing.JButton();
        jPanel1 = new javax.swing.JPanel();
        loginButton = new javax.swing.JButton();
        jPanel4 = new javax.swing.JPanel();
        jLabel6 = new javax.swing.JLabel();
        counterField = new javax.swing.JTextField();
        pauseButton = new javax.swing.JToggleButton();
        jSeparator2 = new javax.swing.JSeparator();
        textPanel = new javax.swing.JPanel();
        textScrollPane = new javax.swing.JScrollPane();
        outputTextArea = new javax.swing.JTextArea();
        exitButton = new javax.swing.JButton();

        setMinimumSize(new java.awt.Dimension(500, 600));
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosing(java.awt.event.WindowEvent evt) {
                exitForm(evt);
            }
        });

        basePanel.setLayout(new javax.swing.BoxLayout(basePanel, javax.swing.BoxLayout.Y_AXIS));

        usersPanel.setLayout(new javax.swing.BoxLayout(usersPanel, javax.swing.BoxLayout.Y_AXIS));
        basePanel.add(usersPanel);
        basePanel.add(jSeparator1);

        loginPanel.setLayout(new javax.swing.BoxLayout(loginPanel, javax.swing.BoxLayout.Y_AXIS));

        userPanel.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT));

        jLabel1.setText("Username");
        userPanel.add(jLabel1);

        usernameTextField.setColumns(25);
        usernameTextField.setMinimumSize(new java.awt.Dimension(6, 200));
        usernameTextField.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                usernameTextFieldActionPerformed(evt);
            }
        });
        userPanel.add(usernameTextField);

        loginPanel.add(userPanel);

        passwordPanel.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT));

        jLabel2.setText("Password");
        passwordPanel.add(jLabel2);

        passwordTextField.setColumns(25);
        passwordTextField.setMinimumSize(new java.awt.Dimension(6, 200));
        passwordPanel.add(passwordTextField);

        loginPanel.add(passwordPanel);

        gifPanel.setLayout(new javax.swing.BoxLayout(gifPanel, javax.swing.BoxLayout.Y_AXIS));

        jPanel2.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT));
        jPanel2.add(imgPanel);

        refreshImgButton.setText("Refresh");
        refreshImgButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                refreshImgButtonActionPerformed(evt);
            }
        });
        jPanel2.add(refreshImgButton);

        jSeparator3.setOrientation(javax.swing.SwingConstants.VERTICAL);
        jPanel2.add(jSeparator3);
        jPanel2.add(dbImgPanel);

        jLabel4.setText("Size");
        jPanel2.add(jLabel4);

        dbImgTextField.setColumns(6);
        dbImgTextField.setEditable(false);
        jPanel2.add(dbImgTextField);

        jLabel5.setText("Verify Code");
        jPanel2.add(jLabel5);

        dbCodeTextField.setColumns(6);
        dbCodeTextField.setEditable(false);
        jPanel2.add(dbCodeTextField);

        gifPanel.add(jPanel2);

        jPanel3.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT));

        jLabel3.setText("Input Verify Code:");
        jPanel3.add(jLabel3);

        verifyTextField.setColumns(6);
        jPanel3.add(verifyTextField);

        dbUpdateButton.setText("Update database");
        dbUpdateButton.setEnabled(false);
        dbUpdateButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                dbUpdateButtonActionPerformed(evt);
            }
        });
        jPanel3.add(dbUpdateButton);

        gifPanel.add(jPanel3);

        loginPanel.add(gifPanel);

        jPanel1.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT));

        loginButton.setText("Login");
        loginButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                loginButtonActionPerformed(evt);
            }
        });
        jPanel1.add(loginButton);

        jPanel4.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.TRAILING));

        jLabel6.setText("Action Count:");
        jPanel4.add(jLabel6);

        jPanel1.add(jPanel4);

        counterField.setColumns(5);
        counterField.setText("jTextField1");
        counterField.setEnabled(false);
        jPanel1.add(counterField);

        pauseButton.setText("Pause");
        pauseButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                pauseButtonActionPerformed(evt);
            }
        });
        jPanel1.add(pauseButton);

        loginPanel.add(jPanel1);

        basePanel.add(loginPanel);
        basePanel.add(jSeparator2);

        textPanel.setLayout(new java.awt.BorderLayout());

        outputTextArea.setColumns(20);
        outputTextArea.setRows(5);
        textScrollPane.setViewportView(outputTextArea);

        textPanel.add(textScrollPane, java.awt.BorderLayout.CENTER);

        basePanel.add(textPanel);

        add(basePanel, java.awt.BorderLayout.CENTER);

        exitButton.setText("Exit");
        exitButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                exitButtonActionPerformed(evt);
            }
        });
        add(exitButton, java.awt.BorderLayout.SOUTH);

        pack();
    }// </editor-fold>                        

    /** Exit the Application */
    private void exitForm(java.awt.event.WindowEvent evt) {                          
        System.exit(0);
    }                         

    private void exitButtonActionPerformed(java.awt.event.ActionEvent evt) {                                           
        System.exit(0);
    }                                          

    private void usernameTextFieldActionPerformed(java.awt.event.ActionEvent evt) {                                                  
        // TODO add your handling code here:
    }                                                 

    private void loginButtonActionPerformed(java.awt.event.ActionEvent evt) {                                            
        
        // update user info.
        currentUser.setUsername(usernameTextField.getText());
        currentUser.setPassword(passwordTextField.getText());
        
        // clear output
        outputTextArea.setText("---- " + (new Date()).toString() + " ----\n");

        verifyCode = verifyTextField.getText();
        //outputTextArea.append("Verify code = '" + verifyCode + "'");
        System.out.println("Verify code = '" + verifyCode + "'");

        boolean firstTimeLogon;
        if (!verifyCodeFlag) {
            // first time, no verify image
            firstTimeLogon = renren.logon(currentUser);
        } else {
            //
            firstTimeLogon = renren.logon(currentUser, verifyCode);
        }
        //System.out.println("first time logon : " + firstTimeLogon);

        if (firstTimeLogon) {
            // login success
            thread.start();
        }

        if (!firstTimeLogon) {
            // require verify code
            System.out.println("verify image url : " + renren.getVerifyImageUrl());

            // show verify image
            try {
                bais = renren.getRenrenVerifyImage();
                System.out.println("bais.size() = " + bais.size());

                String digest = getDigest_md5(bais);
                System.out.println("Digest_md5 = '" + digest + "'");

                Image image = ImageIO.read(new ByteArrayInputStream(bais.toByteArray()));

                imgPanel.removeAll();
                JLabel label = new JLabel(new ImageIcon(image));
                imgPanel.add(label);

                verifyCodeFlag = true;

                // redraw layout
                verifyTextField.setText("");
                gifPanel.setVisible(true);
                validate();
                repaint();
            } catch (IOException ex) {
                Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    }                                           

    private void refreshImgButtonActionPerformed(java.awt.event.ActionEvent evt) {                                                 
        try {
            outputTextArea.setText((new Date()).toString() + " ---- from outputTextArea ----");

            bais = renren.refreshRenrenVerifyImage();
            System.out.println("bais.size() = " + bais.size());

            String digest = getDigest_md5(bais);
            System.out.println("Digest_md5 = '" + digest + "'");

            Image image = ImageIO.read(new ByteArrayInputStream(bais.toByteArray()));

            imgPanel.removeAll();
            JLabel label = new JLabel(new ImageIcon(image));
            imgPanel.add(label);

            // redraw layout
            validate();
            repaint();
        } catch (IOException ex) {
            Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, null, ex);
        }
    }                                                

    private void dbUpdateButtonActionPerformed(java.awt.event.ActionEvent evt) {                                               
    }                                              

    private void pauseButtonActionPerformed(java.awt.event.ActionEvent evt) {                                            
        pauseFlag = pauseButton.isSelected();
    }                                           

    private String getDigest_md5(ByteArrayOutputStream bais) {

        // demo : get md5 digest for String
        StringBuilder hexString = new StringBuilder();

        byte[] defaultBytes = bais.toByteArray();
        try {
            MessageDigest algorithm = MessageDigest.getInstance("MD5");
            algorithm.reset();
            algorithm.update(defaultBytes);
            byte messageDigest[] = algorithm.digest();

            for (int i = 0; i < messageDigest.length; i++) {
                hexString.append(Integer.toHexString(0xFF & messageDigest[i]));
            }
            //String foo = messageDigest.toString();
            //System.out.println("sessionid " + sessionid + " md5 version is " + hexString.toString());
        } catch (NoSuchAlgorithmException nsae) {
        }

        return hexString.toString();
    }

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
//        java.awt.EventQueue.invokeLater(new Runnable() {
//
//            public void run() {
//                new MainFrame().setVisible(true);
//            }
//        });
        MainFrame frame = new MainFrame();
        Thread renrenThread = new Thread(frame);
        frame.setThread(renrenThread);
        frame.setVisible(true);
        frame.init();
    }
    // Variables declaration - do not modify                     
    private javax.swing.JPanel basePanel;
    private javax.swing.JTextField counterField;
    private javax.swing.JTextField dbCodeTextField;
    private javax.swing.JPanel dbImgPanel;
    private javax.swing.JTextField dbImgTextField;
    private javax.swing.JButton dbUpdateButton;
    private javax.swing.JButton exitButton;
    private javax.swing.JPanel gifPanel;
    private javax.swing.JPanel imgPanel;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JSeparator jSeparator2;
    private javax.swing.JSeparator jSeparator3;
    private javax.swing.JButton loginButton;
    private javax.swing.JPanel loginPanel;
    private javax.swing.JTextArea outputTextArea;
    private javax.swing.JPanel passwordPanel;
    private javax.swing.JTextField passwordTextField;
    private javax.swing.JToggleButton pauseButton;
    private javax.swing.JButton refreshImgButton;
    private javax.swing.JPanel textPanel;
    private javax.swing.JScrollPane textScrollPane;
    private javax.swing.JPanel userPanel;
    private javax.swing.JTextField usernameTextField;
    private javax.swing.JPanel usersPanel;
    private javax.swing.JTextField verifyTextField;
    // End of variables declaration                   

    public void run() {
        while (true) {
            if (!pauseFlag) {
                Date date = new Date();
                //System.out.println(date);
                outputTextArea.append("" + date + "\n");
                outputTextArea.scrollRectToVisible(new Rectangle(0, outputTextArea.getHeight() - 2, 1, 1));

                renren.getFarmURLs();
                renren.showStatus0();
                renren.processFarm();

                // loss money
                //List<String> friends = renren.getFriendsURL();
                //for (int index = 0; index < friends.size(); index++) {
                //    renren.processFriend(friends.get(index));
                //}
                renren.showStatus1();

                outputTextArea.append("\n");
                outputTextArea.append("Wait for 5 minutes...\n");
                outputTextArea.append("\n");
                outputTextArea.scrollRectToVisible(new Rectangle(0, outputTextArea.getHeight() + 80, 1, 1));

                actionCounter++;
                counterField.setText("" + actionCounter);
            }

            try {
                Thread.sleep(5 * 60 * 1000); // wait 5 minutes
            } catch (InterruptedException ex) {
                Logger.getLogger(Renren3G_Farm.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    }

    private void setThread(Thread thread) {
        this.thread = thread;
    }
}
   发表时间:2012-04-09  
无图无真相……
0 请登录后投票
   发表时间:2012-04-09  
1,无图无真相
2,能否说下 原理?模拟post?
0 请登录后投票
   发表时间:2012-04-10  
Renren3G_Farm,这个类在哪儿呢?用的人人的SDK?这类名取得真他娘的坑爹,还有你那代码,感觉像是抄的,不像是自己写的,嗯,仅仅感觉而已
0 请登录后投票
   发表时间:2012-04-10   最后修改:2012-04-15
字体颜色字体颜色字体颜色字体颜色
0 请登录后投票
   发表时间:2012-04-10   最后修改:2012-04-15

采用HttpClient登录3g.renren.com,使用Post方法。
0 请登录后投票
   发表时间:2012-04-10  
如果有时间,考虑使用WebService收集大家输入的验证码,存到数据库中,3g人人大约使用9万个验证码,等到收集得差不多了,大家就可以免去输入验证码的工序了,靠!

 
0 请登录后投票
   发表时间:2012-04-10  
大家上班下班时,把程序转上,让它自动收割,什么事情儿都不耽误,只管坐地涨钱,还可以多开几个自己的下线账户,只给自己的账户加饭、加料,又可挣到额外的经验。看这人人农场还能怎么玩?
0 请登录后投票
   发表时间:2012-04-10  


0 请登录后投票
   发表时间:2012-04-10  
别把用户名和密码一起收集了,代码还要重构,一个字:乱~
0 请登录后投票
论坛首页 编程语言技术版

跳转论坛:
Global site tag (gtag.js) - Google Analytics