|
@@ -93,7 +93,7 @@ class SMBScanAttack(BaseAttack.BaseAttack):
|
|
|
self.add_param_value(Param.PROTOCOL_VERSION, "1")
|
|
|
self.add_param_value(Param.IP_DESTINATION_END, "0.0.0.0")
|
|
|
|
|
|
- def generate_attack_pcap(self):
|
|
|
+ def generate_attack_packets(self):
|
|
|
|
|
|
pps = self.get_param_value(Param.PACKETS_PER_SECOND)
|
|
|
|
|
@@ -124,7 +124,7 @@ class SMBScanAttack(BaseAttack.BaseAttack):
|
|
|
invalid_smb_version(hosting_version)
|
|
|
|
|
|
src_platform = self.get_param_value(Param.SOURCE_PLATFORM).lower()
|
|
|
- packets = []
|
|
|
+ self.packets = []
|
|
|
|
|
|
|
|
|
if self.get_param_value(Param.PORT_SOURCE_RANDOMIZE):
|
|
@@ -203,7 +203,7 @@ class SMBScanAttack(BaseAttack.BaseAttack):
|
|
|
request.time = timestamp_next_pkt
|
|
|
|
|
|
|
|
|
- packets.append(request)
|
|
|
+ self.packets.append(request)
|
|
|
|
|
|
|
|
|
timestamp_reply = update_timestamp(timestamp_next_pkt, pps, minDelay)
|
|
@@ -223,7 +223,7 @@ class SMBScanAttack(BaseAttack.BaseAttack):
|
|
|
victim_seq += 1
|
|
|
reply = (reply_ether / reply_ip / reply_tcp)
|
|
|
reply.time = timestamp_reply
|
|
|
- packets.append(reply)
|
|
|
+ self.packets.append(reply)
|
|
|
|
|
|
|
|
|
confirm_ether = request_ether
|
|
@@ -233,7 +233,7 @@ class SMBScanAttack(BaseAttack.BaseAttack):
|
|
|
confirm = (confirm_ether / confirm_ip / confirm_tcp)
|
|
|
timestamp_confirm = update_timestamp(timestamp_reply, pps, minDelay)
|
|
|
confirm.time = timestamp_confirm
|
|
|
- packets.append(confirm)
|
|
|
+ self.packets.append(confirm)
|
|
|
|
|
|
smb_MID = randint(1, 65535)
|
|
|
smb_PID = randint(1, 65535)
|
|
@@ -269,7 +269,7 @@ class SMBScanAttack(BaseAttack.BaseAttack):
|
|
|
|
|
|
timestamp_smb_req = update_timestamp(timestamp_confirm, pps, minDelay)
|
|
|
smb_req_combined.time = timestamp_smb_req
|
|
|
- packets.append(smb_req_combined)
|
|
|
+ self.packets.append(smb_req_combined)
|
|
|
|
|
|
|
|
|
reply_tcp = TCP(sport=smb_port, dport=sport, seq=victim_seq, ack=attacker_seq,
|
|
@@ -277,7 +277,7 @@ class SMBScanAttack(BaseAttack.BaseAttack):
|
|
|
confirm_smb_req = (reply_ether / reply_ip / reply_tcp)
|
|
|
timestamp_reply = update_timestamp(timestamp_smb_req, pps, minDelay)
|
|
|
confirm_smb_req.time = timestamp_reply
|
|
|
- packets.append(confirm_smb_req)
|
|
|
+ self.packets.append(confirm_smb_req)
|
|
|
|
|
|
|
|
|
first_timestamp = time.mktime(time.strptime(self.statistics.get_pcap_timestamp_start()[:19],
|
|
@@ -316,7 +316,7 @@ class SMBScanAttack(BaseAttack.BaseAttack):
|
|
|
smb_rsp_combined = (smb_rsp_combined / smb_rsp_negotiate_body)
|
|
|
|
|
|
smb_rsp_combined.time = timestamp_smb_rsp
|
|
|
- packets.append(smb_rsp_combined)
|
|
|
+ self.packets.append(smb_rsp_combined)
|
|
|
|
|
|
|
|
|
|
|
@@ -325,7 +325,7 @@ class SMBScanAttack(BaseAttack.BaseAttack):
|
|
|
confirm_smb_res = (confirm_ether / confirm_ip / confirm_tcp)
|
|
|
timestamp_confirm = update_timestamp(timestamp_smb_rsp, pps, minDelay)
|
|
|
confirm_smb_res.time = timestamp_confirm
|
|
|
- packets.append(confirm_smb_res)
|
|
|
+ self.packets.append(confirm_smb_res)
|
|
|
|
|
|
|
|
|
confirm_tcp = TCP(sport=sport, dport=smb_port, seq=attacker_seq, ack=victim_seq,
|
|
@@ -334,7 +334,7 @@ class SMBScanAttack(BaseAttack.BaseAttack):
|
|
|
timestamp_src_fin_ack = update_timestamp(timestamp_confirm, pps, minDelay)
|
|
|
source_fin_ack.time = timestamp_src_fin_ack
|
|
|
attacker_seq += 1
|
|
|
- packets.append(source_fin_ack)
|
|
|
+ self.packets.append(source_fin_ack)
|
|
|
|
|
|
|
|
|
reply_tcp = TCP(sport=smb_port, dport=sport, seq=victim_seq, ack=attacker_seq,
|
|
@@ -343,7 +343,7 @@ class SMBScanAttack(BaseAttack.BaseAttack):
|
|
|
timestamp_dest_fin_ack = update_timestamp(timestamp_src_fin_ack, pps, minDelay)
|
|
|
victim_seq += 1
|
|
|
destination_fin_ack.time = timestamp_dest_fin_ack
|
|
|
- packets.append(destination_fin_ack)
|
|
|
+ self.packets.append(destination_fin_ack)
|
|
|
|
|
|
|
|
|
confirm_tcp = TCP(sport=sport, dport=smb_port, seq=attacker_seq, ack=victim_seq,
|
|
@@ -351,7 +351,7 @@ class SMBScanAttack(BaseAttack.BaseAttack):
|
|
|
final_ack = (confirm_ether / confirm_ip / confirm_tcp)
|
|
|
timestamp_final_ack = update_timestamp(timestamp_dest_fin_ack, pps, minDelay)
|
|
|
final_ack.time = timestamp_final_ack
|
|
|
- packets.append(final_ack)
|
|
|
+ self.packets.append(final_ack)
|
|
|
|
|
|
else:
|
|
|
|
|
@@ -361,16 +361,18 @@ class SMBScanAttack(BaseAttack.BaseAttack):
|
|
|
window=destination_win_value, options=[('MSS', destination_mss_value)])
|
|
|
reply = (reply_ether / reply_ip / reply_tcp)
|
|
|
reply.time = timestamp_reply
|
|
|
- packets.append(reply)
|
|
|
+ self.packets.append(reply)
|
|
|
|
|
|
pps = max(get_interval_pps(complement_interval_pps, timestamp_next_pkt), 10)
|
|
|
timestamp_next_pkt = update_timestamp(timestamp_next_pkt, pps)
|
|
|
|
|
|
+ def generate_attack_pcap(self):
|
|
|
+
|
|
|
|
|
|
- self.attack_end_utime = packets[-1].time
|
|
|
+ self.attack_end_utime = self.packets[-1].time
|
|
|
|
|
|
-
|
|
|
- pcap_path = self.write_attack_pcap(sorted(packets, key=lambda pkt: pkt.time))
|
|
|
+
|
|
|
+ pcap_path = self.write_attack_pcap(sorted(self.packets, key=lambda pkt: pkt.time))
|
|
|
|
|
|
|
|
|
- return len(packets), pcap_path
|
|
|
+ return len(self.packets), pcap_path
|