@@ -527,38 +527,6 @@ public function functionHandler($node, $block, $fileSummary){
527
527
//check
528
528
if (!$ funcBody || !is_object ($ funcBody )) return ;
529
529
530
- //处理递归
531
- if ($ funcBody ->getType () == "Stmt_Function " ){
532
- $ traverser = new PhpParser \NodeTraverser ;
533
- $ visitor = new RecursionFunctionVisitor () ;
534
- $ visitor ->funcName = $ funcName ;
535
- $ traverser ->addVisitor ($ visitor ) ;
536
- $ traverser ->traverse (array ($ funcBody )) ;
537
- if ($ visitor ->isRecursion == true ){
538
- return ;
539
- }
540
- }else if ($ funcBody ->getType () == "Stmt_ClassMethod " ){
541
- $ traverser = new PhpParser \NodeTraverser ;
542
- $ visitor = new RecursionFunctionVisitor () ;
543
- $ visitor ->funcName = $ funcName ;
544
- $ traverser ->addVisitor ($ visitor ) ;
545
- $ traverser ->traverse (array ($ funcBody )) ;
546
- if ($ visitor ->isRecursion == true ){
547
- return ;
548
- }
549
-
550
- }else if ($ funcBody ->getType () == "Stmt_StaticCall " ){
551
- $ traverser = new PhpParser \NodeTraverser ;
552
- $ visitor = new RecursionFunctionVisitor () ;
553
- $ visitor ->funcName = $ funcName ;
554
- $ traverser ->addVisitor ($ visitor ) ;
555
- $ traverser ->traverse (array ($ funcBody )) ;
556
- if ($ visitor ->isRecursion == true ){
557
- return ;
558
- }
559
-
560
- }
561
-
562
530
if ($ funcBody ->getType () == "Stmt_ClassMethod " ){
563
531
$ funcBody ->stmts = $ funcBody ->stmts [0 ] ;
564
532
}
@@ -882,51 +850,7 @@ public function leaveNode(Node $node) {
882
850
}
883
851
884
852
885
- /**
886
- * 处理递归语句
887
- * 如果是递归,则返回true
888
- * @author Exploit
889
- *
890
- */
891
- class RecursionFunctionVisitor extends PhpParser \NodeVisitorAbstract{
892
- public $ funcName ;
893
- public $ isRecursion = false ;
894
- public function leaveNode (Node $ node ){
895
- //方法调用
896
- if ($ node ->getType () == "Expr_FuncCall " ){
897
- if ($ node ->name == $ this ->funcName ){
898
- $ this ->isRecursion = true ;
899
- }
900
- }
901
-
902
- //静态方法
903
- if ($ node ->getType () == "Expr_StaticCall " ){
904
- $ name = explode (": " , $ this ->funcName ) ;
905
- if (count ($ name ) >= 2 ){
906
- $ name = $ name [1 ] ;
907
- }else {
908
- $ name = $ this ->funcName ;
909
- }
910
853
911
- if ($ node ->name == $ name ){
912
- $ this ->isRecursion = true ;
913
- }
914
- }
915
-
916
- //类方法
917
- if ($ node ->getType () == "Expr_MethodCall " ){
918
- $ name = explode (": " , $ this ->funcName ) ;
919
- if (count ($ name ) >= 2 ){
920
- $ name = $ name [1 ] ;
921
- }else {
922
- $ name = $ this ->funcName ;
923
- }
924
- if ($ node ->name == $ name ){
925
- $ this ->isRecursion = true ;
926
- }
927
- }
928
- }
929
- }
930
854
931
855
class nodeFunctionVisitor extends PhpParser \NodeVisitorAbstract{
932
856
public $ block ;
@@ -943,6 +867,7 @@ public function leaveNode(Node $node){
943
867
}
944
868
}
945
869
}
870
+
946
871
/**
947
872
* 处理方法调用
948
873
* @author Exploit
@@ -1147,35 +1072,40 @@ public function sinkTracebackBlock($argName,$block,$flowsNum){
1147
1072
}
1148
1073
1149
1074
1150
- //扫描漏洞类型
1151
- $ scan_type = 'ALL ' ;
1152
- echo "<pre> " ;
1075
+ // //扫描漏洞类型
1076
+ // $scan_type = 'ALL';
1077
+ // echo "<pre>" ;
1078
+
1079
+ // //从用户那接受项目路径
1080
+ // $project_path = 'C:/Users/xyw55/Desktop/test/74cms_3.3';
1081
+ // // $project_path = 'E:/School_of_software/information_security/PHPVulScanner_project/simple-log_v1.3.12/upload/';
1082
+ // // $project_path = "D:/MySoftware/wamp/www/code/phpvulhunter/test/test.php" ;
1083
+ // // $project_path = "E:/School_of_software/information_security/PHPVulScanner_project/74cms_3.3/" ;
1084
+
1085
+ // $allFiles = FileUtils::getPHPfile($project_path);
1153
1086
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 );
1087
+ // //初始化
1088
+ // $initModule = new InitModule() ;
1089
+ // $initModule->init($project_path, $allFiles) ;
1159
1090
1160
- //初始化
1161
- $ initModule = new InitModule () ;
1162
- $ initModule ->init ($ project_path , $ allFiles ) ;
1163
1091
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 ) ;
1092
+ // $cfg = new CFGGenerator() ;
1093
+ // $visitor = new MyVisitor() ;
1094
+ // $parser = new PhpParser\Parser(new PhpParser\Lexer\Emulative) ;
1095
+ // $traverser = new PhpParser\NodeTraverser ;
1096
+ // $path = CURR_PATH . '/test/test.php';
1097
+ // $path = 'C:/Users/xyw55/Desktop/test/74cms_3.3/admin/api/locoyspider.php';
1098
+ // $cfg->getFileSummary()->setPath($path);
1099
+ // $code = file_get_contents($path);
1100
+ // $stmts = $parser->parse($code) ;
1101
+ // $traverser->addVisitor($visitor) ;
1102
+ // $traverser->traverse($stmts) ;
1103
+ // $nodes = $visitor->getNodes() ;
1104
+ // $pEntryBlock = new BasicBlock() ;
1105
+ // $pEntryBlock->is_entry = true ;
1106
+ // $ret = $cfg->CFGBuilder($nodes, NULL, NULL, NULL) ;
1178
1107
1108
+ // echo '456';
1179
1109
1180
1110
1181
1111
?>
0 commit comments