mark一下,以后分析

原文:http://sibears.ru/labs/ASIS-CTF-Quals-2016-Leaked_License/

[ASIS CTF Quals 2016] - 泄露许可证[64]

GROKE

, 2016年5月9日

我从朋友的朋友的老兄那里借了这个软件许可证和图书馆!如果我可以伪造今年竞争计算机ID的许可证,那就太好了。

我们获得了Leaked_Lisence.dll和文件admin@nsa.gov.us_license

Groke @ MacBook-Air-groke:〜/ ctf / asis / Leaked_Lisence $ cat admin \ @nsa.gov.us_license 
7e43ecf0b4e27dacfb5e613437b17acb46e8deab2c70510dc71844b492a691ec

在dll中,导出一个验证方法,其参数占用48个字节。如果稍微查看一下该文件,可以看到源代码是C ++中的:

“ios_base :: eofbit set”
“ios_base :: failbit set”
“ios_base :: badbit set”

然后假设参数是std :: string。使用代码,我们恢复以下形式的字符串:

struct  magic {
union {
char * s1 ;
char s2 [ 16 ];
};
int size ;
int real_length ;
};

将此结构添加到id后,很明显验证函数按值接受2个这样的行。

实际上,算法本身如下(伪Python):

DEF  验证(ID , 许可证):
与 开放(“secret.key” ) 作为与 secret_file:
秘密 = secret_file 。read ()
checkString = sha256 (secret )。解码('hex' )
而 len (id ) < 32 :
id = id + id
secretFromUser = “”
license = license 。解码('hex' )
for x in xrange (32 ):
secretFromUser + = chr (ord (id [ i ]) ^ ord (license [ i ]))
check2 = sha256 (secretFromUser )。解码('hex' )
如果 check2 。equal (checkString ):
返回 1
返回 0

显然,这足以让我们从此许可证中获取secretFromUser并在其基础上生成我们自己的许可证。有一个问题,因为不清楚许可证的ID是什么。有一种理论认为某处出现了错误,并且编写了以下文件以便用笔感觉:

#include“stdafx.h”
#include <iostream>
#include <string>
#include <Windows.h> struct magic {
union {
char * s1 ;
char s2 [ 16 ];
};
int size ;
int real_length ;
}; magic * get_my_magic (char * buf ){
struct magic * ret = (magic * )malloc (24 );
int ln = strlen (buf );
ret - > s1 = (char * )malloc (ln );
ret - > size = ln ;
ret - > real_length = ln ;
strncpy (ret - > s1 , buf , ln );
return语句 的RET ;
} int main () {
magic * id = get_my_magic (“admin@nsa.gov.us” );
magic * key = get_my_magic (“7e43ecf0b4e27dacfb5e613437b17acb46e8deab2c70510dc71844b492a691ec” );
auto hMod = LoadLibraryA (“Leaked_Lisence.dll” );
auto myFunc = (int (* )(magic , magic ))GetProcAddress (hMod , “verify” );
汽车 s = myFunc (* id , * key );
std :: cout << s << std :: endl ;
}

需要魔术结构,因为工作室中的sizeof(std :: string)<> 24

然而,实践表明理论计算是正确的,我们回到了id的搜索。尝试过“quals2016@asis-ctf.ir”后,我们获得了以下许可证:
6e52e0f5a99023eeac30672828ec22db53ea9dab30414a1fca4511ebd5bea4fe 
,结果就是flag:

ASIS{6e52e0f5a99023eeac30672828ec22db53ea9dab30414a1fca4511ebd5bea4fe}

最新文章

  1. 使用xtrabackup备份mysql数据库
  2. OpenMP之枚举排序
  3. 巧用JS内置对象Function
  4. Winform调用系统的剪切,复制,粘贴文件功能
  5. Tomcat中xml文件引入各种schma xsd问题原理
  6. Get code int value for different encoding
  7. ArrayList源码解析
  8. Xcode8.2 继续使用插件
  9. panel 绑定鼠标滚轮事件
  10. DIV 和 SPAN 区别
  11. LAMP平台部署(转)
  12. BBS论坛(八)
  13. Chapter 5 Blood Type——11
  14. Web前端:博客美化:三、右上角的Github Ribbon
  15. ORACLE SPA
  16. Java 9 中的 9 个新特性你知道吗
  17. 洛谷 p1352 没有上司的舞会 题解
  18. cocos2d-js 入门 (主要是HTML5)
  19. Kafka controller重设计
  20. HTML转义

热门文章

  1. Vue computed props pass params
  2. ACM-ICPC国际大学生程序设计竞赛北京赛区(2015)网络赛
  3. js 深入原理讲解系列-currying function
  4. CSS Box Model All In One
  5. vuex &amp; redux
  6. 1月加密货币交易所访问量破3亿!NGK生态星空计划、NGK生态所带来双重利好!
  7. 全球首发—鸿蒙开源平台OpenGL
  8. VMware安装centos.6.8无法访问主机的问题
  9. nginx判断状态脚本
  10. Java基本概念:内部类