-->

whaust

2020年2月13日 星期四

CVSS v3.1 Equations



Base
The Base Score is a function of the Impact and Exploitability sub score equations. Where the Base score is defined as,
    If (Impact sub score <= 0)     0 else,
    
Scope Unchanged4                 𝑅𝑜𝑢𝑛𝑑𝑢𝑝(𝑀𝑖𝑛𝑖𝑚𝑢𝑚[(𝐼𝑚𝑝𝑎𝑐𝑡 + 𝐸𝑥𝑝𝑙𝑜𝑖𝑡𝑎𝑏𝑖𝑙𝑖𝑡𝑦), 10])
    
Scope Changed                      𝑅𝑜𝑢𝑛𝑑𝑢𝑝(𝑀𝑖𝑛𝑖𝑚𝑢𝑚[1.08 × (𝐼𝑚𝑝𝑎𝑐𝑡 + 𝐸𝑥𝑝𝑙𝑜𝑖𝑡𝑎𝑏𝑖𝑙𝑖𝑡𝑦), 10])

and the Impact sub score (ISC) is defined as,

    
Scope Unchanged 6.42 × 𝐼𝑆𝐶Base
    
Scope Changed 7.52 × [𝐼𝑆𝐶𝐵𝑎𝑠𝑒 − 0.029] − 3.25 × [𝐼𝑆𝐶𝐵𝑎𝑠𝑒 − 0.02]15

Where,

    
𝐼𝑆𝐶𝐵𝑎𝑠𝑒 = 1 − [(1 − 𝐼𝑚𝑝𝑎𝑐𝑡𝐶𝑜𝑛𝑓) × (1 − 𝐼𝑚𝑝𝑎𝑐𝑡𝐼𝑛𝑡𝑒𝑔) × (1 − 𝐼𝑚𝑝𝑎𝑐𝑡𝐴𝑣𝑎𝑖𝑙)]

 
And the Exploitability sub score is,

    8.22 ×
𝐴𝑡𝑡𝑎𝑐𝑘𝑉𝑒𝑐𝑡𝑜𝑟 × 𝐴𝑡𝑡𝑎𝑐𝑘𝐶𝑜𝑚𝑝𝑙𝑒𝑥𝑖𝑡𝑦 × 𝑃𝑟𝑖𝑣𝑖𝑙𝑒𝑔𝑒𝑅𝑒𝑞𝑢𝑖𝑟𝑒𝑑 × 𝑈𝑠𝑒𝑟𝐼𝑛𝑡𝑒𝑟𝑎𝑐𝑡𝑖𝑜𝑛Temporal
The Temporal score is defined as,

    
𝑅𝑜𝑢𝑛𝑑𝑢𝑝(𝐵𝑎𝑠𝑒𝑆𝑐𝑜𝑟𝑒 × 𝐸𝑥𝑝𝑙𝑜𝑖𝑡𝐶𝑜𝑑𝑒𝑀𝑎𝑡𝑢𝑟𝑖𝑡𝑦 × 𝑅𝑒𝑚𝑒𝑑𝑖𝑎𝑡𝑖𝑜𝑛𝐿𝑒𝑣𝑒𝑙 × 𝑅𝑒𝑝𝑜𝑟𝑡𝐶𝑜𝑛𝑓𝑖𝑑𝑒𝑛𝑐𝑒)Environmental
The environmental score is defined as,

    If (Modified Impact Sub score <= 0)     0 else,

    If Modified Scope is Unchanged           Round up(Round up (Minimum [ (
M.Impact + M.Exploitability) ,10]) × Exploit Code Maturity × Remediation Level × Report Confidence)
  
    If Modified Scope is Changed               Round up(Round up (Minimum [1.08 × (
M.Impact + M.Exploitability) ,10]) × Exploit Code Maturity × Remediation Level × Report Confidence)

