Java外挂开发入门示例

简介:
  由于原文较长,图又比较多,且CSDN博客图片目前无法外部访问|||,所以仅发来部分,全文请去鄙人CSDN的博客: [url]http://blog.csdn.net/cping1982[/url]  ,希望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
        *
        * [url]http://www.apache.org/licenses/LICENSE-2.0[/url]
        *
        * 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:[email]ceponline@yahoo.com.cn[/email]
        * @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注入的接口在其中也提供了, 有兴趣者可以尝试一下,但要注意权限问题.           

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

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

 PS:由于本例中有些敏感API的调用,运行时杀软对Javaw.exe报警请不要少见多怪...下个版本争取干掉杀软^^


本文转自 cping 51CTO博客,原文链接:http://blog.51cto.com/cping1982/125588


相关文章
|
3天前
|
架构师 前端开发 Java
Java开发工程师的职业规划应该是什么样的?
Java开发工程师的职业规划涵盖多个阶段,包括初入行业(0-1年)、技能提升(1-3年)、技术专家(3-5年)及管理或专家路线选择(5年以上)。各阶段设定了明确的技能要求与职业目标,从掌握Java基础、常用框架到深入研究高级技术、微服务架构乃至担任管理职务或成为技术专家。通过持续学习与实践,结合个人兴趣,Java工程师可在技术或管理领域找到合适的发展方向,最终实现职业成功。
184 83
|
1天前
|
前端开发 JavaScript Java
基于Java+Springboot+Vue开发的音乐推荐管理系统
基于Java+Springboot+Vue开发的音乐推荐管理系统(前后端分离),这是一项为大学生课程设计作业而开发的项目。该系统旨在帮助大学生学习并掌握Java编程技能,同时锻炼他们的项目设计与开发能力。通过学习基于Java的音乐推荐管理系统项目,大学生可以在实践中学习和提升自己的能力,为以后的职业发展打下坚实基础。
31 8
基于Java+Springboot+Vue开发的音乐推荐管理系统
|
1天前
|
前端开发 JavaScript Java
基于Java+Springboot+Vue开发的母婴商城管理系统
基于Java+Springboot+Vue开发的母婴商城管理系统(前后端分离),这是一项为大学生课程设计作业而开发的项目。该系统旨在帮助大学生学习并掌握Java编程技能,同时锻炼他们的项目设计与开发能力。通过学习基于Java的网上母婴商城管理系统项目,大学生可以在实践中学习和提升自己的能力,为以后的职业发展打下坚实基础。
19 7
基于Java+Springboot+Vue开发的母婴商城管理系统
|
2天前
|
前端开发 JavaScript Java
基于Java+Springboot+Vue开发的在线摄影预约管理系统
基于Java+Springboot+Vue开发的在线摄影预约管理系统(前后端分离),这是一项为大学生课程设计作业而开发的项目。该系统旨在帮助大学生学习并掌握Java编程技能,同时锻炼他们的项目设计与开发能力。通过学习基于Java的在线摄影管理系统项目,大学生可以在实践中学习和提升自己的能力,为以后的职业发展打下坚实基础。
17 8
基于Java+Springboot+Vue开发的在线摄影预约管理系统
|
2天前
|
前端开发 JavaScript Java
基于Java+Springboot+Vue开发的农产品商城管理系统
基于Java+Springboot+Vue开发的农产品商城管理系统(前后端分离),这是一项为大学生课程设计作业而开发的项目。该系统旨在帮助大学生学习并掌握Java编程技能,同时锻炼他们的项目设计与开发能力。 通过学习基于Java的农产品商城管理系统项目,大学生可以在实践中学习和提升自己的能力,为以后的职业发展打下坚实基础。
16 5
基于Java+Springboot+Vue开发的农产品商城管理系统
|
2天前
|
前端开发 JavaScript Java
基于Java+Springboot+Vue开发的新闻管理系统
基于Java+Springboot+Vue开发的新闻管理系统(前后端分离),这是一项为大学生课程设计作业而开发的项目。该系统旨在帮助大学生学习并掌握Java编程技能,同时锻炼他们的项目设计与开发能力。通过学习基于Java的新闻管理系统项目,大学生可以在实践中学习和提升自己的能力,为以后的职业发展打下坚实基础。
16 3
基于Java+Springboot+Vue开发的新闻管理系统
|
3天前
|
前端开发 JavaScript Java
基于Java+Springboot+Vue开发的体育用品商城管理系统
基于Java+Springboot+Vue开发的体育用品商城管理系统(前后端分离),这是一项为大学生课程设计作业而开发的项目。该系统旨在帮助大学生学习并掌握Java编程技能,同时锻炼他们的项目设计与开发能力。通过学习基于Java的体育用品商城管理系统项目,大学生可以在实践中学习和提升自己的能力,为以后的职业发展打下坚实基础。
15 2
基于Java+Springboot+Vue开发的体育用品商城管理系统
|
3天前
|
设计模式 架构师 Java
Java开发工程师转架构师需要学习什么
Java开发工程师转型为架构师需掌握多项技能:精通Java及框架、数据库与分布式系统;熟悉设计模式与架构模式;积累项目经验;提升沟通与领导力;持续学习新技术;培养系统设计与抽象能力;了解中间件及开发工具;并注重个人特质与职业发展。具体路径应结合个人目标与实际情况制定。
34 18
|
1天前
|
人工智能 前端开发 Java
Java开发工程师转哪个行业比较好?
Java开发工程师转哪个行业比较好?
17 2
|
1天前
|
小程序 前端开发 JavaScript
Java开发工程师转小程序开发的前景如何?
Java开发工程师转小程序开发的前景如何?
9 0