搜尋此網誌

2016/11/3

[linux]Centos/Redhat 6/7 更改hostname方式

Centos/Redhat 6
vi /etc/sysconfig/network

CentOS/RedHat 7
hostnamectl set-hostname 名稱


2016/10/12

[RedHat]CVE Database

https://access.redhat.com/security/security-updates/#/

2016/10/11

[bash]將資料夾內全部檔案做md5並輸出成檔案

find -type f -exec md5sum "{}" + > checklist.chk

[excel]IP2LONG語法

將ip轉成整數後比對範圍,比字串比對效率高的多,看到有網站說明如何轉換的語法,還有sql的語法
http://vcert.blogspot.tw/2013/04/ip2long-and-long2ip-in-excel.html

EXCEL:
=MID(D1,1,FIND("|",SUBSTITUTE(D1,".","|",1))-1)*2^24+MID(D1,FIND("|",SUBSTITUTE(D1,".","|",1))+1,FIND("|",SUBSTITUTE(D1,".","|",2))-FIND("|",SUBSTITUTE(D1,".","|",1))-1)*2^16+MID(D1,FIND("|",SUBSTITUTE(D1,".","|",2))+1,FIND("|",SUBSTITUTE(D1,".","|",3))-FIND("|",SUBSTITUTE(D1,".","|",2))-1)*2^8+MID(D1,FIND("|",SUBSTITUTE(D1,".","|",3))+1,4)


2016/9/28

[python]設定timezone及取時間

我的python有點弱找了一陣子,感覺最簡單的方式算是這樣使用了
筆記一下
import pytz, datetime

tz=pytz.timezone('Asia/Taipei')
dt=datetime.datetime.now(tz)
print dt.strftime("%b %d %H:")
http://strftime.org/
如果要

CodeMeaningExample
%aWeekday as locale’s abbreviated name.Mon
%AWeekday as locale’s full name.Monday
%wWeekday as a decimal number, where 0 is Sunday and 6 is Saturday.1
%dDay of the month as a zero-padded decimal number.30
%-dDay of the month as a decimal number. (Platform specific)30
%bMonth as locale’s abbreviated name.Sep
%BMonth as locale’s full name.September
%mMonth as a zero-padded decimal number.09
%-mMonth as a decimal number. (Platform specific)9
%yYear without century as a zero-padded decimal number.13
%YYear with century as a decimal number.2013
%HHour (24-hour clock) as a zero-padded decimal number.07
%-HHour (24-hour clock) as a decimal number. (Platform specific)7
%IHour (12-hour clock) as a zero-padded decimal number.07
%-IHour (12-hour clock) as a decimal number. (Platform specific)7
%pLocale’s equivalent of either AM or PM.AM
%MMinute as a zero-padded decimal number.06
%-MMinute as a decimal number. (Platform specific)6
%SSecond as a zero-padded decimal number.05
%-SSecond as a decimal number. (Platform specific)5
%fMicrosecond as a decimal number, zero-padded on the left.000000
%zUTC offset in the form +HHMM or -HHMM (empty string if the the object is naive).
%ZTime zone name (empty string if the object is naive).
%jDay of the year as a zero-padded decimal number.273
%-jDay of the year as a decimal number. (Platform specific)273
%UWeek number of the year (Sunday as the first day of the week) as a zero padded decimal number. All days in a new year preceding the first Sunday are considered to be in week 0.39
%WWeek number of the year (Monday as the first day of the week) as a decimal number. All days in a new year preceding the first Monday are considered to be in week 0.39
%cLocale’s appropriate date and time representation.Mon Sep 30 07:06:05 2013
%xLocale’s appropriate date representation.09/30/13
%XLocale’s appropriate time representation.07:06:05
%%A literal '%' character.%

[資安]CVE-2016-6662 mysql、mariadb

都忘記發文了,
主要是CVE-2016-6662這個漏洞,最先公告的地方是這網站
http://legalhackers.com/advisories/MySQL-Exploit-Remote-Root-Code-Execution-Privesc-CVE-2016-6662.txt
簡中版
http://bobao.360.cn/learning/detail/3027.html
影響範圍
MySQL  <= 5.7.14       Remote Root Code Execution / Privilege Escalation (0day)
   5.6.32
    5.5.51

MySQL clones are also affected, including:

MariaDB
PerconaDB 
但底下的III. INTRODUCTION寫了
The vulnerability affects all MySQL servers in default configuration in all 
version branches (5.7, 5.6, and 5.5) including the latest versions, and could 
be exploited by both local and remote attackers. 
Both the authenticated access to MySQL database (via network connection or web 
interfaces such as phpMyAdmin) and SQL Injection could be used as exploitation 
vectors.

