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
68607be4
Commit
68607be4
authored
Jul 12, 2018
by
liuyang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tcpdump 抓包http协议连接及退出测试处理
parent
b4b71f45
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
64 additions
and
9 deletions
+64
-9
BylRobotService.kt
...main/java/com/duolebo/blyrobot/service/BylRobotService.kt
+10
-7
AdbUtil.kt
app/src/main/java/com/duolebo/blyrobot/util/AdbUtil.kt
+54
-2
No files found.
app/src/main/java/com/duolebo/blyrobot/service/BylRobotService.kt
View file @
68607be4
...
...
@@ -27,12 +27,12 @@ class BylRobotService: Service() {
testCapture
()
// screenShot()
count
++
if
(
count
>
4
)
{
if
(
count
>
2
)
{
cancelTimer
()
// proc?.destroy()
}
}
},
2000
,
5
*
1000
)
},
2000
,
10
*
1000
)
}
private
fun
screenShot
()
{
...
...
@@ -52,11 +52,14 @@ class BylRobotService: Service() {
var
proc
:
Process
?=
null
private
fun
testCapture
()
{
if
(
proc
==
null
)
{
Thread
(
Runnable
{
proc
=
AdbUtil
.
tcpCapture
(
""
)
}).
start
()
}
proc
?.
destroy
()
Thread
(
Runnable
{
AdbUtil
.
killTcpdump
()
}).
start
()
Thread
.
sleep
(
3000
)
Thread
(
Runnable
{
proc
=
AdbUtil
.
tcpCapture
(
""
)
}).
start
()
}
private
fun
cancelTimer
()
{
...
...
app/src/main/java/com/duolebo/blyrobot/util/AdbUtil.kt
View file @
68607be4
...
...
@@ -9,7 +9,7 @@ import java.io.InputStreamReader
object
AdbUtil
{
const
val
TAG
=
"AdbUtil"
const
val
SHELL
=
"sh"
const
val
ROOT_SHELL
=
"s
h
"
const
val
ROOT_SHELL
=
"s
u
"
const
val
LINE_BREAK
=
"\n"
const
val
EXIT
=
"exit"
...
...
@@ -174,7 +174,7 @@ object AdbUtil {
}
fun
tcpCapture
(
tcpdump
:
String
):
Process
?
{
val
captureCmd
=
"
su\n tcpdump -p -vv -s 0 -A 'tcp dst port 80 and tcp[((tcp[12:1] & 0xf0) >> 2):4] = 0x47455420' >> /sdcard/capture.txt\nexi
t\n"
val
captureCmd
=
"
tcpdump -p -vv -s 0 -A 'tcp dst port 80 and tcp[((tcp[12:1] & 0xf0) >> 2):4] = 0x47455420' >> /sdcard/capture.tx
t\n"
val
proc
=
getRootShell
()
var
dos
:
DataOutputStream
?
=
null
...
...
@@ -191,7 +191,59 @@ object AdbUtil {
dos
?.
close
()
}
object
:
Thread
()
{
override
fun
run
()
{
val
insBr
=
BufferedReader
(
InputStreamReader
(
proc
?.
inputStream
))
try
{
var
lineStr
:
String
?
=
null
do
{
lineStr
=
insBr
.
readLine
()
if
(
lineStr
.
isNullOrEmpty
())
break
lineStr
=
trimLine
(
lineStr
)
Log
.
i
(
TAG
,
" tcpdump echo line : $lineStr"
)
}
while
(
true
)
}
catch
(
e
:
IOException
)
{
e
.
printStackTrace
()
}
finally
{
try
{
proc
?.
inputStream
?.
close
()
}
catch
(
e
:
IOException
)
{
e
.
printStackTrace
()
}
}
}
}.
start
()
object
:
Thread
()
{
override
fun
run
()
{
val
errBr
=
BufferedReader
(
InputStreamReader
(
proc
?.
errorStream
))
try
{
var
errLine
:
String
?
=
null
do
{
errLine
=
errBr
.
readLine
()
if
(
errLine
.
isNullOrEmpty
())
break
errLine
=
trimLine
(
errLine
)
Log
.
i
(
TAG
,
" tcpdump error line : $errLine"
)
}
while
(
true
)
}
catch
(
e
:
IOException
)
{
e
.
printStackTrace
()
}
finally
{
try
{
proc
?.
errorStream
?.
close
()
}
catch
(
e
:
IOException
)
{
e
.
printStackTrace
()
}
}
}
}.
start
()
return
proc
}
fun
killTcpdump
()
{
exeCmdEcho
(
"killall tcpdump"
,
true
)
}
}
\ 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