linux信息收集命令

1. 內(nèi)核鳍怨,操作系統(tǒng),設(shè)備信息

lsb_release -a  查看系統(tǒng)發(fā)行版本
uname -a    查看內(nèi)核版本
uname -r    內(nèi)核版本
uname -n    系統(tǒng)主機(jī)名
uname -m    查看系統(tǒng)內(nèi)核架構(gòu)(64位/32位)
hostname    系統(tǒng)主機(jī)名
cat /proc/version    內(nèi)核信息
cat /etc/*-release   發(fā)布信息
cat /etc/issue       分發(fā)信息
cat /proc/cpuinfo    CPU信息
cat /etc/lsb-release    # Debian 
cat /etc/redhat-release     # Redhat
ls /boot | grep vmlinuz-

2. 用戶和群組

cat /etc/passwd     列出系統(tǒng)上的所有用戶
cat /var/mail/root
cat /var/spool/mail/root
cat /etc/group      列出系統(tǒng)上的所有組
grep -v -E "^#" /etc/passwd | awk -F: '$3 == 0 { print $1}'      列出所有的超級(jí)用戶賬戶
whoami              查看當(dāng)前用戶
w                   誰(shuí)目前已登錄由境,他們正在做什么
last                最后登錄用戶的列表
lastlog             所有用戶上次登錄的信息
lastlog –u %username%  有關(guān)指定用戶上次登錄的信息
lastlog |grep -v "Never"  以前登錄用戶的完

3. 用戶權(quán)限信息

whoami        當(dāng)前用戶名
id            當(dāng)前用戶信息
cat /etc/sudoers  誰(shuí)被允許以root身份執(zhí)行
sudo -l       當(dāng)前用戶可以以root身份執(zhí)行操作

4. 環(huán)境信息

env        顯示環(huán)境變量
set        現(xiàn)實(shí)環(huán)境變量
echo %PATH 路徑信息
history    顯示當(dāng)前用戶的歷史命令記錄
pwd        輸出工作目錄
cat /etc/profile   顯示默認(rèn)系統(tǒng)變量
cat /etc/shells    顯示可用的shellrc
cat /etc/bashrc
cat ~/.bash_profile
cat ~/.bashrc
cat ~/.bash_logout

5. 進(jìn)程和服務(wù)

ps aux
ps -ef
top
cat /etc/services
查看以root 運(yùn)行的進(jìn)程:
ps aux | grep root
ps -ef | grep root

6. 查看安裝的軟件

ls -alh /usr/bin/
ls -alh /sbin/
ls -alh /var/cache/yum/
dpkg -l

7. 服務(wù)/插件

檢查有沒有不安全的服務(wù)配置颖变,和一些有漏洞的插件:

cat /etc/syslog.conf
cat /etc/chttp.conf
cat /etc/lighttpd.conf
cat /etc/cups/cupsd.conf
cat /etc/inetd.conf
cat /etc/apache2/apache2.conf
cat /etc/my.conf
cat /etc/httpd/conf/httpd.conf
cat /opt/lampp/etc/httpd.conf
ls -aRl /etc/ | awk '$1 ~ /^.*r.*/

8. 計(jì)劃任務(wù)

crontab -l
ls -alh /var/spool/cron
ls -al /etc/ | grep cron
ls -al /etc/cron*
cat /etc/cron*
cat /etc/at.allow
cat /etc/at.deny
cat /etc/cron.allow
cat /etc/cron.deny
cat /etc/crontab
cat /etc/anacrontab
cat /var/spool/cron/crontabs/root

9. 有無(wú)明文存放用戶密碼

grep -i user [filename]
grep -i pass [filename]
grep -C 5 "password" [filename]
find , -name "*.php" -print0 | xargs -0 grep -i -n "var $password"

10. 有無(wú)ssh 私鑰

cat ~/.ssh/authorized_keys
cat ~/.ssh/identity.pub
cat ~/.ssh/identity
cat ~/.ssh/id_rsa.pub
cat ~/.ssh/id_rsa
cat ~/.ssh/id_dsa.pub
cat ~/.ssh/id_dsa
cat /etc/ssh/ssh_config
cat /etc/ssh/sshd_config
cat /etc/ssh/ssh_host_dsa_key.pub
cat /etc/ssh/ssh_host_dsa_key
cat /etc/ssh/ssh_host_rsa_key.pub
cat /etc/ssh/ssh_host_rsa_key
cat /etc/ssh/ssh_host_key.pub
cat /etc/ssh/ssh_host_key

