2015/08/29

原來python打包成exe有三個工具
cx_freeze
py2exe
PyInstaller
之前一直使用的是py2exe
看來cx_freeze也不錯用
下次試看看

http://keliang.blog.51cto.com/3359430/661884

2015/08/24

經過週六日的斷電
cacti GG了 圖出不來
log 顯示
Table 'host_snmp_cache' is marked as crashed and should be repaired

cacti提供了一個工具 repair_database.php
先執行一下看看

2015/08/23

Libreoffice最近出了5版
今天找資料才發現直接用 draw就可以直接編輯pdf了
真棒

https://zh-tw.libreoffice.org/
當完全找不到分割區時
可使用以下工具找看看
分割區救回工具
http://www.cgsecurity.org/wiki/TestDisk

當分割區沒問題  但有軌壞資料無法全部讀取或讀到一半當机時
可使用以下工具試試
壞軌資料救回工具
執行 ddrescue 時必須以分割區下指令不能是整個HD
否則無法mount img來用

ddrescue /dev/sdb1 /tmp/sdb1.img

不能是 ddrescue /dev/sdb /tmp/sdb.img

如要使用image

mount /tmp/sdb1.img /mnt

http://www.gnu.org/software/ddrescue/

誤刪檔救回工具
http://www.cgsecurity.org/wiki/PhotoRec

2015/08/20

昨天上課時臨時需要xp
想說把virtualbox的guest匯出直接co給別人匯入比較快
想不到匯入後竟然開不了機 出現以下訊息
但同樣的檔在ubuntu中匯入卻沒問題





















依字面上來看是有相同名字的node所以無法開机
但就只有一台啊XD
以這個message去找 也找不到什麼東東
只好自己試了 把設定值一個一個取消試看看
試到最後

















在usb的選項把啟用usb取消勾選後
會出現偵測到無效的設定值的訊息
不管他
直接按確定
系統會自動再加回去
但是
這樣再開机就沒問題了吔
見鬼了
是七月沒拜拜嗎

另外 host guest 間的檔案拖放 在不同的 os 中有不同的結果
目前還是先用 共用資料夾 比較沒問題
昨天討論的如何轉eml的問題
如果是在同一台server上
只要把user A的資料夾搬到user B 即可

另外也可以直接請user B開一個資料夾
把匯出的eml直接放進去就可以了

如果一定要使用imap把eml丟到server上
那可以使用foxmail 直接匯入 不用再安裝plugin

2015/08/19

一直以來都有個需求
就是如何把郵件軟体匯出的大量eml檔再匯入到thunderbird或outlook或其他webmail中使用
剛好今天又有user打來問
就記一下
首先要安裝thunderbird
在設定帳號時看要使用imap或pop3
再來thunderbird要安裝importexporttools
但直接從附加元件是找不到的
必須從網頁下載後再手動安裝
















安裝後建立一個資料夾
再到工具 - 以mbox/eml 格式導出導入即可

2015/08/11

debian 裝好使用的是exim4
但是不能對外寄信
要修改以下二行才能使用

/etc/exim4/update-exim4.conf.conf
dc_eximconfig_configtype=’internet’ #預設為 local
dc_smarthost=’msxx.hinet.com’ #遠端的SMTP主機,利用它來發送郵件

http://www.kenming.idv.tw/a_ar_ep_cs_eu_a_exim4_e_marpafoa_cdia_re
honeyd大約測了一週 看來是沒啥問題
但因為之前是直接下載iso回來用 使用的是ubuntu 12.04 有點舊
想說直接換成debian好了 目前是 8.1
只要在
/etc/apt/source.list 
加上
deb http://ftp.us.debian.org/debian squeeze main
apt-get udpate
apt-get install honeyd
就可以了
但裝完後一直不能啟動
原來是要把 /etc/default/honeyd的  RUN="no"改成RUN="yes"
再把NETWORK mark 掉

雖然systemctl start honeyd 時有error 但process 還是有起來
不能enable就是了

沒想到關机出現問題
要重開時一直出現
a stop job is running for /etc/rc.local compatibility
而關不了机
還是第一次碰到這個問題
看來是因為把farpd及honeyd寫到/etc/rc.local後造成的
只好在 root 的 home下寫一個 .bash_logout
在關机前把相關的process kill 掉

寫一個script
kill_process
在關机前把相關的process kill 掉

#!/bin/bash
for i in `pidof farpd`
do
kill -9 $i
done
kill -9 `pidof honeyd`

再把這個script放在
/etc/systemd/system/reboot.target.wants/hwclock-save.service裡

[Service]
Type=oneshot
ExecStart=/sbin/hwclock -D --systohc
ExecStart=/root/kill_process

不知道這樣到底對不對 有沒有什麼潛在的問題 目前有作用就是了

20160217 後記
今天apt-get update後要reboot時又沒法關机了
發現寫進去的東東被洗掉了
再找了一次資料
發現一個很簡單的解法
把/lib/systemd/system/rc-local.service原本的timeout改一下就好了
原本預設為0所以是unlimit改為5問題就解決了 timeout時間一到机器就會關了 不會再一直等

[Unit]
Description=/etc/rc.local Compatibility

[Service]
Type=oneshot
ExecStart=/etc/rc.local
TimeoutSec=5
StandardInput=tty
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target

接下來要把捉到的ip進行處理了

在debian中要取honeyd.log時出現error

grep "123" /var/log/honeypot/honeyd.log
Binary file /var/log/honeypot/honeyd.log matches

也不知為什麼honeyd.log變成binary file了
grep要加上-a才會正常
grep -a "123" /var/log/honeypot/honeyd.log



2015/08/06

本來想把psad移到snort 上
但iptables下完後在收port mirror的nic一直沒法產生log
查了一下文件
iptables 好像沒法在port mirror的情況log
一定要有封包流過去才能log
如下圖


2015/08/04

修改honeyd.conf後要重啟時一時出現以下的錯誤

/etc/honeypot/honeyd.conf:32: Unknown personality "Microsoft Windows xp sp1"
honeyd: parsing configuration file failed

原來 personality這行不能亂設
要比對 nmap.prints這個檔案

grep Finger nmap.prints

跟著打才行

2015/08/03

最近忽然想玩一下honeypot
找了一下
好像都沒什麼新的project
只有看到honeyd好像還滿多人用的
不過也好久沒更新了
另外有一個honeydrive是利用xubuntu 12.04 為base裝了十個honeypot的軟体
所以決定用這個
iso裝好後首先要修改honeyd.conf

範例如下

create linux
set linux personality "Linux 2.4.7 (X86)"
add linux tcp port 25 "/usr/share/honeyd/scripts/unix/general/smtp.pl"
add linux tcp port 110 "/usr/share/honeyd/scripts/unix/general/pop/pop3.sh"
set linux default tcp action reset
set linux uid 32767 gid 32767
bind 192.168.1.1 linux

create windows
set windows personality "Microsoft Windows 2000 SP3"
add windows tcp port 80 "/usr/share/honeyd/scripts/win32/web.sh"
add windows tcp port 135 open
set windows default tcp action reset
set windows default udp action block
set windows uid 32767 gid 32767
bind 192.168.1.2 windows

service honeyd restart

再來就是要執行farpd 這樣才能讓bind的ip生效
語法如下
farpd 192.168.1.1-192.168.1.2

farpd 192.168.1.1/24
如果ip不連續
就要多執行几次
farpd 192.168.1.1
farpd 192.168.1.2

可以用nmap測一下

等個几天再來看看log

http://www.honeyd.org/
http://sourceforge.net/projects/honeydrive/
http://tiserle.blogspot.tw/2011/06/honeyd.html

2015/07/30

昨天下午17點多發生一台cisco不明原因的網路不通
早上去查了一下
找不到原因
只好把昨天早上的config 備份倒回去
說也奇怪 就正常了

到了今天中午
宿舍的4台cisco一起出問題
查了一下log如下
Jul 30 11:10:27 GMT+8: %ACL_ERRMSG-4-UNLOADED: 1 fed:  Output IP Vlan ACL on interface Vlan206 for label 3 on asic255 could not be programmed in hardware and traffic will be dropped.
Jul 30 11:10:27 GMT+8: %ACL_ERRMSG-4-UNLOADED: 1 fed:  Output IP Vlan ACL on interface Vlan207 for label 3 on asic255 could not be programmed in hardware and traffic will be dropped.
Jul 30 11:10:27 GMT+8: %ACL_ERRMSG-4-UNLOADED: 1 fed:  Output IP Vlan ACL on interface Vlan208 for label 3 on asic255 could not be programmed in hardware and traffic will be dropped.
Jul 30 11:10:27 GMT+8: %ACL_ERRMSG-4-UNLOADED: 1 fed:  Output IP Vlan ACL on interface Vlan209 for label 3 on asic255 could not be programmed in hardware and traffic will be dropped.
Jul 30 11:10:27 GMT+8: %ACL_ERRMSG-4-UNLOADED: 1 fed:  Output IP Vlan ACL on interface Vlan210 for label 3 on asic255 could not be programmed in hardware and traffic will be dropped.

詢問廠商後得到這樣的回答

原廠對3850/3650 ACL限制的說明,

ACL TCAM (TAQ)有2塊,分別為in與out,但VACL只能使用其中1塊.限制如下:

1.VACL  => 1.5K 筆 (最多,不分in,out)

2.MAC VACL => 單向460筆(in,out分開算)

3.IPv4 VACL  => 單向690筆(in,out分開算)

4.IPv4 PACL,RACL => 單向1380筆(in,out分開算)

