Android 应用程序包文件 (APK) 是一种Android操作系统上的应用程序安装文件格式,其英文全称为 “application package file” 。
如果懂得使用反编译工具,可以下载apk解析工具,获得反编译代码。
需要下载:SharpZipLib.zip http://www.icsharpcode.net/opensource/sharpziplib/download.aspx
主要方法如下
using ICSharpCode.SharpZipLib.Zip;
public static Dictionary<object, object> getPackageInfo(string path){
Dictionary<object, object> returnMap = new
Dictionary<object, object>();
returnMap.Add("版本编号(VersionCode)",
"");
returnMap.Add("版本名称(VersionName)", "");
returnMap.Add("包名(Package)",
"");
returnMap.Add("签名(Sig)", "");
returnMap.Add("启动activity",
"");
returnMap["证书有效期"] = "";
returnMap["证书过期时间"] =
"";
returnMap["证书Hash"] = "";
returnMap["证书MD5"] =
"";
returnMap["PublicKey"] = "";
List<string> list = new
List<string> { ".DSA", ".RSA" };
if
(string.IsNullOrWhiteSpace(path))
{
throw new Exception("文件路径不正确:" +
path);
}
string str = "";
if (path.LastIndexOf(".") >=
0)
{
str = path.Substring(path.LastIndexOf("."));
}
if
(".apk".Equals(str,
StringComparison.OrdinalIgnoreCase))
{
try
{
ZipInputStream zip =
new ZipInputStream(File.OpenRead(path));
ZipEntry zipEntry = null;
while
((zipEntry = zip.GetNextEntry()) != null)
{
string fileName =
Path.GetFileName(zipEntry.Name);
if ((fileName != null) &&
(fileName.LastIndexOf(".") >= 0))
{
string item =
fileName.Substring(fileName.LastIndexOf("."));
if
("AndroidManifest.xml".Equals(fileName,
StringComparison.OrdinalIgnoreCase))
{
getPackageDetails(zip, zipEntry,
returnMap);
}
else if (list.Contains(item))
{
getSig(zip, zipEntry,
returnMap);
}
}
}
zip.Close();
}
catch (Exception
exception)
{
throw new Exception("解析apk包错误:" +
exception.Message);
}
}
return returnMap;
}
private static void getSig(ZipInputStream zip, ZipEntry zipEntry,
Dictionary<object, object> returnMap)
{
MemoryStream stream = new
MemoryStream();
byte[] rawCertData = new byte[0x400];
int count =
0;
while ((count = zip.Read(rawCertData, 0, 0x400)) >
0)
{
stream.Write(rawCertData, 0, count);
}
stream.Seek(0L,
SeekOrigin.Begin);
string str = "";
X509Certificate certificate = new
X509Certificate(stream.GetBuffer());
returnMap["证书有效期"] =
certificate.GetEffectiveDateString();
returnMap["证书过期时间"] =
certificate.GetExpirationDateString();
returnMap["证书Hash"] =
certificate.GetCertHashString();
returnMap["证书MD5"] =
BitConverter.ToString(MD5.Create().ComputeHash(certificate.GetRawCertData())).Replace(‘-‘,
‘:‘);
returnMap["PublicKey"] =
certificate.GetPublicKeyString();
rawCertData =
certificate.GetRawCertData();
byte[] buffer2 =
SHA1.Create().ComputeHash(certificate.GetRawCertData());
for (int i = 0; i
< buffer2.Length; i++)
{
str = str + ((sbyte)
buffer2[i]);
}
stream.Close();
returnMap["签名(Sig)"] = str;
}
apk文件上传大小限制,web.config文件添加如下:
<system.web>
<httpRuntime maxRequestLength="1073741824"
executionTimeout="3600" />
</system.web>
<system.webServer>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="1073741824">
</requestLimits>
</requestFiltering>
</security>
</system.webServer>
原文:http://www.cnblogs.com/jiaqichinese/p/3594354.html