首页
社区
课程
招聘
[讨论]反逆向学习(1)
2008-8-26 15:16 18104

[讨论]反逆向学习(1)

2008-8-26 15:16
18104
反逆向学习,下面的题要有点逆向技术基础
编译版本为VC6 release模式

include <windows.h>
include<stdio.h>
void main()
{
     char*str="hello world\n";

     //...在这里添加代码,让IDA打开后开不能直接看到"hello world\n"这样的字符串

     MessageBoxA(0,str,0,0);
}

[培训]《安卓高级研修班(网课)》月薪三万计划,掌握调试、分析还原ollvm、vmp的方法,定制art虚拟机自动化脱壳的方法

收藏
点赞7
打赏
分享
最新回复 (30)
雪    币: 65
活跃值: (811)
能力值: ( LV12,RANK:210 )
在线值:
发帖
回帖
粉丝
美丽破船 5 2008-8-26 22:04
2
0
一直没有人来玩吗?
那我就不客气了,我来抛砖引玉!
现丑了,大家别笑话我哦~~~

#include <windows.h>
#include<stdio.h>
#include<stdafx.h>

int APIENTRY WinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPSTR     lpCmdLine,
                     int       nCmdShow)
{
  char *str="hello world\n";
  
     //...在这里添加代码,让IDA打开后开不能直接看到"hello world\n"这样的字符串
  DWORD addrStr = (DWORD)str;
  str = NULL;

  addrStr += 11;
  char *tmp = (char *)addrStr;
  char tmpstr[10];
  int itmp = 1;
  for(int i = 10;i>=0;i--)
  {
    tmpstr[i] = *(tmp-itmp);
    itmp ++;
  }
  str = tmpstr;
  ::MessageBox(0,str,0,0);
  return 0;
}  

不知道用IDA能不能看到哦,我不会用IDA
上传的附件:
雪    币: 62
活跃值: (72)
能力值: ( LV5,RANK:70 )
在线值:
发帖
回帖
粉丝
creakerzgz 1 2008-8-26 22:35
3
0
贴一下我的小码码

#include "stdafx.h"
#include <windows.h>
#include <stdio.h>

#define NPASS 0x24
void fun(char* szstr,char *szDec);

int APIENTRY WinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPSTR     lpCmdLine,
                     int       nCmdShow)
{
        // TODO: Place code here.
        char* str="LAHHK.SKVH@.";
        char pstr[100] = {0};
        fun(str,pstr);
        MessageBoxA(0,pstr,0,0);
        return 0;
}

void fun(char *szstr,char *szDec)
{
        char sztmp[100] = {0};
        int i = 0;
        while (*szstr && i < 100-1)
        {
                sztmp[i] = *szstr ^ NPASS;
                szstr++;
                i++;
        }
        sztmp[i] = '\0';
        strcpy(szDec,sztmp);
}
雪    币: 62
活跃值: (72)
能力值: ( LV5,RANK:70 )
在线值:
发帖
回帖
粉丝
creakerzgz 1 2008-8-26 22:45
4
0
老大说我把"hello world\n"整没了
雪    币: 709
活跃值: (2240)
能力值: ( LV12,RANK:1010 )
在线值:
发帖
回帖
粉丝
sudami 25 2008-8-26 23:04
5
0
IDA中还能显示:
上传的附件:
雪    币: 709
活跃值: (2240)
能力值: ( LV12,RANK:1010 )
在线值:
发帖
回帖
粉丝
sudami 25 2008-8-26 23:09
6
0
其实在程序中就不需要把字符串明文的写出来。
xor后再写到code中去,需要时解密出来再调用就行了。

这样基本在IDA中看不到明文字符串了。

据我所知,GMER是这样做的。。。
雪    币: 8861
活跃值: (2369)
能力值: ( LV12,RANK:760 )
在线值:
发帖
回帖
粉丝
cvcvxk 10 2008-8-27 02:24
7
0
代码段可以写么?
可以写,很容易搞~~
雪    币: 846
活跃值: (221)
能力值: (RANK:570 )
在线值:
发帖
回帖
粉丝
笨笨雄 14 2008-8-27 02:40
8
0
条件不限,爱怎么玩怎么玩。。。就是因为有条件限制。。。所以MJ之前的那个进程保护才那么有难度

估计这样的题目,只有知道不多的唯一技巧。否则也不拿出来当题了

不考虑软件工程的问题,代码写得越垃圾,本身就越难逆。

但是考虑到自己调试排错的代价,以及代码的可读性,使用加密工具依然是首选,无论是源码加密再编译还是编译后再加密
雪    币: 846
活跃值: (221)
能力值: (RANK:570 )
在线值:
发帖
回帖
粉丝
笨笨雄 14 2008-8-27 03:07
9
0
int _tmain(int argc, _TCHAR* argv[])
{
        char*str="hello world\n";

        //...在这里添加代码,让IDA打开后开不能直接看到"hello world\n"这样的字符串

        char szBuff[0x100] = "";
        char *pDest = szBuff;

        while(*pDest ++ = *str ++);

        str = szBuff;

        MessageBoxA(0,str,0,0);

        return 0;
}

