<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:layout_width="match_parent"
android:layout_height="60dip"
android:background="#8866ff00"
android:gravity="center"
android:text="病毒查杀"
android:textSize="24sp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:orientation="horizontal" >
<!-- 帧布局是一层层往上盖,所以就是图片的叠加,后添加的在上面,先添加的在下面 -->
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:background="@drawable/ic_scanner_malware" />
<ImageView
android:id="@+id/iv_scanning"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:background="@drawable/act_scanning_03" />
</FrameLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:orientation="vertical" >
<TextView
android:id="@+id/tv_init_virus"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="初始化8核杀毒引擎" />
<ProgressBar
android:id="@+id/progressBar1"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp" />
</LinearLayout>
</LinearLayout>
<ScrollView
android:id="@+id/scrollView"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:id="@+id/ll_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
</LinearLayout>
</ScrollView>
</LinearLayout>
package com.itheima.mobileguard.activities;

import java.io.File;
import java.io.FileInputStream;
import java.security.MessageDigest;
import java.util.List; import org.w3c.dom.Text; import com.itheima.mobileguard.R;
import com.itheima.mobileguard.db.dao.AntivirusDao;
import com.itheima.mobileguard.domain.AppInfo;
import com.itheima.mobileguard.engine.AppInfoParser;
import com.itheima.mobileguard.utils.Md5Utils; import android.R.bool;
import android.app.Activity;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.res.ColorStateList;
import android.graphics.Color;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.os.SystemClock;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.RotateAnimation;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.ScrollView;
import android.widget.Scroller;
import android.widget.TextView; public class AntivirusActivity extends Activity {
// 扫描开始
protected static final int BEGING = 1;
// 扫描中
protected static final int SCANING = 2;
// 扫描结束
protected static final int FINISH = 3;
private Message message; @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
initUI();
initData();
} Handler handler = new Handler() {
public void handleMessage(android.os.Message msg) {
switch (msg.what) {
case BEGING:
tv_init_virus.setText("初始化八核引擎");
break;
case SCANING:
// 病毒扫描中:
TextView child = new TextView(AntivirusActivity.this);
ScanInfo scanInfo = (ScanInfo) msg.obj;
// 如果为true表示有病毒
if (scanInfo.desc) {
child.setTextColor(Color.RED);
child.setText(scanInfo.appName + "有病毒");
} else {
child.setTextColor(Color.BLACK);
// // 为false表示没有病毒
child.setText(scanInfo.appName + "扫描安全");
} ll_content.addView(child,0);
//自动滚动
scrollView.post(new Runnable() {
@Override
public void run() {
//一直往下面进行滚动
scrollView.fullScroll(scrollView.FOCUS_DOWN);
}
});
System.out.println(scanInfo.appName + "扫描安全");
break;
case FINISH:
// 当扫描结束的时候。停止动画
iv_scanning.clearAnimation();
break;
}
};
}; private TextView tv_init_virus;
private ProgressBar pb;
private ImageView iv_scanning;
private LinearLayout ll_content;
private ScrollView scrollView; private void initData() {
new Thread() {
public void run() {
message = Message.obtain();
message.what = BEGING; PackageManager packageManager = getPackageManager();
// 获取到所有安装的应用程序
List<PackageInfo> installedPackages = packageManager
.getInstalledPackages(0);
// 返回手机上面安装了多少个应用程序
int size = installedPackages.size();
// 设置进度条的最大值
pb.setMax(size);
int progress = 0;
for (PackageInfo packageInfo : installedPackages) {
ScanInfo scanInfo = new ScanInfo(); // 获取到当前手机上面的app的名字
String appName = packageInfo.applicationInfo.loadLabel(
packageManager).toString();
scanInfo.appName = appName;
String packageName = packageInfo.applicationInfo.packageName;
scanInfo.packageName = packageName; // 首先需要获取到每个应用程序的目录
String sourceDir = packageInfo.applicationInfo.sourceDir;
// 获取到文件的md5
String md5 = Md5Utils.getFileMd5(sourceDir);
/*public static String getFileMd5(String sourceDir) {
File file = new File(sourceDir);
try {
FileInputStream fis = new FileInputStream(file);
byte[] buffer = new byte[1024];
int len = -1;
//获取到数字摘要
MessageDigest messageDigest = MessageDigest.getInstance("md5");
while((len = fis.read(buffer))!= -1){
messageDigest.update(buffer, 0, len);
}
byte[] result = messageDigest.digest();
StringBuffer sb = new StringBuffer();
for(byte b : result){
int number = b&0xff; // 加盐 +1 ;
String hex = Integer.toHexString(number);
if(hex.length()==1){
sb.append("0"+hex);
}else{
sb.append(hex);
}
}
return sb.toString();
} catch (Exception e) {
e.printStackTrace();
}
return null;
}*/
// 判断当前的文件是否是病毒数据库里面(根据应用的md5判断是否在病毒库中)
String desc = AntivirusDao.checkFileVirus(md5);
System.out.println("-------------------------");
System.out.println(appName);
System.out.println(md5); // 03-06 07:37:32.505: I/System.out(23660): 垃圾
// 03-06 07:37:32.505: I/System.out(23660): 51dc6ba54cbfbcff299eb72e79e03668
// ["md5":"51dc6ba54cbfbcff299eb72e79e03668","desc":"蝗虫病毒赶快卸载","desc":"蝗虫病毒赶快卸载","desc":"蝗虫病毒赶快卸载"]
// B7DA3864FD19C0B2390C9719E812E649
// 如果当前的描述信息等于null说明没有病毒
if (desc == null) {
scanInfo.desc = false;
} else {
scanInfo.desc = true;
}
progress++; SystemClock.sleep(100);
pb.setProgress(progress);
message = Message.obtain();
message.what = SCANING;
message.obj = scanInfo;
handler.sendMessage(message);
} message = Message.obtain();
message.what = FINISH;
handler.sendMessage(message);
};
}.start(); } static class ScanInfo {
boolean desc;
String appName;
String packageName;
} private void initUI() {
setContentView(R.layout.activity_antivirusa);
iv_scanning = (ImageView) findViewById(R.id.iv_scanning);
tv_init_virus = (TextView) findViewById(R.id.tv_init_virus);
pb = (ProgressBar) findViewById(R.id.progressBar1);
ll_content = (LinearLayout) findViewById(R.id.ll_content);
scrollView = (ScrollView) findViewById(R.id.scrollView); //图片转起来
/**
* 第一个参数表示开始的角度 ,第二个参数表示结束的角度,
* 第三个参数表示X轴参照自己从0.5开始,第四个参数表示Y轴参照自己从0.5开始,
* 初始化旋转动画
*/
RotateAnimation rotateAnimation = new RotateAnimation(0, 360,
Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF,
0.5f);
// 设置动画的时间
rotateAnimation.setDuration(5000);
// 设置动画无限循环
rotateAnimation.setRepeatCount(Animation.INFINITE);
// 开始动画
iv_scanning.startAnimation(rotateAnimation);
}
}
package com.itheima.mobileguard.db.dao;

