OpenWrt 的世界︰樹莓派 3B 【路由器】移星轉斗《四‧五》 Scapy 五

如果將日常使用的個人電腦看成『計算機』 + 『輸出入界面』 + 『操作者』,那麼『自動機器』 Automata 就像無需『操作者』的獨立運行系統。既然早有『圖零測試』的議論,要是將

計算機 → 大腦

輸出入界面 → 神經網路

操作者 → ?

,『生物』能夠被當作『生化物理自動機器』嗎??大語言學家 Noam Chomsky 認為語言是人類的一種天賦,而且為人類所獨有。這從『進化論』的角度來講,『人的語言』必然得是『生物言語』的一種『突破』變化!當真人是『有靈魂』的?還是『五蘊皆空』之『人無我』與『法無我』的呢??要有人說︰他在腦海中,聽到 Tux 在『講話』!那他定然是『瘋』了的吧!!

Tux_Einstein

If we knew what we were doing, it wouldn’t be called research, would it?

要是我們知道我們在幹什麼,這就不叫科學研究的了;不是嗎?

Innovation is not the product of logical thought, even though the final product is tied to a logical structure.

創新並非邏輯思維的產物,儘管最終總符合一定邏輯的結構。 ── 愛因斯坦

△ ︰『大 T 』講︰『地鼠』 gopher 已經瀕臨『衰亡』,現今人世『蜘蛛WWW 當道,事實是︰

當以為知識之圓擴大時,面臨的未知之圓周也是一樣。

As our circle of knowledge expands, so does the circumference of darkness surrounding it.

Tux 啊!我們將『以夷制夷』,讓我們用『天下第一』計

《三十六計‧瞞天過海》

備周則意怠;常見則不疑。陰在陽之內,不在陰之外。太陽,太陰。

建立情資『ㄒㄗ』網的呦!!

Tux 大順, Tux 大順, ㄊ ㄊ ㄊ ㄜ ˋ♬

『色聲香味觸法』進了『腦海』怕它都是『編過碼』之『符號』,連笛卡爾都只能以『我思故我在』帶過,那『桶中之腦??』聽到無有言乎!!

─── 《TUX@RPI ︰ 《咸澤碼訊》

 

難到人類不該以『自我意志』動作,『上緊發條』自動自發乎?

自動機

自動機英語:Automaton,複數:Automata,又稱自動機器自動機械),是指非電源供應,以發條裝置作為動力來源,使自己運作的機器;自動機是必須先手動上緊發條,發條帶動機器內部的齒輪及隨動機械零件,才能自己運作,發條的能量就像蓄電池一樣消耗,必須再上緊發條;運作原理有別於發動機發電機電動機永動機

詞源

Automaton一詞源於古希臘語:αὐτόματος(automatos),意為 「以自我意志動作」。

 

還是靈魂束縛於『具體』實有,無心『抽象』思維也!

自動機理論

理論電腦科學中,自動機理論是對抽象機和它們能解決的問題的研究。自動機理論密切關聯於形式語言理論,因為自動機經常按它們所能辨識的形式語言類來分類。

基本描述

自動機是有限狀態機(FSM)的數學模型。FSM是給定符號輸入,依據(可表達為一個表格的)轉移函式「跳轉」過一系列狀態的一種機器。在常見的FSM的「米利型有限狀態機」(Mealy)變體中 ,這個轉移函式告訴自動機給定當前狀態和當前字元的時候下一個狀態是什麼。

逐個讀取輸入中的符號,直到被完全耗盡(把它當作有一個字寫在其上的磁帶,通過自動機的讀磁頭來讀取它;磁頭在磁帶上前行移動 ,一次讀一個符號)。一旦輸入被耗盡,自動機被稱為「停止」了。

依賴自動機停止時的狀態,稱呼這個自動機要麼是「接受」要麼「拒絕」這個輸入。如果停止於「接受狀態」,則自動機「接受」了這個字。在另一方面,如果它停止於「拒絕狀態」,則這個字被「拒絕」。自動機接受的所有字的集合被稱為「這個自動機接受的語言」。

但要注意,自動機一般不必須有有限數目甚至可數個狀態。比如,量子有限自動機不可數無限個狀態,因為所有可能狀態的集合是在復投影空間中所有點的集合。所以,量子有限自動機和有限狀態機一樣,都是更一般想法拓撲自動機的特殊情況,它的狀態的集合是拓撲空間,而狀態轉移函式取自在這個空間上的所有可能函式。拓撲自動機經常叫做 M-自動機,簡單是半自動機加上接受狀態集合的補充,這裡的集合交集確定初始狀態是被接受還是被拒絕。

一般的說,自動機不需要嚴格的接受或拒絕一個輸入;它可以按某個在零和一之間的機率接受它。還是用量子有限自動機作為展範例子,它只按某個機率接受輸入。這個想法也是更一般情況幾何自動機度量自動機的特殊情況,它的狀態的集合是度量空間,一個語言被這個自動機接受如果在初始點和接受狀態的集合之間的距離關於這個度量是足夠的小。

 

故而想說點『工具觀』︰

Automata

Scapy enables to create easily network automata. Scapy does not stick to a specific model like Moore or Mealy automata. It provides a flexible way for you to choose you way to go.

An automaton in Scapy is deterministic. It has different states. A start state and some end and error states. There are transitions from one state to another. Transitions can be transitions on a specific condition, transitions on the reception of a specific packet or transitions on a timeout. When a transition is taken, one or more actions can be run. An action can be bound to many transitions. Parameters can be passed from states to transitions and from transitions to states and actions.

From a programmer’s point of view, states, transitions and actions are methods from an Automaton subclass. They are decorated to provide meta-information needed in order for the automaton to work.

First example

Let’s begin with a simple example. I take the convention to write states with capitals, but anything valid with Python syntax would work as well.

class HelloWorld(Automaton):
    @ATMT.state(initial=1)
    def BEGIN(self):
        print "State=BEGIN"

    @ATMT.condition(BEGIN)
    def wait_for_nothing(self):
        print "Wait for nothing..."
        raise self.END()

    @ATMT.action(wait_for_nothing)
    def on_nothing(self):
        print "Action on 'nothing' condition"

    @ATMT.state(final=1)
    def END(self):
        print "State=END"

In this example, we can see 3 decorators:

  • ATMT.state that is used to indicate that a method is a state, and that can have initial, final and error optional arguments set to non-zero for special states.
  • ATMT.condition that indicate a method to be run when the automaton state reaches the indicated state. The argument is the name of the method representing that state
  • ATMT.action binds a method to a transition and is run when the transition is taken.

Running this example gives the following result:

>>> a=HelloWorld()
>>> a.run()
State=BEGIN
Wait for nothing...
Action on 'nothing' condition
State=END

This simple automaton can be described with the following graph:

_images/ATMT_HelloWorld.png

The graph can be automatically drawn from the code with:

>>> HelloWorld.graph()

※ 參考︰

 

樂於介紹『pyladies

/ipython-scapy

ipython-scapy/Extra.md

In absolutely no particular order of anything:

Tutorial Resources

Extra Scapy resources

Other tools

  • tcpdump – command-line packet analyzer
  • Metasploit Database – well-kept/well-known database of known vulnerabilities (e.g. CVEs) & exploits

Good to keep handy

 

所整理的筆記以及文件呦☆