Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
I
IOT-fuzz
Overview
Overview
Details
Activity
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
尹启迪
IOT-fuzz
Commits
10f8c730
Commit
10f8c730
authored
Sep 26, 2020
by
张航玮
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add new file
parent
8ea94abc
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
143 additions
and
0 deletions
+143
-0
spider.py
spider.py
+143
-0
No files found.
spider.py
0 → 100644
View file @
10f8c730
import
asyncio
from
pyppeteer
import
launch
import
time
browser
,
page
,
frame
=
None
,
None
,
None
input_list
=
[
"input"
]
click_list
=
[
"label"
,
"button"
,
"a"
]
input_id_list
=
[]
click_id_list
=
[]
async
def
get_element_list
(
page
,
p
):
print
(
"getting"
,
p
)
element_id_list
=
[]
try
:
element_list
=
await
page
.
querySelectorAll
(
p
)
#print(element_list)
for
element
in
element_list
:
id
=
await
page
.
evaluate
(
'(element) => element.id'
,
element
)
if_input
=
True
try
:
if
p
==
"input"
:
element_type
=
await
page
.
evaluate
(
'(element) => element.type'
,
element
)
#print(element_type)
if
element_type
==
"hidden"
:
if_input
=
False
else
:
element_click
=
await
page
.
evaluate
(
'(element) => element.onclick'
,
element
)
#print(element_click)
if
element_click
==
None
:
if_input
=
False
except
:
print
(
"error"
)
#print(id,if_input)
if
if_input
:
element_id_list
.
append
(
"#"
+
id
)
#print(element_id_list)
except
:
print
(
"no"
,
element
)
return
element_id_list
async
def
force_inputorclick
(
page
):
for
In_list
in
input_id_list
:
for
In
in
In_list
:
await
page
.
type
(
In
,
"admin"
)
for
Cl_list
in
click_id_list
:
for
Cl
in
Cl_list
:
await
page
.
click
(
Cl
)
await
page
.
waitFor
(
3000
)
async
def
main
():
global
browser
,
page
,
frame
,
input_id_list
,
click_id_list
browser
=
await
launch
({
'headless'
:
True
,
# 关闭无头模式
'devtools'
:
True
,
# 打开 chromium 的 devtools
'executablePath'
:
'/home/zhw/.local/share/pyppeteer/chrome'
,
'args'
:
[
'--disable-extensions'
,
'--hide-scrollbars'
,
'--disable-bundled-ppapi-flash'
,
'--mute-audio'
,
'--no-sandbox'
,
'--disable-setuid-sandbox'
,
'--disable-gpu'
,
],
'dumpio'
:
True
,
})
print
(
"-----------------login-------------------"
)
url_list
=
[
"http://192.168.0.1/"
]
page
=
await
browser
.
newPage
()
await
page
.
setViewport
({
'width'
:
1366
,
'height'
:
768
})
await
page
.
goto
(
'http://192.168.0.1/'
)
print
(
".................start get page's element_id................."
)
for
p
in
input_list
:
id_list
=
await
get_element_list
(
page
,
p
)
input_id_list
.
append
(
id_list
)
print
(
input_id_list
)
for
p
in
click_list
:
id_list
=
await
get_element_list
(
page
,
p
)
click_id_list
.
append
(
id_list
)
print
(
click_id_list
)
print
(
".................start input/click..................."
)
await
force_inputorclick
(
page
)
#input.buttonBig:nth-child(3)
print
(
"-----------------new page-------------------"
)
new_url
=
page
.
url
print
(
new_url
)
if
new_url
in
url_list
:
print
(
"not goto"
)
else
:
print
(
"new page"
)
url_list
.
append
(
new_url
)
print
(
url_list
)
frames
=
page
.
mainFrame
print
(
frames
)
for
frame
in
frames
.
childFrames
:
input_id_list
=
[]
click_id_list
=
[]
for
p
in
input_list
:
id_list
=
await
get_element_list
(
frame
,
p
)
input_id_list
.
append
(
id_list
)
print
(
input_id_list
)
for
p
in
click_list
:
id_list
=
await
get_element_list
(
frame
,
p
)
click_id_list
.
append
(
id_list
)
print
(
click_id_list
)
try
:
await
frame
.
click
(
"#ol22"
)
await
page
.
waitFor
(
3000
)
new_url
=
page
.
url
print
(
new_url
)
element
=
await
frame
.
querySelector
(
"#a22"
)
print
(
element
)
except
:
print
(
"----------------------not click"
)
await
page
.
waitFor
(
3000
)
await
page
.
screenshot
({
'path'
:
'example.png'
})
await
browser
.
close
()
#print(cookies)
asyncio
.
get_event_loop
()
.
run_until_complete
(
main
())
\ 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