Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
sendether
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
hoerdt-public
sendether
Commits
c3aea3d9
Commit
c3aea3d9
authored
1 year ago
by
Mickaël Hoerdt
Browse files
Options
Downloads
Patches
Plain Diff
allow to send multiple paquets in one command
parent
527ef6ec
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
sendether.py
+12
-6
12 additions, 6 deletions
sendether.py
with
12 additions
and
6 deletions
sendether.py
100644 → 100755
+
12
−
6
View file @
c3aea3d9
...
...
@@ -4,7 +4,8 @@ import sys
import
argparse
from
scapy.all
import
sendp
,
sendpfast
,
Ether
,
IP
,
RandIP
,
RandMAC
,
ICMP
def
macsender
(
iface
):
def
get_etheraddrs
():
smac_rand
=
str
(
RandMAC
(
'
00:*:*:*:*:*
'
))
print
(
smac_rand
)
dmac_rand
=
str
(
RandMAC
(
'
*:*:*:*:*:*
'
))
...
...
@@ -12,21 +13,26 @@ def macsender(iface):
new
=
old
|
0x1
if
old
!=
new
:
dmac_rand
=
"
{0}{1:x}{2}
"
.
format
(
smac_rand
[
0
],
new
,
smac_rand
[
2
:])
return
smac_rand
,
dmac_rand
def
macsender
(
iface
,
count
=
1
):
pkts
=
[]
pkts
.
append
(
Ether
(
src
=
smac_rand
,
dst
=
str
(
RandMAC
(
dmac_rand
)))
/
for
i
in
range
(
count
):
ether_src
,
ether_dst
=
get_etheraddrs
()
pkts
.
append
(
Ether
(
src
=
ether_src
,
dst
=
str
(
RandMAC
(
ether_dst
)))
/
IP
(
src
=
str
(
RandIP
(
'
0.0.0.0/0
'
)),
dst
=
str
(
RandIP
(
'
0.0.0.0/0
'
)))
/
ICMP
())
print
(
pkts
)
sendp
(
pkts
,
iface
=
iface
,
loop
=
False
,
verbose
=
True
)
def
main
():
parser
=
argparse
.
ArgumentParser
(
description
=
"
Random MAC sender tool
"
)
parser
.
add_argument
(
'
-i
'
,
'
--iface
'
,
help
=
"
Output interface name
"
)
parser
.
add_argument
(
'
-c
'
,
'
--count
'
,
type
=
int
,
default
=
1
,
help
=
"
Number of packets to send
"
)
args
=
parser
.
parse_args
()
try
:
macsender
(
iface
=
args
.
iface
)
macsender
(
iface
=
args
.
iface
,
count
=
args
.
count
)
except
ValueError
as
e
:
print
(
"
ERROR: {0}
"
.
format
(
e
))
return
1
...
...
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