11. 查看與當(dāng)前機(jī)器通信的其他用戶或者主機(jī)

lsof -i
lsof -i :80                 #查看端口為80相關(guān)文件
grep 80 /etc/services
netstat -antup
netstat -antpx
netstat -tulpn
chkconfig --list
chkconfig --list | grep 3:on
last
w

12. 日志文件

cat /var/log/boot.log
cat /var/log/cron
cat /var/log/syslog
cat /var/log/wtmp
cat /var/run/utmp
cat /etc/httpd/logs/access_log
cat /etc/httpd/logs/access.log
cat /etc/httpd/logs/error_log
cat /etc/httpd/logs/error.log
cat /var/log/apache2/access_log
cat /var/log/apache2/access.log
cat /var/log/apache2/error_log
cat /var/log/apache2/error.log
cat /var/log/apache/access_log
cat /var/log/apache/access.log
cat /var/log/auth.log
cat /var/log/chttp.log
cat /var/log/cups/error_log
cat /var/log/dpkg.log
cat /var/log/faillog
cat /var/log/httpd/access_log
cat /var/log/httpd/access.log
cat /var/log/httpd/error_log
cat /var/log/httpd/error.log
cat /var/log/lastlog
cat /var/log/lighttpd/access.log
cat /var/log/lighttpd/error.log
cat /var/log/lighttpd/lighttpd.access.log
cat /var/log/lighttpd/lighttpd.error.log
cat /var/log/messages
cat /var/log/secure
cat /var/log/syslog
cat /var/log/wtmp
cat /var/log/xferlog
cat /var/log/yum.log
cat /var/run/utmp
cat /var/webmin/miniserv.log
cat /var/www/logs/access_log
cat /var/www/logs/access.log
ls -alh /var/lib/dhcp3/
ls -alh /var/log/postgresql/
ls -alh /var/log/proftpd/
ls -alh /var/log/samba/

Note: auth.log, boot, btmp, daemon.log, debug, dmesg, kern.log, mail.info, mail.log, mail.warn, messages, syslog, udev, wtmp

13. 交互式shell

python -c 'import pty;pty.spawn("/bin/bash")'
echo os.system('/bin/bash')
/bin/sh -i

14. 可提權(quán)SUID && GUID

find / -perm -1000 -type d 2>/dev/null   # Sticky bit - Only the owner of the directory or the owner of a file can delete or rename here.
find / -perm -g=s -type f 2>/dev/null    # SGID (chmod 2000) - run as the group, not the user who started it.
find / -perm -u=s -type f 2>/dev/null    # SUID (chmod 4000) - run as the owner, not the user who started it.
#常見的可用來(lái)提權(quán)的Linux 可執(zhí)行文件有:Nmap, Vim, find, bash, more, less, nano, cp

find / -perm -g=s -o -perm -u=s -type f 2>/dev/null    # SGID or SUID
for i in `locate -r "bin$"`; do find $i \( -perm -4000 -o -perm -2000 \) -type f 2>/dev/null; done    # Looks in 'common' places: /bin, /sbin, /usr/bin, /usr/sbin, /usr/local/bin, /usr/local/sbin and any other *bin, for SGID or SUID (Quicker search)

# find starting at root (/), SGID or SUID, not Symbolic links, only 3 folders deep, list with more detail and hide any errors (e.g. permission denied)
find / -perm -g=s -o -perm -4000 ! -type l -maxdepth 3 -exec ls -ld {} \; 2>/dev/null

15. 查看可寫/執(zhí)行目錄

find / -writable -type d 2>/dev/null      # world-writeable folders
find / -perm -222 -type d 2>/dev/null     # world-writeable folders
find / -perm -o w -type d 2>/dev/null     # world-writeable folders
find / -perm -o x -type d 2>/dev/null     # world-executable folders
find / \( -perm -o w -perm -o x \) -type d 2>/dev/null   # world-writeable & executable folders

16. 查看安裝過(guò)的工具