看起來是全系列都受影響,但測試舊版的rhel6 mysql、rhel5 mysql發現並無my.cnf內沒有mysqld_safe的相關設定,所以只影響到新版包含使用mysql source code fork出去的資料庫

基本上漏洞使用的方式就是分2種
1、有帳號
使用此漏洞可以修改my.cnf,可以控制my.cnf
2、沒帳號
使用trigger,讓mysql在flush時觸發後提權帳號,再控制my.cnf

暫態解法
https://www.psce.com/blog/2016/09/12/how-to-quickly-patch-mysql-server-against-cve-2016-6662/
https://dev.mysql.com/doc/refman/5.5/en/mysqld-safe.html#option_mysqld_safe_malloc-lib
https://github.com/percona/percona-server/commit/c14be53e029442f576cced1fb8ff96b58e89f2e0#diff-144aa2f11374843c969d96b7b84247eaR261
暫時性可以用的解法在mysql官方還沒正式更新前,就是用github裡的方式,指定可以載入lib的目錄,非這些目錄的不可以載入


http://bobao.360.cn/learning/detail/3026.html
http://www.ithome.com.tw/news/108454
http://avfisher.win/archives/tag/mysql
http://legalhackers.com/exploits/0ldSQL_MySQL_RCE_exploit.py

[分享]南港推拿~ "奕霖損傷整復"

