当前位置:网站首页>Test APK exception control nettraffic attacker development
Test APK exception control nettraffic attacker development
2022-06-23 07:40:00 【Fadi】
1. Purpose
be based on 《 Application experience standard of software Green Alliance 》 in NetTraffic The definition of resources , Yes NetTraffic Simulation of the behavior of multiple small traffic packets in the background . Designed to trigger abnormal power consumption control mechanism in mobile phones .

Screen is off this time NetTraffic At least two levels used more than :30 Time ,60 Time , Execute the following judgment :
The green line does not control the standard : Important perceptible scenarios , Not limited to and including the system application white list 、 Third party application whitelist 、CTS、 Charge 、 Default input method 、 Default clock 、 Audio scene 、 Step counting scenario
The red line should control the standard : The number of small traffic times of non downloading and uploading this time has exceeded 30 Time , exceed 5 Minutes of non perceptible scenes
Be careful : For small packets , Avoid downloading behavior scenarios , Prevent misjudgment
The first level : Notification alerts or power consumption tagging
The second level : Restrict or intercept
2022-06-22 15:00:40.459 2630-23738/com.huawei.iaware I/DownloadState: singleUid: 10175 [com.sufadi.blocknettraffic] speed: 7830 real speed: 7800 (rxB:34116 txB:5036 rxP:73 txP:77)
2022-06-22 15:00:40.474 2630-23738/com.huawei.iaware I/DownloadState: shareUid: 0 /system/bin/netd transmitting data speed : 35 bytes/s (rxB:118 txB:59 rxP:1 txP:1 iface:1)
2022-06-22 15:00:44.711 2630-3079/com.huawei.iaware I/APwActAnalysis: net traffic high power app: com.sufadi.blocknettraffic trafficCount: 30 duration:150180
2. testing procedure
H Mobile phones and T mobile phone 、 Other mobile phones for installation apk.
All mobile phones need to set the app to white list .
2.1 Mobile phone white list setting method :
Cell phone manager -> Apply startup settings : Allow self starting 、 Allow association to start 、 Allow background startup

2.2 Test environment
Turn on the Internet
2.3 Run this apk
Packet usage behavior detection in the background of screen out
2.4 Run this apk
test : After adding white list , Run this apk after , Press home key , Off screen ,30 Minutes later, the screen will be lit to view , Whether there is an abnormal reminder of high power consumption
3. apk Source code
Ben apk effect : Unlimited backstage WiFi Scanning behavior
3.1 UI

3.2 Core logic
3.2.1 MainActivity
package com.sufadi.blocknettraffic
import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
startService(Intent(this, BlockNetTrafficService::class.java))
}
}
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=" Screen is off this time NetTraffic At least two levels used more than :30 Time ,60 Time , Execute the following judgment :\n
\n The green line does not control the standard : Important perceptible scenarios , Not limited to and including the system application white list 、 Third party application whitelist 、CTS、 Charge 、 Default input method 、 Default clock 、 Audio scene 、 Step counting scenario
\n The red line should control the standard : The number of small traffic times of non downloading and uploading this time has exceeded 30 Time , exceed 5 Minutes of non perceptible scenes
\n Be careful : For small packets , Avoid downloading behavior scenarios , Prevent misjudgment
\n The first level : Notification alerts or power consumption tagging
\n The second level : Restrict or intercept
\n The test method :
\n After adding white list , Run this apk after , Press home key , Off screen ,30 Minutes later, the screen will be lit to view , Whether there is an abnormal reminder of high power consumption
"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
3.3.2 Access configuration
Keep alive and connected
<!-- Foreground service attribute permission -->
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<!-- network right -->
<uses-permission android:name="android.permission.INTERNET" />
3.3.3 Core logic
The backstage has been regularly connected to Baidu and resident services
package com.sufadi.blocknettraffic
import android.app.Notification
import android.app.NotificationChannel
import android.app.NotificationManager
import android.app.Service
import android.content.Context
import android.content.Intent
import android.location.Location
import android.location.LocationListener
import android.location.LocationManager
import android.os.Bundle
import android.os.Handler
import android.os.IBinder
import android.os.Message
import android.util.Log
import okhttp3.OkHttpClient
import okhttp3.Request
import java.io.IOException
import java.lang.ref.WeakReference
class BlockNetTrafficService: Service() {
companion object {
val TAG = "BlockNetTrafficService"
val FORGROUND_ID = 0x11
val MSG_UPDATE_NETWORK = 1
}
var mMainHandle: MainHandle? = null
override fun onBind(p0: Intent?): IBinder? {
return null
}
override fun onCreate() {
super.onCreate()
Log.d(TAG, "onCreate")
startMyForeground()
mMainHandle = MainHandle(this)
sendRequestWithHttpClient()
}
override fun onDestroy() {
super.onDestroy()
stopForeground(true)
}
class MainHandle(serviceTct: BlockNetTrafficService) : Handler() {
private val mRefServiceTct: WeakReference<BlockNetTrafficService>
init {
mRefServiceTct = WeakReference(serviceTct)
}
override fun handleMessage(msg: Message) {
val service = mRefServiceTct.get() ?: return
when (msg.what) {
MSG_UPDATE_NETWORK -> {
service?.sendRequestWithHttpClient()
}
}
}
}
private fun startMyForeground() {
Log.d(TAG, "startMyForeground show notification")
Log.d(TAG, "PhoneDataService startMyForeground sdk :" + android.os.Build.VERSION.SDK_INT)
val nb = Notification.Builder(this)
if (android.os.Build.VERSION.SDK_INT >= 26) {
val CHANNEL_ONE_ID = "channel_id_foreground"
val CHANNEL_ONE_NAME = "Channel One"
var notificationChannel: NotificationChannel? = null
notificationChannel = NotificationChannel(
CHANNEL_ONE_ID,
CHANNEL_ONE_NAME, NotificationManager.IMPORTANCE_LOW
)
nb.setChannelId(CHANNEL_ONE_ID)
val manager = getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
manager.createNotificationChannel(notificationChannel)
}
nb.setSmallIcon(R.mipmap.ic_launcher)
nb.setContentTitle(getString(R.string.notification_title))
nb.setContentText(getString(R.string.notification_Content))
try {
startForeground(FORGROUND_ID, nb.build())
} catch (e: Exception) {
e.printStackTrace()
}
}
// Method : Send network request , Get Baidu home page data . Turn on threads inside
private fun sendRequestWithHttpClient() {
Thread(Runnable {
val requestUrl =
"https://www.baidu.com/"
val okHttpClient = OkHttpClient()
val request = Request.Builder()
.url(requestUrl)
.build()
val call = okHttpClient.newCall(request)
Log.v(TAG, "okHttpClient.newCall")
try {
val response = call.execute()
if (response.isSuccessful()) {
//The call was successful.print it to the log
val msg = Message()
msg.what = MSG_UPDATE_NETWORK
msg.obj = response.body().string()
Log.v(TAG, response.body().string())
mMainHandle?.sendMessageDelayed(msg, 1000)
}
} catch (e: IOException) {
e.printStackTrace()
}
}).start()
}
}
3.3.4 Huawei exception detection log