5.MAC PACL,RACL =>單向690筆(in,out分開算)

6.IPv6 PACL,RACL =>單向690筆(in,out分開算)



VLAN Access Control List (VACL) − A VACL is an ACL that is applied to a VLAN. It can only be applied to a VLAN and no other type of interface. The security boundary is to permit or deny traffic that moves between VLANs and permit or deny traffic within a VLAN. The VLAN ACL is supported in hardware, and has no effect on the performance.

Port Access Control List (PACL) − A PACL is an ACL applied to a Layer 2 switchport interface. The security boundary is to permit or deny traffic within a VLAN. The PACL is supported in hardware and has no effect on the performance.

Router ACL (RACL) − An RACL is an ACL that is applied to an interface that has a Layer 3 address assigned to it. It can be applied to any port that has an IP address such as routed interfaces, loopback interfaces, and VLAN interfaces. The security boundary is to permit or deny traffic that moves between subnets or n

意思就是說當acl下超過690條後 机器就會不正常了
XD
cisco吔

為什麼以前都沒發生過咧

不知是因為最近snort升到 2.9.7.5 所以 port scan變的比較敏感
還是port scan真的變多了

反正先改了一下程式
要block的ip直接下到fortiget而不先進LP了
看來也沒啥好方法可以處理了

2015/07/28

如何設定proxmox guest的HA
做個記錄

guest file一定要放在share storage上

datacenter - HA - Add - HA managed VM/CT
輸入vmid









在想要執行HA的node上啟動 RGmanager











https://www.youtube.com/watch?v=rQ3PEfFC7lk

比vmware或hyper-v 方便多了

2015/07/22

雖然網路上已經有很多關於使用ssh不用打密碼的教學文章
還是稍微記一下好了

先在client和server使用者的home目錄下建立.ssh的目錄

在client的机器中執行以下指令

ssh-keygen -t rsa 或 ssh-keygen -t dsa

dsa rsa 是二種不同的加密方式 就看要選擇那一種

之後按個几次enter

會在.ssh這個目錄內產生一對檔案
id_dsa  
id_dsa.pub  
id_rsa  
id_rsa.pub

接下來把.pub那個檔案傳到要連線的server上
scp id_rsa.pub server_ip:~/.ssh/

再連到server上執行
cat .ssh/id_rsa.pub >> .ssh/authorized_keys

exit後再次連到server就無需再打密碼了

若有很多的client端key要放到server上
只要把pub檔附加到authorized_keys即可
cat .ssh/id_rsa.pub >> .ssh/authorized_keys

server端 修改  /etc/ssh/sshd_config

PasswordAuthentication no
PubkeyAuthentication yes


如果要開放 root login

PermitRootLogin prohibit-password

改為:

PermitRootLogin yes


某些os可能不接受dsa的key而無法登入 此時就要換用rsa


2015/07/21

2015/7/19 cacti為了解決script output的問題 更新到 0.8.8f
不用想 也知道又出問題了
這次是在升級時就出現空白畫面
XD
不過這次修正的還算滿快的
今天早上升完了
再觀察看看有沒問題

2015/07/15

又到了每半年一次要使用openvas的時間
果不其然 又出問題了
決定以後要用再下vm 回來就好了
不想再裝了
vm使用的是debian
跑在virtualbox上還ok

跑完後因為報表只需要High跟Medium
所以在用ip sort後要再改 levels=hm 才符合需求

整個filter的條件如下

sort=host first=1 result_hosts_only=1 min_cvss_base= min_qod= levels=hm autofp=0 notes=1 overrides=1 rows=100 delta_states=gn
最近每次升級cacti都有問題
升到 0.8.8e 後原本正常的script output 竟然有個值不見了














到forum看看 已經有人反應了
http://forums.cacti.net/viewtopic.php?f=21&t=54856
只能再等了
無言

2015/07/07

今天接到一個工作
要把snort裡的資料匯出成文字檔給外面的單位
因為BASE沒辦法一次全部匯出
所以要自己寫sql了

select event.cid,signature,sig_name,inet_ntoa(iphdr.ip_src),inet_ntoa(iphdr.ip_dst),timestamp from iphdr,event,signature where event.signature=signature.sig_id and event.cid=iphdr.cid into outfile '/tmp/sqloutput.txt';


http://www.andrew.cmu.edu/user/rdanyliw/snort/acid_db_er_v102.html
http://sgros.blogspot.tw/2012/07/querying-snort-sql-database.html
http://note.tc.edu.tw/670.html

2015/07/05

google drive 一直未推出for linux的版本
因此使用了 grive grive-tools
安裝方式如下

sudo add-apt-repository ppa:nilarimogard/webupd8

sudo add-apt-repository ppa:thefanclub/grive-tools

sudo apt-get update

sudo apt-get install grive-tools grive


已知問題

無法挑選那些目錄不要同步
同步的功能怪怪的