自從工作後,運動時間越來越短受傷機率越來越大
到了台北後,腳扭傷了也不知道去那看又怕治不好囧
在偶然之間,找到了一間還不錯的醫生,離租屋處又近
傷了近十年的大拇指,就在這裡一次處理好了~(噴淚
收費方式是看藥布大小而定~~
推薦給大家
真的很不錯,整個球隊、公司打球的朋友、朋友的朋友也都來這裡看了~~超棒的
喔,對了,腰傷的話,通常要帶X光片去給奕霖,要不然可能不會推喔



2016/8/15

openssl安全性掃描網站

https://www.ssllabs.com/ssltest/

HOSTNAME:輸入要測試的IP

[ubuntu16.4]fcitx安裝嘸蝦米中文輸入法

新酷音輸入法
$ sudo apt-get install fcitx-chewing
無蝦米輸入法
$ sudo apt-get install fcitx-table-boshiamy
倉頡輸入法
$ sudo apt-get install fcitx-table-cangjie5
日文輸入法
$ sudo apt-get install fcitx-anthy

2016/8/4

[資安新聞〕8款來自 BlackHat 2016 的安全工具

標題:8款來自 BlackHat 2016 的安全工具

摘要:
一年一度的美國黑帽大會(Black Hat USA 2016)在拉斯維加斯曼德勒海灣酒店(Mandalay Bay)順利舉行。除了披露重大安全漏洞外,先進的工具展示過程也是大會必不可少的精彩環節。

1. Infection Monkey:
Infection Monkey是一個數據中心滲透測試工具,通過啟動數據中心中隨機散佈的部分受感染虛擬機,以測試整個網絡安全鏈中的潛在盲點,幫助安全團隊提升數據中心的安全恢復能力。

2. Project Delta:
在幫助滲透測試人員嗅探SDN的安全性。該工具包含一個識別OpenFlow路由器安全性能和控制器部署的框架,還包括一個專門定制的模糊測試模塊,以發現SDN網絡中的未知安全漏洞。

3. Ablation:
作為一種靜態分析輔助工具,能夠從執行進程中抽取數據。它的目的是簡化逆向工程流程,幫助研究人員對比樣本代碼而不僅僅是比較數據。

4. Keystone Engine:
新型逆向工程工具,旨在幫助研究人員更容易的選擇安全軟件。

5. AVLeak:
幫助AVLeak用戶偵測出一台機器上是否安裝了反病毒模擬器,進而優化惡意攻擊軟件,使其不被反病毒軟件發現。

6. Swizzler:
移動安全研究員Vincent Tan選擇重新拾起擱置已久的Swizzler,重新開發了該工具以支持移動應用滲透測試人員所需的各種功能。

7. DPTrace:
開源工具DPtrace ~ 半自動的崩潰分析框架,該工具可以幫助研究者在系統崩潰的瞬間掃描輸入區域的映射,分析代碼執行的潛在影響。

8. BLE MITM Proxy:
BLE MITM Proxy是一款開源工具,能夠在樹莓派(Raspberry Pi)中加載運行,通過開發、逆向工程以及調試幫助探測藍牙低功耗設備。

引用來源:
http://www.freebuf.com/sectool/111065.html

原始資料:
http://www.darkreading.com/vulnerabilities---threats/8-bad-ass-tools-coming-out-of-black-hat/d/d-id/1326444

2016/7/25

[linux]could not be found in rpmdb

遇到問題
Setting up Upgrade Process
Error: Package tuple ('openssl-devel', 'x86_64', '0', '1.0.1e', '42.el6_7.4') could not be found in rpmdb


解決方式
1、yum clean all
2、rpmdb --rebuilddb



2016/7/22

[php]使用EOT內要加入變數使用的方式

$text="Jordan";

echo <<<EOT
    Hello {$text}
EOT;

2016/5/28

[linux,mail]linux上可以使用的寄信程式

官網
http://www.logix.cz/michal/devel/smtp-cli/
smtp-cli github
https://github.com/mludvig/smtp-cli


主管推薦發送mail的軟體,完全符合RFC規定
perl開發的,不用因為需要寄信出去而把自己變成mail server,然後再關閉收件功能

套件會用到epel,要先裝epel
redhat、centos
yum  install  perl-IO-Socket-SSL  perl-Digest-HMAC  perl-TermReadKey  \
 perl-MIME-Lite  perl-File-LibMagic  perl-IO-Socket-INET6


Usage: smtp-cli [--options]

        --server=<hostname>[:<port>] 指定伺服器位置或直接加上port
                                Host name or IP address of the SMTP server.
                                May include the port after colon, alternatively
                                use --port.
        --port=<number>         Port where the SMTP server is listening.
                                (default: 25)

        -4 or --ipv4            Use standard IP (IPv4) protocol.
        -6 or --ipv6            Use IPv6 protocol. For hosts that have
                                both IPv6 and IPv4 addresses the IPv6
                                connection is tried first.

        --hello-host=<string>   String to use in the EHLO/HELO command.
        --disable-ehlo          Don't use ESMTP EHLO command, only HELO.
        --force-ehlo            Use EHLO even if server doesn't say ESMTP.

        Transport encryption (TLS)
        --disable-starttls      Don't use encryption even if the remote
                                host offers it.
        --ssl                   Start in SMTP/SSL mode (aka SSMTP).
                                Default when --port=465
        --disable-ssl           Don't start SSMTP even if --port=465
        --ssl-ca-file=<filename>
                                Verify the server's SSL certificate against
                                a trusted CA root certificate file.
        --ssl-ca-path=<dirname> Similar to --ssl-ca-file but will look for
                                the appropriate root certificate file in
                                the given directory. The certificates must
                                must be stored one per file with hash-links
                                generated by, for example, c_rehash script
                                from OpenSSL.

        Authentication options (AUTH)
        --user=<username>       Username for SMTP authentication.
        --pass=<password>       Corresponding password.
        --auth-login            Enable only AUTH LOGIN method.
        --auth-plain            Enable only AUTH PLAIN method.
        --auth-cram-md5         Enable only AUTH CRAM-MD5 method.
        --auth                  Enable all supported methods. This is
                                normally not needed, --user enables
                                everything as well.

        Sender / recipient
        --from=\"Display Name <add\@re.ss>\"
                                Sender's name address (or address only).
        --to=\"Display Name <add\@re.ss>\"
        --cc=\"Display Name <add\@re.ss>\"
        --bcc=\"Display Name <add\@re.ss>\"
                                Message recipients. Each parameter can be
                                used multiple times.
                                The --bcc addresses won't apprear in
                                the composed message.

        SMTP Envelope sender / recipient
        (rarely needed, use --from, --to, --cc and --bcc instead)
        --mail-from=<address>   Address to use in MAIL FROM command.
                                Use --from instead, unless you want
                                a different address in the envelope and
                                in the headers.
        --rcpt-to=<address>     Address to use in RCPT TO command. Can be
                                used multiple times. Normally not needed,
                                use --to, --cc and --bcc instead.
                                If set the --to, --cc and --bcc will only
                                be used for composing the message body and
                                not for delivering the messages.

        Send a complete RFC822-compliant email message:
        --data=<filename>       Name of file to send after DATA command.
                                With \"--data=-\" the script will read
                                standard input (useful e.g. for pipes).

        Alternatively build email a message from provided components:
        --subject=<subject>     Subject of the message
        --body-plain=<text|filename>
        --body-html=<text|filename>
                                Plaintext and/or HTML body of the message
                                If both are provided the message is sent
                                as multipart.
        --charset=<charset>     Character set used for Subject and Body,
                                for example UTF-8, ISO-8859-2, KOI8-R, etc.
        --text-encoding=<encoding>
                                Enforce Content-Transfer-Encoding for text
                                parts of the email, including body and
                                attachments. Must be one of:
                                ".join(", ", @valid_encodings)."
                                The default is: quoted-printable
        --attach=<filename>[\@<MIME/Type>]
                                Attach a given filename.
                                MIME-Type of the attachment is guessed
                                by default guessed but can optionally
                                be specified after '\@' delimiter.
                                For instance: --attach mail.log\@text/plain
                                Parameter can be used multiple times.
        --attach-inline=<filename>[\@<MIME/Type>]
                                Attach a given filename (typically a picture)
                                as a 'related' part to the above 'body-html'.
                                Refer to these pictures as <img src='cid:filename'>
                                in the 'body-html' contents.
                                See --attach for details about MIME-Type.
                                Can be used multiple times.
        --add-header=\"Header: value\"
        --replace-header=\"Header: value\"
        --remove-header=\"Header\"
                                Add, Replace or Remove pretty much any header
                                in the email. For example to set a different
                                Mailer use --replace-header=\"X-Mailer: Blah\",
                                to remove it altogether --remove-header=X-Mailer
                                or to add a completely custom header use
                                --add-header=\"X-Something: foo bar\".
        --print-only            Dump the composed MIME message to standard
                                output. This is useful mainly for debugging
                                or in the case you need to run the message
                                through some filter before sending.

        Other options
        --verbose[=<number>]    Be more verbose, print the SMTP session.
        --missing-modules-ok    Don't complain about missing optional modules.
        --version               Print: smtp-cli version $version
        --help                  Guess what is this option for 

2016/5/10

[Server]Mozilla SSL Configuration Generator

https://mozilla.github.io/server-side-tls/ssl-config-generator/
mozilla的網站,可以依照不同的網站伺服器、openssl版本,產生出安全性較高的config設定



[python]visual code 設定

0x000
環境變數要設定python位置
0x001
執行(ctrl+r)->cmd->python 確認可以執行
0x002
開啟visual code
0x003
先按f1
輸入
>Task Configure Task Runner
修改一些
設定
"command": "python",
"args": [
        // Ask msbuild to generate full paths for file names.
        "${file}"
    ],
0x004
測試檔案
ctrl+shift+b
就可以測試執行


附註:
0x000
如果command要打路徑,就要改
"command": "c:\\python27\\python.exe",
0x001
安裝套件
>ext install
>ext install python

2016/5/2

[devops][鐵人賽]CI Server 30 - Jenkins,文章連結整理自ITHOME

devops越來越重要了,記錄一下重要文章


http://ithelp.ithome.com.tw/articles/10109773
在過去30天中,我們一步一步地建立了我們的CI Server,
從最初簡單的建置專案,到最後擁有完整了測試、分析甚至是部署功能,
讓Jenkins成為幫助我們控管專案程式碼品質的好幫手,
並可以讓我們在程式碼可能產生問題時及早發現,讓專案的進行更加順暢!
※Jenkins所提供的各種服務
在這一系列的文章之中,主要根據Jenkins所提供幾個主要功能做了介紹。
※有了Jenkins讓生活更美好
透過Jenkins接手為我們處理每天可能需要花費時間人力進行的工作之後,
我們可以用更少的代價換取信賴度更高的服務,
由於系統全自動進行各項工作,執行的每一步驟也都有Log紀錄,
讓我們還提供了各種報表讓我們一眼看出關鍵點,
讓我們的軟體開發流程更加的順暢。
1. 讓工程師更專注於開發
相較於讓工程師透過各種程式碼分析工具來掃描自己所撰寫的程式,
雖然程式碼的品質可以在開發時期就保持穩定優良,但也花費了大量的時間,
而在交給Jenkins之後,工程師只要專注在開發、撰寫單元測試上,
其他的所有分析的工作就交給Jenkins來處理,
並透過每天Review專案的報表就可以知道今天所開發程式碼的狀況,
也不怕自己在忙碌時所check in的程式碼無法建置。
2. 讓專案的異動更靈活
由於我們有針對程式碼撰寫單元測試,當異動需求發生時,
我們可以放心大膽的更改我們的程式碼,
若影響到其他的功能就會因為單元測試不通過而得到Jenkins的警告通知,
甚至我們還可以使用之前所建置好的版本來進行還原的動作 (若有設定保留每次的Build),
不必因為害怕改壞原本穩定的功能而讓程式碼的複雜度越來越高
(因為每次總是在最小的範圍修正bug,很可能會養出數千行的function)
3. 讓專案的管理更輕鬆
每天我們都會收到Jenkins所寄出來的專案分析報告,
我們可以很快地看出是不是今天check in的程式碼都有通過測試,
如果有不符合團隊程式碼風格,或是其他有潛在風險的問題都可以第一時間發現,
也因為我們準備好了建置專案的MakeFile,就算要將新專案加入Jenkins也很輕鬆,
而萬一要對所有的程式碼增加額外的分析或操作,也只要修改共用的MakeFile即可,
對於主管來說專案程式碼的透明度更高,不再只能透過Code Review才能控管品質。
※總結
終於寫完了這一系列的Jenkins Server介紹,
也達成了今年自己的小小目標之一,希望這系列文章能夠幫助到想要導入CI Server的朋友,
在練習架設自己的CI Server過程之中,其實遇到了很多瓶頸也學到了很多經驗,
想在這邊把這些東西分享給大家,讓大家在設定Jenkins的過程中可以更快速的上手,
並且感受到CI Server所帶來的種種好處,讓開發的流程更加的順暢。
最後開心的就是終於鐵人鍊成啦!謝謝大家!

2016/4/27

[資安]trend micro出的2016勒索軟體白皮書

trend micro出的2016勒索軟體白皮書
http://blog.trendmicro.com.tw/wp-content/uploads/2016/04/2016-ransomware-white-paper.pdf

[資安]如何關閉windows 執行script ,避免執行勒索軟體(js、vbs之類)

f-secure有寫一篇How-To Disable Windows Script Host教學,如何關閉windows script的執行,

主要是將
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Script Host\Settings


右鍵->新增DWORD ->建立一個名稱為Enabled  數值為:0



就可以停用windows script host存取了


弄了個簡單的reg檔,有興趣的人可以直接下載執行
https://dl.dropboxusercontent.com/u/21052371/Disable%20Windows%20Host.reg

2016/4/26

[資安]locky病毒防範方法之一

前陣子locky這隻勒索病毒非常嚴重,是近幾年來少數利用office macro來執行的病毒了
看網路上說要把巨集整個關掉, 方法大概是下面這樣
因為如果照預設的開啟,會詢問使用者是否執行巨集,但很多人看都不看就會點是了

然後就被加密








參考資料
打開 Word 檔也會中勒索軟體!!新加密勒索軟體Locky,偽裝發票,誘騙下載
http://blog.trendmicro.com.tw/?p=16651
巨集病毒久別再臨 開啟亂碼 Word 檔隨時中勒索軟件
http://unwire.pro/2016/02/23/locky-ransomware-virus-spreading-via-word-documents/news/
Locky ransomware virus spreading via Word documents
https://medium.com/@networksecurity/locky-ransomware-virus-spreading-via-word-documents-51fcb75618d2#.mrn2dx2el

[資安]6個”檔案上傳”功能的資訊安全風險與防護

6個”檔案上傳”功能的資訊安全風險與防護
風險1: 檔案路徑
風險2: Null Byte Injection
風險3: 沒有適當的關閉資源
風險4:上傳惡性程式
風險5:壓縮檔炸彈
風險6:真實檔名


http://www.qa-knowhow.com/?p=1472

[資安]垃圾郵件黑名單檢查網站RBL

被加入黑名單是件很麻煩的事情,常常要檢查自己是不是在黑名單列表裡
下面有幾個常用的黑名單檢查網站,可以檢查自己的ip是不是乾淨的


整合了多個RBL檢查的網站
http://multirbl.valli.org/lookup/

http://www.anti-abuse.org/multi-rbl-check/


TREND MICRO的(中華電信用這個)
https://ers.trendmicro.com/reputations

CISCO
https://www.senderbase.org/lookup/

barracuda
http://www.barracudacentral.org/lookups

2016/4/25

[網站推薦]ransomware tracker 勒索軟體追蹤

之前查勒索軟體時逛到一個網站
有把幾個當紅的勒索軟體的連線的ip列出來,
可以拿來當黑名單擋擋
https://ransomwaretracker.abuse.ch/blocklist/


[資安]OWASP Proactive Controls For Developers 2016 v2.0 10 個高風險的安全防護建置指南


OWASP Proactive Controls For Developers
 2016 v2.0
10 個高風險的安全防護建置指南
作者: 徐祥智 Tony Hsu

1. 盡早驗證, 經常驗證
2. 參數化查詢的輸入
3. 資料編碼
4. 驗證所有的輸入
 5. 身分認證與驗證
6. 權限的存取控管
7. 保護數據
8. 日誌與入侵偵測
9. 善用安全框架與程式庫
10. 錯誤與例外的處理

https://www.owasp.org/images/2/21/OWASPTop10ProactiveControls2016-Chinese.pdf