zoukankan      html  css  js  c++  java
  • C# 使用reflector与reflexil实现代码注入

    需求

    1.         双击窗体,弹出无标题的messageBox

    1.bmp

    源码

    using System;

    using System.Windows.Forms;

     

    namespace ReflexilDemo

    {

        public class DemoForm : Form

        {

            public DemoForm()

            {

                //InitializeComponent();

                this.Click+=DisplayResultButton_Click;

            }

     

            private void ComputeAndDisplay(decimal x, decimal y)

            {

                MessageBox.Show(String.Format("{0}+{1}={2}", x, y, x + y));

            }

     

            private void DisplayResultButton_Click(object sender, EventArgs e)

            {

                decimal a=3.0M;

                decimal b=6.0M;

                ComputeAndDisplay(a, b);

            }

           

            static void Main()

       

            {

                DemoForm df=new DemoForm();

                df.ShowDialog();

               

                Console.Read ();

            }

        }

    }

    2.         注入代码后,双击窗体,弹出有标题的messageBox

    2.bmp

     

    实现

    使用.NET ReflectorReflexil ,修改il代码实现。

    由源码可知,messagebox的调用是在ComputeAndDisplay方法中完成的,所以我们需要修改此方法的il

    实现步骤:

    Reflexil打开 ComputeAndDisplay

     

     

    1.jpg

     

     

    插入字符串

    2.jpg

    修改MessageBoxShowstring----àMessageBox.Show(string,string)

    3.jpg

    4.jpg

    5.jpg

     

     

     

    选择Show(string,string),双击

    6.jpg

     

    然后保存修改后的结果

    7.jpg

    再次运行

    8.jpg

  • 相关阅读:
    hdu 5475(打破固定思维OR线段树)
    hdu 2521 反素数(打表)
    hdu 4540(dp)
    hdu 4535(排列组合之错排公式)
    hdu 4530(数学)
    hdu 4528(搜索好题)
    hdu 4522(图论,构图)
    kalinux 换源
    用python进行wifi密码生成
    hashcat 中文文档
  • 原文地址:https://www.cnblogs.com/hbb0b0/p/1579307.html
Copyright © 2011-2022 走看看