在…..\android_sdk\tools文件下找到emulator-arm.exe,使用UltraEdit文本编辑器打开,搜索CGSN关键字,把0000000000…改成你自己想要的imei号。保存即可。
用apktool+dex2jar+jd_gui反编译apk文件
这三个软件google一下都可以免费下载使用。
我们可以反编译一些软件来学习人家的架构及界面等。
apktool: 可以解析资源文件,比如布局文件xml等,方便查看。
这个简单,不用介绍。
dex2jar:可以将dex文件转换成jar文件
用法:
1.将apk文件后缀改成rar,然后解压,取出其中的classes.dex,放到任意位置;
2.进入cmd,cd到dex2jar所在文件夹,输入命令dex2jar.bat %classes.dex所在目录%\class.dex
3. 命令完成后在%class.dex所在目录%就会生成jar文件
jd_gui:能够将jar文件反编译成java代码
用法:
打开jd_gui,然后将jar包拖放到主界面,就可以看到源代码了。
一个获取APK的packagename,versionCode,versionName
因为应用经常我这里分析包名,所以写了此bat
使用方法,另存下面的内容为xxx.bat,然后把apk直接拖到此bat上,就会把信息直接赋值到剪切板,直接粘贴就是了
ps:需要android环境支持
@echo off title 获取包名 echo 获取包名 aapt d badging %1 >>qq.txt findstr "\<package: name=\'*\'\>" qq.txt >>qq2.txt del qq.txt CLIP < qq2.txt del qq2.txt echo 结束! #pause exit
自动修改android模拟器的imei的小程序
该程序实现一下功能,
1,修改android模拟器的imei,
2,自动启动android模拟器
3,运行开机启动程序,ps:这个开机启动程序apk就没放出来了。
4,停止android模拟器;
重复1,2,3过程
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
public class Test {
/**
* @param args
*/
public static void main(String[] args) {
try {
while(true){//
eidtEmulator();//修改imei
Runtime rt = Runtime.getRuntime();
String command = "C:\\Program Files\\Android\\android-sdk\\tools\\emulator -avd AVD-10";
rt.exec(command); // 运行android模拟器
System.out.println("success run");
Thread.sleep(2*60*1000);// 等待2分钟后,停止android模拟器
if(findRunningWindowsProcess("emulator-arm.exe")){
killRunningWindowsProcess("emulator-arm.exe");
}
}
} catch (IOException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
}
public static void eidtEmulator() throws Exception{
String oldFilePath = "C:\\Program Files\\Android\\android-sdk\\tools\\emulator-arm.exe ";
String newFilePath = "C:\\Program Files\\Android\\android-sdk\\tools\\emulator-arm1.exe";
FileInputStream in = new FileInputStream(oldFilePath);
FileOutputStream out = new FileOutputStream(newFilePath);
byte bytes[] = new byte[1];
byte gsnbytes[] = new byte[3];
byte imeiBytes[] = new byte[15];
int count;
while ((count = in.read(bytes)) != -1) {
out.write(bytes);
if (bytes[0] == 0x43) {// if is char 'C'
count = in.read(gsnbytes);
if (count == -1) {
break;
}
out.write(gsnbytes);
if (gsnbytes[0] == 0x47 && gsnbytes[1] == 0x53 && gsnbytes[2] == 0x4E) {//if is char 'GSN'
count = in.read(bytes);//read char '.'
if (count == -1) {
break;
}
out.write(bytes);
count = in.read(imeiBytes);//read old imei
if (count == -1) {
break;
}
byte[] imeis = getIMEIBytes();
out.write(imeis);//write new imei;
}
}
}
in.close();
out.close();
File oldFile = new File(oldFilePath);
oldFile.delete();
File newFile = new File(newFilePath);
newFile.renameTo(oldFile);
}
public static byte[] getIMEIBytes() {//随即生成15位imei号
StringBuffer bff = new StringBuffer();
byte imeiBytes[] = new byte[15];
for(int i=0;i<imeiBytes.length;i++){
int num = (int) Math.round(Math.random()*8);
bff.append(num);
imeiBytes[i] = Byte.parseByte("3"+num, 16);
}
// printArray(imeiBytes);
System.err.println("start imei: "+bff.toString());
return imeiBytes;
}
public static void printArray(byte bytes[]) {
StringBuffer buff = new StringBuffer();
for (byte b : bytes) {
buff.append(String.format("%02X", b) + " ");
}
System.out.println(buff.toString());
}
public static boolean killRunningWindowsProcess(String processName){
try {
Runtime.getRuntime().exec("taskkill /IM " + processName);
System.out.println("kill process successful");
// System.out.println("Process " + processName + " was killed. Mission completed.");
return true;
} catch (Exception ex) {
ex.printStackTrace();
System.out.println("kill process fail");
System.out.println("Misson failed.");
return false;
}
}
public static boolean findRunningWindowsProcess(String processName) {
BufferedReader bufferedReader = null;
Process proc = null;
try {
proc = Runtime.getRuntime().exec("tasklist /FI \"IMAGENAME eq " + processName + "\"");
bufferedReader = new BufferedReader(new InputStreamReader(proc.getInputStream()));
String line;
while ((line = bufferedReader.readLine()) != null) {
if (line.contains(processName)) {
return true;
}
}
return false;
} catch (Exception ex) {
ex.printStackTrace();
return false;
} finally {
if (bufferedReader != null) {
try {
bufferedReader.close();
} catch (Exception ex) {
}
}
if (proc != null) {
try {
proc.destroy();
} catch (Exception ex) {
}
}
}
}
}
Android之读取Resource和Assets中的文件
public String getFromRes(String FileName){
String result = "";
try{
InputStream in = getResources().openRawResource(R.raw.test2);//获取资源
int length = in.available();//获取文字字数
byte[]buffer = new byte[length];
in.read(buffer);//读到数组中
//设置编码
result = EncodingUtils.getString(buffer, "UTF-8");
}catch (Exception e) {
}
return result;
}
public String getFromAssets(String FileName){
String result = "";
try{
InputStream in = getAssets().open(FileName);//获取资源
int length = in.available();//获取文字字数
byte[]buffer = new byte[length];
in.read(buffer);//读到数组中
//设置编码
result = EncodingUtils.getString(buffer, "UTF-8");
}catch (Exception e) {
}
return result;
}
ps: 继承 Activity
或者可以使用 context.getAssets().open(FileName);// 获取资源