發表文章

目前顯示的是 6月, 2020的文章

設定Linux伺服器不能Ping

設定Linux伺服器不能Ping ping其實就是用icmp封包完成的 系統節點 /proc/sys/net/ipv4/icmp_echo_ignore_all 用bash設定 $ echo 1 | sudo tee /proc/sys/net/ipv4/icmp_echo_ignore_all 1 用sysctl設定 $ sysctl net.ipv4.icmp_echo_ignore_all 1 上述方法都是暫時性的, 如果系統要在開機時套用,請把設定寫在 /etc/sysctl.conf net.ipv4.icmp_echo_ignore_all=1 Ref: http://ubuntuhandbook.org/index.php/2013/07/disable-ping-response-ubuntu-server/

在Windows 10產生md5,sha1雜湊值

Win10內建的Powershell可產生雜湊值 用法: Get-FileHash 文件路徑 -Algorithm 校驗的Hash值類型| Format-List MD5雜湊值 Get-FileHash "你的檔案路徑" -Algorithm MD5| Format-List SHA1雜湊值 Get-FileHash "你的檔案路徑" -Algorithm MD5| Format-List SHA256雜湊值 Get-FileHash "你的檔案路徑" | Format-List 因為Get-FileHash預設就是用SHA256,所以可不需要參數 ref: https://blog.csdn.net/qikexun/article/details/76401102

AOSP差分OTA中加入前後版MD5和版本號紀錄

--- build/tools/releasetools/ota_from_target_files +++ build/tools/releasetools/ota_from_target_files @@ -642,6 +642,15 @@ def LoadSystemFiles(z):        out[fn] = common.File(fn, data)    return out +def GetMD5(path): +    tp_file = open(path,"r") +    if tp_file == False: +        print("WARNING: cannot generate MD5".path) +        return "NONE" +    re_value = hashlib.md5(tp_file.read()).hexdigest() +    tp_file.close() +    del tp_file +    return re_value  def GetBuildProp(prop, info_dict):    """Return the fingerprint of the build of a given target-files info_dict.""" @@ -665,6 +674,12 @@ def WriteIncrementalOTAPackage(target_zip, source_zip, output_zip):                                           OPTIONS.source_info_dict),                "post-timestamp": GetBuildProp("ro.build.date.utc",                                               OPTIONS.target_info_dict), +              &q

抓取主機的IP(含IPv4和IPv6)

抓取主機的IP(IPv4和IPv6) Python部份 import socket addrs = socket.getaddrinfo('www.hinet.net',443) ipv4_addrs = list(set([addr[4][0] for addr in addrs if addr[0] == socket.AF_INET])) ipv6_addrs = list(set([addr[4][0] for addr in addrs if addr[0] == socket.AF_INET6])) print ('first IPv4:', ipv4_addrs[0], ' candidates:', len(ipv4_addrs)) print ('first IPv6:', ipv6_addrs[0], ' candidates:', len(ipv6_addrs)) 以上程式碼測試過python 3.5.2和python 2.7.12 輸出為: first IPv4: 210.61.33.225  candidates: 8 first IPv6: 2001:b000:1e5:1100::8  candidates: 8 BASH部份 $ nslookup -querytype=A www.hinet.net $ nslookup www.hinet.net Server:   127.0.1.1 Address:  127.0.1.1#53 Non-authoritative answer: www.hinet.net canonical name = hinet-hp.cdn.hinet.net. Name: hinet-hp.cdn.hinet.net Address: 210.61.33.229 Name: hinet-hp.cdn.hinet.net Address: 210.61.33.227 Name: hinet-hp.cdn.hinet.net Address: 210.61.33.232 Name: hinet-hp.cdn.hinet.net Address: 210.61.33.231 Name: hinet