fonge 发表于 2007-8-2 09:58:27

字符串隐藏一法

{**************************************************************

  
  code by fonge with almost pure delphi

                                                         2007-08-02

                                    --- 本期隐藏提示字符串专题

**************************************************************}

设计模式:

通过使用char数组来实现字符串隐藏;



具体请看示例代码:

==================================================

源码如下:

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    Button2: TButton;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
  t:array of char;     //用数组来实现隐藏
begin
  t:=Char(103);
  t:=Char(111);
  t:=Char(111);
  t:=Char(100);
  t:=Char(32);
  t:=Char(106);
  t:=Char(111);
  t:=Char(98);
  t:=Char(44);
  t:=Char(32);
  t:=Char(109);
  t:=Char(97);
  t:=Char(110);
  t:=Char(33);
  Showmessage(t);               //英文的“good job, man!”
end;


procedure TForm1.Button2Click(Sender: TObject);
var
  t:array of char;          //用数组来实现隐藏
begin
  t:=Char(185);
  t:=Char(167);
  t:=Char(207);
  t:=Char(178);
  t:=Char(196);
  t:=Char(227);
  t:=Char(163);
  t:=Char(172);
  t:=Char(215);
  t:=Char(162);
  t:=Char(178);
  t:=Char(225);
  t:=Char(179);
  t:=Char(201);
  t:=Char(185);
  t:=Char(166);
  t:=Char(193);
  t:=Char(203);
  t:=Char(163);
  t:=Char(161);
  Showmessage(t);                     //中文的“恭喜你,注册成功了!”
end;


end.





有人会觉得这样写代码很累,没关系,这里有批量生成上面结果的代码,我正用之...
且上面代码均为其生成之...
edit1.text输入你的提示字符串,edit2.text输入为你预定义的变量名,默认为't'...
点击即可生成像上面的代码,保存在ByTeCrypt.txt,直接copy使用之...

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    Edit1: TEdit;
    Edit2: TEdit;
    Label1: TLabel;
    GroupBox1: TGroupBox;
    Label2: TLabel;
    Label3: TLabel;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
    wFile:TextFile;
    wFileName,s,t:String;
    i:Integer;

begin
    s:=Edit1.Text;
    t:=Edit2.Text;
    if length(s)=0 then
        begin
           showmessage('Please input your string');
           exit;
        end;
    if length(t)=0 then
        begin
           showmessage('请输入变量名');
           exit;
        end;
    t:=Edit2.Text;
    wFileName:= 'ByTeCrypt.txt';
    AssignFile(wFile, wFileName);
    Rewrite(wFile);

    Writeln(wFile,'var');
    Writeln(wFile,'  '+t+':array of char;');                  //生成定义t:array of char
    Writeln(wFile,'begin');
    for i:=1 to Length(s) do
       begin
          Writeln(wFile, '  '+t+'['+IntToStr(i)+']:=Char('+IntToStr(Ord(s))+');');     //生成语句t[?]:=Char(?);
       end;
    Writeln(wFile,'  Showmessage('+t+');');
    Writeln(wFile,'end;');
    CloseFile(wFile);
    showmessage('执行完毕,请查看同目录下ByTeCrypt.txt文件!');

end;

end.









_____________________________
个性签名:附件又传不上来了...地

[ 本帖最后由 fonge 于 2007-8-2 10:14 编辑 ]

黑夜彩虹 发表于 2007-8-2 10:03:04

这个是不是不作软件安全设计 ?

倒比较合适技巧运用~~

还是支持一下!

fonge 发表于 2007-8-2 10:14:43

不了....

快雪时晴 发表于 2007-8-2 10:44:02

Tag it,或许以后用的上:P

mervyn_81 发表于 2007-8-2 12:35:59

直接用现成的算法比如DES加解密,密码自己设,比这个简单而且强度高

pengge 发表于 2007-8-2 12:39:32

这个隐秘性很好哦!:eek

lgjxj 发表于 2007-8-2 13:44:48

这种隐蔽效果不好,我早就使用过了,还是很容易被发现的

大菜一号 发表于 2007-8-2 16:53:31

支持,支持自家大哥!
用mfc类也是个不错的方法,在这里也支持一下笨哥:lol

diabloII 发表于 2007-8-2 17:29:08

我来解释一下吧.

原理是把字符转换为函数, 字符会被当成字符资源来处理, 反汇编之后可以立即看到,甚至用编辑器打开即可看到字符, 而函数需要调试跟踪才能还原.

x:=char(101) 和 x:="g" 编译后的代码是不一样的.

可以使用很多函数来达到此目的.

小子贼野 发表于 2007-8-2 23:12:32

感谢fonge的文章,实在是太有用了,直接copy:lol

壹只老虎 发表于 2007-8-3 02:51:19

支持自家兄弟!~````````

海风月影 发表于 2007-8-3 13:09:43

现在的木马都用这招~~~~~·
唉~

llll 发表于 2007-8-5 09:48:02

感谢fonge的文章,试一下看

此ID转让 发表于 2007-8-24 16:21:17

封在数组里,方法,巧妙,但不够安全!

free 发表于 2007-8-24 19:10:11

原帖由 海风月影 于 2007-8-3 13:09 发表 http://www.unpack.cn/images/common/back.gif
现在的木马都用这招~~~~~·
唉~
同意,后门中应用最多。:lol
页: [1] 2 3
查看完整版本: 字符串隐藏一法