And the modified Impact sub score is defined as,

    If Modified Scope is Unchanged 6.42 × [
𝐼𝑆𝐶𝑀𝑜𝑑𝑖𝑓𝑖𝑒𝑑]
  
    
If Modified Scope is Changed 7.52 × [𝐼𝑆𝐶𝑀𝑜𝑑𝑖𝑓𝑖𝑒𝑑 − 0.029]-3.25× [𝐼𝑆𝐶𝑀𝑜𝑑𝑖𝑓𝑖𝑒𝑑 × 0.9731 − 0.02] 13

Where,
    
𝐼𝑆𝐶𝑀𝑜𝑑𝑖𝑓𝑖𝑒𝑑 = 𝑀𝑖𝑛𝑖𝑚𝑢𝑚 [[1 − (1 − 𝑀. 𝐼𝐶𝑜𝑛𝑓 × 𝐶𝑅) × (1 − 𝑀. 𝐼𝐼𝑛𝑡𝑒𝑔 × 𝐼𝑅) × (1 − 𝑀. 𝐼𝐴𝑣𝑎𝑖𝑙 × 𝐴𝑅)], 0.915]

The Modified Exploitability sub score is,

    8.22 ×
𝑀. 𝐴𝑡𝑡𝑎𝑐𝑘𝑉𝑒𝑐𝑡𝑜𝑟 × 𝑀. 𝐴𝑡𝑡𝑎𝑐𝑘𝐶𝑜𝑚𝑝𝑙𝑒𝑥𝑖𝑡𝑦 × 𝑀. 𝑃𝑟𝑖𝑣𝑖𝑙𝑒𝑔𝑒𝑅𝑒𝑞𝑢𝑖𝑟𝑒𝑑 × 𝑀. 𝑈𝑠𝑒𝑟𝐼𝑛𝑡𝑒𝑟𝑎𝑐𝑡𝑖𝑜n4 Where “Round up” is defined as the smallest number, specified to one decimal place, that is equal to or higher than its input. For example, Round up (4.02) is 4.1; and Round up (4.00) is 4.0.


Source : https://nvd.nist.gov/vuln-metrics/cvss/v3-calculator

2020年2月10日 星期一

「程式開發安全管理 S-SDLC」課程評量


課程日期:1090214
時  間:10:00 - 12:00
課程名稱:S-SDLC Training
課程地點: 
授課講師:


一、單位:      姓名:      分數:    

一、選擇題
1
1.     SSDLC階段,以下何者為非?
1.  安全開發委外。
2.  安全軟體測試。
3.  安全軟體設計。
4.  安全需求確認。
4
2.     軟體安全特性,以下何者為是?
1.  完整性
2.  身份認證
3.  會話管理
4.  以上皆是
4
3.     軟體安全特性發展策略考量的因素以下何者為非?
1.  常見資安威脅
2.  常見系統弱點
3.  組織安全目標
4.  使用者體驗
1
4.     威脅建模過程(Threat Modeling Process),以下何者為非?
1.  威脅情資分享
2.  識別威脅
3.  威脅緩解
4.  評估威脅
4
5.     以下何者是常見的OWASP Top10攻擊手法?
1.  注入攻擊 (Injection)
2.  跨站腳本攻擊 (XSS)
3.  不安全的反序列化風險(Java)
4. 以上皆是。
1
6.     進行網站管理時,密碼強度應符合複雜性原則。下列哪一組密碼相對上不是弱密碼?
1.  ApKr!2#4%
2.  Apkr12345
3.  TJKLKPKGTR
4.  erpowepowerisgood
1
7.     當發現專案內程式碼出現漏洞時,應儘速進行應變更正,下列作法何者為非?
1.  繼續開發工作,等安全軟體測試階段被檢出再修正
2.  盡快通報PM
3.  設置修正作為,並紀錄處理過程
4.  運用源碼檢測工具確認問題
4
8.     有關常見駭客密碼破解手法,以下何者為是?
1.  暴力攻擊
2.  字典攻擊
3.  運用其他地方外洩密碼進行猜測攻擊
4.  以上皆是。

2
9.     有關於系統弱點掃瞄,下列何者為非 ?
1. 弱點掃瞄一般分初掃與複掃,以利追蹤弱點是否已修正
2. 掃瞄前不需確認程式與特徵碼是否已更新
3. 遇程式更版、重大資安事件、配合定期稽核時需實施弱點掃瞄
4. 掃瞄頻率原則上每半年需要掃描一次