VS2005   RELEASE

.text:00401030 loc_401030:                             ; CODE XREF: _wmain+3Ej
.text:00401030                 mov     cl, ds:byte_4020F4[eax]
.text:00401036                 mov     [esp+eax+104h+Text], cl
.text:00401039                 add     eax, 1
.text:0040103C                 test    cl, cl
.text:0040103E                 jnz     short loc_401030
.text:00401040                 push    0               ; uType
.text:00401042                 push    0               ; lpCaption
.text:00401044                 lea     ecx, [esp+10Ch+Text]
.text:00401048                 push    ecx             ; lpText
.text:00401049                 push    0               ; hWnd
.text:0040104B                 call    ds:MessageBoxA

.rdata:004020EC                                         ; DATA XREF: ___report_gsfailure+D4o
.rdata:004020F4 byte_4020F4     db 68h                  ; DATA XREF: _wmain:loc_401030r
.rdata:004020F5 aElloWorld      db 'ello world',0Ah,0
.rdata:00402101                 align 8
.rdata:00402108                 unicode 0, <H>,0
雪    币: 63
活跃值: (17)
能力值: ( LV8,RANK:130 )
在线值:
发帖
回帖
粉丝
nevergone 3 2008-8-27 08:55
10
0
原来就这么整
偶还以为要加密呀一大堆的
雪    币: 249
活跃值: (10)
能力值: ( LV3,RANK:30 )
在线值:
发帖
回帖
粉丝
洋洋洒洒 2008-8-27 10:12
11
0
都已经....
char*str="hello world\n";


晕 原来我理解错了 .
用asm弄很简单 没有意义

sz db 'hello world ',13,10,0

