@@ -233,39 +233,29 @@ private function assignHandler($node,$block,$dataFlow,$type){
233
233
if ($ part && ($ part ->getType () == "Expr_FuncCall " ||
234
234
$ part ->getType () == "Expr_MethodCall " ||
235
235
$ part ->getType () == "Expr_StaticCall " ) ){
236
-
236
+
237
237
//处理 id = urlencode($_GET['id']) ;
238
- if (!SymbolUtils::isValue ($ part )){
238
+ if ($ type == ' right ' && !SymbolUtils::isValue ($ part )){
239
239
$ funcName = NodeUtils::getNodeFunctionName ($ part ) ;
240
240
BIFuncUtils::assignFuncHandler ($ part , $ type , $ dataFlow , $ funcName ) ;
241
241
if ($ dataFlow ->getValue () != null ){
242
+ //如果处理完函数赋值,则立即返回
243
+ $ block ->getBlockSummary ()->addDataFlowItem ($ dataFlow );
242
244
return ;
243
- }
244
- }
245
-
246
- //处理编码和净化信息
247
- if ($ type == 'right ' ){
248
- //处理iconv等函数
249
- //处理 id = urlencode($_GET['id']) ;
250
- $ encode_convert = array ('iconv ' ) ;
251
- $ funcName = NodeUtils::getNodeFunctionName ($ part );
252
- if (array_key_exists ($ funcName , $ encode_convert )){
253
- //将函数加入净化栈
254
- $ oneFunction = new OneFunction ($ funcName );
255
- $ dataFlow ->getLocation ()->addSanitization ($ oneFunction ) ;
256
245
}else {
246
+ //处理 id = urlencode($_GET['id']) ;
257
247
//检查是否为sink函数
258
248
$ this ->functionHandler ($ part , $ block , $ this ->fileSummary );
259
-
249
+
260
250
//处理净化信息和编码信息
261
251
SanitizationHandler::setSanitiInfo ($ part ,$ dataFlow , $ block , $ this ->fileSummary ) ;
262
252
EncodingHandler::setEncodeInfo ($ part , $ dataFlow , $ block , $ this ->fileSummary ) ;
263
253
}
264
254
}
255
+
265
256
}
266
257
//处理类型强制转换
267
- if ($ part
268
- && ($ part ->getType () == "Expr_Cast_Int " || $ part ->getType () == "Expr_Cast_Double " )
258
+ if ($ part && ($ part ->getType () == "Expr_Cast_Int " || $ part ->getType () == "Expr_Cast_Double " )
269
259
&& $ type == "right " ){
270
260
$ dataFlow ->getLocation ()->setType ("int " ) ;
271
261
$ symbol = SymbolUtils::getSymbolByNode ($ part ->expr ) ;
@@ -1147,34 +1137,34 @@ public function sinkTracebackBlock($argName,$block,$flowsNum){
1147
1137
}
1148
1138
1149
1139
1150
- //扫描漏洞类型
1151
- $ scan_type = 'ALL ' ;
1152
- echo "<pre> " ;
1140
+ // // 扫描漏洞类型
1141
+ // $scan_type = 'ALL';
1142
+ // echo "<pre>" ;
1153
1143
1154
- //从用户那接受项目路径
1155
- $ project_path = 'E:/School_of_software/information_security/PHPVulScanner_project/simple-log_v1.3.12/upload/ ' ;
1156
- $ project_path = "D:/MySoftware/wamp/www/code/phpvulhunter/test/test.php " ;
1157
- $ project_path = "E:/School_of_software/information_security/PHPVulScanner_project/74cms_3.3/ " ;
1158
- $ allFiles = FileUtils::getPHPfile ($ project_path );
1144
+ // // // 从用户那接受项目路径
1145
+ // // $project_path = 'E:/School_of_software/information_security/PHPVulScanner_project/simple-log_v1.3.12/upload/';
1146
+ // // $project_path = "D:/MySoftware/wamp/www/code/phpvulhunter/test/test.php" ;
1147
+ // // $project_path = "E:/School_of_software/information_security/PHPVulScanner_project/74cms_3.3/" ;
1148
+ // // $allFiles = FileUtils::getPHPfile($project_path);
1159
1149
1160
- //初始化
1161
- $ initModule = new InitModule () ;
1162
- $ initModule ->init ($ project_path , $ allFiles ) ;
1150
+ // // // 初始化
1151
+ // // $initModule = new InitModule() ;
1152
+ // // $initModule->init($project_path, $allFiles) ;
1163
1153
1164
- $ cfg = new CFGGenerator () ;
1165
- $ visitor = new MyVisitor () ;
1166
- $ parser = new PhpParser \Parser (new PhpParser \Lexer \Emulative ) ;
1167
- $ traverser = new PhpParser \NodeTraverser ;
1168
- $ path = CURR_PATH . '/test/test.php ' ;
1169
- $ cfg ->getFileSummary ()->setPath ($ path );
1170
- $ code = file_get_contents ($ path );
1171
- $ stmts = $ parser ->parse ($ code ) ;
1172
- $ traverser ->addVisitor ($ visitor ) ;
1173
- $ traverser ->traverse ($ stmts ) ;
1174
- $ nodes = $ visitor ->getNodes () ;
1175
- $ pEntryBlock = new BasicBlock () ;
1176
- $ pEntryBlock ->is_entry = true ;
1177
- $ ret = $ cfg ->CFGBuilder ($ nodes , NULL , NULL , NULL ) ;
1154
+ // $cfg = new CFGGenerator() ;
1155
+ // $visitor = new MyVisitor() ;
1156
+ // $parser = new PhpParser\Parser(new PhpParser\Lexer\Emulative) ;
1157
+ // $traverser = new PhpParser\NodeTraverser ;
1158
+ // $path = CURR_PATH . '/test/test.php';
1159
+ // $cfg->getFileSummary()->setPath($path);
1160
+ // $code = file_get_contents($path);
1161
+ // $stmts = $parser->parse($code) ;
1162
+ // $traverser->addVisitor($visitor) ;
1163
+ // $traverser->traverse($stmts) ;
1164
+ // $nodes = $visitor->getNodes() ;
1165
+ // $pEntryBlock = new BasicBlock() ;
1166
+ // $pEntryBlock->is_entry = true ;
1167
+ // $ret = $cfg->CFGBuilder($nodes, NULL, NULL, NULL) ;
1178
1168
1179
1169
1180
1170
0 commit comments