Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
scapy
Manage
Activity
Members
Plan
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
CodeLinaro
public-release-test-restored
platform
external
scapy
Commits
200ecb02
Commit
200ecb02
authored
16 years ago
by
Phil
Browse files
Options
Downloads
Patches
Plain Diff
Move RandDHCPOptions to layers/dhcp.py
parent
b0b33845
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
scapy/layers/dhcp.py
+22
-0
22 additions, 0 deletions
scapy/layers/dhcp.py
scapy/volatile.py
+0
-22
0 additions, 22 deletions
scapy/volatile.py
with
22 additions
and
22 deletions
scapy/layers/dhcp.py
+
22
−
0
View file @
200ecb02
...
...
@@ -10,6 +10,7 @@ from scapy.fields import *
from
scapy.ansmachine
import
*
from
scapy.layers.inet
import
UDP
from
scapy.base_classes
import
Net
from
scapy.volatile
import
RandField
dhcpmagic
=
"
c
\x82
Sc
"
...
...
@@ -145,6 +146,27 @@ del(k)
class
RandDHCPOptions
(
RandField
):
def
__init__
(
self
,
size
=
None
,
rndstr
=
None
):
if
size
is
None
:
size
=
RandNumExpo
(
0.05
)
self
.
size
=
size
if
rndstr
is
None
:
rndstr
=
RandBin
(
RandNum
(
0
,
255
))
self
.
rndstr
=
rndstr
self
.
_opts
=
DHCPOptions
.
values
()
self
.
_opts
.
remove
(
"
pad
"
)
self
.
_opts
.
remove
(
"
end
"
)
def
_fix
(
self
):
op
=
[]
for
k
in
range
(
self
.
size
):
o
=
random
.
choice
(
self
.
_opts
)
if
type
(
o
)
is
str
:
op
.
append
((
o
,
self
.
rndstr
*
1
))
else
:
op
.
append
((
o
.
name
,
o
.
randval
().
_fix
()))
return
op
class
DHCPOptionsField
(
StrField
):
islist
=
1
...
...
This diff is collapsed.
Click to expand it.
scapy/volatile.py
+
0
−
22
View file @
200ecb02
...
...
@@ -205,28 +205,6 @@ class RandOID(RandString):
oid
.
append
(
i
)
return
"
.
"
.
join
(
oid
)
class
RandDHCPOptions
(
RandField
):
def
__init__
(
self
,
size
=
None
,
rndstr
=
None
):
if
size
is
None
:
size
=
RandNumExpo
(
0.05
)
self
.
size
=
size
if
rndstr
is
None
:
rndstr
=
RandBin
(
RandNum
(
0
,
255
))
self
.
rndstr
=
rndstr
self
.
_opts
=
DHCPOptions
.
values
()
self
.
_opts
.
remove
(
"
pad
"
)
self
.
_opts
.
remove
(
"
end
"
)
def
_fix
(
self
):
op
=
[]
for
k
in
range
(
self
.
size
):
o
=
random
.
choice
(
self
.
_opts
)
if
type
(
o
)
is
str
:
op
.
append
((
o
,
self
.
rndstr
*
1
))
else
:
op
.
append
((
o
.
name
,
o
.
randval
().
_fix
()))
return
op
# Automatic timestamp
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment