Question: PYTHON SCAPY HELP I need help modifying this code so that the ip address is not hardcoded. Please show code running I am trying to

PYTHON SCAPY HELP
I need help modifying this code so that the ip address is not hardcoded. Please show code running I am trying to figure out VM operating systems using IPID's.
from scapy.all import *
target_ip ="x.x.x.x"
target_port =80
syn_packet = IP(dst=target_ip)/ TCP(dport=target_port, flags="S")
syn_response = sr1(syn_packet, timeout=1, verbose=False)
if syn_response:
ipid_syn_ack = syn_response.id
ack_packet = IP(dst=target_ip)/ TCP(dport=target_port, flags="A", ack=syn_response.seq +1)
ack_response = sr1(ack_packet, timeout=1, verbose=False)
if ack_response:
ipid_ack_ack = ack_response.id
rst_packet = IP(dst=target_ip)/ TCP(dport=target_port, flags="R", seq=ack_response.ack)
rst_response = sr1(rst_packet, timeout=1, verbose=False)
if rst_response:
ipid_rst_ack = rst_response.id
if ipid_syn_ack == ipid_ack_ack and ipid_rst_ack == ipid_ack_ack +1:
print("The OS is likely FreeBSD")
elif ipid_syn_ack != ipid_ack_ack and ipid_rst_ack == ipid_ack_ack:
print("The OS is likely Windows")
else:
print("The OS is likely Linux")
else:
print("No response to RST packet")
else:
print("No response to ACK packet")
else:
print("No response to SYN packet")

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!