Showing
2 changed files
with
15 additions
and
6 deletions
... | @@ -69,7 +69,7 @@ namespace VulnCrawler | ... | @@ -69,7 +69,7 @@ namespace VulnCrawler |
69 | 69 | ||
70 | // var fields = VulnWorker.GetCriticalVariant(@"return _is_safe_url(url, host) and _is_safe_url(url.replace('\\', '/'), host)"); | 70 | // var fields = VulnWorker.GetCriticalVariant(@"return _is_safe_url(url, host) and _is_safe_url(url.replace('\\', '/'), host)"); |
71 | var c = new VulnC(); | 71 | var c = new VulnC(); |
72 | - var fields = c.GetCriticalVariant(@"cs64_chunk.chunkSize64 = 12345678;"); | 72 | + var fields = c.ExtractCriticalVariant(@"!DoReadFile (infile, &ds64_chunk, sizeof (DS64Chunk), &bcount) ||/* aaaa */"); |
73 | foreach (var item in fields) | 73 | foreach (var item in fields) |
74 | { | 74 | { |
75 | Console.WriteLine(item); | 75 | Console.WriteLine(item); | ... | ... |
... | @@ -168,24 +168,33 @@ namespace VulnCrawler | ... | @@ -168,24 +168,33 @@ namespace VulnCrawler |
168 | /// </summary> | 168 | /// </summary> |
169 | /// <param name="line">현재 코드줄</param> | 169 | /// <param name="line">현재 코드줄</param> |
170 | /// <returns></returns> | 170 | /// <returns></returns> |
171 | - public IEnumerable<string> GetCriticalVariant(string line) | 171 | + public IEnumerable<string> ExtractCriticalVariant(string line) |
172 | { | 172 | { |
173 | line = line.Trim(); | 173 | line = line.Trim(); |
174 | + if (string.IsNullOrWhiteSpace(line)) | ||
175 | + { | ||
176 | + yield break; | ||
177 | + } | ||
174 | if (line.StartsWith("//")) | 178 | if (line.StartsWith("//")) |
175 | { | 179 | { |
176 | yield break; | 180 | yield break; |
177 | } | 181 | } |
178 | string declarePattern = @"(?<Declare>[a-zA-Z0-9_\.]+) [a-zA-Z0-9_\.]+ ="; | 182 | string declarePattern = @"(?<Declare>[a-zA-Z0-9_\.]+) [a-zA-Z0-9_\.]+ ="; |
179 | // 메서드 정규식 패턴 | 183 | // 메서드 정규식 패턴 |
180 | - string methodPattern = @"(\w+)\s*\("; | 184 | + string methodPattern = @"([a-zA-Z0-9_\.]+)\s*\("; |
181 | // 변수 정규식 패턴 | 185 | // 변수 정규식 패턴 |
182 | - string fieldPattern = @"^*?[a-zA-Z0-9_\.]+"; | 186 | + string fieldPattern = @"^*?[a-zA-Z0-9_\.\[\]]+"; |
183 | 187 | ||
184 | string invalidPattern = @"^[\d\.]+"; | 188 | string invalidPattern = @"^[\d\.]+"; |
185 | 189 | ||
186 | - string commentPattern = @"("".*"")"; | 190 | + string commentPattern = @"[""].*[""]"; |
191 | + | ||
192 | + string commentPattern2 = @"\/\/.*"; | ||
193 | + string commentPattern3 = @"\/\*.+\*\/"; | ||
187 | 194 | ||
188 | line = Regex.Replace(line, commentPattern, ""); | 195 | line = Regex.Replace(line, commentPattern, ""); |
196 | + line = Regex.Replace(line, commentPattern2, ""); | ||
197 | + line = Regex.Replace(line, commentPattern3, ""); | ||
189 | // 메서드 목록 | 198 | // 메서드 목록 |
190 | var methodSets = new HashSet<string>(); | 199 | var methodSets = new HashSet<string>(); |
191 | 200 | ||
... | @@ -208,7 +217,7 @@ namespace VulnCrawler | ... | @@ -208,7 +217,7 @@ namespace VulnCrawler |
208 | if (method.Success) | 217 | if (method.Success) |
209 | { | 218 | { |
210 | Console.WriteLine(method.Groups[1].Value); | 219 | Console.WriteLine(method.Groups[1].Value); |
211 | - methodSets.Add(method.Groups[1].Value); | 220 | + methodSets.Add(method.Groups[1].Value); // aaaa |
212 | } | 221 | } |
213 | } | 222 | } |
214 | Console.WriteLine("----"); | 223 | Console.WriteLine("----"); | ... | ... |
-
Please register or login to post a comment