Obfuscated C++

原创 2001年11月27日 17:27:00

 

Obfuscated C++

作者:Robert Murray

译者:袁小凯

Email – ccplusplus@21cn.com


译序

在我看到这个题目后,就想试着写出其输出。结果和我写的相同,但是,我没有喜乐,而是一脸的迷惑。因为我不知道如何用我有限的C++知识去解释为什么,我只是猜对的,可悲吧!但看了结论后,一切都是那么的简单,那么明了。帖上这篇文章,让更多的人消除这该死的迷惑。但我自知水平有限,翻译的不好,也煅炼一下。请大家不要见笑,请多多批评。

正文

    以下是这段令人迷惑的C++程式:

#include <iostream>

using namespace std;

 

struct C;

 

struct D {

    void operator*(D) { cout << "one/n"; }

} C;

 

struct E {

    void operator*(E) { cout << "two/n"; }

} F;

 

struct F;

 

int main(){

    C* C;

    F* F;

    return 0;

}

这个难题的关健在于主函式main中那两条语句的含义。依照C++语法,看起来好像是定义两个指针。那空格是罪魁祸首,它极易使人产生这种误解。名字(C or F)在相同的作用范围(全局)内被同时声明为类名和对象名,这种情况下, 不管那个在先那个在后,对象名会屏蔽类名。使用类名时必须使用清楚的型别指示(如:struct C* C;)。注 [1]

    因此,函式main中的每条语句是一个两元operator*函式的调用。它和下面的程式有着相同的功效:

int main(){

    C.operator*(C); // Invokes D::operator*(D)

    F.operator*(F); // Invokes E::operator*(E)

return 0;

}

程式输出为:

one

two

 

这就是令人迷惑的原因,亲爱的C++朋友们!

作者后语:

This is my last "Obfuscated C++" Column. I've been writing this column for a bit over 11 years now, ever since the first issue of C++ Report was published in January 1989. C++ has grown over the years, as have I, and my life has taken me in other directions. C++ is no longer a part of what I do, so it's time to put this column to bed. I've had the pleasure of working with a lot of talented people over the years; you know who you are. Thanks for the ride, I'll never forget it!

注:

1.The class name can only be invoked using an elaborated type specifier (e.g. struct C* C;,).

 


About the Author

As Red Sky's Chief Technology Officer, Rob Murray is responsible for tracking and evaluating current and new Internet technologies. These technologies provide the "plumbing" that is critical to Web-based solutions that are full-featured, robust and fast. "Focus is key," he says. "New tools appear on the market every day. We identify and adopt those technologies that are the very best match for our skills and our customers' needs. Most don't make the cut." Before stepping into the CTO role, Mr. Murray was the Director of Systems Development for the Irvine office of Nuforia, where he was responsible for all fulfillment work in that office. An industry veteran, Mr. Murray spent the first 14 years of his career at AT&T Bell Laboratories, where he worked on object-oriented software and tools, including the first publicly released C++ compiler. He was the founding editor of the C++ Report in 1988, and has been a regular contributor to this respected trade magazine. Mr. Murray has been a prepublication reviewer for many technical textbooks, including important works by C++ inventor Bjarne Stroustrup and Java inventor James Gosling. His own book, C++ Strategies and Tactics (Addison-Wesley 1993), is currently in its seventh printing and has been translated into French and Japanese. His mission statement? "I have to keep three sets of people happy: my customers (who pay the bills); my employees and co-workers (who make successful projects happen); and my bosses (who sign my paycheck). One of the nice things about Red Sky is that if I take care of sets one and two, set three takes care of itself." Mr. Murray has a BS in Computer Science from Michigan State University, and a Master's in Computer Science from the University of Southern California.

怎么处理加密解密核心问题

net保护可以从两个方面去做,1:流程混淆(有些带类名字段混淆),2:整体加密。 第一种虽然可以看到部分代码,但是你会看到大堆的 goto 或是   switch,更多的显示 // This ite...
  • luyuncsd123
  • luyuncsd123
  • 2012年11月01日 00:11
  • 1071

Obfuscated C++

你能预测下面这个程序的输出结果吗:#include using namespace std;namespace N { void g(int) { cout ...
  • linghushaonian
  • linghushaonian
  • 2002年04月15日 09:08
  • 434

obfuscated

wget -O ofcssh.tar.gz https://github.com/brl/obfuscated-openssh/tarball/master
  • tg5156
  • tg5156
  • 2014年08月12日 00:12
  • 519

配合混淆ssh(obfuscated)的proxy智能线路选择

也不知道怎么了,一些网站访问总是不稳定, 速度也不能令人满意(呵呵,你懂的),总是上演道高一尺魔高一丈的激情攻防游戏。最近又学习了obfuscated ssh,作者08年开发出来但一直没受到重视,甚至...
  • xuyaqun
  • xuyaqun
  • 2015年01月23日 11:23
  • 3287

.net程序可以轻松被反编译 大家都是采取什么措施防御呢

听说要用 混淆器 查了查资料 混淆器好像也能被反编译 这微软到底是想干什么啊?请高人指点指点,怎么才能做到不让反编译,然后说下用哪个混淆器好吗?基本上不太可能做到完全不让反编译。也就是能给增加一点难度...
  • h57020877
  • h57020877
  • 2010年10月02日 10:41
  • 1229

Obfuscated Regex

Regex is quite useful to obfuscated.for example, grabbing assets from intenet web page, the key thin...
  • sanoboy
  • sanoboy
  • 2010年07月29日 00:15
  • 399

unity3d 混淆

内容提要:Unity引擎下的代码保护,由于Unity引擎的一些特殊性,实行起来较为复杂,在国内外业界并没有现成的方案。笔者通过在《QQ乐团》项目上的实际尝试,得出了一种具体可行,能够有效保护代码逻辑的...
  • xfnjlove
  • xfnjlove
  • 2014年07月08日 19:34
  • 661

dotfuscator使用方法

转载自:http://hi.baidu.com/free3people/item/0fba87d34091df15d80e4400 dotfuscator如何对.net程序进行混淆保护对于程序代码的...
  • laipixiaoxi
  • laipixiaoxi
  • 2015年07月17日 17:02
  • 673

Obfuscated ssh Client under Linux

SSH is a powerful tool for astronomers. We often use it to download observation data from the observ...
  • s464036801
  • s464036801
  • 2013年03月12日 15:26
  • 925

Weevely使用及源码分析(二)

1. 定义(术语、名词解释)    客户端:运行Weevely进程的计算机。    服务端:存有PHP木马的服务器。 2. 协议交互流程    在客户端,Weevely每执行一条命令就通过H...
  • yaofeiNO1
  • yaofeiNO1
  • 2018年01月30日 09:14
  • 995
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:Obfuscated C++
举报原因:
原因补充:

(最多只允许输入30个字)