mov ecx,0
loop sz+3
mov eax,sz - 3
add eax,3
invoke .............
雪    币: 7300
活跃值: (3758)
能力值: (RANK:1130 )
在线值:
发帖
回帖
粉丝
海风月影 22 2008-8-27 10:18
12
0
LZ是来宣传群号的吧
真正的大牛在群里面要不是灌水,要不是潜水
雪    币: 2071
活跃值: (77)
能力值: ( LV9,RANK:180 )
在线值:
发帖
回帖
粉丝
sessiondiy 4 2008-8-27 10:48
13
0
[QUOTE=笨笨雄;501532]int _tmain(int argc, _TCHAR* argv[])
{
  char*str="hello world\n";

  //...在这里添加代码,让IDA打开后开不能直接看到"hello world\n"这样的字符串

  char ...[/QUOTE]

我的IDA是清朝时期的. 这招没用.

.text:00401150            push    ebp
.text:00401151            mov     ebp, esp
.text:00401153            add     esp, 0FFFFFF00h
.text:00401159            push    esi
.text:0040115A            push    edi
.text:0040115B            mov     eax, offset aHelloWorld ; "hello world\n"
.text:00401160            mov     esi, offset unk_409128
.text:00401165            lea     edi, [ebp+Text]
.text:0040116B            mov     ecx, 40h
.text:00401170            repe movsd
.text:00401172            lea     edx, [ebp+Text]
.text:00401178 loc_401178:
.text:00401178            mov     cl, [eax]
.text:0040117A            inc     eax
.text:0040117B            inc     edx
.text:0040117C            mov     [edx-1], cl
.text:0040117F            test    cl, cl
.text:00401181            jnz     short loc_401178
.text:00401183            lea     eax, [ebp+Text]
.text:00401189            push    0               ; uType
.text:0040118B            push    0               ; lpCaption
.text:0040118D            push    eax             ; lpText
.text:0040118E            push    0               ; hWnd
.text:00401190            call    MessageBoxA
.text:00401195            xor     eax, eax
.text:00401197            pop     edi
.text:00401198            pop     esi
.text:00401199            mov     esp, ebp
.text:0040119B            pop     ebp
.text:0040119C            retn
.t
雪    币: 846
活跃值: (221)
能力值: (RANK:570 )
在线值:
发帖
回帖
粉丝
笨笨雄 14 2008-8-27 10:58
14
0
编译器,所以我注明环境了,还有贴出汇编代码,你编译出的东西跟我编译出的不同
雪    币: 2071
活跃值: (77)
能力值: ( LV9,RANK:180 )
在线值:
发帖
回帖
粉丝
sessiondiy 4 2008-8-27 11:14
15
0
能否提供你的exe. 我想试试早期的IDA效果.
谢谢!
雪    币: 203
活跃值: (28)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
reXeh 2008-8-27 11:33
16
0
用SMC应该可以.....
雪    币: 846
活跃值: (221)
能力值: (RANK:570 )
在线值:
发帖
回帖
粉丝
笨笨雄 14 2008-8-27 12:15
17
0
你说得没错,刚试了下,的确也会受IDA版本影响。这是修改后的两个版本。依然是VS2005 RELEASE方式,公司统一用的,家里的电脑为了工作方便也是装的2005,没有VC6。方法1,即使完全不用,内存依然会存在那个字符串的。附件是编译后的EXE

int FuckStrRef1()
{
	char*str="hello world\n";

	//...在这里添加代码,让IDA打开后开不能直接看到"hello world\n"这样的字符串

	char szBuff[0x100] = "";
	szBuff[0] = str[0];
	szBuff[1] = str[1];
	szBuff[2] = str[2];
	szBuff[3] = str[3];
	szBuff[4] = str[4];
	szBuff[5] = str[5];
	szBuff[6] = str[6];
	szBuff[7] = str[7];
	szBuff[8] = str[8];
	szBuff[9] = str[9];
	szBuff[10] = str[10];
	szBuff[11] = str[11];
	szBuff[12] = str[12];
	szBuff[13] = str[13];
	szBuff[14] = str[14];
	str = szBuff;

	MessageBoxA(0,str,0,0);

	return 0;
}


int FuckStrRef2()
{
	char*str="hello world\n";

	//...在这里添加代码,让IDA打开后开不能直接看到"hello world\n"这样的字符串

	char szBuff[0x100] = "";
	szBuff[0] = *str;
	char *pDest = &szBuff[1];
	const char *pSrc = str + 1;
	while(*pDest++ = *pSrc ++);
	str = szBuff;

	MessageBoxA(0,str,0,0);

	return 0;
}
上传的附件:
雪    币: 2071
活跃值: (77)
能力值: ( LV9,RANK:180 )
在线值:
发帖
回帖
粉丝
sessiondiy 4 2008-8-27 12:39
18
0
用IDA 4.3  二者在code都看不到 'Hello World' 的提示注释.
and 二种都是以byte为基础弄到Stack供MessageBoxA使用
亦即用的不是 .data 的 hello world
也不知楼主的的想法'要求为何? 没写清楚.
雪    币: 203
活跃值: (28)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
reXeh 2008-8-27 12:50
19
0
忘记SMC是在运行时才起作用的了,真不好意思
雪    币: 200
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
jydyb 2008-8-27 12:54
20
0
逆向啊...昨天看到一个驱动....很花...有时间给大家逆一下
雪    币: 342
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
haras 2008-8-27 12:59
21
0
modify...
雪    币: 62
活跃值: (72)
能力值: ( LV5,RANK:70 )
在线值:
发帖
回帖
粉丝
creakerzgz 1 2008-8-27 21:19
22
0
终于做出来了

#include "stdafx.h"
#include <windows.h>
#include <stdio.h>

#define N 41000         //N必须大于字符串的长度
char* fn(char* str);

int APIENTRY WinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPSTR     lpCmdLine,
                     int       nCmdShow)
{
        char *str = "Hello World\n";
        int i = (int)&str[N];
        MessageBoxA(0,fn((char*)i),0,0);
        return 0;
}
char* fn(char* str)
{
        return str - N;
}
雪    币: 2071
活跃值: (77)
能力值: ( LV9,RANK:180 )
在线值:
发帖
回帖
粉丝
sessiondiy 4 2008-8-27 21:26
23
0
这一条已不符合要求了
MessageBoxA(0,fn((char*)i),0,0);

题目是:
MessageBoxA(0,str,0,0);
雪    币: 62
活跃值: (72)
能力值: ( LV5,RANK:70 )
在线值:
发帖
回帖
粉丝
creakerzgz 1 2008-8-27 21:45
24
0
这下好了

#include "stdafx.h"
#include <windows.h>
#include <stdio.h>

#define N 41000         //N必须大于字符串的长度
char* fn(char* str);

int APIENTRY WinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPSTR     lpCmdLine,
                     int       nCmdShow)
{
        char *str = "Hello World\n";
    str = fn((char*)&str[N]);
        MessageBoxA(0,str,0,0);
        return 0;
}
char* fn(char* str)
{
        return str - N;
}
雪    币: 62
活跃值: (72)
能力值: ( LV5,RANK:70 )
在线值:
发帖
回帖
粉丝
creakerzgz 1 2008-8-28 21:09
25
0
太笨了,弄了3天才搞定

//第一期学习内容 harass 2008-8-26
//请大家做做 做出后提交群里写上你大名,然后讨论,把大家的经验集起来
//取长补短

#include "stdafx.h"
#include <windows.h>
#include <stdio.h>

int APIENTRY WinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPSTR     lpCmdLine,
                     int       nCmdShow)
{
        char *str = "Hello World\n";

        char *pc = &"Hello World\n"[10000];

        __asm
        {
                mov                eax, pc
                sub                eax, 10000
                mov                pc, eax
        }
        str = pc;

       
        MessageBoxA(0,str,0,0);
        return 0;
}
游客
登录 | 注册 方可回帖
返回