Screen is off this time NetTraffic At least two levels used more than :30 Time ,60 Time , Execute the following judgment :
The green line does not control the standard : Important perceptible scenarios , Not limited to and including the system application white list 、 Third party application whitelist 、CTS、 Charge 、 Default input method 、 Default clock 、 Audio scene 、 Step counting scenario
The red line should control the standard : The number of small traffic times of non downloading and uploading this time has exceeded 30 Time , exceed 5 Minutes of non perceptible scenes
Be careful : For small packets , Avoid downloading behavior scenarios , Prevent misjudgment
The first level : Notification alerts or power consumption tagging
The second level : Restrict or intercept
2022-06-22 15:00:40.459 2630-23738/com.huawei.iaware I/DownloadState: singleUid: 10175 [com.sufadi.blocknettraffic] speed: 7830 real speed: 7800 (rxB:34116 txB:5036 rxP:73 txP:77)
2022-06-22 15:00:40.474 2630-23738/com.huawei.iaware I/DownloadState: shareUid: 0 /system/bin/netd transmitting data speed : 35 bytes/s (rxB:118 txB:59 rxP:1 txP:1 iface:1)
2022-06-22 15:00:44.711 2630-3079/com.huawei.iaware I/APwActAnalysis: net traffic high power app: com.sufadi.blocknettraffic trafficCount: 30 duration:150180
边栏推荐
猜你喜欢

【星球精选】如何高效构建 Roam 与 theBrain 间细粒度双向链接?

在线文本过滤小于指定长度工具

Eureka service registration and discovery

Can you think of a better way to solve the problem of string inversion?

Heuristic search strategy

Wechat multiplayer chat and Roulette Games (websocket Implementation)

Solutions to abnormal network connection of Xiaoai speakers

Simpledateformat thread safety issues

EXCEL VBA 入门与实用例子

Yan's DP analysis
随机推荐
MYSQL牛客刷题
Unity picture loading and saving
How to quickly and gracefully download large files from Google cloud disk (II)
csrf攻击在laravel中如何解决
Make a record of glib2.14 upgrading glib2.18 and the principle of the steps
[deep learning] [original] how to detect targets and draw map and other parameter maps without yolov5 weights or models
g++编译命令使用
NFS 特别注意权限的问题
Console Application
Ntu-rgbd data set download and data format analysis
1.概率论-组合分析
【AI实战】机器学习数据处理之数据归一化、标准化
Design of temperature detection and alarm system based on 51 single chip microcomputer
EXCEL VBA 入门与实用例子
如何优雅的快速下载谷歌云盘的大文件 (二)
CIRIUM(睿思誉)逐渐成为航空公司二氧化碳排放报告的标准
【唠嗑篇】普通人到底该怎么学技术啊?
G++ compilation command use
MySQL (V) - locks and transactions
NFS special attention to permissions