|
13 | 13 | //
|
14 | 14 | $_securityNotices=array(
|
15 | 15 | 'APPSEC-1034, addressing bypassing custom admin URL' => array(
|
16 |
| - 'grep' => array( |
17 |
| - 'grep -irl "<use>admin</use>"'. ' '. $_magentoPath. 'app/code/*' |
| 16 | + 'text' => '', |
| 17 | + 'exec' => array( |
| 18 | + 'path' => array( |
| 19 | + $_magentoPath. 'app/code/*' |
| 20 | + ), |
| 21 | + 'cmd' => 'grep -irl ' , |
| 22 | + 'query' => array( |
| 23 | + '"<use>admin</use>"' |
| 24 | + ) |
18 | 25 | ),
|
19 | 26 | 'magentopath' => $_magentoPath),
|
20 | 27 | 'APPSEC-1063, addressing possible SQL injection' => array(
|
21 |
| - 'grep' => array( |
22 |
| - 'grep -irl "collection->addFieldToFilter(\'"'. ' '. $_magentoPath. 'app/code/community/*', |
23 |
| - 'grep -irl "collection->addFieldToFilter(\'"'. ' '. $_magentoPath. 'app/code/local/*', |
24 |
| - 'grep -irl "collection->addFieldToFilter(\'\`"'. ' '. $_magentoPath. 'app/code/community/*', |
25 |
| - 'grep -irl "collection->addFieldToFilter(\'\`"'. ' '. $_magentoPath. 'app/code/local/*' |
| 28 | + 'text' => '', |
| 29 | + 'exec' => array( |
| 30 | + 'path' => array( |
| 31 | + $_magentoPath. 'app/code/community/*', |
| 32 | + $_magentoPath. 'app/code/local/*' |
| 33 | + ), |
| 34 | + 'cmd' => 'grep -irl ' , |
| 35 | + 'query' => array( |
| 36 | + '"collection->addFieldToFilter(\'"', |
| 37 | + '"collection->addFieldToFilter(\'\`"', |
| 38 | + ) |
26 | 39 | ),
|
27 | 40 | 'magentopath' => $_magentoPath),
|
28 | 41 | 'APPSEC-1057, template processing method allows access to private information' => array(
|
29 |
| - 'grep' => array( |
30 |
| - 'grep -irl "{{config path="'. ' '. $_magentoPath. 'app/code/community/*', |
31 |
| - 'grep -irl "{{config path="'. ' '. $_magentoPath. 'app/code/local/*', |
32 |
| - 'grep -irl "{{config path="'. ' '. $_magentoPath. 'app/locale/*', |
33 |
| - 'grep -irl "{{config path="'. ' '. $_magentoPath. 'app/design/frontend/*', |
34 |
| - 'grep -irl "{{block type="'. ' '. $_magentoPath. 'app/code/community/*', |
35 |
| - 'grep -irl "{{block type="'. ' '. $_magentoPath. 'app/code/local/*', |
36 |
| - 'grep -irl "{{block type="'. ' '. $_magentoPath. 'app/locale/*', |
37 |
| - 'grep -irl "{{block type="'. ' '. $_magentoPath. 'app/design/frontend/*' |
| 42 | + 'text' => '', |
| 43 | + 'exec' => array( |
| 44 | + 'path' => array( |
| 45 | + $_magentoPath. 'app/code/community/*', |
| 46 | + $_magentoPath. 'app/code/local/*', |
| 47 | + $_magentoPath. 'app/locale/*', |
| 48 | + $_magentoPath. 'app/design/frontend/*' |
| 49 | + ), |
| 50 | + 'cmd' => 'grep -irl ' , |
| 51 | + 'query' => array( |
| 52 | + '"{{config path="', |
| 53 | + '"{{block type="', |
| 54 | + ) |
38 | 55 | ),
|
39 |
| - 'magentopath' => $_magentoPath) |
| 56 | + 'magentopath' => $_magentoPath) |
40 | 57 | );
|
41 | 58 |
|
42 | 59 | // EXEC
|
|
59 | 76 | function doExec($_securityNotice)
|
60 | 77 | {
|
61 | 78 | $_text='';
|
| 79 | + $_exec=$_securityNotice['exec']['cmd']; |
62 | 80 |
|
63 |
| - foreach ($_securityNotice['grep'] as $_grep) |
| 81 | + foreach ($_securityNotice['exec']['path'] as $_searchPath) |
64 | 82 | {
|
65 |
| - $_exec=$_grep; |
| 83 | + |
66 | 84 | $_count=0;
|
67 | 85 | $_search='';
|
68 |
| - |
69 |
| - exec($_exec, $_output, $_status); |
70 |
| - preg_match('/"([^"]+)"/', $_grep, $_query); |
71 |
| - |
72 |
| - if (1 === $_status) |
73 |
| - { |
74 | 86 |
|
75 |
| - $_text=$_text.$_query[1]. ' not found.'. "\n"; |
76 |
| - continue; |
77 |
| - } |
78 |
| - |
79 |
| - if (0 === $_status) |
| 87 | + foreach ($_securityNotice['exec']['query'] as $_searchQuery) |
80 | 88 | {
|
81 |
| - $_count=count($_output); |
| 89 | + |
| 90 | + $_text=$_text.'looking in '. $_searchPath. ' for '. $_searchQuery. "\n"; |
| 91 | + |
| 92 | + exec($_exec. $_searchQuery. ' '. $_searchPath, $_output, $_status); |
82 | 93 |
|
83 |
| - foreach ($_output as $_line) |
| 94 | + if (1 === $_status) |
| 95 | + { |
| 96 | + |
| 97 | + $_text=$_text.$_searchQuery. ' not found.'. "\n"; |
| 98 | + continue; |
| 99 | + } |
| 100 | + |
| 101 | + if (0 === $_status) |
84 | 102 | {
|
85 |
| - $_search=$_search.$_query[1]. ' found in '. str_replace($_securityNotice['magentopath'],' ', $_line). "\n"; |
| 103 | + $_count=count($_output); |
| 104 | + |
| 105 | + foreach ($_output as $_line) |
| 106 | + { |
| 107 | + $_search=$_search.$_searchQuery. ' found in '. str_replace($_securityNotice['magentopath'],' ', $_line). "\n"; |
| 108 | + } |
| 109 | + |
| 110 | + } else { |
| 111 | + $_text=$_text. 'Command '. $_securityNotice['exec']['cmd']. ' failed with status: ' . $_status. "\n"; |
86 | 112 | }
|
87 | 113 |
|
88 |
| - } else { |
89 |
| - $_text=$_text. 'Command '. $_grep. ' failed with status: ' . $_status. "\n"; |
| 114 | + $_text=$_text.$_count. ' effected files : '. "\n". $_search. "\n"; |
90 | 115 | }
|
91 |
| - |
92 |
| - $_text=$_text.$_count. ' effected files : '. "\n". $_search; |
93 | 116 | }
|
94 | 117 |
|
95 | 118 | return $_text;
|
|
0 commit comments