`
hyperzhen
  • 浏览: 22221 次
  • 性别: Icon_minigender_1
  • 来自: 无锡
社区版块
存档分类
最新评论

Java外挂开发入门示例

    博客分类:
  • java
阅读更多
由于原文较长,图又比较多,且CSDN博客图片目前无法外部访问|||,所以仅发来部分,全文请去鄙人CSDN的博客:http://blog.csdn.net/cping1982 ,希望51cto能早日提供博客迁移功能……

  示例运行结果如下图:
 

package org.loon.test.os;

/**
        * Copyright 2008
        *
        * Licensed under the Apache License, Version 2.0 (the "License"); you may not
        * use this file except in compliance with the License. You may obtain a copy of
        * the License at
        *
        * http://www.apache.org/licenses/LICENSE-2.0
        *
        * Unless required by applicable law or agreed to in writing, software
        * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
        * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
        * License for the specific language governing permissions and limitations under
        * the License.
        *
        * @project loonframework
        * @author chenpeng
        * @email:ceponline@yahoo.com.cn
        * @version 0.1
        */
import java.awt.Dimension;
import javax.swing.JButton;
import java.awt.Rectangle;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.EventQueue;
import java.awt.SystemColor;
import java.awt.Color;

import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JFrame;
import javax.swing.JTextField;
import javax.swing.JLabel;

import org.loon.framework.os.ASM;
import org.loon.framework.os.OSProcess;


public class TestCallForm extends JFrame {

                 private static final long serialVersionUID = 1L;

                 private JPanel jContentPane = null;

                 private JButton btnHP = null;

                 private JButton btnHome = null;

                 private JButton btnBaseEax = null;

                 private JButton btnIce = null;

                 private JButton btnFire = null;

                 private JButton btnSP = null;

                 private JTextField txtIntPtr = null;

                 private JLabel jLabel = null;

                 public TestCallForm() {
                                 super();
                                 initialize();
                 }

                 private void initialize() {

                                 this.setResizable(false);
                                 this.setSize(238, 315);
                                 this.setContentPane(getJContentPane());
                                 this.setTitle("Java外挂开发入门示例");
                                 this.setLocationRelativeTo(null);
                                 this.addWindowListener(new WindowAdapter() {
                                                 public void windowClosing(WindowEvent e) {
                                                                 System.exit(0);
                                                 }
                                 });
                 }

                 private JPanel getJContentPane() {
                                 if (jContentPane == null) {
                                                 jLabel = new JLabel();
                                                 jLabel.setBounds(new Rectangle(30, 20, 180, 30));
                                                 jLabel.setForeground(Color.white);
                                                 jLabel.setText("寄存器EAX值(针对本机环境)");
                                                 jContentPane = new JPanel();
                                                 jContentPane.setLayout(null);
                                                 jContentPane.setSize(new Dimension(236, 241));
                                                 jContentPane.setBackground(SystemColor.activeCaption);
                                                 jContentPane.add(getBtnHP(), null);
                                                 jContentPane.add(getBtnHome(), null);
                                                 jContentPane.add(getBaseIntPtr(), null);
                                                 jContentPane.add(getBtnIce(), null);
                                                 jContentPane.add(getBtnFire(), null);
                                                 jContentPane.add(getBtnSP(), null);
                                                 jContentPane.add(getTxtIntPtr(), null);
                                                 jContentPane.add(jLabel, null);
                                 }
                                 return jContentPane;
                 }

                 private JButton getBtnHP() {
                                 if (btnHP == null) {
                                                 btnHP = new JButton();
                                                 btnHP.setBounds(new Rectangle(15, 106, 95, 30));
                                                 btnHP.setText("吃血");
                                                 btnHP.addMouseListener(new java.awt.event.MouseAdapter() {
                                                                 public void mouseClicked(java.awt.event.MouseEvent e) {
                                                                                 clickEvent("hp");
                                                                 }
                                                 });
                                 }
                                 return btnHP;
                 }

                 private JButton getBtnHome() {
                                 if (btnHome == null) {
                                                 btnHome = new JButton();
                                                 btnHome.setBounds(new Rectangle(15, 195, 200, 30));
                                                 btnHome.setText("回城");
                                                 btnHome.addMouseListener(new java.awt.event.MouseAdapter() {
                                                                 public void mouseClicked(java.awt.event.MouseEvent e) {
                                                                                 clickEvent("home");
                                                                 }
                                                 });
                                 }
                                 return btnHome;
                 }

                 private JButton getBtnIce() {
                                 if (btnIce == null) {
                                                 btnIce = new JButton();
                                                 btnIce.setBounds(new Rectangle(120, 150, 95, 30));
                                                 btnIce.setText("冰系魔法");
                                                 btnIce.addMouseListener(new java.awt.event.MouseAdapter() {
                                                                 public void mouseClicked(java.awt.event.MouseEvent e) {
                                                                                 clickEvent("ice");
                                                                 }
                                                 });
                                 }
                                 return btnIce;
                 }

                 private JButton getBtnFire() {
                                 if (btnFire == null) {
                                                 btnFire = new JButton();
                                                 btnFire.setBounds(new Rectangle(15, 150, 95, 30));
                                                 btnFire.setText("火系魔法");
                                                 btnFire.addMouseListener(new java.awt.event.MouseAdapter() {
                                                                 public void mouseClicked(java.awt.event.MouseEvent e) {
                                                                                 clickEvent("fire");
                                                                 }
                                                 });
                                 }
                                 return btnFire;
                 }

                 private JButton getBtnSP() {
                                 if (btnSP == null) {
                                                 btnSP = new JButton();
                                                 btnSP.setBounds(new Rectangle(120, 106, 95, 30));
                                                 btnSP.setText("加蓝");
                                                 btnSP.addMouseListener(new java.awt.event.MouseAdapter() {
                                                                 public void mouseClicked(java.awt.event.MouseEvent e) {
                                                                                 clickEvent("sp");
                                                                 }
                                                 });
                                 }
                                 return btnSP;
                 }

                 private JButton getBaseIntPtr() {
                                 if (btnBaseEax == null) {
                                                 btnBaseEax = new JButton();
                                                 btnBaseEax.setBounds(new Rectangle(15, 235, 200, 30));
                                                 btnBaseEax.setText("获得本机EAX数值");
                                                 btnBaseEax.addMouseListener(new java.awt.event.MouseAdapter() {
                                                                 public void mouseClicked(java.awt.event.MouseEvent e) {
                                                                                 clickEvent("find");
                                                                 }
                                                 });
                                 }
                                 return btnBaseEax;
                 }

                 private JTextField getTxtIntPtr() {
                                 if (txtIntPtr == null) {
                                                 txtIntPtr = new JTextField();
                                                 txtIntPtr.setBounds(new Rectangle(18, 57, 199, 30));
                                                 txtIntPtr.setText("00D52070");
                                 }
                                 return txtIntPtr;
                 }

                 /**
                        * 触发事件
                        *
                        * @param eventName
                        */
                 private void clickEvent(final String eventName) {
                                 int pid = OSProcess.findWindowProcessId("TForm1", "游戏找CALL练习实例one");
                                 if (pid == 0) {
                                                 JOptionPane.showMessageDialog(this, "您的游戏程序尚未启动,外挂无法加载!");
                                                 return;
                                 }
                                 int eaxPtr = 0;
                                 try {
                                                 eaxPtr = ASM.getHexStringToInt(this.txtIntPtr.getText().trim());
                                 } catch (Exception ex) {
                                                 JOptionPane.showMessageDialog(this, "寄存器数值设定格式有误,外挂无法加载!");
                                                 return;
                                 }
                                 // 从基址获取寄存器中eax数值
                                 if ("find".equalsIgnoreCase(eventName)) {
                                                 this.txtIntPtr.setText(OSProcess.readProcessMemory(pid, 0x456D68));
                                 }
                                 // 实例化asm类以进行java与汇编混合操作
                                 ASM asm = new ASM();

                                 // 保存所有寄存器,即全部进栈
                                 asm._PUSHAD();
                                 // 示例程序执行时,目标寄存器eax中的必备数值(PS:在我的机器上是00D52070,
                                 // 而找Call测试程序作者提供的是00D51FE4,请自行查找。错误时目标程序将崩溃。)
                                 asm._MOV_EAX(eaxPtr);
                                 // 吃红
                                 if ("hp".equalsIgnoreCase(eventName)) {
                                                 asm._MOV_EDX(0x453028);
                                                 asm._CALL(0x452E98);
                                 }
                                 // 吃蓝
                                 else if ("sp".equalsIgnoreCase(eventName)) {
                                                 asm._MOV_EDX(0x453040);
                                                 asm._CALL(0x452E98);
                                 }
                                 // 火系魔法
                                 else if ("fire".equalsIgnoreCase(eventName)) {
                                                 asm._MOV_ECX(0x45309C);
                                                 asm._MOV_EDX(2);
                                                 asm._CALL(0x452DF8);
                                                 // 冰系魔法
                                 } else if ("ice".equalsIgnoreCase(eventName)) {
                                                 asm._MOV_ECX(0x45307C);
                                                 asm._MOV_EDX(1);
                                                 asm._CALL(0x452DF8);
                                 }
                                 // 回城
                                 else if ("home".equalsIgnoreCase(eventName)) {
                                                 asm._MOV_EDX(0x45305C);
                                                 asm._CALL(0x452E98);
                                 }
                                 // 还原所有寄存器,即全部出栈
                                 asm._POPAD();
                                 // 结尾标记,操作开始执行
                                 asm._RET();

                                 // 要求进行代码注入的进程id
                                 asm.doInject(pid);

                 }


                 public static void main(String[] args) {

                                 EventQueue.invokeLater(new Runnable() {
                                                 public void run() {
                                                                 TestCallForm callForm = new TestCallForm();
                                                                 callForm.setVisible(true);
                                                 }
                                 });

                 }

}

最后,再额外补充两点:

一,示例程序和真正的CALL外挂开发虽然原理上一样,工作量却是天差地别的,时间不充裕者请不要轻易尝试--|||

二,这个示例仅仅演示了localos的一部分功能,比如dll注入的接口在其中也提供了, 有兴趣者可以尝试一下,但要注意权限问题.          

程序源码及示例下载地址:http://code.google.com/p/greenvm/downloads/list (暂时先丢这里,源码在jar内)

OD下载地址:http://download.csdn.net/source/940795

PS:由于本例中有些敏感API的调用,运行时杀软对Javaw.exe报警请不要少见多怪...下个版本争取干掉杀软^^
本文出自 “Java究竟怎么玩” 博客,请务必保留此出处http://cping1982.blog.51cto.com/601635/125588
分享到:
评论
1 楼 coreymylife 2010-04-01  
我丝毫没看出来JAVA在这里面有什么作用。。。。

相关推荐

    JavaSLG游戏开发入门示例及源码

    JavaSLG游戏开发入门示例及其源码(源码在jar内)

    Java版AVG游戏开发入门示例

    这是一个Java版的桌面AVG游戏入门示例程序(源码在Jar内),演示了一个AVG游戏需要的基本功能。

    Mapxtreme_for_java_入门示例简单图解2.doc

    ### MapXtreme for Java 入门示例详解 #### 一、HTMLEmbeddedMapServlet实例解析 HTMLEmbeddedMapServlet是MapXtreme for Java提供的一种嵌入式地图服务实例,用于展示如何在Java Web应用中集成地图功能。此实例...

    Java开发从入门到精通 扶松柏,陈小玉编著 2016.09 随书光盘

    《Java开发从入门到精通》是由扶松柏和陈小玉两位专家编著的书籍,旨在帮助初学者和有一定基础的开发者系统学习和掌握Java编程技术。2016年9月出版的这本书包含了丰富的教学内容,配合随书光盘,提供了一套完整的...

    Java2.5D游戏开发入门示例代

    java游戏开发必备案例或者模板,盖晗主要功能游戏开发必备

    Mapxtreme for java 入门示例简单图解1

    在本文中,我们将深入探讨Mapxtreme for Java的入门示例,通过简单的图解来帮助初学者理解其核心概念和使用方法。 1. **Mapxtreme简介** Mapxtreme是Extremesoft公司开发的一款产品,它提供了丰富的API和控件,...

    java手机开发入门框架代码

    这个"java手机开发入门框架代码"很可能是为初学者准备的一个基础开发环境,包含了必要的库、示例代码和可能的开发工具。下面将详细阐述Java在手机开发中的应用及其相关知识点。 1. **Java ME简介**: Java ME是...

    Mapxtreme for java 入门示例简单图解3

    总的来说,MapXtreme for Java的入门示例展示了如何在JSP页面中嵌入地图,通过Servlet处理地图相关的请求,并利用`iframe`标签动态加载不同主题的地图。这仅仅是MapXtreme功能的冰山一角,深入学习和实践可以帮助...

    jquery json java 入门示例

    这个"jquery json java 入门示例"项目,结合了这些技术,旨在帮助初学者理解它们如何协同工作。下面将详细阐述这些技术及其在实际应用中的作用。 首先,jQuery是一个高效、简洁的JavaScript库,它简化了HTML文档...

    Java学习从入门到精通.pdf

    JDK是Java开发的工具包,包含了编写Java程序所需的编译器(javac)、运行环境(JRE)和其他工具。JRE是Java程序运行时环境,包含了Java虚拟机(JVM)和运行Java程序所必需的类库和组件。 JVM是Java程序能够跨平台...

    Java Web从入门到精通光盘源码1-15

    为了更好地利用这些资源,你需要安装Java开发环境(JDK)、选择一个Web容器,以及一个合适的IDE。然后,根据每个项目的README或指示,配置所需的jar文件,构建并运行源码,逐步深入学习和理解Java Web的各个方面。...

    初学者必看的JAVA开发入门(源代码)

    总的来说,"初学者必看的JAVA开发入门(源代码)"这个资源包旨在通过实际的代码示例和详尽的文档,帮助新手快速上手Java开发,理解编程的基本原理和最佳实践。配合这些资料,加上不断的实践和调试,相信初学者能够...

    Mapxtreme_for_java_入门示例简单图解1.doc

    确保Eclipse已安装在你的计算机上,并且版本支持Java开发。如果尚未安装,可以从官方网站下载最新版本。 #### 步骤2:创建新工程 在Eclipse中,通过“File”菜单选择“New”,然后选择“Java Project”,按照向导...

    Mapxtreme for java 入门示例简单图解2

    在这个"MapXtreme for Java 入门示例简单图解2"中,我们将深入探讨如何使用MapXtreme与Servlet技术相结合,以实现Web上的动态地图服务。 首先,Servlet是一种Java服务器端程序,用于处理HTTP请求并返回响应。在...

    Java从入门到精通核心技术教程全套千峰2021新版35G

    ├─第01章 Java开发入门 │ 002_Java开发入门_计算机基本概念与DOS命令.mp4 │ 003_Java开发入门_发展史体系与下载.mp4 │ 005_Java开发入门_HelloWorld案例与分析.mp4 │ 006_Java开发入门_JavaDoc与跨平台...

    Java 7入门经典

    书中包含大量的示例,清晰地解释了涉及的关键概念,演示了Java开发的复杂细节。在阅读各个章节的过程中,您还能获得无价的编程经验,并逐步开始编写功能全面的Java程序。Ivor Horton在编写入门类编程图书方面独具...

    Mapxtreme for java 入门示例简单图解2(bak)

    此外,`Mapxtreme for java 入门示例简单图解2`的压缩包很可能包含了更详细的步骤和示例代码,帮助你理解和实践Mapxtreme的Servlet使用。 总的来说,Mapxtreme for Java通过Servlet接口提供了一种高效且灵活的方式...

    JAVA6开发WebService JWS示例

    JAVA6 开发WebService JWS示例 WebService 概念 WebService 是一种软件系统,旨在支持跨网络的机器之间相互操作交互。它有一个机器可识别的描述格式,特别是 WSDL。不同的系统之间可以通过 SOAP 消息在规定的方式...

    java 从入门到精通 源代码

    Java编程语言是世界上最流行的编程语言之一,尤其在企业级应用开发中占据主导地位。本资源“java 从入门到精通 源代码”是针对初学者设计的一套完整的学习资料,旨在帮助读者从零基础逐步掌握Java编程的核心概念和...

    domino-web-java快速开发入门

    【标题】"Domino-Web-Java快速开发入门"是一个针对初学者的教程,旨在帮助开发者迅速掌握在Domino环境中进行Web应用的开发,并利用Java技术进行深入的系统集成和二次开发。本教程覆盖了从基础配置到实际编程的关键...

Global site tag (gtag.js) - Google Analytics