getit 攻防世界 (有个坑)

分析代码
常规题,但有个坑

int __cdecl main(int argc, const char **argv, const char **envp)
{
  char v3; // al
  __int64 v5; // [rsp+0h] [rbp-40h]
  int i; // [rsp+4h] [rbp-3Ch]
  FILE *stream; // [rsp+8h] [rbp-38h]
  char filename[8]; // [rsp+10h] [rbp-30h]
  unsigned __int64 v9; // [rsp+28h] [rbp-18h]
 
  v9 = __readfsqword(0x28u);
  LODWORD(v5) = 0;
  while ( (signed int)v5 < strlen(s) )
  {
    if ( v5 & 1 )
      v3 = 1;
    else
      v3 = -1;
    *(&t + (signed int)v5 + 10) = s[(signed int)v5] + v3;
    LODWORD(v5) = v5 + 1;
  }
  strcpy(filename, "/tmp/flag.txt");
  stream = fopen(filename, "w");
  fprintf(stream, "%s\n", u, v5);
  for ( i = 0; i < strlen(&t); ++i )
  {
    fseek(stream, p[i], 0);
    fputc(*(&t + p[i]), stream);
    fseek(stream, 0LL, 0);
    fprintf(stream, "%s\n", u);
  }
  fclose(stream);
  remove(filename);
  return 0;
}

分析关键的地方:

LODWORD(v5) = 0;
  while ( (signed int)v5 < strlen(s) )
  {
    if ( v5 & 1 )
      v3 = 1;
    else
      v3 = -1;
    *(&t + (signed int)v5 + 10) = s[(signed int)v5] + v3;
    LODWORD(v5) = v5 + 1;
  }

查看s和t变量的值,

s:

.data:00000000006010A0 s
db ‘c61b68366edeb7bdce3c6820314b7498’,0

t:

.data:00000000006010E1
aHarifctf???
db ‘harifCTF{???}’,0

请认真观看,t的代码组成

python脚本:



s='c61b68366edeb7bdce3c6820314b7498'

t1='harifCTF{????????????????????????????????}'

t=[]

for x in t1:
    t.append(x)

v6=0

while v6

打出一个错的。

原来有个坑,
观看题目
SharifCTF 2016

而t中少了S

怪不得我一直数不到十个,对应不起来,

原来故意隐藏起来了。

加上S

就OK了

ps:经验:要严格记住flag的形式!根据形式找或者猜想答案!

你可能感兴趣的:(攻防世界)