Python Decorator的一些细节

装饰器函数并不是在被修饰函数调用的时候才执行,而是修饰语句所在的代码块被执行的时候执行。

而且当一个文件(模块)被import的时候,文件内的所有装饰器就会被激活执行。因为装饰器语句相当于文件中的普通语句,而非函数声明或者类声明的一部分。

用以下代码方便理解:

# sample.py

def decorator_function(func):
    print "executing the decorator."

    def wrapper(*args, **kwargs):
        print "decorated function is executing."
        return func(*args, **kwargs)

    return wrapper


print "this python file is executing."


@decorator_function
def test_function(sth):
    print "blablabla"+sth

test_function("yeah")

而当我们对一个类里面的普通函数使用修饰符进行修饰的时候,然后我们正常调用这一函数(通过实例化的对象调用),会报错提示这一函数变成了unbound method,缺少了类中函数默认的首参数self。这一问题是由于经过装饰器修饰的函数,实际上是被传递到了装饰器函数中,在这个装饰器函数中被独立调用的,而非被其原先所在的类对象调用。因此在这个装饰器函数中,没有其原来所在的类来对它进行调用,导致提示unbound method.

2016/3/31 19:14 下午 posted in  Python

通过EMET来禁用EMET——EMET的禁用与绕过思路讲解

原文链接:https://www.fireeye.com/blog/threat-research/2016/02/using_emet_to_disabl.html
注:本文并未由任何媒体进行翻译发布。搜索引擎中搜到的国内媒体仅为标题翻译进行推送。

微软的Enhanced Mitigation Experience Toolkit (EMET)是一项提高程序安全性的项目。它通过动态链接库(DLL)来运行在『受保护』的程序中,并且做一些修改来使得破解更加困难。

我们已经见过很多次EMET在过去的研究或者攻击中被绕过了[2, 3, 4, 5, 6, 7, 8]。通常来说,微软都是通过修改或者增加一些安全设计来搞定现有的绕过问题。 EMET的设计目的是使得破解行为的成本升高,而不是一个『傻瓜式的防破解方案』[1]。所以,只要拥有在进程空间中读写的能力,理论上我们就能搞定所有的安全设计[2]。

如果一个攻击者能够毫不费力地绕过EMET,那这就完全打破了EMET提高破解成本的最初目的。我们在新技术那段展示了一种禁用EMET的技术。微软在EMET5.5中打了个补丁来解决这个问题。

讨论完这个新技术之后,我们来说说之前提到的用来绕过或搞掉EMET的那个技术。如果你想了解关于EMET是怎么实现保护程序的,请参考附录。

Read more   2016/3/27 11:46 上午 posted in  Security Info

Ideas for Neural Network

  • Use genetic algorithm to evolve the parameters in Neural Network, to make a self-develop algorithm.
    • automatically find and make training set from search engine
    • the paremeters include:
      • learning rate
      • iteration times
      • regularization term \(\lambda\)
      • activation function
      • number of hidden layers(units)
Read more   2016/3/4 20:44 下午 posted in  Pattern Recognition

Notes for Neural Network

Notes:

  • If we set the initial \(\Theta\) be the same, the units in next layer with the same \(x_i\) will get the same result, then all units in the same layer will get the same output. At last, the cost function will also get same cost, so we will update the \(\Theta\) with same step.

  • seems \(\delta^{(l)}_{i}\) means the cost of \(i_{th}\) unit in the \(l_{th}\) layer

Read more   2016/3/3 0:57 上午 posted in  Pattern Recognition

Note for "Thesis - Behavior of Machine Learning Algorithms in Adversarial Environments.pdf"(1)

1.1 Motivation and Methodology

Learning approach is well-suited to the scenario when:

  1. The process is too complex to designed for human operator
  2. Requirement of dynamical development
Read more   2016/2/4 16:55 下午 posted in  Adversary Learning

封装,与协议的分层

TODO: 为何要分层

要理解协议的分层,若是了解编程理念中的『封装』,可能更有助于理解分层的意义。

『封装』,狭义上指的是编写程序时,通过把一些重复操作的代码写成一个单独的函数,这就可以叫做一个简单的封装。

而我对于封装的理解,举个例子,当你忙了一天回到家,站在你的家门口,想要打开你家的房门时,你需要做以下事情:

st=>start: 站在家门口
op1=>operation: 拿出钥匙
op2=>operation: 找到对应的钥匙
op3=>operation: 把钥匙插到锁孔中
op4=>operation: 旋转钥匙
op5=>operation: 拉开门
op6=>operation: 拔出钥匙
end=>end: 开门结束

st->op1->op2->op3->op4->op5->op6->end
Read more   2016/1/29 18:41 下午 posted in  TCP/IP

网络协议

连接不同的计算机是非常有必要的,能够大幅度提升工作效率。

比如:一个工作需要经过三个步骤,分别是步骤A/步骤B/步骤C。三个步骤分别由三台不同的计算机A/B/C执行。

com_A=>operation: 计算机A
com_B=>operation: 计算机B
com_C=>operation: 计算机C


com_A->com_B->com_C
Read more   2016/1/29 18:40 下午 posted in  TCP/IP

Notes for "ICMLC2009-FabioRoli.pdf"

Understanding:

1. What is adversarial classification? Basic concepts and motivations

The Classifier which take the adversary actions into account. It can develop according to the adversary actions.

Its motivations is that the classical model cannot perform well in adversarial environments. Because the classical model is build and set up base on the random noise, it’s also use for normal random noise environment. But in adversarial environment, the noise it face is adversarial noise, which is generated by adversary on purpose.

Read more   2016/1/29 14:14 下午 posted in  Adversary Learning

新建VPS应该做的事情

  1. 创建root密码

    passwd
    
  2. 安装oh-my-zsh

    这里是debian, 所以使用apt-get

    1. 当然,首先,update & upgrade apt-get

      apt-get update; apt-get upgrade
      
    2. 安装zsh、git、pip

      sudo apt-get install zsh git python-pip python-dev
      
    3. 安装oh my zsh

      wget https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O - | sh
      
Read more   2016/4/9 21:8 下午

2015暑假

晒猫

正式开始学习技术以来的第二个暑假了,上一个暑假的效率之高,可能没有什么机遇的话挺难超越的了。

先放一张这次暑假一开始的计划图以及其完成度。
暑假计划

Read more   2015/9/2 22:3 下午