find / -name perl*
find / -name python*
find / -name gcc*
...
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末咸产,一起剝皮案震驚了整個(gè)濱河市盖高,隨后出現(xiàn)的幾起案子福压,更是在濱河造成了極大的恐慌,老刑警劉巖或舞,帶你破解...
    沈念sama閱讀 218,941評(píng)論 6 508
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場(chǎng)離奇詭異蒙幻,居然都是意外死亡映凳,警方通過(guò)查閱死者的電腦和手機(jī),發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 93,397評(píng)論 3 395
  • 文/潘曉璐 我一進(jìn)店門邮破,熙熙樓的掌柜王于貴愁眉苦臉地迎上來(lái)诈豌,“玉大人,你說(shuō)我怎么就攤上這事抒和〗糜妫” “怎么了?”我有些...
    開封第一講書人閱讀 165,345評(píng)論 0 356
  • 文/不壞的土叔 我叫張陵摧莽,是天一觀的道長(zhǎng)庙洼。 經(jīng)常有香客問我,道長(zhǎng)镊辕,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 58,851評(píng)論 1 295
  • 正文 為了忘掉前任,我火速辦了婚禮竖瘾,結(jié)果婚禮上俏扩,老公的妹妹穿的比我還像新娘。我一直安慰自己卖哎,他們只是感情好鬼悠,可當(dāng)我...
    茶點(diǎn)故事閱讀 67,868評(píng)論 6 392
  • 文/花漫 我一把揭開白布。 她就那樣靜靜地躺著亏娜,像睡著了一般焕窝。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上照藻,一...
    開封第一講書人閱讀 51,688評(píng)論 1 305
  • 那天袜啃,我揣著相機(jī)與錄音,去河邊找鬼幸缕。 笑死群发,一個(gè)胖子當(dāng)著我的面吹牛晰韵,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播熟妓,決...
    沈念sama閱讀 40,414評(píng)論 3 418
  • 文/蒼蘭香墨 我猛地睜開眼雪猪,長(zhǎng)吁一口氣:“原來(lái)是場(chǎng)噩夢(mèng)啊……” “哼!你這毒婦竟也來(lái)了起愈?” 一聲冷哼從身側(cè)響起只恨,我...
    開封第一講書人閱讀 39,319評(píng)論 0 276
  • 序言:老撾萬(wàn)榮一對(duì)情侶失蹤,失蹤者是張志新(化名)和其女友劉穎抬虽,沒想到半個(gè)月后官觅,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體,經(jīng)...
    沈念sama閱讀 45,775評(píng)論 1 315
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡阐污,尸身上長(zhǎng)有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 37,945評(píng)論 3 336
  • 正文 我和宋清朗相戀三年休涤,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片笛辟。...
    茶點(diǎn)故事閱讀 40,096評(píng)論 1 350
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡功氨,死狀恐怖,靈堂內(nèi)的尸體忽然破棺而出手幢,到底是詐尸還是另有隱情捷凄,我是刑警寧澤,帶...
    沈念sama閱讀 35,789評(píng)論 5 346
  • 正文 年R本政府宣布围来,位于F島的核電站跺涤,受9級(jí)特大地震影響,放射性物質(zhì)發(fā)生泄漏监透。R本人自食惡果不足惜钦铁,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 41,437評(píng)論 3 331
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望才漆。 院中可真熱鬧牛曹,春花似錦、人聲如沸醇滥。這莊子的主人今日做“春日...
    開封第一講書人閱讀 31,993評(píng)論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽(yáng)鸳玩。三九已至阅虫,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間不跟,已是汗流浹背颓帝。 一陣腳步聲響...
    開封第一講書人閱讀 33,107評(píng)論 1 271
  • 我被黑心中介騙來(lái)泰國(guó)打工, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留,地道東北人购城。 一個(gè)月前我還...
    沈念sama閱讀 48,308評(píng)論 3 372
  • 正文 我出身青樓吕座,卻偏偏與公主長(zhǎng)得像,于是被迫代替她去往敵國(guó)和親瘪板。 傳聞我的和親對(duì)象是個(gè)殘疾皇子吴趴,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 45,037評(píng)論 2 355

推薦閱讀更多精彩內(nèi)容