<?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. 基于Fragment实现Tab的切换,滑出侧边栏

    最近在学习Fragment(碎片)这是android3.0以后提出的概念,很多pad上面的设置部分都是通过Fragment来实现的,先看看具体的效果吧(图一)  (图二) (图三)第一章图片是初始时的 ...

  2. 转载:fstream和ifstream详细用法

    文件 I/O 在C++中比烤蛋糕简单多了.在这篇文章里,我会详细解释ASCII和二进制文件的输入输出的每个细节,值得注意的是,所有这些都是用C++完成的. 一.ASCII 输出 为了使用下面的方法, ...

  3. CodeForces 148D-Bag of mice(概率dp)

    题意: 袋子里有w个白球b个黑球,现在两个人轮流每次取一个球(不放回),先取到白球的获胜,当后手取走一个球时,袋子里的球会随机的漏掉一个,问先手获胜的概率. 分析: dp[i][j]表示袋子中i个白球 ...

  4. Cadence原理图与Allegro交互

    1:激活orCAD与Allegro的交互程序 打开原理图,Options->Preference在Miscellaneous里勾选 2:打开用到的工程 原理图,还有Allegro PCB Des ...

  5. ASP.NET单点登录(代码)

    [p=25, null, left]由于某些原因,在我们的应用中会遇到一个用户只能在一个地方登录的情况,也就是我们通常所说的单点登录.在ASP.NET中实现单点登录其实很简单,下面就把主要的方法和全部 ...

  6. 去除下载电影和电视剧文件名中的多余字符[python实现]

    讨厌下载电影和电视剧文件名中的多余字符(如网址和广告字样),,搞得文件名好长,可以使用下面的Python代码,自行修改即可. #!\usr\bin\env python # -*- coding: u ...

  7. python中yield用法

    在介绍yield前有必要先说明下Python中的迭代器(iterator)和生成器(constructor). 一.迭代器(iterator) 在Python中,for循环可以用于Python中的任何 ...

  8. Unbutu网卡驱动安装(Intel内置网卡8086:15b8)

    工作中需要在新的实验平台上安装unbuntu14.04操作系统,系统安装好之后发现无法连接网络,分析后是由于缺少网卡驱动的原因. 下面把分析问题的过程及安装网卡驱动步骤介绍如下: 查看PCI信息 su ...

  9. NetAddr

    http://www.searchdatabase.com.cn/showcontent_66349.htm   [techTarget中国,其专注于IT领域企业级高端市场,为IT专业技术人员和管理决 ...

  10. POJ3237-Tree (树链剖分,线段树区间更新+点更新+区间查询)

    两个更新操作,一个将第i条路径权值改为w,一个是将a-b之间所有路径权值取反. 一个查询操作,求a-b之间路径中权值最大的边. 很容易想到维护一个最大最小值,取反就是把最大最小取反交换一下. 开始遇到 ...