3

linux主机信息收集 | Dar1in9's Blog

 1 year ago
source link: https://dar1in9s.github.io/2022/03/05/%E6%B8%97%E9%80%8F/Linux%E4%B8%BB%E6%9C%BA%E4%BF%A1%E6%81%AF%E6%94%B6%E9%9B%86/#%E7%BD%91%E7%BB%9C%E5%92%8C%E6%9C%8D%E5%8A%A1%E4%BF%A1%E6%81%AF
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

linux信息收集

可以使用linux信息枚举脚本:https://github.com/rebootuser/LinEnum

系统和主机信息

查询发布信息

shell
lsb_release -a
cat /etc/-release
cat /etc/issue

查看内核信息

shell
uname -a
cat /proc/version

查看cpu信息

shell
cat /proc/cpuinfo

查看所有磁盘信息

shell
df -ah

查询环境信息

shell
env					# 打印系统环境信息
set # 打印系统环境信息
echo $PATH # 环境变量中的路径信息
history # 打印历史命令
cat /etc/profile # 显示默认系统遍历
cat /etc/shells # 显示可用的shell
lsof # 查看打开的文件
shell
whoami				# 打印当前登录用户
w # 显示目前登入系统的用户有那些人,以及他们正在执行的程序
id # 查询当前用户id
last # 显示登入过的用户信息
lastlog # 显示系统中所有用户最近一次登录信息
cat /etc/passwd # 查看系统用户信息
cat /etc/group # 查看系统组信息
cat /etc/sudoers # 可以使用sudo提升到root的用户(需要root权限)
sudo -l # 列出目前用户可执行与无法执行的指令

grep -v -E "^#" /etc/passwd | awk -F: '$3==0{print $1}' # 查询管理员用户

网络和服务信息

shell
/sbin/ifconfig -a				# 列出网络接口信息
netstat -pantu # 打印本地端口开放信息
iptables -L # 列出iptable的配置规则
arp -a # 查看系统arp表
route # 打印路由信息
cat /etc/network/interfaces # 列出网络接口信息
cat /etc/resolv.conf # 查看dns配置信息

进程和服务信息

shell
crontab -l -u root			# 显示指定用户的计划作业
ls -la /etc/cron* # 计划任务
cat /etc/services # 查看端口服务映射
service --status-all # 列出服务项

ps -aux # 查看进程信息
top -bn 1 -i -c # 查看进程信息(可以看到cpu等信息)

存活主机探测

shell
for k in $(seq 1 255);do ping -c 1 192.168.1.$k|grep "ttl"|awk -F "[ :]+" '{print $4}'; done 

for i in 192.168.111.{1..254}; do if ping -c 3 -w 3 $i &>/dev/null; then echo $i is alived; fi; done

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK