Wednesday, December 30, 2009

Unicode Directory Traversal Attack

Preface
The reason I research about this topic is to have a strong understanding about Unicode Directory Traversal Attack and to know what are the techniques the attacker can do to obfuscate the attack.

Introduction
Manipulation of URL in such a way that can access restricted files by backtracking through a computer's directories. Any device or application that used an HTTP based interface is potentially vulnerable to Directory Traversal Attack.

Most of web servers have restriction to a specific portion of the filesystem, typically called "root directory" in which the users are confined.

For Linux/Unix, the apache document root directory is by default in the line:
DocumentRoot "/var/www/html"

For Windows, the IIS default document root directory is in:
c:\Inetpub\wwwroot

Depending on how the web server is setup the attacker will execute commands that can step out of the root directory and access other parts of the file system that can lead to a full compromise.

What is Directory Traversal Attack?
Directory Traversal also known as Path Traversal or dot dot slash attack (../) is an HTTP exploit which allow attackers to access restricted directories/files, view data and execute commands outside of the web server's root directory. This vulnerability can exist either in the web server software itself like apache/IIS or in the web application code by taking advantage of improper handling of user supplied input that may allow to execute arbitrary commands.

The main objectives of this attack is to have access to a file or program that is not intended to be accessible on the web server.

How does it work?
In order to perform a directory traversal attack, an attacker needs is a web browser and constructing a URL that would navigate to desired folder in the same drive. This can be achieved using Unicode character representations of dot("."), forward slash("/") and backslash("\"). According to RFC 2396 URI may be encoded using the percent sign (%) and hexadecimal characters.

Different type of Unicode encoding.

1. Hex Encoding - The simplest method of encoding a URL in IIS and Apache, consisting of the percent character "%" followed by the ASCII equivalent in hexadecimal digits.

%2e%2e%2f becomes ../ on the first decoding

2. Double Percent Hex Encoding - This encoding is supported by Microsoft IIS. The first percent is encoded using hex encoding followed by the hexadecimal byte value to be encoded.

%252e %252e %252f becomes "%2e %2e %2f" on the first decoding and "../" on the second decoding.

3. Double Nibble Hex Encoding - This encoding is supported by Microsoft IIS, each hexadecimal digit is encoded using the standard hex encoding.

Now we start with %%32%65 %%32%65 %%32%66 which becomes %2e %2e %2f on its first decoding and ../ on its second decoding.

Attack : http://server.com/scripts/%%32%65%%32%65%%32%66/Windows/System32/cmd.exe?/c+dir+c:\

4. First Nibble Hex Encoding - This encoding is supported by Microsoft IIS, only the first nibble is encoded in the following example :

%%32e %%32e %%32f becomes %2e %2e %2f on its first decoding and ../ on its second decoding

Attack : http://www.victim.com/userdata.php?file=%%32e%%32e%%32f%%32e%%32e%%32f%%32e%%32e%%32fwinnt/system32/cmd.exe?/c+dir

5. Second Nibble Hex Encoding - This encoding is supported by Microsoft IIS, same with first nibble hex encoding, the only difference is that the second hexadecimal digit is encoded.

%2%65 %2%65 %2%66 becomes %2e %2e %2f and ../ on its second decoding.

Attack : http://www.victim.com/shows.asp?view=%2%65%2%65%2%66%2%65%2%65%2%66%2%65%2%65%2%66Windows/system.ini

6. Microsoft %u Encoding - Microsoft IIS server supports a non-standard method of encoding web requests, known as '%u' encoding. Because %u method is non-standard, most network intrusion detection systems may not detect attacks encoded using this method.

URL requests in a format that uses "%uXXXX" where "XXXX" represent hexadecimal for example %u002e %u002e %u002f becomes ../

Attack : http://www.victim.com/userdata.php?file=%u002e%u002e%u002f%u002e%u002e%u002f%u002e%u002e%u002f%u002e%u002e%u002fetc/passwd

7. Null Byte Encoding - an evasion technique effective againt application developed using C based programming languages. When a URL-encoded null byte it will treated as the end of the string.

(, or 0x00 in hex)

Normal : http://www.victim.com/userdata.php?file=mydata.dat
Attack : http://www.victim.com/userdata.php?file=../../../etc/passwd

How do I protect?
- Apply the most up-to-date security patches
- Setup the web root directory on a non-system partition
- Any user input must be filter

References

http://en.wikipedia.org/wiki/Directory_traversal
http://www.imperva.com/resources/glossary/directory_traversal.html
http://www.acunetix.com/websitesecurity/directory-traversal.htm
http://www.securityfocus.com/bid/1806/exploit
http://www.owasp.org/index.php/Path_Traversal
http://www.webappsec.org/projects/threat/classes/path_traversal.shtml
http://www.mysecurecyberspace.com/encyclopedia/index/directory-traversal-attack.html
http://www.ietf.org/rfc/rfc2396.txt
http://www.cert.org/advisories/CA-2001-12.html

Thursday, December 10, 2009

QoS on Cisco ASA

Ang sulating ito ang naglalayong turuan ang mga Network Administrators kung paano magconfigure ng
QOS o Quality of Service sa Cisco ASA. Ang QOS ay isang paraan upang masulit ang paggamit ng bandwidth
at matiyak na ang mahahalagang traffic ay nauunang ipadala kaysa sa ibang normal o d gaanong importanteng
impormasyon. Simple naming ipapaliwanag ang mga suportadong
mekanismo at magbibigay ng mga halimbawa kung paano ito gamitin.

Ang mga sumusunod ay ang iba't-ibang paraan paano gagamitin ang QOS sa network.

Traffic Policing:

Kung ang kabuuang traffic ay lumalagpas sa itinakdang hangganan, kadalasan, mas
nakabubuting ito ay bantayan o i-police. Sa ganitong paraan, ang bandwidth ay hindi lamang
nagagamit o nauubos ng isang user or program; paghihigpit ng traffic ay isinasagawa upang
ito ay hindi maganap. Ang ASA ay may kakayanang i-police ang mga pumapasok at lumalabas na
traffic papunta at galing sa interface. Maaari nating i-configure ang ASA na harangan o
payagan ang mga sobrang traffic na dadaloy sa ASA.

Traffic Shaping

Ang Traffic Shaping ay kabilang sa mga tampok ng bersyong 7.2.4 ng ASA. Ibig sabihin,ito
rin ay maaring gawin sa mga bersyong 8.0 at 8.1, kasama ang mga 'trains' nito. Sa traffic
shaping, ang mga traffic na lalagpas sa itinakdang hangganan ay ipipila muna at maipapadala
lamang kung ang traffic ang bumaba na sa itinakdang threshold. Ang mga traffic na ito ay
hindi haharangin or ibabagsak ng ASA. Ito ay nakabubuti sa mga program na laging apektado
ng pagkawala ng packet.

Priority Queueing

Ang Priority Queueing ay may kakayanang unahin ang mga packet na importante sakaling
magsabay-sabay ang mga ito. Kabilang sa mga ito ay ang voice. Ang firewall ay limitado sa
Low Latency Queueing. Hindi tulad ng mga router na may kakayanang gawin ang mga
sopistakadong prioritization mechanisms.

Mga Dapat Isaalang-alang

1. Ang mga traffic na nakarating sa interface ng ASA ay nakagamit na ng bandwidth.

2. Ang Priority Queueing ay dapat gamitin kasabay ng policing o traffic shaping sa
kadahilanang hangga't ang link ng LLQ ay puspos, ang packet ay hindi mapapriorita. Ang
interfaces ng ASA ay karaniwang 100Mbps, 1Gbps o higit pa kaya ang pagkabisi or pagkakapuno
nito ay malayong mangyari, o kung mangyari man, sa mga bibihirang pagkakataon lamang. Sa
pagsasagawa ng policing o traffic shaping kahanay ng LLQ, ang LLQ ang masusunod kapag ang
hangganan ng policing o shaping ay naabot na.

3. Kung isinasagawa ang priority queueing sa mga program na tumatakbo sa gitna ng dalawang
pook, ipinapayo ang paglalagay ng prioritization sa mga mga traffic ng parehong pook. Ito
ay sa kadahilanang kung sa isang pook mo lamang isinagawa ang pagprapriorita, ang pabalik
na traffic ay maaaring mahuli rin. Ibig sabihin, para ka ring walang prioritization.

Traffic Policing kasabay ng Prioritization

Isipin natin na mayroon tayong ASA na nagpapadaan ng voice traffic sa VPN tunnel at gusto
natin mauuna lagi o i-prioritize yung voice traffic sa mga dadaaan sa VPN tunnel. Nais rin
natin i-police yung mga hindi voice traffic at iba pang TCP traffic.

Sabihin natin na ang upload bandwidth para sa outside interface ay 1Mbps. Maguukol tayo ng
300Kbps sa VPN, 100Kbps nito ay nakalaan para sa voice. Ibig sabihin ang natitirang 200Kbps
ay para sa traffic na hindi voice. 500Kbps ay para sa tcp traffic at 200Kbps para sa iba
pang traffic na hindi nabanggit. Ang voice traffic sa halimbawang ito ay nakaflag ng dchp
field ef (ito ang karaniwang default kadalasan)

Ang pangalan ng tunnel group sa halimbawang ito ay tunnel-grp1. Hindi kabilang ang
configuration ng buong VPN upang makaiwas sa pagkalito.

ASA(config)# priority-queue outside

ASA(config)# access-list tcp-traffic-acl permit tcp any any
ASA(config)# class-map tcp-traffic-class
ASA(config-cmap)# match access-list tcp-traffic-acl

ASA(config)# class-map TG1-voice-class
ASA(config-cmap)# match tunnel-group tunnel-grp1
ASA(config-cmap)# match dscp ef

ASA(config-cmap)# class-map TG1-rest-class
ASA(config-cmap)# match tunnel-group tunnel-grp1
ASA(config-cmap)# match flow ip destination-address

ASA(config)# policy-map police-priority-policy
ASA(config-pmap)# class tcp-traffic-class
ASA(config-pmap-c)# police output 500000
ASA(config-pmap-c)# class TG1-voice-class
ASA(config-pmap-c)# priority
ASA(config-pmap-c)# class TG1-rest-class
ASA(config-pmap-c)# police output 200000
ASA(config-pmap-c)# class class-default
ASA(config-pmap-c)# police output 200000
ASA(config-pmap-c)# service-policy police-priority-policy interface outside


Traffic Shaping kasabay ng Prioritization

Isipin nating mayroon tayong parehong ASA na nabanggit sa taas. Ngayon, nais nating
i-traffic shape lahat ng dumaraang packet at unahin ang voice sa VPN tunnel. sa madaling
salita, maguukol tayo ng 900Kbps para sa hindi voice at ang natitirang 100Kbps ay gagamitin
lamang ng voice. Ang voice traffic ulet sa halimbawang ito ay nakaflag ng dchp field ef
(ito ang karaniwang default kadalasan) at ang pangalan ng tunnel group ay tunnel-grp1.
Hindi pa rin kabilang ang configuration ng buong VPN.

ASA(config)# priority-queue outside

ASA(config)# class-map TG1-voice-class
ASA(config-cmap)# match tunnel-group tunnel-grp1
ASA(config-cmap)# match dscp ef

ASA(config-cmap)# policy-map priority-policy
ASA(config-pmap)# class TG1-voice-class
ASA(config-pmap-c)# priority

ASA(config-pmap-c)# policy-map shape-priority-policy
ASA(config-pmap)# class class-default
ASA(config-pmap-c)# shape average 900000
ASA(config-pmap-c)# service-policy priority-policy

ASA(config-pmap-c)# service-policy shape-priority-policy interface outside

Pagtingin sa Estatistika ng QOS

Maari nating gamitin ang show commands sa baba. Ang mga ulat sa baba ay hindi kaugnay ng
mga nasa taas at ginamit lamang bilang halimbawa.

Para sa Policing:

ASA# show service-policy police

Global policy:
Service-policy: global_fw_policy
Interface outside:
Service-policy: qos
Class-map: browse
police Interface outside:
cir 56000 bps, bc 10500 bytes
conformed 10065 packets, 12621510 bytes; actions: transmit
exceeded 499 packets, 625146 bytes; actions: drop
conformed 5600 bps, exceed 5016 bps
Class-map: cmap2
police Interface outside:
cir 200000 bps, bc 37500 bytes
conformed 17179 packets, 20614800 bytes; actions: transmit
exceeded 617 packets, 770718 bytes; actions: drop
conformed 198785 bps, exceed 2303 bps


Para sa Prioritization:

ASA# show service-policy priority

Global policy:
Service-policy: global_fw_policy
Interface outside:
Service-policy: qos
Class-map: TG1-voice-class
Priority:
Interface outside: aggregate drop 0, aggregate transmit 9383


Para sa Shaping:

ASA# show service-policy shape

Interface outside:
Service-policy: shape
Class-map: class-default
Queueing
queue limit 64 packets
(queue depth/total drops/no-buffer drops) 0/0/0
(pkts output/bytes output) 0/0
shape (average) cir 2000000, bc 16000, be 16000
Service-policy: voip
Class-map: voip
Queueing
queue limit 64 packets
(queue depth/total drops/no-buffer drops) 0/0/0
(pkts output/bytes output) 0/0
Class-map: class-default
queue limit 64 packets
(queue depth/total drops/no-buffer drops) 0/0/0
(pkts output/bytes output) 0/0


Ang mga halimbawang output na ginamit sa sulating ito ay mula sa www.cisco.com.

Saturday, December 5, 2009

In Promiscuous Mode

Since we can foresee that we'll be having a lot of research based on packets, payloads, and logs from different network devices, we have dedicated a blog site for that. You guys can check out In Promiscuous Mode for more information.

Tuesday, December 1, 2009

The Architects

Michael Dungog - Security+. Linux+. OCA. OCP.
Mhike has been working in the IT industry for 11 years, handling various technologies with networks, databases and systems. He is very interested in the field of research about rootkits, malwares, and penetration testing. He is well versed with administering Windows and Unix systems such as Open/FreeBSD, and Solaris. Currently working on projects related to System and Log Analysis, honeypot research, and forensic analysis.

Marvi Napoles - CCNA. CCSP. MCP.
Marv has over 8 years of IT exposure, spending the first 3 years delivering lectures about various IT subjects to students of a growing international computer school. The remaining five was managing a pool of Cisco Security Engineers. He specializes on Cisco Security products which include PIX, ASA, ACS Software/Appliance, Network and Host IDS, VPN Client but his favorite - the VPN Concentrator. He is actively discovering and studying features, management techniques and configuration schemes of other IPS/IDS such as Fortigate, Snort and Sonicwall, inline with his current role as a Security Analyst - hardcore analysis of packets and logs.

Ralph Payumo - CCNA. CCSP. Security+
A computer networking and security savvy guy for more than 4 years. He previously worked as a network security engineer specializes on Cisco devices such as IOS routers, Catalyst switches, Wireless technology, PIX/ASA firewalls, IPS/IDS, VPN, Access Control Server and other vendor networking products. Currently working on projects related to penetration testing, packet/payload analysis and network security designing. Presently, Ralph works as a Security Analyst and a part time instructor teaching networking and security.

Isaac Sabas - CCNA. Security+. CEH.
Ice is an aspiring security analyst who has two years experience in information and network security theories and concepts. He also has more than two years of experience in developing tools for different platforms and web applications and websites using PHP and AJAX. He is very interested in penetration testing, packet/payload analysis, and research about malwares and worms. Currently working on projects related to OS development, packet and log analysis, neural networks, and penetration testing.

  © Building IT Securely thesecurityarchitects.blogspot.com 2009

Back to TOP