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
01ac767b
Commit
01ac767b
authored
7 years ago
by
Guillaume Valadon
Browse files
Options
Downloads
Patches
Plain Diff
Answering machines unit tests
parent
3c092b9e
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
test/answering_machines.uts
+61
-0
61 additions, 0 deletions
test/answering_machines.uts
with
61 additions
and
0 deletions
test/answering_machines.uts
0 → 100644
+
61
−
0
View file @
01ac767b
% Regression tests for Scapy Answering Machines
# More informations at http://www.secdev.org/projects/UTscapy/
############
############
+ Answering Machines
= Generic answering machine mocker
import mock
@mock.patch("scapy.ansmachine.sniff")
def test_am(cls_name, packet_query, check_reply, mock_sniff, **kargs):
def sniff(*args,**kargs):
kargs["prn"](packet_query)
mock_sniff.side_effect = sniff
am = cls_name(**kargs)
am.send_reply = check_reply
am()
= BOOT_am
def check_BOOTP_am_reply(packet):
assert(BOOTP in packet and packet[BOOTP].op == 2)
assert(packet[BOOTP].yiaddr == "192.168.1.128" and packet[BOOTP].giaddr == "192.168.1.1")
test_am(BOOTP_am,
IP()/UDP()/BOOTP(op=1),
check_BOOTP_am_reply)
= DHCP_am
def check_DHCP_am_reply(packet):
assert(DHCP in packet and len(packet[DHCP].options))
assert(("domain", "localnet") in packet[DHCP].options)
test_am(DHCP_am,
IP()/UDP()/BOOTP(op=1)/DHCP(),
check_DHCP_am_reply)
= ARP_am
def check_ARP_am_reply(packet):
assert(ARP in packet and packet[ARP].psrc == "10.28.7.1")
assert(packet[ARP].hwsrc == "00:01:02:03:04:05")
test_am(ARP_am,
Ether()/ARP(pdst="10.28.7.1"),
check_ARP_am_reply,
IP_addr="10.28.7.1",
ARP_addr="00:01:02:03:04:05")
= DNS_am
def check_DNS_am_reply(packet):
assert(DNS in packet and packet[DNS].ancount == 1)
assert(packet[DNS].an.rdata == "192.168.1.1")
test_am(DNS_am,
IP()/UDP()/DNS(qd=DNSQR(qname="www.secdev.org")),
check_DNS_am_reply)
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