import org.json.JSONObject;

import com.google.gson.Gson;
import com.itheima.mobileguard.domain.Virus;
import com.lidroid.xutils.HttpUtils;
import com.lidroid.xutils.exception.HttpException;
import com.lidroid.xutils.http.ResponseInfo;
import com.lidroid.xutils.http.callback.RequestCallBack;
import com.lidroid.xutils.http.client.HttpRequest.HttpMethod; import android.content.ContentValues;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
//主动防御:如果有软件想改变c盘改变浏览器改变注册表就认为是病毒,权限判断就是提醒用户他会改变这些东西。
public class AntivirusDao { /**
* 检查当前的md5值是否在病毒数据库
*/
public static String checkFileVirus(String md5){
String desc = null;
SQLiteDatabase db = SQLiteDatabase.openDatabase(
"/data/data/com.itheima.mobileguard/files/antivirus.db", null,
SQLiteDatabase.OPEN_READONLY);
//查询当前传过来的md5是否在病毒数据库里面
Cursor cursor = db.rawQuery("select desc from datable where md5 = ?", new String[]{md5});
//判断当前的游标是否可以移动
if(cursor.moveToNext()){
desc = cursor.getString(0);
}
cursor.close();
return desc;
}
/**
* 添加病毒数据库
* @param md5 特征码
* @param desc 描述信息
*/
public static void addVirus(String md5,String desc){
SQLiteDatabase db = SQLiteDatabase.openDatabase(
"/data/data/com.itheima.mobileguard/files/antivirus.db", null,
SQLiteDatabase.OPEN_READWRITE);
ContentValues values = new ContentValues();
values.put("md5", md5);
values.put("type", 6);
values.put("name", "Android.Troj.AirAD.a");
values.put("desc", desc);
db.insert("datable", null, values);
db.close();
} /**
* 联网进行更新病毒数据库
*/
private void updataVirus() {
dao = new AntivirusDao();
//联网从服务器获取到最新数据的md5的特征码
HttpUtils httpUtils = new HttpUtils(); String url = "http://192.168.13.126:8080/virus.json";
httpUtils.send(HttpMethod.GET, url, new RequestCallBack<String>() {
@Override
public void onFailure(HttpException arg0, String arg1) {
} @Override
public void onSuccess(ResponseInfo<String> arg0) {
System.out.println(arg0.result);
// {"md5":"51dc6ba54cbfbcff299eb72e79e03668","desc":"蝗虫病毒赶快卸载"}
try {
JSONObject jsonObject = new JSONObject(arg0.result);
Gson gson = new Gson();
//解析json
Virus virus = gson.fromJson(arg0.result, Virus.class);
// String md5 = jsonObject.getString("md5");
// String desc = jsonObject.getString("desc");
dao.addVirus(virus.md5, virus.desc);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
}

android146 360 病毒查杀的更多相关文章

  1. 028 Android 旋转动画+病毒查杀效果+自定义样式的ProgressBar

    1.目标效果 旋转动画+病毒查杀效果 2.xml布局文件 (1)activity_kill_virus.xml <?xml version="1.0" encoding=&q ...

  2. Linux服务器感染kerberods病毒 | 挖矿病毒查杀及分析 | (curl -fsSL lsd.systemten.org||wget -q -O- lsd.systemten.org)|sh)

    概要: 一.症状及表现 二.查杀方法 三.病毒分析 四.安全防护 五.参考文章 一.症状及表现 1.CPU使用率异常,top命令显示CPU统计数数据均为0,利用busybox 查看CPU占用率之后,发 ...

  3. Linux十字病毒查杀处理

    之前处理过一次十字病毒,但未好好整理处理过程,现在转载一篇来自51cto的文章. 转自:http://blog.51cto.com/ixdba/2163018 十字符病毒,杀不死的小强,一次云服务器沦 ...

  4. Virus:病毒查杀

    简介 小伙伴们,大家好,今天分享一次Linux系统杀毒的经历,还有个人的一些总结,希望对大家有用. 这次遇到的是一个挖矿的病毒,在挖一种叫门罗币(XMR)的数字货币,行情走势请看 https://ww ...

  5. 安装ClamAV对centos系统进行病毒查杀

    安装ClamAV 1.安装epel源 yum install epel-release 在安装了EPEL源后,运行下面的命令安装ClamAV # yum install clamav-server c ...

  6. Centos6 服务器病毒查杀命令历史

    top whereis vhowazeclu ll /usr/bin/v* more /usr/bin/vhowazeclu ps aux|grep vhowa ps aux|grep vhowaze ...

  7. i春秋手动病毒查杀

    1:查看系统进程程   tasklist命令 2:当任务管理器无法打开的时候可以利用 taskkill /f /im [程序所显示的pid]   两个参数的意思分别是强制和程序在内存中的印象 3:ms ...

  8. 病毒木马查杀实战第010篇:QQ盗号木马之十六进制代码分析

    前言 按照我的个人习惯,在运用诸如IDA Pro与OllyDBG对病毒进行逆向分析之前,我都会利用一些自动化的工具,通过静态或动态的分析方法(参见<病毒木马查杀第008篇:熊猫烧香之病毒查杀总结 ...

  9. 病毒木马查杀实战第009篇:QQ盗号木马之手动查杀

    前言 之前在<病毒木马查杀第002篇:熊猫烧香之手动查杀>中,我在不借助任何工具的情况下,基本实现了对于"熊猫烧香"病毒的查杀.但是毕竟"熊猫烧香" ...

随机推荐

  1. C#复习反射

    反射中常用方法: //获取对象类型 One one = new One(); Type t = one.GetType(); //动态加载 Assembly a = Assembly.LoadFile ...

  2. 【原】Mongodb相关资料

    Mongodb与关系型数据库对比 Mongodb与关系型数据库对比 由于之前主要接触的是关系型数据库,所以主要将Mongodb与关系型数据库进行对比:主要从术语.Server与Client.数据定义语 ...

  3. Python 学习笔记(四)正则、闭合、生成器

    (一)正则表达式 基本规则: ^ 匹配字符串开始位置. $ 匹配字符串结束位置. \b 匹配一个单词边界. \d 匹配一个数字. \D 匹配一个任意的非数字字符. x? 匹配可选的x字符.换句话说,就 ...

  4. Ensemble learning(集成学习)

    集成学习:是目前机器学习的一大热门方向,所谓集成学习简单理解就是指采用多个分类器对数据集进行预测,从而提高整体分类器的泛化能力. 我们在前面介绍了.所谓的机器学习就是通过某种学习方法在假设空间中找到一 ...

  5. CentOS6 root 用户 vi/vim 无法开启高亮

    编辑 /etc/profile.d/vim.sh if [ -n "$BASH_VERSION" -o -n "$KSH_VERSION" -o -n &quo ...

  6. 将大数据利用 BCP 导出SqlServer数据到CSV

    --导出数据 --BCP [数据库]..[数据库表] out "d:\abc.csv" -c -t "|" -T bcp "SELECT * FROM ...

  7. 解决oracle启动的错误: ORA-00119 ORA-00132

    $ sqlplus / as sysdbaSQL>create pfile fromspfile修改$ORACLE_HOME/dbs下的文件initDEV.ora中的*.local_listen ...

  8. DBMS_ERRLOG记录DML错误日志(二)

    上一篇简单介绍了DML记录语句的限制,虽然所有的例子都是利用INSERT语句,但是LOG ERRORS语句并没有这个限制,UPDATE.DELETE和MERGE都可以使用这个语句.下面要说的就是这篇的 ...

  9. Spring MVC ControllerClassNameHandlerMapping example

    handler mapping是把url跟控制器关联起来. In Spring MVC, ControllerClassNameHandlerMapping use convention to map ...

  10. POJ 1679 The Unique MST (次小生成树)

    题目链接:http://poj.org/problem?id=1679 有t组数据,给你n个点,m条边,求是否存在相同权值的最小生成树(次小生成树的权值大小等于最小生成树). 先求出最小生成树的大小, ...