`
yang02301
  • 浏览: 2887 次
  • 性别: Icon_minigender_1
  • 来自: 珠海
最近访客 更多访客>>
文章分类
社区版块
存档分类
最新评论

人人农场 renren 外挂 Java 实现

阅读更多
看过《被偷无奈写个收菜外挂》 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;
    }
}
分享到:
评论

相关推荐

    经典游戏Java实现QQ农场小游戏(附源码)

    实现方式: 虚拟经济:游戏中使用虚拟货币(金币)作为交易媒介,玩家可以通过游戏内任务、活动获取金币,用于购买种子、道具等。 游戏设计:游戏以简单易上手的操作方式为主,注重玩家间的社交互动和合作,通过...

    开心农场源码及素材java源码

    虽然这个源码并没有实现开心农场的全部功能,但它依然可以作为一个学习和实践Java编程、游戏开发以及面向对象设计的良好实例。通过分析和修改这些代码,开发者可以进一步理解游戏逻辑的实现以及Java编程的技巧。

    用java实现的仿真农场

    在这个“用Java实现的仿真农场”项目中,我们可以通过编程技术来模拟一个虚拟的农场环境,使得用户能够体验到管理、养殖、收获等农场活动的乐趣。以下是一些关于这个主题的关键知识点: 1. **面向对象编程**:Java...

    java做的开心农场

    《基于Java的“开心农场”课程设计详解》 在IT领域,编程语言的学习与实践是提升技能的关键途径,其中Java以其强大的跨平台能力和丰富的库支持,成为许多初学者及专业人士的首选。本篇将深入探讨一个名为“开心农场...

    人人农场经验总结

    人人农场游戏开发技术经验总结,总结如何优化等

    java Swing实现开心农场采用面向对象思想

    java Swing实现开心农场采用面向对象思想 java Swing实现开心农场采用面向对象思想 采用面向对象的思路,实现开心农场,适合初学者,以及对面向对象有更深层次理解的开发者或者同学。 使用原生的java swing进行窗口...

    基于JAVA设计的现实版的“开心农场”软件源码+说明文档.zip

    基于JAVA设计的现实版的“开心农场”软件源码+说明文档 通过本课程设计的实践及其前后的准备与总结,复习、领会、巩固和运用软件工程课堂上所学的软件开发方法和知识,在农场里用户通过鼠标操作实现种子购买、作物...

    开心农场源码及素材java源码 下载

    【开心农场源码及素材Java源码下载】是一款基于Java编程语言开发的模拟农场经营的项目,它提供了完整的源代码和相关素材,旨在帮助开发者学习和理解Java编程以及游戏开发的基本概念。在这个项目中,我们可以深入研究...

    自定义开心农场完整源码及素材(Java实现)

    【自定义开心农场完整源码及素材(Java实现)】是一个基于Java Swing技术的游戏开发项目,旨在模拟现实中的农场管理,让玩家体验作物种植、生长和收获的乐趣。在这个项目中,开发者利用Java语言的强大功能,结合...

    人人农场的计算公式 幸运的开始

    人人农场的计算公式 ,方便大家玩这个游戏,呵呵

    JAVA 农场demo

    【JAVA 农场demo】是一个基于JAVA编程语言开发的简单农场模拟游戏的示例项目。这个demo旨在提供一个基础的框架,帮助初学者理解如何在JAVA中构建一个基本的游戏环境,以及如何处理游戏循环、对象交互和基本的图形...

    java做开心农场完整版(保证可以安装运行,有安装说明)

    再说明一点,大家别再下载我以前上传的农场,下这个完整版的。欢迎大家宣传。以下是安装步骤: 1.把文件NetBeansProjects放到D盘下面 2.把农场数据库附加入你的SQL SERVER 2005 3.用NetBeans把项目导入进去(不知道...

    java小程序,小型农场源码

    这类程序通常由一系列Java类和资源文件组成,用于实现用户交互、游戏逻辑、图像展示等功能。由于是小程序,它的设计可能相对简单,易于理解和学习,适合初学者进行代码阅读和实践。 【描述】中的指导说明了如何运行...

    【ssm项目源码】农场信息管理系统.zip

    【SSM项目源码】农场信息管理系统是一款基于Java技术栈的Web应用,旨在实现对农场的全面信息管理。系统的核心技术栈包括Spring、SpringMVC和MyBatis,这三大框架构成了SSM(Spring+SpringMVC+MyBatis)开发模式。...

    java小游戏开心农场

    "Java小游戏开心农场"是一个展示Java游戏编程技术的例子。这个项目基于Java语言,利用其强大的面向对象特性、丰富的类库和跨平台兼容性,为用户提供了一个在Eclipse集成开发环境中可以运行的农场模拟游戏。 首先,...

    09年人人农场经验总结PPT.rar

    【标题】:“09年人人农场经验总结PPT”是一个关于网络游戏开发与运营的教程,主要聚焦于人人农场这款游戏在2009年的运营策略、用户增长和产品优化的实战经验。这款PPT旨在教授如何成功地打造和管理一款游戏产品,...

    Java编写的QQ农场的程序

    在这个Java编写的QQ农场模拟游戏中,开发者很可能使用了类(Class)和对象(Object)的概念来表示农场、作物、工具等元素,同时运用条件语句(如if-else)和循环(如for、while)来实现作物生长、收获等逻辑。...

Global site tag (gtag.js) - Google Analytics