Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
B
BYLAppRobot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
liuyang
BYLAppRobot
Commits
84041751
Commit
84041751
authored
Jul 19, 2018
by
liuyang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
抓包结果通过浏览器查看
parent
d872cdf0
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
109 additions
and
18 deletions
+109
-18
MainActivity.kt
app/src/main/java/com/duolebo/blyrobot/MainActivity.kt
+28
-6
AppUtil.kt
app/src/main/java/com/duolebo/blyrobot/util/AppUtil.kt
+36
-0
Constants.kt
app/src/main/java/com/duolebo/blyrobot/util/Constants.kt
+3
-0
CaptureWebServer.kt
...rc/main/java/com/duolebo/blyrobot/web/CaptureWebServer.kt
+7
-0
activity_main.xml
app/src/main/res/layout/activity_main.xml
+35
-12
No files found.
app/src/main/java/com/duolebo/blyrobot/MainActivity.kt
View file @
84041751
...
@@ -3,19 +3,18 @@ package com.duolebo.blyrobot
...
@@ -3,19 +3,18 @@ package com.duolebo.blyrobot
import
android.app.Activity
import
android.app.Activity
import
android.content.Context
import
android.content.Context
import
android.content.Intent
import
android.content.Intent
import
android.os.Build
import
android.os.Bundle
import
android.os.Bundle
import
android.support.v7.app.AppCompatActivity
import
android.support.v7.app.AppCompatActivity
import
android.util.Log
import
android.util.Log
import
android.view.View
import
android.widget.*
import
android.widget.Button
import
android.widget.Toast
import
com.duolebo.blyrobot.activity.PackageListActivity
import
com.duolebo.blyrobot.activity.PackageListActivity
import
com.duolebo.blyrobot.data.ApkPackageInfo
import
com.duolebo.blyrobot.data.ApkPackageInfo
import
com.duolebo.blyrobot.service.BylWebService
import
com.duolebo.blyrobot.service.BylWebService
import
com.duolebo.blyrobot.util.AppUtil
import
com.duolebo.blyrobot.util.AppUtil
import
com.duolebo.blyrobot.util.Constants
import
com.minhui.vpn.ProxyConfig
import
com.minhui.vpn.ProxyConfig
import
com.minhui.vpn.VPNConstants.*
import
com.minhui.vpn.VPNConstants.*
import
com.minhui.vpn.service.FirewallVpnService
import
com.minhui.vpn.utils.ThreadProxy
import
com.minhui.vpn.utils.ThreadProxy
import
com.minhui.vpn.utils.VpnServiceHelper
import
com.minhui.vpn.utils.VpnServiceHelper
import
com.minhui.vpn.utils.VpnServiceHelper.START_VPN_SERVICE_REQUEST_CODE
import
com.minhui.vpn.utils.VpnServiceHelper.START_VPN_SERVICE_REQUEST_CODE
...
@@ -53,10 +52,29 @@ class MainActivity : AppCompatActivity() {
...
@@ -53,10 +52,29 @@ class MainActivity : AppCompatActivity() {
selectApp
()
selectApp
()
}
}
captureButton
=
findViewById
(
R
.
id
.
captureB
utto
n
)
captureButton
=
findViewById
(
R
.
id
.
captureB
t
n
)
captureButton
.
setOnClickListener
{
captureButton
.
setOnClickListener
{
runOrStopCapture
()
runOrStopCapture
()
}
}
val
clearBtn
=
findViewById
<
Button
>(
R
.
id
.
clearBtn
)
clearBtn
.
setOnClickListener
{
clearHistoryData
()
}
initCheckbox
()
val
webUrlText
=
findViewById
<
TextView
>(
R
.
id
.
webUrl
)
webUrlText
.
text
=
"启动抓取后请在浏览器打开:\nhttp://"
+
AppUtil
.
getIPAddress
(
true
,
null
)
+
":48080"
}
private
fun
initCheckbox
()
{
val
checkbox
=
findViewById
<
CheckBox
>(
R
.
id
.
videoCheckbox
)
val
sp
=
getSharedPreferences
(
VPN_SP_NAME
,
Context
.
MODE_PRIVATE
)
checkbox
.
isChecked
=
sp
.
getBoolean
(
Constants
.
ONLY_VIDEO
,
false
)
checkbox
.
setOnCheckedChangeListener
{
_
,
isChecked
->
sp
.
edit
().
putBoolean
(
Constants
.
ONLY_VIDEO
,
isChecked
).
apply
()
}
}
}
override
fun
onResume
()
{
override
fun
onResume
()
{
...
@@ -80,7 +98,11 @@ class MainActivity : AppCompatActivity() {
...
@@ -80,7 +98,11 @@ class MainActivity : AppCompatActivity() {
private
fun
runOrStopCapture
()
{
private
fun
runOrStopCapture
()
{
if
(
VpnServiceHelper
.
vpnRunningStatus
())
{
if
(
VpnServiceHelper
.
vpnRunningStatus
())
{
// stopService(Intent(this, BylWebService::class.java))
// 由于5.0以下系统无法控制抓取规则,所以停止抓取之后才能通过web查看
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
LOLLIPOP
)
{
stopService
(
Intent
(
this
,
BylWebService
::
class
.
java
))
}
VpnServiceHelper
.
changeVpnRunningStatus
(
this
,
false
)
VpnServiceHelper
.
changeVpnRunningStatus
(
this
,
false
)
}
}
else
{
else
{
...
...
app/src/main/java/com/duolebo/blyrobot/util/AppUtil.kt
View file @
84041751
package
com.duolebo.blyrobot.util
package
com.duolebo.blyrobot.util
import
android.text.TextUtils
import
java.io.File
import
java.io.File
import
java.io.FileFilter
import
java.io.FileFilter
import
java.net.Inet4Address
import
java.net.InetAddress
import
java.net.NetworkInterface
import
java.util.*
object
AppUtil
{
object
AppUtil
{
fun
deleteFile
(
file
:
File
?,
fileFilter
:
FileFilter
)
{
fun
deleteFile
(
file
:
File
?,
fileFilter
:
FileFilter
)
{
...
@@ -25,4 +30,35 @@ object AppUtil {
...
@@ -25,4 +30,35 @@ object AppUtil {
}
}
file
.
delete
()
file
.
delete
()
}
}
fun
getIPAddress
(
useIPv4
:
Boolean
,
interfaceName
:
String
?):
String
{
try
{
val
interfaces
=
Collections
.
list
(
NetworkInterface
.
getNetworkInterfaces
())
for
(
intf
in
interfaces
)
{
if
(!
TextUtils
.
isEmpty
(
interfaceName
)
&&
intf
.
name
!=
interfaceName
)
{
continue
}
val
addrs
=
Collections
.
list
(
intf
.
inetAddresses
)
for
(
addr
in
addrs
)
{
if
(!
addr
.
isLoopbackAddress
)
{
val
sAddr
=
addr
.
hostAddress
.
toUpperCase
()
// boolean isIPv4 = InetAddressUtils.isIPv4Address(sAddr);
val
isIPv4
=
addr
is
Inet4Address
//Since API-23 InetAddressUtils was removed
if
(
useIPv4
)
{
if
(
isIPv4
)
return
sAddr
}
else
{
if
(!
isIPv4
)
{
val
delim
=
sAddr
.
indexOf
(
'%'
)
// drop ip6 port suffix
return
if
(
delim
<
0
)
sAddr
else
sAddr
.
substring
(
0
,
delim
)
}
}
}
}
}
}
catch
(
ex
:
Exception
)
{
}
// for now eat exceptions
return
""
}
}
}
\ No newline at end of file
app/src/main/java/com/duolebo/blyrobot/util/Constants.kt
View file @
84041751
...
@@ -22,4 +22,7 @@ object Constants {
...
@@ -22,4 +22,7 @@ object Constants {
"ok"
to
"23"
,
"ok"
to
"23"
,
"back"
to
"4"
,
"back"
to
"4"
,
"mute"
to
"164"
)
"mute"
to
"164"
)
const
val
ONLY_VIDEO
=
"only_video"
val
VIDEO_EXTS
=
"m3u8|.ts|.mp4|.rmvb|.mkv|.wmv"
}
}
\ No newline at end of file
app/src/main/java/com/duolebo/blyrobot/web/CaptureWebServer.kt
View file @
84041751
package
com.duolebo.blyrobot.web
package
com.duolebo.blyrobot.web
import
android.content.Context
import
android.content.Context
import
com.duolebo.blyrobot.util.Constants
import
com.minhui.vpn.ProxyConfig
import
com.minhui.vpn.ProxyConfig
import
com.minhui.vpn.VPNConstants
import
com.minhui.vpn.VPNConstants
import
com.minhui.vpn.VPNConstants.DEFAULT_PACKAGE_ID
import
com.minhui.vpn.VPNConstants.DEFAULT_PACKAGE_ID
...
@@ -71,6 +72,7 @@ class CaptureWebServer : NanoHTTPD {
...
@@ -71,6 +72,7 @@ class CaptureWebServer : NanoHTTPD {
val
sp
=
context
.
getSharedPreferences
(
VPNConstants
.
VPN_SP_NAME
,
Context
.
MODE_PRIVATE
)
val
sp
=
context
.
getSharedPreferences
(
VPNConstants
.
VPN_SP_NAME
,
Context
.
MODE_PRIVATE
)
val
selectPackage
=
sp
.
getString
(
DEFAULT_PACKAGE_ID
,
null
)
val
selectPackage
=
sp
.
getString
(
DEFAULT_PACKAGE_ID
,
null
)
val
onlyVideo
=
sp
.
getBoolean
(
Constants
.
ONLY_VIDEO
,
false
)
while
(
iterator
.
hasNext
())
{
while
(
iterator
.
hasNext
())
{
val
next
=
iterator
.
next
()
val
next
=
iterator
.
next
()
if
(
next
.
bytesSent
==
0
&&
next
.
receiveByteNum
==
0L
)
{
if
(
next
.
bytesSent
==
0
&&
next
.
receiveByteNum
==
0L
)
{
...
@@ -82,6 +84,11 @@ class CaptureWebServer : NanoHTTPD {
...
@@ -82,6 +84,11 @@ class CaptureWebServer : NanoHTTPD {
continue
continue
}
}
if
(
onlyVideo
&&
!(
next
.
getRequestUrl
().
contains
(
".ts"
)
||
next
.
getRequestUrl
().
contains
(
"m3u8"
)))
{
iterator
.
remove
()
continue
}
val
appInfo
=
next
.
appInfo
val
appInfo
=
next
.
appInfo
if
(
appInfo
!=
null
)
{
if
(
appInfo
!=
null
)
{
...
...
app/src/main/res/layout/activity_main.xml
View file @
84041751
...
@@ -5,20 +5,43 @@
...
@@ -5,20 +5,43 @@
android:layout_height=
"match_parent"
android:layout_height=
"match_parent"
android:layout_width=
"match_parent"
>
android:layout_width=
"match_parent"
>
<Button
<LinearLayout
android:id=
"@+id/selectBtn"
android:layout_width=
"wrap_content"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"选择App抓包"
android:orientation=
"vertical"
android:layout_centerInParent=
"true"
/>
android:layout_centerInParent=
"true"
>
<Button
android:id=
"@+id/selectBtn"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"选择目标App"
/>
<Button
<Button
android:id=
"@+id/captureButton"
android:id=
"@+id/captureBtn"
android:layout_width=
"wrap_content"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"10dp"
android:layout_marginTop=
"10dp"
android:layout_centerHorizontal=
"true"
android:text=
"开始抓包"
/>
android:layout_below=
"@+id/selectBtn"
android:text=
"开始抓包"
/>
<CheckBox
android:id=
"@+id/videoCheckbox"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"10dp"
android:text=
"只抓取视频"
/>
<Button
android:id=
"@+id/clearBtn"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"10dp"
android:text=
"清除历史"
/>
<TextView
android:id=
"@+id/webUrl"
android:layout_marginTop=
"10dp"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
/>
</LinearLayout>
</RelativeLayout>
</RelativeLayout>
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment