This screencast demonstrates hijacking applications when they are being downloaded from the Internet and replacing the program with a meterpreter agent instead. The files can be downloaded either via the target or another program (For example, self-updating programs).
The attacker takes control of the traffic by doing a "Man In The Middle" (MITM) attack, to analyse the traffic, in-which if the requested file ends in ".exe", it is redirected to the attacker's web server that will always reply with the same filename as the agent creating the illusion that it was the requested file.
Please note: Unlike the other two previous videos, where the attacker was targeting programs/services that comes with the Operating System, the attacker pursuits 3rd party applications - or the process of trying to install them. The result of this is, there is more user interaction needed than before, whereas before it was either very little (visit any web page) or nothing. Therefore the attacker needs the target to perform a certain action(s) (either willing or unaware). The chosen method of attack can be performed by a simpler method, however this method was chosen for reasons of future posts.
Watch video on-line:
Download Script (replace.pl): *Coming soon*
This is the third video in a series of attacking Operating Systems and our target has now updated to Windows XP Service Pack 3, in the aid of seeking better security, after becoming compromised... twice. ;)
After spending hours re-formatting, installing and restarting the target is using a fully up-to-date system running Windows XP SP3 system with the latest security patches as of March 2011. They haven't used their system "much" as every setting is still at their default options and haven't installed any programs such as Anti-Virus, Firewalls or any browser-based application (E.g. Flash or Java). ;)
This time around, the attacker approaches the attack by attacking the process of installing new or updating existing software.
- Nmap – (Can be found in BackTrack 4-R2)
- PostgreSQL – (Can be found in BackTrack 4-R2)
- Metasploit – (Can be found in BackTrack 4-R2)
- Apache – (Can be found in BackTrack 4-R2)
- A Text Editor – (Kate can be found in BackTrack 4-R2)
- Squid – (Can be found in the BackTrack repository)
- arpspoof – (Part of the DSniff suite which can be found in the BackTrack 4-R2)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
- Start network services and obtain an IP address
- Create resource file and agent for metasploit
- Start and configure metasploit to listen for the backdoor
- Configure and start apache web server
- Download, install and configure Squid proxy
- Perform a man in the middle attack
- Wait for target to download a program (either willing or unknown)
- Game Over
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
The attacker once again starts off by doing a quick sweep of the network with nmap and after identifying the target proceeds to do a port scan on the target. However this time around, no ports respond (due to the firewall being enabled by default now), which limits the returned information.
The attacker then moves onto creating a resource file for metasploit which, by using railgun calls a simple Windows API command to display a message box which is used to give feedback to the target that the program has been executed and not left wondering what’s happening.
The attacker continues the metasploit usage by creating the agent and configuring metasploit to listen for a connection back to it. Once a connection has been created the attacker sets the resource script to be automatically executed.
The attacker proceeds by setting up an Apache web server which is used to deliver the agent to the user. The attacker enables and creates a "distributed configuration file" (.htaccess), that links any requested URL to the metasploit agent and returns with the same name as requested.
As the attacker now has a backdoor and a delivery system ready the attacker needs a method of filtering the web traffic to create a rule to replace any requested URL which ends in EXE (which is a very common application extension used in a windows environment) to be redirected to the attacker's web server instead. The attacker installs Squid3 cache proxy that can do such a thing by using a perl script (replace.pl).
Ettercap could have also been used for an alternative solution, however due to limited scripting functionality the results weren't as high.
As everything is now ready, the attacker just needs to redirect the traffic via their machine. Like before, the attack performs an ARP man in the middle attack with the aid of arpspoof.
Everything is in place and ready for the target to request a program. This can be done by either requesting it themselves (visiting a site and downloading it "manually") or by a program that is already installed (it has to check for an update, fidn that there is an update available and automatically download & execute the program.)
After waiting, the attacker notices that a session has been created and is able to stop the man in the middle attack as the attacker doesn't need to have the target's traffic as they have a direct connection to the target themselves.
A simple bit of privilege escalation gives the attacker complete access to the target's machine.
- The recording software did glitch in a few places - of which I re-recorded a section and edited it in.
- The first time when the target tries to download an application, they click on the notification bar at the top, rather than re-clicking on the click.
- Adobe flash official web site, detects the browser agent and uses a different delivery system to install, which wouldn't have worked in default browser (Internet Explorer).
- Not every auto-update features use ".exe" files to update.
- It is recommended to check the checksum (E.g. MD5 or SHA1) of download programs before executing.
- It is recommended to only download from the official sites, sources or mirrors. Flash was downloaded from adobe.com (filehippo redirects to it), whereas notepad was hosted on filehippo.com
Video length: 10:00
Capture length: 34:11