Chinaunix首页 | 论坛 | 博客
  • 博客访问: 973
  • 博文数量: 2
  • 博客积分: 125
  • 博客等级: 入伍新兵
  • 技术积分: 30
  • 用 户 组: 普通用户
  • 注册时间: 2012-10-30 09:23
文章分类

全部博文(2)

文章存档

2012年(2)

我的朋友
最近访客

分类: 嵌入式

2012-10-30 09:52:48

转自 http://developer.aiwgame.com/android-antivirus-principles-and-examples.html


REVIEW: an anti-virus soft-most core of the part is a virus database one antivirus enginevirus database from the server to obtain, antivirus engine actually is the procedures for determining the package name and signature whether to match the virus databasepackage name and signature, if the matchcompared with the virus, the interface makes … 

An anti-virus soft-core part of a virus database is an anti-virus engine and virus databasefrom the server, the anti-virus engine is actually a package name and the procedures for determining whether the signature matches the package name and signature in the virus database, if the match is compared withvirus, the interface using the frame animation to display.

Ideas:

From the server-side version of the library information of the virus download will parse the data stored in a List collection

(2) access to all applications in the mobile phone package name and signature of theprogram

3 virus database to match the package name and signature of the mobile application

4 ScrollView label automatically scroll

The key code is as follows:

Trojan horse virus database information:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
  
  
  tory.virus
  
  cn.itcast.virus
  
  Malicious software, read the user logs
  
  3082020730820170a00302010202044ea7598f300d06092a864886f70d010105050030483
  10a30080603550406130131310a30080603550408130131310a3008060355040713013131
  0a3008060355040a130131310a3008060355040b130131310a30080603550403130131301
  e170d3131313032363030353132375a170d3231313032333030353132375a3048310a3008
  0603550406130131310a30080603550408130131310a30080603550407130131310a30080
  60355040a130131310a3008060355040b130131310a3008060355040313013130819f300d
  06092a864886f70d010101050003818d0030818902818100d915d7a98cde8bcd69b87ec52
  11012ace847de42129a71bf679a059c2c55e893bc0ea886874432ab8b9097724211df6769
  eacd3381ccac779ab7422d8101320b1e0b14e06ac8ee095b20e52cbe6163e10a87dc410b8
  a91fb73d53c5bdb4a22d1295c61e04b8f8b68c475e69c1754a1dc35745e7c6ae0275c2620
  b863b0d9ea8f0203010001300d06092a864886f70d01010505000381810038e1119fbb710
  4180fddba4bc8b2c275df63f0df418b7480d8eba2891da20d34d3d083cfed7bb3eb546863
  c76bc67cc93f2fa0e9377c470881c9a763c99cc035093184bb50f76e74155592eca3566a3
  10af55e5fec19d6fdc1a74f226aef485f84389126e8e3f4b59fe2797cbfcac660b9f2cc81
  e6f3dcaa7cb2001ecc496a7b
  
  
  

Antivirus engine:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
  /*
 
* Antivirus engine (download the virus database, access to the package name and signature of the program and to match)
 
* (non-Javadoc)
 
* @see Android.app.Activity#onTouchEvent(android.view.MotionEvent)
 
*/
 
@Override
 
public boolean onTouchEvent(MotionEvent event) {
 
packagenames = new ArrayList();
 
virusResult = new ArrayList();
 
infos = new ArrayList();
 
animationDrawable.start();//Play back the movie you scan for viruses
 
new Thread(){
 
@Override
 
public void run() {
 
try {
 
URL url = new URL("http://192.168.1.168:8080/virus.xml");
 
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
 
InputStream is = conn.getInputStream();
 
//Get to the collection of the virus database from the server to resolve the virus databaseand
 
virusbeans = VirusInfo.getVirusInfos(is);
 
TaskInfo taskInfo = new TaskInfo(KillVirusActivity.this); //Instantiate the Package Explorer
 
//Get to the phone inside the package name
 
infos = pm.getInstalledApplications(0);
 
for(ApplicationInfo info : infos ){
 
packagenames.add(info.packageName);
 
}
 
int count=0;
 
//Antivirus engine, virus database than the current system inside the program packagesignature anti-virus
 
StringBuilder sb = new StringBuilder();
 
for(String packname : packagenames){
 
sb.append("Scanning "+ packname);
 
sb.append("\n");
 
Message msg = new Message();
 
msg.what = SCANNING;
 
msg.obj = sb;
 
handler.sendMessage(msg);
 
//Check the current packname and corresponding signature http://www.aiwgame.com is avirus library inside information
 
for(VirusBean virusbean : virusbeans){
 
if(packname.equals(virusbean.getPackname())&&
 
taskInfo.getAppSignature(packname).equals(virusbean.getSignature()))
 
{
 
virusResult.add(packname);//Add a virus
 
}
 
}
 
count ++;//Record the total number of virus
 
}
 
Message msg = new Message();
 
msg.what = SCANNING_FINISH;
 
msg.obj = count;
 
handler.sendMessage(msg);
 
} catch (Exception e) {
 
e.printStackTrace();
 
}
 
}
 
}.start();
 
return super.onTouchEvent(event);
 
}

Virus scan information is displayed:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
 Handler handler = new Handler(){
 
@Override
 
public void handleMessage(Message msg) {
 
super.handleMessage(msg);
 
switch (msg.what) {
 
case SCANNING:
 
StringBuilder sb = (StringBuilder) msg.obj;
 
tv_killvirus_info.setText(sb.toString());
 
sv.scrollBy(0, 25);//Increments will automatically move down the screen
 
break;
 
case SCANNING_FINISH:
 
int i = (Integer) msg.obj;
 
StringBuilder sb1 = new StringBuilder();
 
sb1.append("Scan finished scanning a total of"+ i+ " programs");
 
if(virusResult。size()>0){
 
sb1.append("Discovery of the virus \n");
 
for(String packname : virusResult){
 
sb1.append("Virus name"+ packname);
 
sb1.append("\n");
 
}
 
}
 
tv_killvirus_info.setText(sb1.toString());
 
animationDrawable.stop();
 
break;
 
}
 
}
 
};

Get to the signature of the program:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
  /*
 
* Obtain the signature of the program
 
*/
 
public String getAppSignature(String packname){
 
try {
 
PackageInfo packinfo =pm.getPackageInfo(packname, PackageManager.GET_SIGNATURES);
 
//Get to all the privileges
 
return packinfo.signatures[0].toCharsString();
 
} catch (NameNotFoundException e) {
 
e.printStackTrace();
 
return null;
 
}
 
}

To display the scanned document pages and automatically scroll:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
  
 
Android:layout_width="wrap_content"
 
Android:layout_height="wrap_content"
 
Android:layout_below="@id/iv_killvirus_am"
 
Android:id="@+id/sv_killvirus"
 
>
 
 
Android:layout_width="wrap_content"
 
Android:layout_height="wrap_content"
 
Android:id="@+id/tv_killvirus_info"
 
>
 
阅读(173) | 评论(0) | 转发(0) |
0

上一篇:没有了

下一篇:没有了

给主人留下些什么吧!~~