Scapy Prepper
Tangle Coalbox:
Welcome to the roof! Alabaster Snowball here.
I'm watching some elves play NetWars!
Feel free to try out our Scapy Present Packet Prepper!
If you get stuck, you can
help()
to see how to get tasks and hints.
TL;DR
yes
task.submit("start")
task.submit(send)
task.submit(sniff)
task.submit(1)
task.submit(rdpcap)
task.submit(2)
task.submit(UDP_PACKETS[0])
task.submit(TCP_PACKETS[1][TCP])
UDP_PACKETS[0][IP].src="127.0.0.1"
task.submit(UDP_PACKETS[0])
[pkt[Raw].load for pkt in TCP_PACKETS if Raw in pkt]
task.submit("echo")
task.submit(ICMP_PACKETS[1][ICMP].chksum)
task.submit(3)
task.submit(IP(dst="127.127.127.127")/UDP(dport=5000))
task.submit(IP(dst="127.2.3.4")/UDP(dport=53)/DNSQR(qname="elveslove.santa"))
ARP_PACKETS[1].hwsrc="00:13:46:0b:22:ba"
ARP_PACKETS[1].hwdst="00:16:ce:6e:8b:24"
ARP_PACKETS[1].op=2
task.submit(ARP_PACKETS)
Location
On the roof (see map)
Solution
Let's jump into the terminal and get started
Welcome to the "Present Packet Prepper" interface! The North Pole could use your help preparing present packets for shipment. Start by running the
task.submit()
function passing in a string argument of 'start'. Typetask.help()
for help on this question.
>>> task.submit("start")
Correct! adding a () to a function or class will execute it. Ex - FunctionExecuted()
Submit the class object of the scapy module that sends packets at layer 3 of the OSI model.
>>> task.submit(send)
Correct! The "send" scapy class will send a crafted scapy packet out of a network interface.
Submit the class object of the scapy module that sniffs network packets and returns those packets in a list.
>>> task.submit(sniff)
Correct! the "sniff" scapy class will sniff network traffic and return these packets in a list.
Submit the NUMBER only from the choices below that would successfully send a TCP packet and then return the first sniffed response packet to be stored in a variable named
pkt
:
pkt = sr1(IP(dst="127.0.0.1")/TCP(dport=20))
pkt = sniff(IP(dst="127.0.0.1")/TCP(dport=20))
pkt = sendp(IP(dst="127.0.0.1")/TCP(dport=20))
>>> task.submit(1)
Correct! sr1 will send a packet, then immediately sniff for a response packet.
Submit the class object of the scapy module that can read pcap or pcapng files and return a list of packets.
>>> task.submit(rdpcap)
Correct! the "rdpcap" scapy class can read pcap files.
The variable UDP_PACKETS contains a list of UDP packets. Submit the NUMBER only from the choices below that correctly prints a summary of
UDP_PACKETS
:
UDP_PACKETS.print()
UDP_PACKETS.show()
UDP_PACKETS.list()
>>> task.submit(2)
Correct! .show() can be used on lists of packets AND on an individual packet.
Submit only the first packet found in
UDP_PACKETS
.
>>> task.submit(UDP_PACKETS[0])
Correct! Scapy packet lists work just like regular python lists so packets can be accessed by their position in the list starting at offset 0.
Submit only the entire TCP layer of the second packet in
TCP_PACKETS
.
>>> task.submit(TCP_PACKETS[1][TCP]
Correct! Most of the major fields like Ether, IP, TCP, UDP, ICMP, DNS, DNSQR, DNSRR, Raw, etc... can be accessed this way. Ex - pkt[IP][TCP]
Change the source IP address of the first packet found in
UDP_PACKETS
to127.0.0.1
and then submit this modified packet
>>> UDP_PACKETS[0][IP].src="127.0.0.1"
>>> task.submit(UDP_PACKETS[0])
Correct! You can change ALL scapy packet attributes using this method.
Submit the password
task.submit('elf_password')
of the useralabaster
as found in the packet listTCP_PACKETS
.
>>> [pkt[Raw].load for pkt in TCP_PACKETS if Raw in pkt]
[b'220 North Pole FTP Server\r\n', b'USER alabaster\r', b'331 Password required for alabaster.\r', b'PASS echo\r\n', b'230 User alabaster logged in.\r']
>>> task.submit("echo")
Correct! Here is some really nice list comprehension that will grab all the raw payloads from tcp packets:
[pkt[Raw].load for pkt in TCP_PACKETS if Raw in pkt]
The
ICMP_PACKETS
variable contains a packet list of several icmp echo-request and icmp echo-reply packets. Submit only the ICMP chksum value from the second packet in theICMP_PACKETS
list.
>>> task.submit(ICMP_PACKETS[1][ICMP].chksum)
Correct! You can access the ICMP chksum value from the second packet using ICMP_PACKETS[1][ICMP].chksum .
Submit the number of the choice below that would correctly create a ICMP echo request packet with a destination IP of
127.0.0.1
stored in the variable namedpkt
1.pkt = Ether(src='127.0.0.1')/ICMP(type="echo-request")
2.pkt = IP(src='127.0.0.1')/ICMP(type="echo-reply")
3.pkt = IP(dst='127.0.0.1')/ICMP(type="echo-request")
>>> task.submit(3)
Correct! Once you assign the packet to a variable named "pkt" you can then use that variable to send or manipulate your created packet.
Create and then submit a UDP packet with a dport of
5000
and a dst IP of127.127.127.127
. (all other packet attributes can be unspecified)
>>> task.submit(IP(dst="127.127.127.127")/UDP(dport=5000))
Correct! Your UDP packet creation should look something like this:
pkt = IP(dst="127.127.127.127")/UDP(dport=5000)
task.submit(pkt)
Create and then submit a UDP packet with a dport of
53
, a dst IP of127.2.3.4
, and is a DNS query with a qname ofelveslove.santa
. (all other packet attributes can be unspecified)
>>> task.submit(IP(dst="127.2.3.4")/UDP(dport=53)/DNSQR(qname="elveslove.santa"))
Correct! Your UDP packet creation should look something like this:
pkt = IP(dst="127.2.3.4")/UDP(dport=53)/DNS(rd=1,qd=DNSQR(qname="elveslove.santa"))
task.submit(pkt)
The variable
ARP_PACKETS
contains an ARP request and response packets. The ARP response (the second packet) has 3 incorrect fields in the ARP layer. Correct the second packet inARP_PACKETS
to be a proper ARP response and thentask.submit(ARP_PACKETS)
for inspection.
>>> ARP_PACKETS[1].hwsrc="00:13:46:0b:22:ba"
>>> ARP_PACKETS[1].hwdst="00:16:ce:6e:8b:24"
>>> ARP_PACKETS[1].op=2
>>> ARP_PACKETS[1]
<Ether dst=00:16:ce:6e:8b:24 src=00:13:46:0b:22:ba type=ARP |<ARP hwtype=0x1 ptype=IPv4 hwlen=6 plen=4 op=is-at hwsrc=00:13:46:0b:22:ba psrc=192.168.0.1 hwdst=00:16:ce:6e:8b:24 pdst=192.168.0.114 |<Padding load='\xc0\xa8\x00r' |>>>
>>> task.submit(ARP_PACKETS)
Great, you prepared all the present packets!
Congratulations, all pretty present packets properly prepared for processing!