31 lines
1.1 KiB
C#
31 lines
1.1 KiB
C#
|
|
using System;
|
||
|
|
using System.IO;
|
||
|
|
|
||
|
|
class Scan {
|
||
|
|
static int Count(byte[] hay, byte[] needle) {
|
||
|
|
int n = 0;
|
||
|
|
for (int i = 0; i + needle.Length <= hay.Length; i++) {
|
||
|
|
bool m = true;
|
||
|
|
for (int j = 0; j < needle.Length; j++) if (hay[i + j] != needle[j]) { m = false; break; }
|
||
|
|
if (m) n++;
|
||
|
|
}
|
||
|
|
return n;
|
||
|
|
}
|
||
|
|
static void Main(string[] args) {
|
||
|
|
string dir = args[0];
|
||
|
|
string[] pats = { "AECH", "AERE", "AEREP", "Claim", "challenge" };
|
||
|
|
foreach (string f in Directory.GetFiles(dir, "*.dll")) {
|
||
|
|
byte[] b = File.ReadAllBytes(f);
|
||
|
|
string hits = "";
|
||
|
|
foreach (string p in pats) {
|
||
|
|
byte[] a = System.Text.Encoding.ASCII.GetBytes(p);
|
||
|
|
byte[] u = System.Text.Encoding.Unicode.GetBytes(p);
|
||
|
|
int ca = Count(b, a), cu = Count(b, u);
|
||
|
|
if (ca > 0 || cu > 0) hits += string.Format(" {0}(ascii={1},utf16={2})", p, ca, cu);
|
||
|
|
}
|
||
|
|
if (hits.Length > 0) Console.WriteLine(Path.GetFileName(f) + ":" + hits);
|
||
|
|
}
|
||
|
|
Console.WriteLine("scan done");
|
||
|
|
}
|
||
|
|
}
|