4
10.   如何避免駭客利用已知弱點的元件進行攻擊 ?
1.  識別整理專案中所有使用到的元件,底層軟體及其版本資訊,並建立清單管制
2.  定期維護該清單並確保正確性
3.  使用外部元件或軟體,注意其安全通告並且評估更新
4.  以上皆是


[歡迎轉載, 只要註明出處就好]

2020年2月4日 星期二

Decimal to Binary / Binary to Decimal 十進位轉二進位/ 二進位轉十進位 (Python)







Decimal to Binary / Binary to Decimal (Python)

十進位轉二進位
二進位轉十進位


# -*- coding: utf-8 -*-
"""
Created on Tue Feb  4 21:24:56 2020

Decimal to Binary
Binary to Decimal

"""

def DecimalToBinary(num): 
    if num > 1: 
        DecimalToBinary(num // 2) 
    print(num % 2, end = '')


def BinaryToDecimal(binary, i = 0):
    # If we reached last character  
    n = len(binary)  
    if (i == n - 1) : 
        return int(binary[i]) - 0
    # Add current tern and recur for  
    # remaining terms  
    return (((int(binary[i]) - 0) << (n - i - 1)) + BinaryToDecimal(binary, i + 1))     


if __name__ == '__main__': 
    numberDecimal = int(input("Please enter a Decimal number : "))
    DecimalToBinary(numberDecimal) 
    print("\n")
    
    numberBinary =  str(input("Please enter a Binary number : "))
    BinaryToDecimal(numberBinary)
    print(BinaryToDecimal(numberBinary)) 


Python算術運算符


以下假設變量a為10,變量b為21:
運算符 描述 實例
+加- 兩個對象相加a + b 輸出結果31
-減- 得到負數或是一個數減去另一個數a - b 輸出結果-11
*乘- 兩個數相乘或是返回一個被重複若干次的字符串a * b 輸出結果210
/除- x 除以 yb / a 輸出結果2.1
%取模- 返回除法的餘數b % a 輸出結果 1
**冪- 返回x的y次冪a**b 為10的21次方
//取整除- 向下取接近除數的整數
# 9 //2   4 
# -9 //2  -5

2020年2月3日 星期一

print all Prime numbers in two integers Interval . (Python)

在兩個正整數之間印出所有質數。 (Python)

給定兩個正整數開始和結束。
任務是編寫一個Python程式印出兩個正整數間隔中的所有質數。


定義:

質數是大於1的自然數,除1及其本身外,沒有除數。
前幾個質數是{2、3、5、7、11…。}。

解決此問題的想法是使用for循環從頭到尾 迭代val,對於每個數字,如果它大於1,請檢查是否將n除盡。
如果找到其他除數,請打印該值。


Given two positive integer start and end. The task is to write a Python program to print all Prime numbers in an Interval.
Definition: A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself. The first few prime numbers are {2, 3, 5, 7, 11, ….}.
The idea to solve this problem is to iterate the val from start to end using a for loop and for every number, if it is greater than 1, check if it divides n. If we find any other number which divides, print that value.



# -*- coding: utf-8 -*-

t = 0

numberStart = int(input("Enter a Start number: "))

numberEnd = int(input("Enter a End number: "))

for val in range(numberStart, numberEnd + 1): 

   if val > 1: 

       for n in range(2, val): 

           if (val % n) == 0: 

               break

       else: 

           print(val)

           t = t + 1

print("There are " , t , " Primes"  )



2020年2月1日 星期六

[Class3] Python 環境搭建

Python  環境搭建

本章節我們將向大家介紹如何在本地搭建Python開發環境。
Python可應用於多平台包括Linux 和Mac OS X。
你可以通過終端窗口輸入"python" 命令來查看本地是否已經安裝Python以及Python的安裝版本。
  • Unix (Solaris, Linux, FreeBSD, AIX, HP/UX, SunOS, IRIX, 等等。)
  • Win 9x/NT/2000
  • Macintosh (Intel, PPC, 68K)
  • OS/2
  • DOS (多個DOS版本)
  • PalmOS
  • Nokia 移動手機
  • Windows CE
  • Acorn/RISC OS
  • BeOS
  • Amiga
  • VMS/OpenVMS
  • QNX
  • VxWorks
  • Psion
  • Python 同樣可以移植到Java 和.NET 虛擬機上。


Python下載

Python最新源碼,二進製文檔,新聞資訊等可以在Python的官網查看到:
Python官網:http://www.python.org/
你可以在以下鏈接中下載Python 的文檔,你可以下載HTML、PDF 和PostScript 等格式的文檔。
Python文檔下載地址:www.python.org/doc/


Python安裝

Python已經被移植在許多平台上(經過改動使它能夠工作在不同平台上)。
您需要下載適用於您使用平台的二進制代碼,然後安裝Python。
如果您平台的二進制代碼是不可用的,你需要使用C編譯器手動編譯源代碼。
編譯的源代碼,功能上有更多的選擇性, 為python安裝提供了更多的靈活性。
以下為不同平台上安裝Python的方法:

Unix & Linux 平台安裝Python:

以下為在Unix & Linux 平台上安裝Python 的簡單步驟:
  • 打開WEB瀏覽器訪問http://www.python.org/download/
  • 選擇適用於Unix/Linux的源碼壓縮包。
  • 下載及解壓壓縮包。
  • 如果你需要自定義一些選項修改Modules/Setup
  • 執行  ./configure腳本
  • make
  • make install
執行以上操作後,Python會安裝在/usr/local/bin 目錄中,Python庫安裝在/usr/local/lib/pythonXX,XX為你使用的Python的版本號。

Window 平台安裝Python:

以下為在Window 平台上安裝Python 的簡單步驟:
  • 打開WEB瀏覽器訪問http://www.python.org/download/
  • 在下載列表中選擇Window平台安裝包,包格式為:python-XYZ.msi  文件, XYZ為你要安裝的版本號。
  • 要使用安裝程序  python-XYZ.msi , Windows系統必須支持Microsoft Installer 2.0搭配使用。只要保存安裝文件到本地計算機,然後運行它,看看你的機器支持MSI。Windows XP和更高版本已經有MSI,很多老機器也可以安裝MSI。
  • 下載後,雙擊下載包,進入Python安裝嚮導,安裝非常簡單,你只需要使用默認的設置一直點擊"下一步"直到安裝完成即可。

MAC 平台安裝Python:

最近的Macs系統都自帶有Python環境,你也可以在鏈接 http://www.python.org/download/ 上下載最新版安裝。


環境變量配置

程序和可執行文件可以在許多目錄,而這些路徑很可能不在操作系統提供可執行文件的搜索路徑中。
path(路徑)存儲在環境變量中,這是由操作系統維護的一個命名的字符串。這些變量包含可用的命令行解釋器和其他程序的信息。
Unix或Windows中路徑變量為PATH(UNIX區分大小寫,Windows不區分大小寫)。
在Mac OS中,安裝程序過程中改變了python的安裝路徑。如果你需要在其他目錄引用Python,你必須在path中添加Python目錄。

在Unix/Linux 設置環境變量

  • 在csh shell:  輸入 
    setenv PATH "$PATH:/usr/local/bin/python"
    , 按下"Enter"。
  • 在bash shell (Linux):  輸入 
    export PATH="$PATH:/usr/local/bin/python"
    ,按下"Enter"。
  • 在sh或者ksh shell:  輸入 
    PATH="$PATH:/usr/local/bin/python"
    , 按下"Enter"。
注意:  /usr/local/bin/python是Python的安裝目錄。

在Windows 設置環境變量

在環境變量中添加Python目錄:
在命令提示框中(cmd) :  輸入 
path=%path%;C:\Python
按下"Enter"。

注意:  C:\Python是Python的安裝目錄。
也可以通過以下方式設置:
  • 右鍵點擊"計算機",然後點擊"屬性"
  • 然後點擊"高級系統設置"
  • 選擇"系統變量"窗口下面的"Path",雙擊即可!

  • 然後在"Path"行,添加python安裝路徑即可(我的D:\Python32),所以在後面,添加該路徑即可。 ps:記住,路徑直接用分號";"隔開!
  • 最後設置成功以後,在cmd命令行,輸入命令"python",就可以有相關顯示。

Python 環境變量

下面幾個重要的環境變量,它應用於Python:
變量名描述
PYTHONPATHPYTHONPATH是Python搜索路徑,默認我們import的模塊都會從PYTHONPATH裡面尋找。
PYTHONSTARTUPPython啟動後,先尋找PYTHONSTARTUP環境變量,然後執行此文件中變量指定的執行代碼。
PYTHONCASEOK加入PYTHONCASEOK的環境變量, 就會使python導入模塊的時候不區分大小寫.
PYTHONHOME另一種模塊搜索路徑。它通常內嵌於的PYTHONSTARTUP或PYTHONPATH目錄中,使得兩個模塊庫更容易切換。


運行Python

有三種方式可以運行Python:

1、交互式解釋器:

你可以通過命令行窗口進入python並開在交互式解釋器中開始編寫Python代碼。
你可以在Unix,DOS或任何其他提供了命令行或者shell的系統進行python編碼工作。
$ python # Unix/Linux 

或者 

C:>python # Windows/DOS
以下為Python命令行參數:
選項描述
-d在解析時顯示調試信息
-O生成優化代碼( .pyo 文件 )
-S啟動時不引入查找Python路徑的位置
-V輸出Python版本號
-X從1.6版本之後基於內建的異常(僅僅用於字符串)已過時。
-c cmd執行Python 腳本,並將運行結果作為cmd 字符串。
file在給定的python文件執行python腳本。

2、命令行腳本

在你的應用程序中通過引入解釋器可以在命令行中執行Python腳本,如下所示:
$ python script.py # Unix/Linux 

或者 

C:>python script.py # Windows/DOS
注意:在執行腳本時,請檢查腳本是否有可執行權限。

3、整合式開發環境(IDE:Integrated Development Environment): PyCharm

PyCharm 是由JetBrains 打造的一款Python IDE,支持macOS、 Windows、 Linux 系統。
PyCharm 功能: 調試、語法高亮、Project管理、代碼跳轉、智能提示、自動完成、單元測試、版本控制……
PyCharm 下載地址: https://www.jetbrains.com/pycharm/download/
繼續下一章之前,請確保您的環境已搭建成功。如果你不能夠建立正確的環境,那麼你就可以從您的系統管理員的幫助。
在以後的章節中給出的例子已在Python2.7.6 版本測試通過。

2020年1月19日 星期日

Impact of Food Traders Cut corners on Public Health and Food Safety

Enzo / Food Safety Specialist in Japan, Long-term focus on food safety in Asia

Motivation

Nowadays, most people have the habit of eating out because of work and school. However, in recent years, food safety problems have emerged endlessly, such as tincture oil, melamine milk powder, toxic starch, plasticizers, and the fenponi "poison egg" that broke out this year And other major food safety incidents have made consumers worry about whether the food they eat is really safe. From the above incidents, it can be seen that Taiwan still has many deficiencies in food safety management. The most dissatisfied society is that judges will judge whether they violate the "Food Safety Law" based on "whether it is harmful to human health." There are cases of "seeing, but not punishing".


An Economic Perspective of Business Cut-offs

   Businessmen are very valuable from an economic point of view. Every step from raw material transportation to food processing to final sales requires costs. Factors that affect costs include the balance of supply and demand in the market and the reasonable profit of food sales. Under the good market mechanism, traders can use reasonable raw materials for processing. What happens if the market supply and demand do not reach a balance today? The price of goods in the sales market is already lower than the cost of the original raw materials and the processing and value-added activities of the merchant. Forcing businessmen to not reduce the cost of raw materials, in order to make money, they will choose things with lower processing costs to process, and then make profits between them, but the use of such "low-cost processed products" may cause human health to be affected , So people have been nicknamed the "black-hearted businessman".



From a legal point of view, the businessman cut corners

    The government has established laws to establish relevant standards, such as food processing standards, food additive standards, and food marketing and labeling standards. Merchants can sell inferior goods by category, or sell food that is about to expire. For example, tofu in miso soup, you can use poorly sold tofu instead of beautifully packaged tofu. This selection can indeed reduce production costs, or improve the processing method. If the merchants all meet the above standards, and the government agencies have actual law enforcement, such as auditing and enforcement, this will increase the public's trust in food and the government . So the merchant did not meet the relevant standards and the method of reducing costs was improper? For example, the contents of sales products are not clearly marked, things that should not be added, inappropriate methods, such as using industrial catalysts to accelerate production time However, it may cause harm to health, or change the shelf life at will. These improper methods will cause bad foods, and then leave the human body in an unhealthy state.



Conclusion

    From the above two perspectives, similar conclusions can be drawn: everything that a businessman does costs, because of market factors, reducing production costs. If a reasonable and legal processing method is selected and the government has conducted a rigorous review, people will have a sense of trust; if an unreasonable processing method is used, it may affect human health. This is a virtuous circle and a vicious circle. I prefer a virtuous circle. In this era of food for all, in order to eat at ease, the cooperation of consumers, businessmen, and the government is required to minimize the impact of food safety issues.

食品商人偷工減料的對民眾健康及食品安全的影響

Enzo / 旅日食品安全專家,長期關注亞洲地區食品安全


動機

現今大多數人因為工作、上學的關係而有在外用餐的習慣,但是近年來食安問題層出不窮,如餿水油、三聚氰胺奶粉、毒澱粉、塑化劑,到今年爆發的芬普尼「毒蛋」等重大食安事件,讓消費者擔心吃下肚的食物是否真的安全。從上述的幾項事件可看出台灣在食安管理上仍有許多不足的地方,而最讓社會不滿的是法官會依據「是否危害人體健康」來判斷是否觸犯《食安法》,因此常有「看得到,罰不到」的情形發生。



以經濟的角度看商人偷工減料的行為

   商人在經濟角度中,是相當有價值的,從原料運送,到食品加工,至最後的銷售,每一個步驟都需要成本。影響成本的因素有市場的供需平衡、和食品銷售的合理利潤。在良好的市場機制下,商人得以用合理的原物料進行加工。     要是今天市場供需沒有達到平衡會發生什麼事情?在銷售市場的商品價格,已經比原先原物料的成本、和商人加工,做加值這個動作的成本還要低了。迫使商人在不能降低原物料成本,為了要賺錢,會選擇加工成本更低的東西來進行加工,進而賺取之間的利潤,但利用這樣的”低成本加工物”可能會導致人體健康受到影響,因而被人們冠上「黑心商人」的臭名。

以法律的角度看商人偷工減料的行為

    政府訂定法律來建立相關的標準,譬如說食品加工的標準、食品添加物標準及食品標售、標示的標準。商人可以將次等商品進行分類銷售,或即將到期的食物進行分類銷售。比方說味噌湯裡面的豆腐,在選擇上面可以使用賣相較差的豆腐,來取代精美包裝的豆腐。這樣選用可以確實降低生產成本,亦或是加工方法改良商品商人如果都有符合以上的標準,且政府機關有確實執法,像是稽核、執行,如此一來會使民眾對食品和政府加深信賴感。     那麼商人沒有達到相關的標準且降低成本的方法不當呢?譬如說銷售商品內容標示得不清不楚、添加不該添加的東西、用不當的工法,像是使用工業用觸媒加速生產時間,卻對健康造成傷害、又或著隨意更改保存期限,這些不當的方式會導致不良食品的造成,進而使人體處於非健康狀態。

結論

    從上面的兩個角度中,可以得到相似的結論 : 商人做的每件事情都需要成本,因為市場因素,而降低了生產成本。如果選用合理、合法的加工方式,且政府有確實審核,會使人民產生信賴感;如果使用不合理的加工方式,可能會影響人體的健康。這分別是良性與惡性循環,我偏向的是良性循環。在這人人外食的時代下,為了吃得安心,需要消費者、商人、及政府三者共同合作,才能使食品安全的問題所造成的影響減至最小。  

Popular