Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
R
routersploit
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
czos-dpend
routersploit
Commits
d7c2e865
Commit
d7c2e865
authored
Nov 13, 2019
by
dark-lbp
Committed by
Marcin Bury
Nov 12, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make OptInteger handle value 0 and hex value. (#613)
parent
47183c74
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
1 deletions
+16
-1
option.py
routersploit/core/exploit/option.py
+4
-1
test_option.py
tests/core/test_option.py
+12
-0
No files found.
routersploit/core/exploit/option.py
View file @
d7c2e865
...
...
@@ -20,7 +20,7 @@ class Option(object):
except
ValueError
:
raise
OptionValidationError
(
"Invalid value. Cannot cast '{}' to boolean."
.
format
(
advanced
))
if
default
:
if
default
or
default
==
0
:
self
.
__set__
(
""
,
default
)
else
:
self
.
display_value
=
""
...
...
@@ -93,6 +93,9 @@ class OptInteger(Option):
self
.
display_value
=
str
(
value
)
self
.
value
=
int
(
value
)
except
ValueError
:
try
:
self
.
value
=
int
(
value
,
16
)
except
ValueError
:
raise
OptionValidationError
(
"Invalid option. Cannot cast '{}' to integer."
.
format
(
value
))
...
...
tests/core/test_option.py
View file @
d7c2e865
...
...
@@ -118,6 +118,18 @@ def test_opt_integer():
assert
opt_integer
.
value
==
9999999
assert
opt_integer
.
__get__
(
None
,
None
)
==
9999999
# Test OptInteger setting to 0
opt_integer
=
OptInteger
(
0
,
"Test Integer with 0"
)
assert
opt_integer
.
display_value
==
"0"
assert
opt_integer
.
value
==
0
assert
opt_integer
.
__get__
(
None
,
None
)
==
0
# Test OptInteger setting to 0x100
opt_integer
.
__set__
(
None
,
"0x100"
)
assert
opt_integer
.
display_value
==
"0x100"
assert
opt_integer
.
value
==
0x100
assert
opt_integer
.
__get__
(
None
,
None
)
==
0x100
# Test OptInteget setting to invalid value
try
:
opt_integer
.
__set__
(
None
,
"Invalid Value"
)
...
...
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